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

📄 cookieparamasprimitivetest.java

📁 resetful样式的ws样例,一种面向资源的webservices服务
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }            }        @Path("/wrappers/default/override")    public static class ResourceHeaderPrimitiveWrappersDefaultOverride {        @GET        @ProduceMime("application/boolean")        public String doGet(@CookieParam("boolean") @DefaultValue("false") Boolean v) {            assertEquals(true, v.booleanValue());            return "content";        }                        @GET        @ProduceMime("application/byte")        public String doGet(@CookieParam("byte") @DefaultValue("1") Byte v) {            assertEquals(127, v.byteValue());            return "content";        }                        @GET        @ProduceMime("application/short")        public String doGet(@CookieParam("short") @DefaultValue("1") Short v) {            assertEquals(32767, v.shortValue());            return "content";        }                        @GET        @ProduceMime("application/int")        public String doGet(@CookieParam("int") @DefaultValue("1") Integer v) {            assertEquals(2147483647, v.intValue());            return "content";        }                        @GET        @ProduceMime("application/long")        public String doGet(@CookieParam("long") @DefaultValue("1") Long v) {            assertEquals(9223372036854775807L, v.longValue());            return "content";        }                        @GET        @ProduceMime("application/float")        public String doGet(@CookieParam("float") @DefaultValue("0.0") Float v) {            assertEquals(3.14159265f, v.floatValue());            return "content";        }                        @GET        @ProduceMime("application/double")        public String doGet(@CookieParam("double") @DefaultValue("0.0") Double v) {            assertEquals(3.14159265358979d, v.doubleValue());            return "content";        }            }        @Path("/list")    public static class ResourceHeaderPrimitiveList {        @GET        @ProduceMime("application/boolean")        public String doGetBoolean(@CookieParam("boolean") List<Boolean> v) {            assertEquals(true, v.get(0).booleanValue());            return "content";        }                        @GET        @ProduceMime("application/byte")        public String doGetByte(@CookieParam("byte") List<Byte> v) {            assertEquals(127, v.get(0).byteValue());            return "content";        }                        @GET        @ProduceMime("application/short")        public String doGetShort(@CookieParam("short") List<Short> v) {            assertEquals(32767, v.get(0).shortValue());            return "content";        }                        @GET        @ProduceMime("application/int")        public String doGetInteger(@CookieParam("int") List<Integer> v) {            assertEquals(2147483647, v.get(0).intValue());            return "content";        }                        @GET        @ProduceMime("application/long")        public String doGetLong(@CookieParam("long") List<Long> v) {            assertEquals(9223372036854775807L, v.get(0).longValue());            return "content";        }                        @GET        @ProduceMime("application/float")        public String doGetFloat(@CookieParam("float") List<Float> v) {            assertEquals(3.14159265f, v.get(0).floatValue());            return "content";        }                        @GET        @ProduceMime("application/double")        public String doGetDouble(@CookieParam("double") List<Double> v) {            assertEquals(3.14159265358979d, v.get(0).doubleValue());            return "content";        }            }        @Path("/list/default/null")    public static class ResourceHeaderPrimitiveListDefaultNull {        @GET        @ProduceMime("application/boolean")        public String doGetBoolean(@CookieParam("boolean") List<Boolean> v) {            assertEquals(null, v);            return "content";        }                        @GET        @ProduceMime("application/byte")        public String doGetByte(@CookieParam("byte") List<Byte> v) {            assertEquals(null, v);            return "content";        }                        @GET        @ProduceMime("application/short")        public String doGetShort(@CookieParam("short") List<Short> v) {            assertEquals(null, v);            return "content";        }                        @GET        @ProduceMime("application/int")        public String doGetInteger(@CookieParam("int") List<Integer> v) {            assertEquals(null, v);            return "content";        }                        @GET        @ProduceMime("application/long")        public String doGetLong(@CookieParam("long") List<Long> v) {            assertEquals(null, v);            return "content";        }                        @GET        @ProduceMime("application/float")        public String doGetFloat(@CookieParam("float") List<Float> v) {            assertEquals(null, v);            return "content";        }                        @GET        @ProduceMime("application/double")        public String doGetDouble(@CookieParam("double") List<Double> v) {            assertEquals(null, v);            return "content";        }            }        @Path("/list/default")    public static class ResourceHeaderPrimitiveListDefault {        @GET        @ProduceMime("application/boolean")        public String doGetBoolean(@CookieParam("boolean") @DefaultValue("true") List<Boolean> v) {            assertEquals(true, v.get(0).booleanValue());            return "content";        }                        @GET        @ProduceMime("application/byte")        public String doGetByte(@CookieParam("byte") @DefaultValue("127") List<Byte> v) {            assertEquals(127, v.get(0).byteValue());            return "content";        }                        @GET        @ProduceMime("application/short")        public String doGetShort(@CookieParam("short") @DefaultValue("32767") List<Short> v) {            assertEquals(32767, v.get(0).shortValue());            return "content";        }                        @GET        @ProduceMime("application/int")        public String doGetInteger(@CookieParam("int") @DefaultValue("2147483647") List<Integer> v) {            assertEquals(2147483647, v.get(0).intValue());            return "content";        }                        @GET        @ProduceMime("application/long")        public String doGetLong(@CookieParam("long") @DefaultValue("9223372036854775807") List<Long> v) {            assertEquals(9223372036854775807L, v.get(0).longValue());            return "content";        }                        @GET        @ProduceMime("application/float")        public String doGetFloat(@CookieParam("float") @DefaultValue("3.14159265") List<Float> v) {            assertEquals(3.14159265f, v.get(0).floatValue());            return "content";        }                        @GET        @ProduceMime("application/double")        public String doGetDouble(@CookieParam("double") @DefaultValue("3.14159265358979") List<Double> v) {            assertEquals(3.14159265358979d, v.get(0).doubleValue());            return "content";        }            }        @Path("/list/default/override")    public static class ResourceHeaderPrimitiveListDefaultOverride {        @GET        @ProduceMime("application/boolean")        public String doGetBoolean(@CookieParam("boolean") @DefaultValue("false") List<Boolean> v) {            assertEquals(true, v.get(0).booleanValue());            return "content";        }                        @GET        @ProduceMime("application/byte")        public String doGetByte(@CookieParam("byte") @DefaultValue("0") List<Byte> v) {            assertEquals(127, v.get(0).byteValue());            return "content";        }                        @GET        @ProduceMime("application/short")        public String doGetShort(@CookieParam("short") @DefaultValue("0") List<Short> v) {            assertEquals(32767, v.get(0).shortValue());            return "content";        }                        @GET        @ProduceMime("application/int")        public String doGetInteger(@CookieParam("int") @DefaultValue("0") List<Integer> v) {            assertEquals(2147483647, v.get(0).intValue());            return "content";        }                        @GET        @ProduceMime("application/long")        public String doGetLong(@CookieParam("long") @DefaultValue("0") List<Long> v) {            assertEquals(9223372036854775807L, v.get(0).longValue());            return "content";        }                        @GET        @ProduceMime("application/float")        public String doGetFloat(@CookieParam("float") @DefaultValue("0.0") List<Float> v) {            assertEquals(3.14159265f, v.get(0).floatValue());            return "content";        }                        @GET        @ProduceMime("application/double")        public String doGetDouble(@CookieParam("double") @DefaultValue("0.0") List<Double> v) {            assertEquals(3.14159265358979d, v.get(0).doubleValue());            return "content";        }            }            public void _test(String type, String value) {        resource("/").accept("application/" + type).                cookie(new Cookie(type, value)).get(String.class);                resource("/wrappers").accept("application/" + type).                cookie(new Cookie(type, value)).get(String.class);                    resource("/list").accept("application/" + type).                cookie(new Cookie(type, value)).                get(String.class);    }        public void _testDefault(String base, String type, String value) {        resource(base + "default/null").accept("application/" + type).                get(String.class);                resource(base + "default").accept("application/" + type).                get(String.class);                resource(base + "default/override").accept("application/" + type).                cookie(new Cookie(type, value)).get(String.class);            }        public void _testDefault(String type, String value) {        _testDefault("/", type, value);    }        public void _testWrappersDefault(String type, String value) {        _testDefault("/wrappers/", type, value);    }    public void _testListDefault(String type, String value) {        _testDefault("/list/", type, value);    }    public void testGetBoolean() {        _test("boolean", "true");    }        public void testGetBooleanPrimitivesDefault() {        _testDefault("boolean", "true");    }        public void testGetBooleanPrimitiveWrapperDefault() {        _testWrappersDefault("boolean", "true");    }        public void testGetBooleanPrimitiveListDefault() {        _testListDefault("boolean", "true");    }            public void testGetByte() {        _test("byte", "127");    }        public void testGetBytePrimitivesDefault() {        _testDefault("byte", "127");    }        public void testGetBytePrimitiveWrappersDefault() {        _testWrappersDefault("byte", "127");    }        public void testGetBytePrimitiveListDefault() {        _testListDefault("byte", "127");    }            public void testGetShort() {        _test("short", "32767");    }        public void testGetShortPrimtivesDefault() {        _testDefault("short", "32767");    }        public void testGetShortPrimtiveWrappersDefault() {        _testWrappersDefault("short", "32767");    }        public void testGetShortPrimtiveListDefault() {        _testListDefault("short", "32767");    }            public void testGetInt() {        _test("int", "2147483647");    }        public void testGetIntPrimitivesDefault() {        _testDefault("int", "2147483647");    }        public void testGetIntPrimitiveWrappersDefault() {        _testWrappersDefault("int", "2147483647");    }        public void testGetIntPrimitiveListDefault() {        _testListDefault("int", "2147483647");    }            public void testGetLong() {        _test("long", "9223372036854775807");    }        public void testGetLongPrimitivesDefault() {        _testDefault("long", "9223372036854775807");    }        public void testGetLongPrimitiveWrappersDefault() {        _testWrappersDefault("long", "9223372036854775807");    }        public void testGetLongPrimitiveListDefault() {        _testListDefault("long", "9223372036854775807");    }            public void testGetFloat() {        _test("float", "3.14159265");    }        public void testGetFloatPrimitivesDefault() {        _testDefault("float", "3.14159265");    }        public void testGetFloatPrimitiveWrappersDefault() {        _testWrappersDefault("float", "3.14159265");    }        public void testGetFloatPrimitiveListDefault() {        _testListDefault("float", "3.14159265");    }            public void testGetDouble() {        _test("double", "3.14159265358979");    }        public void testGetDoublePrimitivesDefault() {        _testDefault("double", "3.14159265358979");    }        public void testGetDoublePrimitiveWrappersDefault() {        _testWrappersDefault("double", "3.14159265358979");    }        public void testGetDoublePrimitiveListDefault() {        _testListDefault("double", "3.14159265358979");    }        public void testBadPrimitiveValue() {        ClientResponse response = resource("/", false).accept("application/int").                cookie(new Cookie("int", "abcdef")).get(ClientResponse.class);                assertEquals(400, response.getStatus());    }        public void testBadPrimitiveWrapperValue() {        ClientResponse response = resource("/wrappers", false).accept("application/int").                cookie(new Cookie("int", "abcdef")).get(ClientResponse.class);                assertEquals(400, response.getStatus());    }        public void testBadPrimitiveListValue() {        ClientResponse response = resource("/wrappers", false).accept("application/int").                cookie(new Cookie("int", "abcdef")).                get(ClientResponse.class);                assertEquals(400, response.getStatus());    }}

⌨️ 快捷键说明

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