You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by ng...@apache.org on 2009/06/23 07:38:19 UTC
svn commit: r787553 [16/34] - in /incubator/wink/contrib/ibm-jaxrs/tests: ./
fvt/ fvt/demo/ fvt/demo/jaxrs/ fvt/demo/jaxrs/cache/
fvt/demo/jaxrs/cache/server/ fvt/demo/jaxrs/cache/test/
fvt/demo/jaxrs/datasource/ fvt/demo/jaxrs/datasource/server/ fvt/d...
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/server/UserContextProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/server/UserContextProvider.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/server/UserContextProvider.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/server/UserContextProvider.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.jaxb.context.server;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+import javax.xml.bind.JAXBContext;
+
+import jaxrs.tests.jaxb.context.server.jaxb.ObjectFactory;
+
+@Provider
+public class UserContextProvider implements ContextResolver<JAXBContext> {
+
+ public JAXBContext getContext(Class<?> clazz) {
+ if (clazz == User.class) {
+ try {
+ return JAXBContext.newInstance(ObjectFactory.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/server/jaxb/ObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/server/jaxb/ObjectFactory.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/server/jaxb/ObjectFactory.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/server/jaxb/ObjectFactory.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.jaxb.context.server.jaxb;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRegistry;
+
+import jaxrs.tests.jaxb.context.server.User;
+
+@XmlRegistry
+public class ObjectFactory {
+
+ @XmlElement(name = "user", namespace = "http://jaxb.context.tests")
+ public User createUser() {
+ return new User();
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/test/ContextTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/test/ContextTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/test/ContextTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/jaxb/context/test/ContextTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.jaxb.context.test;
+
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import jaxrs.tests.jaxb.context.server.User;
+import jaxrs.tests.jaxb.context.server.jaxb.ObjectFactory;
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+
+import framework.defaults.test.DefaultURIInfo;
+import framework.defaults.test.FVTTestCase;
+
+public class ContextTest extends FVTTestCase {
+
+ protected HttpClient httpClient = new HttpClient();
+
+ final private static String USER_URI = DefaultURIInfo
+ .getClassDefaultBaseURI(ContextTest.class)
+ + "/user";
+
+ public static Test suite() {
+ return FVTTestCase.getTestSuite(ContextTest.class,
+ jaxrs.tests.jaxb.context.server.Application.class.getName());
+ }
+
+ public void testUserContextProvider() throws Exception {
+ PostMethod postMethod = new PostMethod(USER_URI);
+ GetMethod getMethod = new GetMethod(USER_URI + "/joedoe@example.com");
+ try {
+ User user = new User();
+ user.setUserName("joedoe@example.com");
+ JAXBElement<User> element = new JAXBElement<User>(new QName(
+ "http://jaxb.context.tests", "user"), User.class, user);
+ JAXBContext context = JAXBContext.newInstance(ObjectFactory.class);
+ StringWriter sw = new StringWriter();
+ Marshaller m = context.createMarshaller();
+ m.marshal(element, sw);
+ postMethod.setRequestEntity(new ByteArrayRequestEntity(sw
+ .toString().getBytes(), "text/xml"));
+ httpClient.executeMethod(postMethod);
+ httpClient.executeMethod(getMethod);
+ Unmarshaller u = context.createUnmarshaller();
+ element = u.unmarshal(new StreamSource(getMethod
+ .getResponseBodyAsStream()), User.class);
+ assertNotNull(element);
+ user = element.getValue();
+ assertNotNull(user);
+ assertEquals("joedoe@example.com", user.getUserName());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.toString());
+ } finally {
+ postMethod.releaseConnection();
+ getMethod.releaseConnection();
+ }
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/buildTest.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/buildTest.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/buildTest.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/buildTest.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project name="jaxrs.tests.large" default="all">
+ <import file="../../../buildCommon.xml" />
+</project>
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/Application.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.large.server;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Application extends javax.ws.rs.core.Application {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> clazzes = new HashSet<Class<?>>();
+ clazzes.add(LargeResource.class);
+ clazzes.add(JARInputStreamProvider.class);
+ return clazzes;
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/JARInputStreamProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/JARInputStreamProvider.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/JARInputStreamProvider.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/JARInputStreamProvider.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.large.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.jar.JarInputStream;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+@Consumes("application/jar")
+public class JARInputStreamProvider implements MessageBodyReader<JarInputStream> {
+
+ public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+ return JarInputStream.class.isAssignableFrom(arg0);
+ }
+
+ public JarInputStream readFrom(Class<JarInputStream> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
+ throws IOException, WebApplicationException {
+ return new JarInputStream(arg5);
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/LargeResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/LargeResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/LargeResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/server/LargeResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.large.server;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+@Path("/large")
+public class LargeResource {
+
+ @POST
+ public Response appendStrings(String input) {
+ StringBuffer sb = new StringBuffer(input);
+ /*
+ * use only 2048 characters in header because of Jetty configuration
+ * which has a buffer limit of only 4096. give some room for other
+ * possible headers
+ */
+ return Response.status(277).entity(input + "entity").header(
+ "appendStringsHeader", sb.subSequence(0, 2042) + "header")
+ .build();
+ }
+
+ @POST
+ @Path("zip")
+ public Response findFirstEntry(JarInputStream jarInputStream)
+ throws IOException {
+ if (jarInputStream == null) {
+ return Response.status(Status.BAD_REQUEST).entity("no jar").build();
+ }
+ JarEntry je = null;
+ List<String> l = new ArrayList<String>();
+ while ((je = jarInputStream.getNextJarEntry()) != null) {
+ l.add(je.getName());
+ }
+ Collections.sort(l);
+ if (l.size() > 0) {
+ return Response.status(290).entity(l.get(0)).build();
+ }
+ return Response.status(Status.NO_CONTENT).build();
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/test/LargeEntityTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/test/LargeEntityTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/test/LargeEntityTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/large/test/LargeEntityTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.large.test;
+
+import java.io.File;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.FileRequestEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+
+import framework.defaults.test.FVTTestCase;
+
+public class LargeEntityTest extends FVTTestCase {
+
+ public static junit.framework.Test suite() {
+ return FVTTestCase.getTestSuite(LargeEntityTest.class,
+ "jaxrs.tests.large.server.Application");
+ }
+
+ /**
+ * Tests sending a large string. Possible failures including the servlet
+ * request buffer being too small, so the status headers do not get set
+ * correctly since the message body will have to be flushed out of the
+ * servlet response buffer.
+ *
+ * @throws Exception
+ */
+ public void testSendLargeString() throws Exception {
+ PostMethod postMethod = new PostMethod(getBaseURI() + "/large");
+ HttpClient client = new HttpClient();
+ try {
+ StringBuffer sb = new StringBuffer();
+ for (long c = 0; c < 5000000; ++c) {
+ sb.append("a");
+ }
+ postMethod.setRequestEntity(new StringRequestEntity(sb.toString(),
+ "text/xml", null));
+ client.executeMethod(postMethod);
+ assertEquals(277, postMethod.getStatusCode());
+ Header header = postMethod.getResponseHeader("appendStringsHeader");
+ assertNotNull(header);
+ assertEquals(sb.subSequence(0, 2042) + "header", header.getValue());
+ String resp = postMethod.getResponseBodyAsString();
+ assertEquals(sb.toString() + "entity", resp);
+ } finally {
+ postMethod.releaseConnection();
+ }
+ }
+
+ /**
+ * Tests sending a JAR file.
+ *
+ * @throws Exception
+ */
+ public void testSendJAR() throws Exception {
+ PostMethod postMethod = new PostMethod(getBaseURI() + "/large/zip");
+ HttpClient client = new HttpClient();
+ try {
+ postMethod.setRequestEntity(new FileRequestEntity(new File(
+ "lib/commons-httpclient-3.1.jar"), "application/jar"));
+ client.executeMethod(postMethod);
+ assertEquals(290, postMethod.getStatusCode());
+ String resp = postMethod.getResponseBodyAsString();
+ assertEquals("META-INF/LICENSE.txt", resp);
+ } finally {
+ postMethod.releaseConnection();
+ }
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/buildTest.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/buildTest.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/buildTest.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/buildTest.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project name="jaxrs.tests.lifecycle" default="all">
+ <import file="../../../buildCommon.xml" />
+</project>
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/Application.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.lifecycle.server;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Application extends javax.ws.rs.core.Application {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> clazzes = new HashSet<Class<?>>();
+ clazzes.add(MyResource.class);
+ clazzes.add(MyMessageBodyWriter.class);
+ return clazzes;
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/MyMessageBodyWriter.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/MyMessageBodyWriter.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/MyMessageBodyWriter.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/MyMessageBodyWriter.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.lifecycle.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.helpers.IOUtils;
+
+@Provider
+@Produces("text/plain")
+@Consumes("text/plain")
+public class MyMessageBodyWriter implements MessageBodyWriter<Object>, MessageBodyReader<Object> {
+
+ public static AtomicInteger readFromCounter = new AtomicInteger(0);
+
+ public static AtomicInteger writeToCounter = new AtomicInteger(0);
+
+ public static AtomicInteger constructorCounter = new AtomicInteger(0);
+
+ public MyMessageBodyWriter() {
+ constructorCounter.incrementAndGet();
+ }
+
+ public long getSize(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) {
+ return ((String) arg0).getBytes().length;
+ }
+
+ public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+
+ return String.class.equals(arg0);
+ }
+
+ public void writeTo(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4, MultivaluedMap<String, Object> arg5, OutputStream arg6)
+ throws IOException, WebApplicationException {
+ writeToCounter.incrementAndGet();
+ arg6.write(((String) arg0).getBytes());
+ }
+
+ public boolean isReadable(Class<?> arg0, Type arg1, Annotation[] arg2, MediaType arg3) {
+ return String.class.equals(arg0);
+ }
+
+ public Object readFrom(Class<Object> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream arg5)
+ throws IOException, WebApplicationException {
+ readFromCounter.incrementAndGet();
+ return IOUtils.readStringFromStream(arg5);
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/MyResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/MyResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/MyResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/server/MyResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.lifecycle.server;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+@Path("jaxrs/tests/lifecycles")
+public class MyResource {
+
+ @POST
+ public String getString(String echo) {
+ return echo;
+ }
+
+ @GET
+ public String getCounters() {
+ return MyMessageBodyWriter.constructorCounter.get() + ":"
+ + MyMessageBodyWriter.readFromCounter.get() + ":"
+ + MyMessageBodyWriter.writeToCounter.get();
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/test/LifeCycleTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/test/LifeCycleTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/test/LifeCycleTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/lifecycle/test/LifeCycleTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.lifecycle.test;
+
+import java.io.IOException;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+
+import framework.defaults.test.FVTTestCase;
+
+public class LifeCycleTest extends FVTTestCase {
+
+ public static junit.framework.Test suite() {
+ return FVTTestCase.getTestSuite(LifeCycleTest.class,
+ "jaxrs.tests.lifecycle.server.Application");
+ }
+
+ /**
+ * Tests that providers are singletons no matter what.
+ * @throws HttpException
+ * @throws IOException
+ */
+ public void testProvidersAreSingleton() throws HttpException, IOException {
+ HttpClient client = new HttpClient();
+ for (int counter = 0; counter < 100; ++counter) {
+ PostMethod postMethod = new PostMethod(getBaseURI()
+ + "/jaxrs/tests/lifecycles");
+ try {
+ StringBuffer sb = new StringBuffer();
+ for (long c = 0; c < 5000; ++c) {
+ sb.append("a");
+ }
+ postMethod.setRequestEntity(new StringRequestEntity(sb
+ .toString(), "text/plain", null));
+ client.executeMethod(postMethod);
+ assertEquals(200, postMethod.getStatusCode());
+ assertEquals(sb.toString(), postMethod
+ .getResponseBodyAsString());
+ } finally {
+ postMethod.releaseConnection();
+ }
+ }
+
+ GetMethod getMethod = new GetMethod(getBaseURI()
+ + "/jaxrs/tests/lifecycles");
+ client.executeMethod(getMethod);
+ assertEquals(200, getMethod.getStatusCode());
+ assertEquals("1:100:100", getMethod.getResponseBodyAsString());
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/buildTest.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/buildTest.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/buildTest.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/buildTest.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project name="jaxrs.tests.mediatype" default="all">
+ <import file="../../../buildCommon.xml" />
+</project>
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/server/Application.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.mediatype.server;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Application extends javax.ws.rs.core.Application {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> clazzes = new HashSet<Class<?>>();
+ return clazzes;
+ }
+
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/test/SampleTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/test/SampleTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/test/SampleTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/mediatype/test/SampleTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.mediatype.test;
+
+import framework.defaults.test.FVTTestCase;
+
+public class SampleTest extends FVTTestCase {
+
+ public static junit.framework.Test suite() {
+ return FVTTestCase.getTestSuite(SampleTest.class,
+ "jaxrs.tests.mediatype.server.Application");
+ }
+
+ public void testSomething() {
+
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/buildTest.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/buildTest.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/buildTest.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/buildTest.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project name="jaxrs.tests.params" default="all">
+ <import file="../../../buildCommon.xml" />
+</project>
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/Application.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/Application.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/Application.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/Application.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.params.server;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import jaxrs.tests.params.server.form.FormParamResource;
+import jaxrs.tests.params.server.header.HeaderParamDefaultResource;
+import jaxrs.tests.params.server.header.HeaderParamExceptionResource;
+import jaxrs.tests.params.server.query.QueryParamsExceptionResource;
+
+/**
+ * Parameters annotation test application.
+ */
+public class Application extends javax.ws.rs.core.Application {
+
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+
+ public Application() {
+ classes = new HashSet<Class<?>>();
+ classes.add(HeaderParamResource.class);
+ classes.add(MatrixParamResource.class);
+ classes.add(QueryParamResource.class);
+ classes.add(EncodingParamResource.class);
+ classes.add(AutoDecodeParamResource.class);
+ classes.add(DefaultValueResource.class);
+ classes.add(CookieParamResource.class);
+
+ classes.add(HeaderParamDefaultResource.class);
+ classes.add(HeaderParamExceptionResource.class);
+
+ classes.add(QueryParamsExceptionResource.class);
+
+ classes.add(FormParamResource.class);
+
+ classes.add(QueryParamNotSetResource.class);
+ classes.add(MatrixParamNotSetResource.class);
+
+ classes.add(PathSegmentResource.class);
+
+ // classes.add(MultipleEntityParamsResource.class);
+
+ classes = Collections.unmodifiableSet(classes);
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return classes;
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/AutoDecodeParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/AutoDecodeParamResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/AutoDecodeParamResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/AutoDecodeParamResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.params.server;
+
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+
+@Path("/decodedparams")
+public class AutoDecodeParamResource {
+
+ final private String appVersion;
+
+ public AutoDecodeParamResource(@MatrixParam("appversion") String appVersion) {
+ this.appVersion = appVersion;
+ }
+
+ @GET
+ @Path("country/{location}")
+ public String getShopInCountryDecoded(@PathParam("location") String location) {
+ return "getShopInCountryDecoded:location=" + location + ";appversion="
+ + appVersion;
+ }
+
+ @GET
+ @Path("city")
+ public String getShopInCityDecoded(@QueryParam("location") String location) {
+ return "getShopInCityDecoded:location=" + location + ";appversion="
+ + appVersion;
+ }
+
+ @GET
+ @Path("street")
+ public String getShopOnStreetDecoded(@MatrixParam("location") String location) {
+ return "getShopOnStreetDecoded:location=" + location + ";appversion="
+ + appVersion;
+ }
+
+ @POST
+ @Path("region")
+ public String getShopInRegionDecoded(@FormParam("location") String location) {
+ return "getShopInRegionDecoded:location=" + location + ";appversion="
+ + appVersion;
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/CookieParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/CookieParamResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/CookieParamResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/CookieParamResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.params.server;
+
+import javax.ws.rs.CookieParam;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.NewCookie;
+import javax.ws.rs.core.Response;
+
+@Path("cookiemonster")
+public class CookieParamResource {
+
+ @PUT
+ @Produces("text/plain")
+ public Response swipe(@CookieParam("jar") @DefaultValue("0") String jarSwipes) {
+ return Response.ok("swiped:" + jarSwipes).cookie(
+ new NewCookie("jar", (Integer.valueOf(jarSwipes) + 1) + ""))
+ .build();
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/DefaultValueResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/DefaultValueResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/DefaultValueResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/DefaultValueResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.params.server;
+
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+@Path("defaultvalue")
+public class DefaultValueResource {
+
+ private String version;
+
+ @DefaultValue("100")
+ @QueryParam("limit")
+ private String limit;
+
+ private String sort;
+
+ public DefaultValueResource(@HeaderParam("requestVersion") @DefaultValue("1.0") String version) {
+ this.version = version;
+ }
+
+ public static class Page {
+
+ private String offset;
+
+ public Page(String offset, int dummy) {
+ this.offset = offset;
+ System.out.println("Executed constructor");
+ }
+
+ public String getOffset() {
+ return offset;
+ }
+
+ public int getPage() {
+ return Integer.valueOf(offset) * 1; // Integer.valueOf(limit);
+ }
+
+ public static Page valueOf(String offset) {
+ return new Page(offset, 123);
+ }
+ }
+
+ @GET
+ public String getRow(@QueryParam("offset") @DefaultValue("0") Page page) {
+ return "getRow:" + "offset=" + page.getOffset() + ";version=" + version
+ + ";limit=" + limit + ";sort=" + sort;
+ }
+
+ @DefaultValue("normal")
+ @QueryParam("sort")
+ public void setSort(String sort) {
+ this.sort = sort;
+ }
+
+ public String getSort() {
+ return sort;
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/EncodingParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/EncodingParamResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/EncodingParamResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/EncodingParamResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.params.server;
+
+import javax.ws.rs.Encoded;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+
+@Path("/encodingparam")
+public class EncodingParamResource {
+
+ final private String appVersion;
+
+ public EncodingParamResource(@Encoded @MatrixParam("appversion") String appVersion) {
+ this.appVersion = appVersion;
+ }
+
+ //
+ // @GET
+ // @Path("city/{city}")
+ // public String getShopInCity(@Encoded @QueryParam("q") String searchQuery,
+ // @PathParam("city") String city) {
+ // return "getShopInCity:q=" + searchQuery + ";city=" + city +
+ // ";appversion=" + appVersion;
+ // }
+
+ // @GET
+ // @Path("loc/{location}")
+ // @Encoded
+ // public String getShopInLocation(@QueryParam("q") String searchQuery,
+ // @Encoded @PathParam("location") String location) {
+ // return "getShopInLocation:q=" + searchQuery + ";location=" + location +
+ // ";appversion=" + appVersion;
+ // }
+
+ @GET
+ @Path("country/{location}")
+ public String getShopInCountry(@Encoded @PathParam("location") String location) {
+ return "getShopInCountry:location=" + location + ";appversion="
+ + appVersion;
+ }
+
+ @GET
+ @Path("method/country/{location}")
+ @Encoded
+ public String getShopInCountryMethod(@PathParam("location") String location) {
+ return "getShopInCountryMethod:location=" + location + ";appversion="
+ + appVersion;
+ }
+
+ @GET
+ @Encoded
+ @Path("method/city")
+ public String getShopInCityMethod(@QueryParam("location") String location) {
+ return "getShopInCityMethod:location=" + location + ";appversion="
+ + appVersion;
+ }
+
+ @GET
+ @Path("city")
+ public String getShopInCity(@Encoded @QueryParam("location") String location) {
+ return "getShopInCity:location=" + location + ";appversion="
+ + appVersion;
+ }
+
+ @GET
+ @Encoded
+ @Path("method/street")
+ public String getShopOnStreetMethod(@MatrixParam("location") String location) {
+ return "getShopOnStreetMethod:location=" + location + ";appversion="
+ + appVersion;
+ }
+
+ @GET
+ @Path("street")
+ public String getShopOnStreet(@Encoded @MatrixParam("location") String location) {
+ return "getShopOnStreet:location=" + location + ";appversion="
+ + appVersion;
+ }
+
+ @POST
+ @Path("region")
+ public String getShopInRegion(@Encoded @FormParam("location") String location) {
+ return "getShopInRegion:location=" + location + ";appversion="
+ + appVersion;
+ }
+
+ @POST
+ @Encoded
+ @Path("method/region")
+ public String getShopInRegionMethod(@FormParam("location") String location) {
+ return "getShopInRegionMethod:location=" + location + ";appversion="
+ + appVersion;
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/HeaderParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/HeaderParamResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/HeaderParamResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/HeaderParamResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.params.server;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+
+/**
+ * Resource with<code>HeaderParam</code>.
+ *
+ * @see HeaderParam
+ */
+@Path("header")
+public class HeaderParamResource {
+
+ private String cstrHeaderParam;
+
+ @HeaderParam("Accept-Language")
+ private String acceptLanguage;
+
+ private String agent;
+
+ static public class HeaderValueOf {
+ private HeaderValueOf(String somevalue) {
+ }
+
+ public static HeaderValueOf valueOf(String someValue) {
+ if ("throwex".equals(someValue)) {
+ throw new WebApplicationException(499);
+ } else if ("throwruntimeex".equals(someValue)) {
+ throw new IllegalArgumentException();
+ }
+ return new HeaderValueOf(someValue);
+ }
+ }
+
+ static public class HeaderConstructor {
+ public HeaderConstructor(String somevalue) {
+ if ("throwex".equals(somevalue)) {
+ throw new WebApplicationException(499);
+ } else if ("throwruntimeex".equals(somevalue)) {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
+ public HeaderParamResource(@HeaderParam("customHeaderParam") String cstrHeaderParam) {
+ this.cstrHeaderParam = cstrHeaderParam;
+ }
+
+ @GET
+ public Response getHeaderParam(@HeaderParam("Accept-Language") String methodLanguage) {
+ return Response.ok(
+ "getHeaderParam:" + cstrHeaderParam + ";User-Agent:" + agent
+ + ";Accept-Language:" + acceptLanguage
+ + ";language-method:" + methodLanguage).header(
+ "custResponseHeader", "secret").build();
+ }
+
+ @POST
+ public Response getHeaderParamPost(@HeaderParam("CustomHeader") HeaderValueOf customHeader, @HeaderParam("CustomConstructorHeader") HeaderConstructor customHeader2) {
+ return Response.ok().entity("made successful call").build();
+ }
+
+ @HeaderParam("User-Agent")
+ public void setUserAgent(String aUserAgent) {
+ agent = aUserAgent;
+ }
+
+ public String getUserAgent() {
+ return agent;
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/MatrixParamNotSetResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/MatrixParamNotSetResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/MatrixParamNotSetResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/MatrixParamNotSetResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.params.server;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.Path;
+
+@Path("/matrixparamnotset")
+public class MatrixParamNotSetResource {
+
+ @Path("int")
+ @GET
+ public int getDefault(@MatrixParam("count") int count) {
+ return count;
+ }
+
+ @Path("short")
+ @GET
+ public short getDefault(@MatrixParam("smallCount") short smallCount) {
+ return smallCount;
+ }
+
+ @Path("long")
+ @GET
+ public long getDefault(@MatrixParam("longCount") long longCount) {
+ return longCount;
+ }
+
+ @Path("float")
+ @GET
+ public float getDefault(@MatrixParam("floatCount") float floatCount) {
+ return floatCount;
+ }
+
+ @Path("double")
+ @GET
+ public double getDefault(@MatrixParam("count") double count) {
+ return count;
+ }
+
+ @Path("byte")
+ @GET
+ public byte getDefault(@MatrixParam("b") byte count) {
+ return count;
+ }
+
+ @Path("char")
+ @GET
+ public String getDefault(@MatrixParam("letter") char letter) {
+ return letter + "";
+ }
+
+ @Path("set")
+ @GET
+ public int getDefault(@MatrixParam("bag") Set<Integer> stuff) {
+ return stuff.size();
+ }
+
+ @Path("list")
+ @GET
+ public int getDefault(@MatrixParam("letter") List<String> stuff) {
+ return stuff.size();
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/MatrixParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/MatrixParamResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/MatrixParamResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/MatrixParamResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,319 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.params.server;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+
+/**
+ * A simple resource to test <code>@MatrixParam</code>.
+ */
+@Path("/matrix")
+public class MatrixParamResource {
+
+ private String constructorParam;
+
+ /**
+ * Resource constructor.
+ *
+ * @param aConstructorParam
+ * a simple <code>@MatrixParam</code> constructor parameter
+ */
+ public MatrixParamResource(@MatrixParam("cstrparam") String aConstructorParam) {
+ this.constructorParam = aConstructorParam;
+ }
+
+ /**
+ * GET method for constructor matrix parameter.
+ *
+ * @return transformed string
+ */
+ @GET
+ public String getConstructorMatrixParam() {
+ return "getConstructorMatrixParam:" + constructorParam;
+ }
+
+ /**
+ * POST method for constructor matrix parameter.
+ *
+ * @return transformed string
+ */
+ @POST
+ public String postConstructorMatrixParam() {
+ return "postConstructorMatrixParam:" + constructorParam;
+ }
+
+ /**
+ * PUT method for constructor matrix parameter.
+ *
+ * @return transformed string
+ */
+ @PUT
+ public String putConstructorMatrixParam() {
+ return "putConstructorMatrixParam:" + constructorParam;
+ }
+
+ /**
+ * DELETE method for constructor matrix parameter.
+ *
+ * @return transformed string
+ */
+ @DELETE
+ public String deleteConstructorMatrixParam() {
+ return "deleteConstructorMatrixParam:" + constructorParam;
+ }
+
+ /**
+ * GET method for simple matrix parameter.
+ *
+ * @param life
+ * simple parameter
+ * @return transformed string
+ */
+ @GET
+ @Path("simple")
+ public String getSimpleMatrixParam(@MatrixParam("life") String life) {
+ return "getSimpleMatrixParam:" + constructorParam + ";" + life;
+ }
+
+ /**
+ * POST method for simple matrix parameter.
+ *
+ * @param life
+ * simple parameter
+ * @return transformed string
+ */
+ @POST
+ @Path("simple")
+ public String postSimpleMatrixParam(@MatrixParam("life") String life) {
+ return "postSimpleMatrixParam:" + constructorParam + ";" + life;
+ }
+
+ /**
+ * PUT method for simple matrix parameter.
+ *
+ * @param life
+ * simple parameter
+ * @return transformed string
+ */
+ @PUT
+ @Path("simple")
+ public String putSimpleMatrixParam(@MatrixParam("life") String life) {
+ return "putSimpleMatrixParam:" + constructorParam + ";" + life;
+ }
+
+ /**
+ * DELETE method for simple matrix parameter.
+ *
+ * @param life
+ * simple parameter
+ * @return transformed string
+ */
+ @DELETE
+ @Path("simple")
+ public String deleteSimpleMatrixParam(@MatrixParam("life") String life) {
+ return "deleteSimpleMatrixParam:" + constructorParam + ";" + life;
+ }
+
+ /**
+ * GET method for multiple matrix parameters.
+ *
+ * @param first
+ * @param uppercaseOneMoreParam
+ * @param lowercaseOneMoreParam
+ * @return transformed string
+ */
+ @GET
+ @Path("multiple")
+ public String getMultipleMatrixParam(@MatrixParam("1st") String first, @MatrixParam("ONEMOREPARAM") String uppercaseOneMoreParam, @MatrixParam("onemoreparam") String lowercaseOneMoreParam) {
+ return "getMultipleMatrixParam:" + first + ";" + uppercaseOneMoreParam
+ + ";" + lowercaseOneMoreParam;
+ }
+
+ /**
+ * POST method for multiple matrix parameters.
+ *
+ * @param first
+ * @param uppercaseOneMoreParam
+ * @param lowercaseOneMoreParam
+ * @return transformed string
+ */
+ @POST
+ @Path("multiple")
+ public String postMultipleMatrixParam(@MatrixParam("1st") String first, @MatrixParam("ONEMOREPARAM") String uppercaseOneMoreParam, @MatrixParam("onemoreparam") String lowercaseOneMoreParam) {
+ return "postMultipleMatrixParam:" + first + ";" + uppercaseOneMoreParam
+ + ";" + lowercaseOneMoreParam;
+ }
+
+ /**
+ * PUT method for multiple matrix parameters.
+ *
+ * @param first
+ * @param uppercaseOneMoreParam
+ * @param lowercaseOneMoreParam
+ * @return transformed string
+ */
+ @PUT
+ @Path("multiple")
+ public String putMultipleMatrixParam(@MatrixParam("1st") String first, @MatrixParam("ONEMOREPARAM") String uppercaseOneMoreParam, @MatrixParam("onemoreparam") String lowercaseOneMoreParam) {
+ return "putMultipleMatrixParam:" + first + ";" + uppercaseOneMoreParam
+ + ";" + lowercaseOneMoreParam;
+ }
+
+ /**
+ * DELETE method for multiple matrix parameters.
+ *
+ * @param first
+ * @param uppercaseOneMoreParam
+ * @param lowercaseOneMoreParam
+ * @return transformed string
+ */
+ @DELETE
+ @Path("multiple")
+ public String deleteMultipleMatrixParam(@MatrixParam("1st") String first, @MatrixParam("ONEMOREPARAM") String uppercaseOneMoreParam, @MatrixParam("onemoreparam") String lowercaseOneMoreParam) {
+ return "deleteMultipleMatrixParam:" + first + ";"
+ + uppercaseOneMoreParam + ";" + lowercaseOneMoreParam;
+ }
+
+ /**
+ * GET method to test primitive matrix typed parameters
+ *
+ * @param aBoolean
+ * @param anInteger
+ * @param aDouble
+ * @param aByte
+ * @param ch
+ * @param aLong
+ * @param aShort
+ * @param aFloat
+ * @return a transformed string
+ */
+ @GET
+ @Path("types/primitive")
+ public String getMatrixPrimitiveTypes(@MatrixParam("bool") Boolean aBoolean, @MatrixParam("intNumber") int anInteger, @MatrixParam("dbl") double aDouble, @MatrixParam("bite") byte aByte, @MatrixParam("ch") char ch, @MatrixParam("lng") long aLong, @MatrixParam("float") short aShort, @MatrixParam("short") float aFloat) {
+ return "getMatrixParameterPrimitiveTypes:" + aBoolean + ";" + anInteger
+ + ";" + aDouble + ";" + aByte + ";" + ch + ";" + aLong + ";"
+ + aShort + ";" + aFloat;
+ }
+
+ /**
+ * A type with a public string constructor.
+ */
+ public static class ParamWithStringConstructor {
+ private String value = null;
+
+ /**
+ * Should not be called.
+ */
+ public ParamWithStringConstructor() {
+ value = "noconstructor";
+ }
+
+ /**
+ * Should not be called.
+ *
+ * @param anInt
+ */
+ public ParamWithStringConstructor(Integer anInt) {
+ value = "intconstructor";
+ }
+
+ /**
+ * String constructor
+ *
+ * @param aValue
+ */
+ public ParamWithStringConstructor(String aValue) {
+ this.value = aValue;
+ }
+
+ /**
+ * Transform the value to something else.
+ *
+ * @return a transformed value
+ */
+ public Integer transformedValue() {
+ return Integer.valueOf(value);
+ }
+ }
+
+ /**
+ * GET method to test matrix parameter types with a public string
+ * constructor.
+ *
+ * @param param
+ * parameter which has a string constructor
+ * @return a transformed value
+ */
+ @GET
+ @Path("types/stringcstr")
+ public String getQueryParameterStringConstructor(@MatrixParam("paramStringConstructor") ParamWithStringConstructor param) {
+ return "getMatrixParameterStringConstructor:"
+ + param.transformedValue();
+ }
+
+ /**
+ * Type with a public static valueOf method to test query parameters.
+ */
+ public static class ParamWithValueOf {
+ private String value = null;
+
+ protected ParamWithValueOf(String aValue, int aNum) {
+ value = aValue + aNum;
+ }
+
+ /**
+ * The transformed type value
+ *
+ * @return the transformed type value
+ */
+ public String transformedValue() {
+ return value;
+ }
+
+ /**
+ * Public static valueOf method.
+ *
+ * @param aValue
+ * string value to transform into type
+ * @return an instance of the type
+ */
+ public static ParamWithValueOf valueOf(String aValue) {
+ return new ParamWithValueOf(aValue, 789);
+ }
+ }
+
+ /**
+ * GET method to test matrix parameter with a static valueOf(String) method.
+ *
+ * @param param
+ * the parameter type has a static valueOf(String) method
+ * @return a transformed value
+ */
+ @GET
+ @Path("types/valueof")
+ public String getQueryParameterValueOf(@MatrixParam("staticValueOf") ParamWithValueOf param) {
+ return "getMatrixParameterValueOf:" + param.transformedValue();
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/PathSegmentResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/PathSegmentResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/PathSegmentResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/PathSegmentResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.params.server;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.PathSegment;
+
+@Path("/params/pathsegment")
+public class PathSegmentResource {
+
+ @Path("{loc}")
+ @GET
+ public String helloPath(@PathParam("loc") PathSegment pathSegment) {
+ return pathSegment.getPath();
+ }
+
+ @Path("matrix/{loc}")
+ @GET
+ public String helloPath(@PathParam("loc") PathSegment pathSegment, @MatrixParam("mp") String matrix, @PathParam("loc") String path) {
+ return path + "-" + pathSegment.getPath() + "-"
+ + pathSegment.getMatrixParameters().get(matrix) + "-" + matrix;
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/QueryParamNotSetResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/QueryParamNotSetResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/QueryParamNotSetResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/QueryParamNotSetResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.params.server;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+@Path("/queryparamnotset")
+public class QueryParamNotSetResource {
+
+ @Path("int")
+ @GET
+ public String getDefault(@QueryParam("count") int count) {
+ return Integer.valueOf(count).toString();
+ }
+
+ @Path("short")
+ @GET
+ public short getDefault(@QueryParam("smallCount") short smallCount) {
+ return smallCount;
+ }
+
+ @Path("long")
+ @GET
+ public long getDefault(@QueryParam("longCount") long longCount) {
+ return longCount;
+ }
+
+ @Path("float")
+ @GET
+ public float getDefault(@QueryParam("floatCount") float floatCount) {
+ return floatCount;
+ }
+
+ @Path("double")
+ @GET
+ public double getDefault(@QueryParam("d") double count) {
+ return count;
+ }
+
+ @Path("byte")
+ @GET
+ public byte getDefault(@QueryParam("b") byte count) {
+ return count;
+ }
+
+ @Path("char")
+ @GET
+ public String getDefault(@QueryParam("letter") char count) {
+ return count + "";
+ }
+
+ @Path("set")
+ @GET
+ public int getDefault(@QueryParam("bag") Set<Integer> stuff) {
+ return stuff.size();
+ }
+
+ @Path("list")
+ @GET
+ public int getDefault(@QueryParam("letter") List<String> stuff) {
+ return stuff.size();
+ }
+}
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/QueryParamResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/QueryParamResource.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/QueryParamResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/jaxrs/tests/params/server/QueryParamResource.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,326 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package jaxrs.tests.params.server;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+/**
+ * A simple resource to test <code>@QueryParam</code>.
+ */
+@Path("query")
+public class QueryParamResource {
+
+ private String aQueryID = "notset";
+
+ /**
+ * Constructor that will not be called.
+ */
+ public QueryParamResource() {
+ /* this code should not be called ever */
+ aQueryID = "notvalid";
+ }
+
+ /**
+ * Constructor with simple query parameter.
+ *
+ * @param aQueryID
+ * a query parameter
+ */
+ public QueryParamResource(@QueryParam("queryid") String aQueryID) {
+ this.aQueryID = aQueryID;
+ }
+
+ /**
+ * GET method on root resource.
+ *
+ * @return modified string with constructor query parameter
+ */
+ @GET
+ public String getConstructorQueryID() {
+ return "getConstructorQueryID:" + aQueryID;
+ }
+
+ /**
+ * PUT method on root resource.
+ *
+ * @return modified string with constructor query parameter
+ */
+ @PUT
+ public String putConstructorQueryID() {
+ return "putConstructorQueryID:" + aQueryID;
+ }
+
+ /**
+ * POST method on root resource.
+ *
+ * @return modified string with constructor query parameter
+ */
+ @POST
+ public String postConstructorQueryID() {
+ return "postConstructorQueryID:" + aQueryID;
+ }
+
+ /**
+ * DELETE method on root resource.
+ *
+ * @return modified string with constructor query parameter
+ */
+ @DELETE
+ public String deleteConstructorQueryID() {
+ return "deleteConstructorQueryID:" + aQueryID;
+ }
+
+ /**
+ * GET method with different path and additional query parameter.
+ *
+ * @param aSimpleParameter
+ * an additional simple parameter
+ * @return modified string with constructor and path query parameters
+ */
+ @GET
+ @Path("simple")
+ public String getSimpleQueryParameter(@QueryParam("simpleParam") String aSimpleParameter) {
+ return "getSimpleQueryParameter:" + aQueryID + ";" + aSimpleParameter;
+ }
+
+ /**
+ * PUT method with different path and additional query parameter.
+ *
+ * @param aSimpleParameter
+ * an additional simple parameter
+ * @return modified string with constructor and path query parameters
+ */
+ @DELETE
+ @Path("simple")
+ public String deleteSimpleQueryParameter(@QueryParam("simpleParam") String aSimpleParameter) {
+ return "deleteSimpleQueryParameter:" + aQueryID + ";"
+ + aSimpleParameter;
+ }
+
+ /**
+ * POST method with different path and additional query parameter.
+ *
+ * @param aSimpleParameter
+ * an additional simple parameter
+ * @return modified string with constructor and path query parameters
+ */
+ @PUT
+ @Path("simple")
+ public String putSimpleQueryParameter(@QueryParam("simpleParam") String aSimpleParameter) {
+ return "putSimpleQueryParameter:" + aQueryID + ";" + aSimpleParameter;
+ }
+
+ /**
+ * GET method with different path and additional query parameter.
+ *
+ * @param aSimpleParameter
+ * an additional simple parameter
+ * @return modified string with constructor and path query parameters
+ */
+ @POST
+ @Path("simple")
+ public String postSimpleQueryParameter(@QueryParam("simpleParam") String aSimpleParameter) {
+ return "postSimpleQueryParameter:" + aQueryID + ";" + aSimpleParameter;
+ }
+
+ /**
+ * GET method with multiple query parameters.
+ *
+ * @param multiparam1
+ * @param param123
+ * @param oneMoreParam
+ * @return modified string with constructor and all path query parameters
+ */
+ @GET
+ @Path("multiple")
+ public String getMultiQueryParameter(@QueryParam("multiParam1") String multiparam1, @QueryParam("123Param") String param123, @QueryParam("1MOREParam") String oneMoreParam) {
+ return "getMultiQueryParameter:" + aQueryID + ";" + multiparam1 + ";"
+ + param123 + ";" + oneMoreParam;
+ }
+
+ /**
+ * DELETE method with multiple query parameters.
+ *
+ * @param multiparam1
+ * @param param123
+ * @param oneMoreParam
+ * @return modified string with constructor and all path query parameters
+ */
+ @DELETE
+ @Path("multiple")
+ public String deleteMultiQueryParameter(@QueryParam("multiParam1") String multiparam1, @QueryParam("123Param") String param123, @QueryParam("1MOREParam") String oneMoreParam) {
+ return "deleteMultiQueryParameter:" + aQueryID + ";" + multiparam1
+ + ";" + param123 + ";" + oneMoreParam;
+ }
+
+ /**
+ * POST method with multiple query parameters.
+ *
+ * @param multiparam1
+ * @param param123
+ * @param oneMoreParam
+ * @return modified string with constructor and all path query parameters
+ */
+ @POST
+ @Path("multiple")
+ public String postMultiQueryParameter(@QueryParam("multiParam1") String multiparam1, @QueryParam("123Param") String param123, @QueryParam("1MOREParam") String oneMoreParam) {
+ return "postMultiQueryParameter:" + aQueryID + ";" + multiparam1 + ";"
+ + param123 + ";" + oneMoreParam;
+ }
+
+ /**
+ * PUT method with multiple query parameters.
+ *
+ * @param multiparam1
+ * @param param123
+ * @param oneMoreParam
+ * @return modified string with constructor and all path query parameters
+ */
+ @PUT
+ @Path("multiple")
+ public String putMultiQueryParameter(@QueryParam("multiParam1") String multiparam1, @QueryParam("123Param") String param123, @QueryParam("1MOREParam") String oneMoreParam) {
+ return "putMultiQueryParameter:" + aQueryID + ";" + multiparam1 + ";"
+ + param123 + ";" + oneMoreParam;
+ }
+
+ /**
+ * GET method with multiple primitive typed query parameters.
+ *
+ * @param aBoolean
+ * @param anInteger
+ * @param aDouble
+ * @param aByte
+ * @param ch
+ * @param aLong
+ * @param aShort
+ * @param aFloat
+ * @return a concatenated string in method parameter order
+ */
+ @GET
+ @Path("types/primitive")
+ public String getQueryParameterPrimitiveTypes(@QueryParam("bool") Boolean aBoolean, @QueryParam("intNumber") int anInteger, @QueryParam("dbl") double aDouble, @QueryParam("bite") byte aByte, @QueryParam("ch") char ch, @QueryParam("lng") long aLong, @QueryParam("float") short aShort, @QueryParam("short") float aFloat) {
+ return "getQueryParameterPrimitiveTypes:" + aBoolean + ";" + anInteger
+ + ";" + aDouble + ";" + aByte + ";" + ch + ";" + aLong + ";"
+ + aShort + ";" + aFloat;
+ }
+
+ /**
+ * A type with a public string constructor.
+ */
+ public static class ParamWithStringConstructor {
+ private String value = null;
+
+ /**
+ * Should not be called.
+ */
+ public ParamWithStringConstructor() {
+ value = "noconstructor";
+ }
+
+ /**
+ * Should not be called.
+ *
+ * @param anInt
+ */
+ public ParamWithStringConstructor(Integer anInt) {
+ value = "intconstructor";
+ }
+
+ /**
+ * String constructor
+ *
+ * @param aValue
+ */
+ public ParamWithStringConstructor(String aValue) {
+ this.value = aValue;
+ }
+
+ /**
+ * Transform the value to something else.
+ *
+ * @return a transformed value
+ */
+ public Integer transformedValue() {
+ return Integer.valueOf(value);
+ }
+ }
+
+ /**
+ * GET method to test parameter types with a public string constructor.
+ *
+ * @param param
+ * parameter which has a string constructor
+ * @return a transformed value
+ */
+ @GET
+ @Path("types/stringcstr")
+ public String getQueryParameterStringConstructor(@QueryParam("paramStringConstructor") ParamWithStringConstructor param) {
+ return "getQueryParameterStringConstructor:" + param.transformedValue();
+ }
+
+ /**
+ * Type with a public static valueOf method to test query parameters.
+ */
+ public static class ParamWithValueOf {
+ private String value = null;
+
+ protected ParamWithValueOf(String aValue, int aNum) {
+ value = aValue + aNum;
+ }
+
+ /**
+ * The transformed type value
+ *
+ * @return the transformed type value
+ */
+ public String transformedValue() {
+ return value;
+ }
+
+ /**
+ * Public static valueOf method.
+ *
+ * @param aValue
+ * string value to transform into type
+ * @return an instance of the type
+ */
+ public static ParamWithValueOf valueOf(String aValue) {
+ return new ParamWithValueOf(aValue, 789);
+ }
+ }
+
+ /**
+ * GET method to test parameter with a static valueOf(String) method.
+ *
+ * @param param
+ * the parameter type has a static valueOf(String) method
+ * @return a transformed value
+ */
+ @GET
+ @Path("types/valueof")
+ public String getQueryParameterValueOf(@QueryParam("staticValueOf") ParamWithValueOf param) {
+ return "getQueryParameterValueOf:" + param.transformedValue();
+ }
+}