📄 cookieparamasprimitivetest.java
字号:
/* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development * and Distribution License("CDDL") (collectively, the "License"). You * may not use this file except in compliance with the License. You can obtain * a copy of the License at https://jersey.dev.java.net/CDDL+GPL.html * or jersey/legal/LICENSE.txt. See the License for the specific * language governing permissions and limitations under the License. * * When distributing the software, include this License Header Notice in each * file and include the License file at jersey/legal/LICENSE.txt. * Sun designates this particular file as subject to the "Classpath" exception * as provided by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the License * Header, with the fields enclosed by brackets [] replaced by your own * identifying information: "Portions Copyrighted [year] * [name of copyright owner]" * * Contributor(s): * * If you wish your version of this file to be governed by only the CDDL or * only the GPL Version 2, indicate your decision by adding "[Contributor] * elects to include this software in this distribution under the [CDDL or GPL * Version 2] license." If you don't indicate a single choice of license, a * recipient has the option to distribute your version of this file under * either the CDDL, the GPL Version 2 or to extend the choice of license to * its licensees as provided above. However, if you add GPL Version 2 code * and therefore, elected the GPL Version 2 license, then the option applies * only if the new code is made subject to such option by the copyright * holder. */package com.sun.jersey.impl.methodparams;import com.sun.jersey.impl.AbstractResourceTester;import com.sun.jersey.impl.AbstractResourceTester;import com.sun.jersey.api.client.ClientResponse;import java.util.List;import javax.ws.rs.DefaultValue;import javax.ws.rs.GET;import javax.ws.rs.ProduceMime;import javax.ws.rs.CookieParam;import javax.ws.rs.Path;import javax.ws.rs.core.Cookie;/** * * @author Paul.Sandoz@Sun.Com */public class CookieParamAsPrimitiveTest extends AbstractResourceTester { public CookieParamAsPrimitiveTest(String testName) { super(testName); initiateWebApplication( ResourceHeaderPrimitives.class, ResourceHeaderPrimitivesDefaultNull.class, ResourceHeaderPrimitivesDefault.class, ResourceHeaderPrimitivesDefaultOverride.class, ResourceHeaderPrimitiveWrappers.class, ResourceHeaderPrimitiveWrappersDefaultNull.class, ResourceHeaderPrimitiveWrappersDefault.class, ResourceHeaderPrimitiveWrappersDefaultOverride.class, ResourceHeaderPrimitiveList.class, ResourceHeaderPrimitiveListDefaultNull.class, ResourceHeaderPrimitiveListDefault.class, ResourceHeaderPrimitiveListDefaultOverride.class ); } @Path("/") public static class ResourceHeaderPrimitives { @GET @ProduceMime("application/boolean") public String doGet(@CookieParam("boolean") boolean v) { assertEquals(true, v); return "content"; } @GET @ProduceMime("application/byte") public String doGet(@CookieParam("byte") byte v) { assertEquals(127, v); return "content"; } @GET @ProduceMime("application/short") public String doGet(@CookieParam("short") short v) { assertEquals(32767, v); return "content"; } @GET @ProduceMime("application/int") public String doGet(@CookieParam("int") int v) { assertEquals(2147483647, v); return "content"; } @GET @ProduceMime("application/long") public String doGet(@CookieParam("long") long v) { assertEquals(9223372036854775807L, v); return "content"; } @GET @ProduceMime("application/float") public String doGet(@CookieParam("float") float v) { assertEquals(3.14159265f, v); return "content"; } @GET @ProduceMime("application/double") public String doGet(@CookieParam("double") double v) { assertEquals(3.14159265358979d, v); return "content"; } } @Path("/default/null") public static class ResourceHeaderPrimitivesDefaultNull { @GET @ProduceMime("application/boolean") public String doGet(@CookieParam("boolean") boolean v) { assertEquals(false, v); return "content"; } @GET @ProduceMime("application/byte") public String doGet(@CookieParam("byte") byte v) { assertEquals(0, v); return "content"; } @GET @ProduceMime("application/short") public String doGet(@CookieParam("short") short v) { assertEquals(0, v); return "content"; } @GET @ProduceMime("application/int") public String doGet(@CookieParam("int") int v) { assertEquals(0, v); return "content"; } @GET @ProduceMime("application/long") public String doGet(@CookieParam("long") long v) { assertEquals(0l, v); return "content"; } @GET @ProduceMime("application/float") public String doGet(@CookieParam("float") float v) { assertEquals(0.0f, v); return "content"; } @GET @ProduceMime("application/double") public String doGet(@CookieParam("double") double v) { assertEquals(0.0d, v); return "content"; } } @Path("/default") public static class ResourceHeaderPrimitivesDefault { @GET @ProduceMime("application/boolean") public String doGet(@CookieParam("boolean") @DefaultValue("true") boolean v) { assertEquals(true, v); return "content"; } @GET @ProduceMime("application/byte") public String doGet(@CookieParam("byte") @DefaultValue("127") byte v) { assertEquals(127, v); return "content"; } @GET @ProduceMime("application/short") public String doGet(@CookieParam("short") @DefaultValue("32767") short v) { assertEquals(32767, v); return "content"; } @GET @ProduceMime("application/int") public String doGet(@CookieParam("int") @DefaultValue("2147483647") int v) { assertEquals(2147483647, v); return "content"; } @GET @ProduceMime("application/long") public String doGet(@CookieParam("long") @DefaultValue("9223372036854775807") long v) { assertEquals(9223372036854775807L, v); return "content"; } @GET @ProduceMime("application/float") public String doGet(@CookieParam("float") @DefaultValue("3.14159265") float v) { assertEquals(3.14159265f, v); return "content"; } @GET @ProduceMime("application/double") public String doGet(@CookieParam("double") @DefaultValue("3.14159265358979") double v) { assertEquals(3.14159265358979d, v); return "content"; } } @Path("/default/override") public static class ResourceHeaderPrimitivesDefaultOverride { @GET @ProduceMime("application/boolean") public String doGet(@CookieParam("boolean") @DefaultValue("false") boolean v) { assertEquals(true, v); return "content"; } @GET @ProduceMime("application/byte") public String doGet(@CookieParam("byte") @DefaultValue("1") byte v) { assertEquals(127, v); return "content"; } @GET @ProduceMime("application/short") public String doGet(@CookieParam("short") @DefaultValue("1") short v) { assertEquals(32767, v); return "content"; } @GET @ProduceMime("application/int") public String doGet(@CookieParam("int") @DefaultValue("1") int v) { assertEquals(2147483647, v); return "content"; } @GET @ProduceMime("application/long") public String doGet(@CookieParam("long") @DefaultValue("1") long v) { assertEquals(9223372036854775807L, v); return "content"; } @GET @ProduceMime("application/float") public String doGet(@CookieParam("float") @DefaultValue("0.0") float v) { assertEquals(3.14159265f, v); return "content"; } @GET @ProduceMime("application/double") public String doGet(@CookieParam("double") @DefaultValue("0.0") double v) { assertEquals(3.14159265358979d, v); return "content"; } } @Path("/wrappers") public static class ResourceHeaderPrimitiveWrappers { @GET @ProduceMime("application/boolean") public String doGet(@CookieParam("boolean") Boolean v) { assertEquals(true, v.booleanValue()); return "content"; } @GET @ProduceMime("application/byte") public String doGet(@CookieParam("byte") Byte v) { assertEquals(127, v.byteValue()); return "content"; } @GET @ProduceMime("application/short") public String doGet(@CookieParam("short") Short v) { assertEquals(32767, v.shortValue()); return "content"; } @GET @ProduceMime("application/int") public String doGet(@CookieParam("int") Integer v) { assertEquals(2147483647, v.intValue()); return "content"; } @GET @ProduceMime("application/long") public String doGet(@CookieParam("long") Long v) { assertEquals(9223372036854775807L, v.longValue()); return "content"; } @GET @ProduceMime("application/float") public String doGet(@CookieParam("float") Float v) { assertEquals(3.14159265f, v.floatValue()); return "content"; } @GET @ProduceMime("application/double") public String doGet(@CookieParam("double") Double v) { assertEquals(3.14159265358979d, v.doubleValue()); return "content"; } } @Path("/wrappers/default/null") public static class ResourceHeaderPrimitiveWrappersDefaultNull { @GET @ProduceMime("application/boolean") public String doGet(@CookieParam("boolean") Boolean v) { assertEquals(null, v); return "content"; } @GET @ProduceMime("application/byte") public String doGet(@CookieParam("byte") Byte v) { assertEquals(null, v); return "content"; } @GET @ProduceMime("application/short") public String doGet(@CookieParam("short") Short v) { assertEquals(null, v); return "content"; } @GET @ProduceMime("application/int") public String doGet(@CookieParam("int") Integer v) { assertEquals(null, v); return "content"; } @GET @ProduceMime("application/long") public String doGet(@CookieParam("long") Long v) { assertEquals(null, v); return "content"; } @GET @ProduceMime("application/float") public String doGet(@CookieParam("float") Float v) { assertEquals(null, v); return "content"; } @GET @ProduceMime("application/double") public String doGet(@CookieParam("double") Double v) { assertEquals(null, v); return "content"; } } @Path("/wrappers/default") public static class ResourceHeaderPrimitiveWrappersDefault { @GET @ProduceMime("application/boolean") public String doGet(@CookieParam("boolean") @DefaultValue("true") Boolean v) { assertEquals(true, v.booleanValue()); return "content"; } @GET @ProduceMime("application/byte") public String doGet(@CookieParam("byte") @DefaultValue("127") Byte v) { assertEquals(127, v.byteValue()); return "content"; } @GET @ProduceMime("application/short") public String doGet(@CookieParam("short") @DefaultValue("32767") Short v) { assertEquals(32767, v.shortValue()); return "content"; } @GET @ProduceMime("application/int") public String doGet(@CookieParam("int") @DefaultValue("2147483647") Integer v) { assertEquals(2147483647, v.intValue()); return "content"; } @GET @ProduceMime("application/long") public String doGet(@CookieParam("long") @DefaultValue("9223372036854775807") Long v) { assertEquals(9223372036854775807L, v.longValue()); return "content"; } @GET @ProduceMime("application/float") public String doGet(@CookieParam("float") @DefaultValue("3.14159265") Float v) { assertEquals(3.14159265f, v.floatValue()); return "content"; } @GET @ProduceMime("application/double") public String doGet(@CookieParam("double") @DefaultValue("3.14159265358979") Double v) { assertEquals(3.14159265358979d, v.doubleValue()); return "content";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -