⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 allinjectablestest.java

📁 resetful样式的ws样例,一种面向资源的webservices服务
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            assertNotNull(sc);            arg6.write(arg0.getBytes());        }                @Context ResourceConfig rc;                @Context MessageBodyWorkers mbw;                @Context TemplateContext tc;                @Context HttpContext hca;                @Context HttpHeaders hs;                @Context UriInfo ui;                @Context ExtendedUriInfo eui;                @Context Request r;                        @Context SecurityContext sc;    }        @Provider    @ConsumeMime({"text/plain", "*/*"})    @ProduceMime({"text/plain", "*/*"})    public static class StringWriterConstructor implements MessageBodyWriter<String> {        public StringWriterConstructor(                @Context ResourceConfig rc,                @Context MessageBodyWorkers mbw,                @Context TemplateContext tc,                @Context HttpContext hca,                @Context HttpHeaders hs,                @Context UriInfo ui,                @Context ExtendedUriInfo eui,                @Context Request r,                @Context SecurityContext sc) {            assertNotNull(rc);            assertNotNull(mbw);            assertNotNull(tc);            assertNotNull(hca);            assertNotNull(hs);            assertNotNull(ui);            assertNotNull(eui);            assertNotNull(r);            assertNotNull(sc);        }                                public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2) {            return arg0 == String.class;        }        public long getSize(String arg0) {            return -1;        }        public void writeTo(String arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4, MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException, WebApplicationException {            arg6.write(arg0.getBytes());        }            }        @Provider    @ConsumeMime({"text/plain", "*/*"})    @ProduceMime({"text/plain", "*/*"})    public static class StringWriterMutlipleConstructor implements MessageBodyWriter<String> {        public StringWriterMutlipleConstructor(                @Context ResourceConfig rc,                @Context MessageBodyWorkers mbw,                @Context TemplateContext tc,                @Context HttpContext hca,                @Context HttpHeaders hs,                @Context UriInfo ui,                @Context ExtendedUriInfo eui,                @Context Request r,                @Context SecurityContext sc) {            assertNotNull(rc);            assertNotNull(mbw);            assertNotNull(tc);            assertNotNull(hca);            assertNotNull(hs);            assertNotNull(ui);            assertNotNull(eui);            assertNotNull(r);            assertNotNull(sc);        }                                public StringWriterMutlipleConstructor(                @Context ResourceConfig rc,                @Context MessageBodyWorkers mbw,                @Context TemplateContext tc) {            assertTrue(false);        }                                public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2) {            return arg0 == String.class;        }        public long getSize(String arg0) {            return -1;        }        public void writeTo(String arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4, MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException, WebApplicationException {            arg6.write(arg0.getBytes());        }            }        @Provider    @ConsumeMime({"text/plain", "*/*"})    @ProduceMime({"text/plain", "*/*"})    public static class StringWriterMutliplePartialConstructor implements MessageBodyWriter<String> {        public StringWriterMutliplePartialConstructor(                @Context ResourceConfig rc,                @Context MessageBodyWorkers mbw,                @Context TemplateContext tc,                @Context HttpContext hca,                @Context HttpHeaders hs,                @Context UriInfo ui,                @Context ExtendedUriInfo eui,                @Context Request r,                @Context SecurityContext sc) {            assertNotNull(rc);            assertNotNull(mbw);            assertNotNull(tc);            assertNotNull(hca);            assertNotNull(hs);            assertNotNull(ui);            assertNotNull(eui);            assertNotNull(r);            assertNotNull(sc);        }                                public StringWriterMutliplePartialConstructor(                String rc,                @Context MessageBodyWorkers mbw,                @Context TemplateContext tc,                @Context HttpContext hca,                @Context HttpHeaders hs,                @Context UriInfo ui,                @Context ExtendedUriInfo eui,                @Context Request r,                @Context SecurityContext sc) {            assertTrue(false);        }                                public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2) {            return arg0 == String.class;        }        public long getSize(String arg0) {            return -1;        }        public void writeTo(String arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4, MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException, WebApplicationException {            arg6.write(arg0.getBytes());        }            }        @Provider    @ConsumeMime({"text/plain", "*/*"})    @ProduceMime({"text/plain", "*/*"})    public static class StringWriterMutliplePartialConstructor2 implements MessageBodyWriter<String> {        public StringWriterMutliplePartialConstructor2(                @Context HttpContext hca,                @Context HttpHeaders hs,                @Context UriInfo ui,                @Context ExtendedUriInfo eui,                @Context Request r,                @Context SecurityContext sc) {            assertNotNull(hca);            assertNotNull(hs);            assertNotNull(ui);            assertNotNull(eui);            assertNotNull(r);            assertNotNull(sc);        }                                public StringWriterMutliplePartialConstructor2(                String rc,                @Context MessageBodyWorkers mbw,                @Context TemplateContext tc,                @Context HttpContext hca,                @Context HttpHeaders hs,                @Context UriInfo ui,                @Context ExtendedUriInfo eui,                @Context Request r,                @Context SecurityContext sc) {            assertTrue(false);        }                                public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2) {            return arg0 == String.class;        }        public long getSize(String arg0) {            return -1;        }        public void writeTo(String arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4, MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException, WebApplicationException {            arg6.write(arg0.getBytes());        }            }        public void testProviderField() throws IOException {        initiateWebApplication(StringWriterResource.class, StringWriterField.class);                assertEquals("GET", resource("/").get(String.class));            }                   public void testProviderInstanceField() throws IOException {        ResourceConfig rc = new DefaultResourceConfig(StringWriterResource.class);        rc.getProviderInstances().add(new StringWriterField());        initiateWebApplication(rc);                assertEquals("GET", resource("/").get(String.class));            }                   public void testProviderConstructor() throws IOException {        initiateWebApplication(StringWriterResource.class, StringWriterConstructor.class);                assertEquals("GET", resource("/").get(String.class));            }                   public void testProviderMultipleConstructor() throws IOException {        initiateWebApplication(StringWriterResource.class, StringWriterMutlipleConstructor.class);                assertEquals("GET", resource("/").get(String.class));            }                   public void testProviderMultiplePartialConstructor() throws IOException {        initiateWebApplication(StringWriterResource.class, StringWriterMutliplePartialConstructor.class);                assertEquals("GET", resource("/").get(String.class));            }                   public void testProviderMultiplePartialConstructor2() throws IOException {        initiateWebApplication(StringWriterResource.class, StringWriterMutliplePartialConstructor2.class);                assertEquals("GET", resource("/").get(String.class));            }                   @Path("/{p}")    public static class PerRequestFieldResource {                @PathParam("p") String p;                @QueryParam("q") String q;                        @GET        public String get() {            return p+q;        }                    }        public void testPerRequestParamInjected() throws IOException {        initiateWebApplication(PerRequestFieldResource.class);                assertEquals("foobar", resource("/foo?q=bar").get(String.class));            }               }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -