You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by jr...@apache.org on 2010/06/14 19:48:36 UTC
svn commit: r954566 [5/9] - in /incubator/wink/branches/wink-1.1-incubating:
./ wink-assembly/ wink-assembly/apache-wink/
wink-assembly/wink-assembly-aggregatejar-osgi/
wink-assembly/wink-assembly-aggregatejar/ wink-client-apache-httpclient/
wink-clien...
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/pom.xml?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/pom.xml (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/pom.xml Mon Jun 14 17:48:32 2010
@@ -1,99 +1,98 @@
-<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>wink-itest</artifactId>
- <groupId>org.apache.wink</groupId>
- <version>1.1-incubating</version>
- </parent>
- <groupId>org.apache.wink</groupId>
- <artifactId>wink-itest-client-timeout</artifactId>
- <packaging>war</packaging>
- <name>Apache Wink client Timeout System Property Tests</name>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- <executions>
- <execution>
- <id>test</id>
- <phase>test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <skip>true</skip>
- </configuration>
- </execution>
- <execution>
- <id>integration</id>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <skip>false</skip>
- <systemProperties>
- <property>
- <name>wink-test-context-root</name>
- <value>${artifactId}</value>
- </property>
- <property>
- <name>wink-test-hostname</name>
- <value>${wink.server.hostname}</value>
- </property>
- <property>
- <name>wink-test-port</name>
- <value>${wink.server.port}</value>
- </property>
- <property>
- <name>wink-test-work-dir</name>
- <value>${project.build.directory}</value>
- </property>
- <property>
- <name>wink-test-container</name>
- <value>${assemblyId}</value>
- </property>
- <property>
- <name>wink-rest-filter-used</name>
- <value>${wink.rest.filter.used}</value>
- </property>
- <property>
- <name>wink.client.readTimeout</name>
- <value>10000</value>
- </property>
- <property>
- <name>wink.client.connectTimeout</name>
- <value>10000</value>
- </property>
- </systemProperties>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>wink-itest</artifactId>
+ <groupId>org.apache.wink</groupId>
+ <version>1.1.1-incubating-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.wink</groupId>
+ <artifactId>wink-itest-client-timeout</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Wink client Timeout System Property Tests</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>integration</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ <systemProperties>
+ <property>
+ <name>wink-test-context-root</name>
+ <value>${artifactId}</value>
+ </property>
+ <property>
+ <name>wink-test-hostname</name>
+ <value>${wink.server.hostname}</value>
+ </property>
+ <property>
+ <name>wink-test-port</name>
+ <value>${wink.server.port}</value>
+ </property>
+ <property>
+ <name>wink-test-work-dir</name>
+ <value>${project.build.directory}</value>
+ </property>
+ <property>
+ <name>wink-test-container</name>
+ <value>${assemblyId}</value>
+ </property>
+ <property>
+ <name>wink-rest-filter-used</name>
+ <value>${wink.rest.filter.used}</value>
+ </property>
+ <property>
+ <name>wink.client.readTimeout</name>
+ <value>10000</value>
+ </property>
+ <property>
+ <name>wink.client.connectTimeout</name>
+ <value>10000</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/main/java/org/apache/wink/itest/client/timeout/TimeoutApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/main/java/org/apache/wink/itest/client/timeout/TimeoutApplication.java?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/main/java/org/apache/wink/itest/client/timeout/TimeoutApplication.java (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/main/java/org/apache/wink/itest/client/timeout/TimeoutApplication.java Mon Jun 14 17:48:32 2010
@@ -1,36 +1,36 @@
-/*
- * 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 org.apache.wink.itest.client.timeout;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.ws.rs.core.Application;
-
-public class TimeoutApplication extends Application {
-
- @Override
- public Set<Class<?>> getClasses() {
- Set<Class<?>> classes = new HashSet<Class<?>>();
- classes.add(TimeoutResource.class);
- return classes;
- }
-
-}
+/*
+ * 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 org.apache.wink.itest.client.timeout;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class TimeoutApplication extends Application {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(TimeoutResource.class);
+ return classes;
+ }
+
+}
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/main/java/org/apache/wink/itest/client/timeout/TimeoutResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/main/java/org/apache/wink/itest/client/timeout/TimeoutResource.java?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/main/java/org/apache/wink/itest/client/timeout/TimeoutResource.java (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/main/java/org/apache/wink/itest/client/timeout/TimeoutResource.java Mon Jun 14 17:48:32 2010
@@ -1,36 +1,36 @@
-/*
- * 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 org.apache.wink.itest.client.timeout;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.QueryParam;
-
-@Path("timeout")
-public class TimeoutResource {
-
- @GET
- public String timeout(@QueryParam("timeout") long timeout) {
- try {
- Thread.sleep(timeout);
- } catch(Exception e) {}
- return "request processed";
- }
-}
+/*
+ * 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 org.apache.wink.itest.client.timeout;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+@Path("timeout")
+public class TimeoutResource {
+
+ @GET
+ public String timeout(@QueryParam("timeout") long timeout) {
+ try {
+ Thread.sleep(timeout);
+ } catch(Exception e) {}
+ return "request processed";
+ }
+}
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/test/java/org/apache/wink/itest/client/timeout/TimeoutApacheHTTPTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/test/java/org/apache/wink/itest/client/timeout/TimeoutApacheHTTPTest.java?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/test/java/org/apache/wink/itest/client/timeout/TimeoutApacheHTTPTest.java (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/test/java/org/apache/wink/itest/client/timeout/TimeoutApacheHTTPTest.java Mon Jun 14 17:48:32 2010
@@ -1,46 +1,46 @@
-/*
- * 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 org.apache.wink.itest.client.timeout;
-
-import org.apache.wink.client.ApacheHttpClientConfig;
-import org.apache.wink.client.RestClient;
-
-public class TimeoutApacheHTTPTest extends TimeoutTest {
-
- @Override
- public RestClient getConnectTimeoutClient() {
- ApacheHttpClientConfig config = new ApacheHttpClientConfig();
- config.connectTimeout(20000);
- return new RestClient(config);
- }
-
- @Override
- public RestClient getDefaultClient() {
- return new RestClient(new ApacheHttpClientConfig());
- }
-
- @Override
- public RestClient getReadTimeoutClient() {
- ApacheHttpClientConfig config = new ApacheHttpClientConfig();
- config.readTimeout(20000);
- return new RestClient(config);
- }
-
-}
+/*
+ * 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 org.apache.wink.itest.client.timeout;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class TimeoutApacheHTTPTest extends TimeoutTest {
+
+ @Override
+ public RestClient getConnectTimeoutClient() {
+ ApacheHttpClientConfig config = new ApacheHttpClientConfig();
+ config.connectTimeout(20000);
+ return new RestClient(config);
+ }
+
+ @Override
+ public RestClient getDefaultClient() {
+ return new RestClient(new ApacheHttpClientConfig());
+ }
+
+ @Override
+ public RestClient getReadTimeoutClient() {
+ ApacheHttpClientConfig config = new ApacheHttpClientConfig();
+ config.readTimeout(20000);
+ return new RestClient(config);
+ }
+
+}
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/test/java/org/apache/wink/itest/client/timeout/TimeoutTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/test/java/org/apache/wink/itest/client/timeout/TimeoutTest.java?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/test/java/org/apache/wink/itest/client/timeout/TimeoutTest.java (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client-timeout/src/test/java/org/apache/wink/itest/client/timeout/TimeoutTest.java Mon Jun 14 17:48:32 2010
@@ -1,109 +1,109 @@
-/*
- * 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 org.apache.wink.itest.client.timeout;
-
-import junit.framework.TestCase;
-
-import org.apache.wink.client.ClientConfig;
-import org.apache.wink.client.ClientResponse;
-import org.apache.wink.client.ClientRuntimeException;
-import org.apache.wink.client.Resource;
-import org.apache.wink.client.RestClient;
-import org.apache.wink.test.integration.ServerEnvironmentInfo;
-
-public class TimeoutTest extends TestCase {
-
- public static String getBaseURI() {
- return ServerEnvironmentInfo.getBaseURI() + "/timeout";
- }
-
- /**
- * Test that the wink.client.readTimeout property value of 10000 is read
- */
- public void testReadTimeoutValue() {
- assertEquals(10000, getDefaultClient().getConfig().getReadTimeout());
- }
-
- /**
- * Test that the wink.client.connectTimeout property value of 10000 is read
- */
- public void testConnectTimeoutValue() {
- assertEquals(10000, getDefaultClient().getConfig().getConnectTimeout());
- }
-
- /**
- * Test that the system property for the read timeout can be overwritten
- * programatically
- */
- public void testOverrideReadTimeout() {
- assertEquals(20000, getReadTimeoutClient().getConfig().getReadTimeout());
- }
-
- /**
- * Test that the system property for the connect timeout can be overwritten
- * programmatically
- */
- public void testOverrideConnectTimeout() {
- assertEquals(20000, getConnectTimeoutClient().getConfig().getConnectTimeout());
- }
-
- /**
- * Test that a request is processed if it takes less time than the timeout
- * value
- */
- public void testReadTimeoutNoTimeout() {
- RestClient client = getDefaultClient();
- Resource resource = client.resource(getBaseURI() + "?timeout=5000");
- ClientResponse response = resource.get();
- assertEquals(200, response.getStatusCode());
- assertEquals("request processed", response.getEntity(String.class));
- }
-
- /**
- * Test that the client times out if the request is not processed in less
- * than the readTimeout value
- */
- public void testReadTimeoutTimeout() {
- RestClient client = getDefaultClient();
- Resource resource = client.resource(getBaseURI() + "?timeout=30000");
- try {
- resource.get();
- fail("The client did not timeout after waiting more than 20000 milliseconds for the request.");
- } catch (ClientRuntimeException e) {
- assertTrue(e.getMessage().indexOf("SocketTimeoutException") != -1);
- }
- }
-
- public RestClient getDefaultClient() {
- return new RestClient();
- }
-
- public RestClient getReadTimeoutClient() {
- ClientConfig config = new ClientConfig();
- config.readTimeout(20000);
- return new RestClient(config);
- }
-
- public RestClient getConnectTimeoutClient() {
- ClientConfig config = new ClientConfig();
- config.connectTimeout(20000);
- return new RestClient(config);
- }
-}
+/*
+ * 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 org.apache.wink.itest.client.timeout;
+
+import junit.framework.TestCase;
+
+import org.apache.wink.client.ClientConfig;
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.ClientRuntimeException;
+import org.apache.wink.client.Resource;
+import org.apache.wink.client.RestClient;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class TimeoutTest extends TestCase {
+
+ public static String getBaseURI() {
+ return ServerEnvironmentInfo.getBaseURI() + "/timeout";
+ }
+
+ /**
+ * Test that the wink.client.readTimeout property value of 10000 is read
+ */
+ public void testReadTimeoutValue() {
+ assertEquals(10000, getDefaultClient().getConfig().getReadTimeout());
+ }
+
+ /**
+ * Test that the wink.client.connectTimeout property value of 10000 is read
+ */
+ public void testConnectTimeoutValue() {
+ assertEquals(10000, getDefaultClient().getConfig().getConnectTimeout());
+ }
+
+ /**
+ * Test that the system property for the read timeout can be overwritten
+ * programatically
+ */
+ public void testOverrideReadTimeout() {
+ assertEquals(20000, getReadTimeoutClient().getConfig().getReadTimeout());
+ }
+
+ /**
+ * Test that the system property for the connect timeout can be overwritten
+ * programmatically
+ */
+ public void testOverrideConnectTimeout() {
+ assertEquals(20000, getConnectTimeoutClient().getConfig().getConnectTimeout());
+ }
+
+ /**
+ * Test that a request is processed if it takes less time than the timeout
+ * value
+ */
+ public void testReadTimeoutNoTimeout() {
+ RestClient client = getDefaultClient();
+ Resource resource = client.resource(getBaseURI() + "?timeout=5000");
+ ClientResponse response = resource.get();
+ assertEquals(200, response.getStatusCode());
+ assertEquals("request processed", response.getEntity(String.class));
+ }
+
+ /**
+ * Test that the client times out if the request is not processed in less
+ * than the readTimeout value
+ */
+ public void testReadTimeoutTimeout() {
+ RestClient client = getDefaultClient();
+ Resource resource = client.resource(getBaseURI() + "?timeout=30000");
+ try {
+ resource.get();
+ fail("The client did not timeout after waiting more than 20000 milliseconds for the request.");
+ } catch (ClientRuntimeException e) {
+ assertTrue(e.getMessage().indexOf("SocketTimeoutException") != -1);
+ }
+ }
+
+ public RestClient getDefaultClient() {
+ return new RestClient();
+ }
+
+ public RestClient getReadTimeoutClient() {
+ ClientConfig config = new ClientConfig();
+ config.readTimeout(20000);
+ return new RestClient(config);
+ }
+
+ public RestClient getConnectTimeoutClient() {
+ ClientConfig config = new ClientConfig();
+ config.connectTimeout(20000);
+ return new RestClient(config);
+ }
+}
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client/pom.xml?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client/pom.xml (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-client/pom.xml Mon Jun 14 17:48:32 2010
@@ -17,12 +17,11 @@
specific language governing permissions and limitations
under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>wink-itest</artifactId>
<groupId>org.apache.wink</groupId>
- <version>1.1-incubating</version>
+ <version>1.1.1-incubating-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.wink</groupId>
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-context/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-context/pom.xml?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-context/pom.xml (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-context/pom.xml Mon Jun 14 17:48:32 2010
@@ -18,11 +18,11 @@
under the License.
-->
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>wink-itest</artifactId>
<groupId>org.apache.wink</groupId>
- <version>1.1-incubating</version>
+ <version>1.1.1-incubating-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>wink-itest-context</artifactId>
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/pom.xml?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/pom.xml (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/pom.xml Mon Jun 14 17:48:32 2010
@@ -15,12 +15,11 @@
See the License for the specific language governing permissions
and limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>wink-itest</artifactId>
<groupId>org.apache.wink</groupId>
- <version>1.1-incubating</version>
+ <version>1.1.1-incubating-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.wink</groupId>
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/JAXBResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/JAXBResource.java?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/JAXBResource.java (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/JAXBResource.java Mon Jun 14 17:48:32 2010
@@ -1,180 +1,180 @@
-/*******************************************************************************
- * 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 org.apache.wink.jaxrs.test.jaxb;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.GenericEntity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.bind.JAXBElement;
-import javax.xml.namespace.QName;
-
-import org.apache.wink.jaxrs.test.jaxb.book.Author;
-import org.apache.wink.jaxrs.test.jaxb.book.Book;
-import org.apache.wink.jaxrs.test.jaxb.person.Person;
-
-@Path("jaxbresource")
-public class JAXBResource {
-
- @Path("booklist")
- @Produces(MediaType.APPLICATION_XML)
- @Consumes(MediaType.APPLICATION_XML)
- @POST
- public List<Book> echoBookList(List<Book> books) {
- List<Book> ret = new ArrayList<Book>();
- Author author = null;
- Author retAuthor = null;
- Book retBook = null;
- for(Book book : books) {
- author = book.getAuthor();
- retAuthor = new Author();
- retAuthor.setFirstName("echo " + author.getFirstName());
- retAuthor.setLastName("echo " + author.getLastName());
- retBook = new Book();
- retBook.setAuthor(retAuthor);
- retBook.setTitle("echo " + book.getTitle());
- ret.add(retBook);
- }
- return ret;
- }
-
- @Path("bookarray")
- @Produces(MediaType.APPLICATION_XML)
- @Consumes(MediaType.APPLICATION_XML)
- @POST
- public Book[] echoBookArray(Book[] books) {
- Book[] ret = new Book[books.length];
- Author author = null;
- Author retAuthor = null;
- Book retBook = null;
- int i = 0;
- for(Book book : books) {
- author = book.getAuthor();
- retAuthor = new Author();
- retAuthor.setFirstName("echo " + author.getFirstName());
- retAuthor.setLastName("echo " + author.getLastName());
- retBook = new Book();
- retBook.setAuthor(retAuthor);
- retBook.setTitle("echo " + book.getTitle());
- ret[i++] = retBook;
- }
- return ret;
- }
-
- @Path("booklistresponse")
- @Produces(MediaType.APPLICATION_XML)
- @Consumes(MediaType.APPLICATION_XML)
- @POST
- public Response echoBookListResponse(List<Book> books) {
- List<Book> ret = echoBookList(books);
- Response response = Response.ok(new GenericEntity<List<Book>>(ret){}, MediaType.APPLICATION_XML).build();
- return response;
- }
-
- @Path("booklistjaxbelement")
- @Produces(MediaType.APPLICATION_XML)
- @Consumes(MediaType.APPLICATION_XML)
- @POST
- public List<JAXBElement<Book>> echoJAXBElementBookList(List<JAXBElement<Book>> bookElements) {
- List<JAXBElement<Book>> ret = new ArrayList<JAXBElement<Book>>();
- Author author = null;
- Author retAuthor = null;
- Book retBook = null;
- for(JAXBElement<Book> bookElement : bookElements) {
- author = bookElement.getValue().getAuthor();
- retAuthor = new Author();
- retAuthor.setFirstName("echo " + author.getFirstName());
- retAuthor.setLastName("echo " + author.getLastName());
- retBook = new Book();
- retBook.setAuthor(retAuthor);
- retBook.setTitle("echo " + bookElement.getValue().getTitle());
- JAXBElement<Book> element = new JAXBElement<Book>(new QName("book"), Book.class, retBook);
- ret.add(element);
- }
- return ret;
- }
-
- @Path("personlist")
- @Produces(MediaType.APPLICATION_XML)
- @Consumes(MediaType.APPLICATION_XML)
- @POST
- public List<Person> echoPersonList(List<Person> people) {
- List<Person> ret = new ArrayList<Person>();
- Person retPerson = null;
- for(Person person : people) {
- retPerson = new Person();
- retPerson.setName("echo " + person.getName());
- retPerson.setDesc("echo " + person.getDesc());
- ret.add(retPerson);
- }
- return ret;
- }
-
- @Path("personlistresponse")
- @Produces(MediaType.APPLICATION_XML)
- @Consumes(MediaType.APPLICATION_XML)
- @POST
- public Response echoPersonListResponse(List<Person> people) {
- List<Person> ret = echoPersonList(people);
- Response response = Response.ok(new GenericEntity<List<Person>>(ret){}, MediaType.APPLICATION_XML).build();
- return response;
- }
-
- @Path("personarray")
- @Produces(MediaType.APPLICATION_XML)
- @Consumes(MediaType.APPLICATION_XML)
- @POST
- public Person[] echoPersonArray(Person[] people) {
- Person[] ret = new Person[people.length];
- Person retPerson = null;
- int i = 0;
- for(Person person : people) {
- retPerson = new Person();
- retPerson.setName("echo " + person.getName());
- retPerson.setDesc("echo " + person.getDesc());
- ret[i++] = retPerson;
- }
- return ret;
- }
-
- @Path("personlistjaxbelement")
- @Produces(MediaType.APPLICATION_XML)
- @Consumes(MediaType.APPLICATION_XML)
- @POST
- public List<JAXBElement<Person>> echoPersonJAXBElementList(List<JAXBElement<Person>> peopleElements) {
- List<JAXBElement<Person>> ret = new ArrayList<JAXBElement<Person>>();
- Person retPerson = null;
- for(JAXBElement<Person> personElement : peopleElements) {
- retPerson = new Person();
- retPerson.setName("echo " + personElement.getValue().getName());
- retPerson.setDesc("echo " + personElement.getValue().getDesc());
- JAXBElement<Person> element = new JAXBElement<Person>(new QName("person"), Person.class, retPerson);
- ret.add(element);
- }
- return ret;
- }
-}
+/*******************************************************************************
+ * 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 org.apache.wink.jaxrs.test.jaxb;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.GenericEntity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.apache.wink.jaxrs.test.jaxb.book.Author;
+import org.apache.wink.jaxrs.test.jaxb.book.Book;
+import org.apache.wink.jaxrs.test.jaxb.person.Person;
+
+@Path("jaxbresource")
+public class JAXBResource {
+
+ @Path("booklist")
+ @Produces(MediaType.APPLICATION_XML)
+ @Consumes(MediaType.APPLICATION_XML)
+ @POST
+ public List<Book> echoBookList(List<Book> books) {
+ List<Book> ret = new ArrayList<Book>();
+ Author author = null;
+ Author retAuthor = null;
+ Book retBook = null;
+ for(Book book : books) {
+ author = book.getAuthor();
+ retAuthor = new Author();
+ retAuthor.setFirstName("echo " + author.getFirstName());
+ retAuthor.setLastName("echo " + author.getLastName());
+ retBook = new Book();
+ retBook.setAuthor(retAuthor);
+ retBook.setTitle("echo " + book.getTitle());
+ ret.add(retBook);
+ }
+ return ret;
+ }
+
+ @Path("bookarray")
+ @Produces(MediaType.APPLICATION_XML)
+ @Consumes(MediaType.APPLICATION_XML)
+ @POST
+ public Book[] echoBookArray(Book[] books) {
+ Book[] ret = new Book[books.length];
+ Author author = null;
+ Author retAuthor = null;
+ Book retBook = null;
+ int i = 0;
+ for(Book book : books) {
+ author = book.getAuthor();
+ retAuthor = new Author();
+ retAuthor.setFirstName("echo " + author.getFirstName());
+ retAuthor.setLastName("echo " + author.getLastName());
+ retBook = new Book();
+ retBook.setAuthor(retAuthor);
+ retBook.setTitle("echo " + book.getTitle());
+ ret[i++] = retBook;
+ }
+ return ret;
+ }
+
+ @Path("booklistresponse")
+ @Produces(MediaType.APPLICATION_XML)
+ @Consumes(MediaType.APPLICATION_XML)
+ @POST
+ public Response echoBookListResponse(List<Book> books) {
+ List<Book> ret = echoBookList(books);
+ Response response = Response.ok(new GenericEntity<List<Book>>(ret){}, MediaType.APPLICATION_XML).build();
+ return response;
+ }
+
+ @Path("booklistjaxbelement")
+ @Produces(MediaType.APPLICATION_XML)
+ @Consumes(MediaType.APPLICATION_XML)
+ @POST
+ public List<JAXBElement<Book>> echoJAXBElementBookList(List<JAXBElement<Book>> bookElements) {
+ List<JAXBElement<Book>> ret = new ArrayList<JAXBElement<Book>>();
+ Author author = null;
+ Author retAuthor = null;
+ Book retBook = null;
+ for(JAXBElement<Book> bookElement : bookElements) {
+ author = bookElement.getValue().getAuthor();
+ retAuthor = new Author();
+ retAuthor.setFirstName("echo " + author.getFirstName());
+ retAuthor.setLastName("echo " + author.getLastName());
+ retBook = new Book();
+ retBook.setAuthor(retAuthor);
+ retBook.setTitle("echo " + bookElement.getValue().getTitle());
+ JAXBElement<Book> element = new JAXBElement<Book>(new QName("book"), Book.class, retBook);
+ ret.add(element);
+ }
+ return ret;
+ }
+
+ @Path("personlist")
+ @Produces(MediaType.APPLICATION_XML)
+ @Consumes(MediaType.APPLICATION_XML)
+ @POST
+ public List<Person> echoPersonList(List<Person> people) {
+ List<Person> ret = new ArrayList<Person>();
+ Person retPerson = null;
+ for(Person person : people) {
+ retPerson = new Person();
+ retPerson.setName("echo " + person.getName());
+ retPerson.setDesc("echo " + person.getDesc());
+ ret.add(retPerson);
+ }
+ return ret;
+ }
+
+ @Path("personlistresponse")
+ @Produces(MediaType.APPLICATION_XML)
+ @Consumes(MediaType.APPLICATION_XML)
+ @POST
+ public Response echoPersonListResponse(List<Person> people) {
+ List<Person> ret = echoPersonList(people);
+ Response response = Response.ok(new GenericEntity<List<Person>>(ret){}, MediaType.APPLICATION_XML).build();
+ return response;
+ }
+
+ @Path("personarray")
+ @Produces(MediaType.APPLICATION_XML)
+ @Consumes(MediaType.APPLICATION_XML)
+ @POST
+ public Person[] echoPersonArray(Person[] people) {
+ Person[] ret = new Person[people.length];
+ Person retPerson = null;
+ int i = 0;
+ for(Person person : people) {
+ retPerson = new Person();
+ retPerson.setName("echo " + person.getName());
+ retPerson.setDesc("echo " + person.getDesc());
+ ret[i++] = retPerson;
+ }
+ return ret;
+ }
+
+ @Path("personlistjaxbelement")
+ @Produces(MediaType.APPLICATION_XML)
+ @Consumes(MediaType.APPLICATION_XML)
+ @POST
+ public List<JAXBElement<Person>> echoPersonJAXBElementList(List<JAXBElement<Person>> peopleElements) {
+ List<JAXBElement<Person>> ret = new ArrayList<JAXBElement<Person>>();
+ Person retPerson = null;
+ for(JAXBElement<Person> personElement : peopleElements) {
+ retPerson = new Person();
+ retPerson.setName("echo " + personElement.getValue().getName());
+ retPerson.setDesc("echo " + personElement.getValue().getDesc());
+ JAXBElement<Person> element = new JAXBElement<Person>(new QName("person"), Person.class, retPerson);
+ ret.add(element);
+ }
+ return ret;
+ }
+}
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/Author.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/Author.java?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/Author.java (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/Author.java Mon Jun 14 17:48:32 2010
@@ -1,56 +1,56 @@
-/*******************************************************************************
- * 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 org.apache.wink.jaxrs.test.jaxb.book;
-
-import javax.xml.bind.annotation.XmlType;
-
-@XmlType
-public class Author {
-
- private String firstName;
- private String lastName;
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public boolean equals(Object other) {
- if (!(other instanceof Author))
- return false;
-
- Author o = (Author)other;
- return (((this.firstName == null && o.firstName == null) || (this.firstName != null && this.firstName
- .equals(o.firstName))) && ((this.lastName == null && o.lastName == null) || (this.lastName != null && this.lastName
- .equals(o.lastName))));
- }
-}
+/*******************************************************************************
+ * 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 org.apache.wink.jaxrs.test.jaxb.book;
+
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType
+public class Author {
+
+ private String firstName;
+ private String lastName;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public boolean equals(Object other) {
+ if (!(other instanceof Author))
+ return false;
+
+ Author o = (Author)other;
+ return (((this.firstName == null && o.firstName == null) || (this.firstName != null && this.firstName
+ .equals(o.firstName))) && ((this.lastName == null && o.lastName == null) || (this.lastName != null && this.lastName
+ .equals(o.lastName))));
+ }
+}
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/Book.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/Book.java?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/Book.java (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/Book.java Mon Jun 14 17:48:32 2010
@@ -1,56 +1,56 @@
-/*******************************************************************************
- * 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 org.apache.wink.jaxrs.test.jaxb.book;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class Book {
-
- private Author author;
- private String title;
-
- public Author getAuthor() {
- return author;
- }
-
- public void setAuthor(Author author) {
- this.author = author;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public boolean equals(Object other) {
- if (!(other instanceof Book))
- return false;
-
- Book o = (Book)other;
- return (((this.author == null && o.author == null) || (this.author != null && this.author
- .equals(o.getAuthor()))) && ((this.title == null && o.title == null) || (this.title != null && this.title
- .equals(o.title))));
- }
-}
+/*******************************************************************************
+ * 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 org.apache.wink.jaxrs.test.jaxb.book;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Book {
+
+ private Author author;
+ private String title;
+
+ public Author getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(Author author) {
+ this.author = author;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public boolean equals(Object other) {
+ if (!(other instanceof Book))
+ return false;
+
+ Book o = (Book)other;
+ return (((this.author == null && o.author == null) || (this.author != null && this.author
+ .equals(o.getAuthor()))) && ((this.title == null && o.title == null) || (this.title != null && this.title
+ .equals(o.title))));
+ }
+}
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/ObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/ObjectFactory.java?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/ObjectFactory.java (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/book/ObjectFactory.java Mon Jun 14 17:48:32 2010
@@ -1,31 +1,31 @@
-/*******************************************************************************
- * 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 org.apache.wink.jaxrs.test.jaxb.book;
-
-import javax.xml.bind.annotation.XmlRegistry;
-
-@XmlRegistry
-public class ObjectFactory {
-
- public Book createBook() {
- return new Book();
- }
-}
+/*******************************************************************************
+ * 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 org.apache.wink.jaxrs.test.jaxb.book;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+@XmlRegistry
+public class ObjectFactory {
+
+ public Book createBook() {
+ return new Book();
+ }
+}
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/person/Person.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/person/Person.java?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/person/Person.java (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/main/java/org/apache/wink/jaxrs/test/jaxb/person/Person.java Mon Jun 14 17:48:32 2010
@@ -1,56 +1,56 @@
-/*******************************************************************************
- * 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 org.apache.wink.jaxrs.test.jaxb.person;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class Person {
-
- private String name;
-
- private String desc;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDesc() {
- return desc;
- }
-
- public void setDesc(String desc) {
- this.desc = desc;
- }
-
- public boolean equals(Object other) {
- if (!(other instanceof Person))
- return false;
-
- Person o = (Person)other;
- return (((this.name == null && o.name == null) || (this.name != null && this.name
- .equals(o.name))) && ((this.desc == null && o.desc == null) || (this.desc != null && this.desc
- .equals(o.desc))));
- }
-}
+/*******************************************************************************
+ * 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 org.apache.wink.jaxrs.test.jaxb.person;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Person {
+
+ private String name;
+
+ private String desc;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+
+ public boolean equals(Object other) {
+ if (!(other instanceof Person))
+ return false;
+
+ Person o = (Person)other;
+ return (((this.name == null && o.name == null) || (this.name != null && this.name
+ .equals(o.name))) && ((this.desc == null && o.desc == null) || (this.desc != null && this.desc
+ .equals(o.desc))));
+ }
+}
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/test/java/org/apache/wink/jaxrs/test/JAXBCollectionHTTPClientTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/test/java/org/apache/wink/jaxrs/test/JAXBCollectionHTTPClientTest.java?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/test/java/org/apache/wink/jaxrs/test/JAXBCollectionHTTPClientTest.java (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/test/java/org/apache/wink/jaxrs/test/JAXBCollectionHTTPClientTest.java Mon Jun 14 17:48:32 2010
@@ -1,32 +1,32 @@
-/*******************************************************************************
- * 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 org.apache.wink.jaxrs.test;
-
-import org.apache.wink.client.ApacheHttpClientConfig;
-import org.apache.wink.client.RestClient;
-
-public class JAXBCollectionHTTPClientTest extends JAXBCollectionTest {
-
- public void setUp() throws Exception {
- ApacheHttpClientConfig config = new ApacheHttpClientConfig();
- client = new RestClient(config);
- }
-}
+/*******************************************************************************
+ * 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 org.apache.wink.jaxrs.test;
+
+import org.apache.wink.client.ApacheHttpClientConfig;
+import org.apache.wink.client.RestClient;
+
+public class JAXBCollectionHTTPClientTest extends JAXBCollectionTest {
+
+ public void setUp() throws Exception {
+ ApacheHttpClientConfig config = new ApacheHttpClientConfig();
+ client = new RestClient(config);
+ }
+}
Modified: incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/test/java/org/apache/wink/jaxrs/test/JAXBCollectionTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/test/java/org/apache/wink/jaxrs/test/JAXBCollectionTest.java?rev=954566&r1=954565&r2=954566&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/test/java/org/apache/wink/jaxrs/test/JAXBCollectionTest.java (original)
+++ incubator/wink/branches/wink-1.1-incubating/wink-itests/wink-itest/wink-itest-extra-providers/src/test/java/org/apache/wink/jaxrs/test/JAXBCollectionTest.java Mon Jun 14 17:48:32 2010
@@ -1,225 +1,225 @@
-/*******************************************************************************
- * 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 org.apache.wink.jaxrs.test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.core.GenericEntity;
-import javax.ws.rs.core.MediaType;
-
-import junit.framework.TestCase;
-
-import org.apache.wink.client.ClientConfig;
-import org.apache.wink.client.ClientResponse;
-import org.apache.wink.client.EntityType;
-import org.apache.wink.client.Resource;
-import org.apache.wink.client.RestClient;
-import org.apache.wink.jaxrs.test.jaxb.book.Author;
-import org.apache.wink.jaxrs.test.jaxb.book.Book;
-import org.apache.wink.jaxrs.test.jaxb.person.Person;
-import org.apache.wink.test.integration.ServerEnvironmentInfo;
-
-public class JAXBCollectionTest extends TestCase {
-
- private static String BASE_URI =
- ServerEnvironmentInfo.getBaseURI() + "/optionalproviders/jaxbresource";
- protected RestClient client;
-
- static {
- if (ServerEnvironmentInfo.isRestFilterUsed()) {
- BASE_URI = ServerEnvironmentInfo.getBaseURI() + "/jaxbresource";
- }
- }
-
- public void setUp() throws Exception {
- ClientConfig config = new ClientConfig();
- client = new RestClient(config);
- }
-
- public void testXMLRootWithObjectFactoryList() throws Exception {
- List<Book> source = getBookSource();
- Resource resource = client.resource(BASE_URI + "/booklist");
- ClientResponse response =
- resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
- .post(new GenericEntity<List<Book>>(source) {
- });
- List<Book> responseEntity = response.getEntity(new EntityType<List<Book>>() {
- });
-
- verifyResponse(responseEntity, Book.class);
- }
-
- public void testXMLRootWithObjectFactoryArray() throws Exception {
- Book[] source = getBookSource().toArray(new Book[]{});
- Resource resource = client.resource(BASE_URI + "/bookarray");
- ClientResponse response =
- resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
- .post(new GenericEntity<Book[]>(source) {
- });
- Book[] responseEntity = response.getEntity(new EntityType<Book[]>() {
- });
-
- verifyResponse(responseEntity, Book.class);
- }
-
- public void testXMLRootWithObjectFactoryListResponse() throws Exception {
- List<Book> source = getBookSource();
- Resource resource = client.resource(BASE_URI + "/booklistresponse");
- ClientResponse response =
- resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
- .post(new GenericEntity<List<Book>>(source) {
- });
- List<Book> responseEntity = response.getEntity(new EntityType<List<Book>>() {
- });
-
- verifyResponse(responseEntity, Book.class);
- }
-
- public void testXMLRootWithObjectFactoryJAXBElement() throws Exception {
- List<Book> source = getBookSource();
- Resource resource = client.resource(BASE_URI + "/booklistjaxbelement");
- ClientResponse response =
- resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
- .post(new GenericEntity<List<Book>>(source) {
- });
- List<Book> responseEntity = response.getEntity(new EntityType<List<Book>>() {
- });
-
- verifyResponse(responseEntity, Book.class);
- }
-
- public void testXMLRootNoObjectFactoryList() throws Exception {
- List<Person> source = getPersonSource();
- Resource resource = client.resource(BASE_URI + "/personlist");
- ClientResponse response =
- resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
- .post(new GenericEntity<List<Person>>(source) {
- });
- List<Person> responseEntity = response.getEntity(new EntityType<List<Person>>() {
- });
-
- verifyResponse(responseEntity, Person.class);
- }
-
- public void testXMLRootNoObjectFactoryArray() throws Exception {
- Person[] source = getPersonSource().toArray(new Person[]{});
- Resource resource = client.resource(BASE_URI + "/personarray");
- ClientResponse response =
- resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
- .post(new GenericEntity<Person[]>(source) {
- });
- Person[] responseEntity = response.getEntity(new EntityType<Person[]>() {
- });
-
- verifyResponse(responseEntity, Person.class);
- }
-
- public void testXMLRootNoObjectFactoryListResponse() throws Exception {
- List<Person> source = getPersonSource();
- Resource resource = client.resource(BASE_URI + "/personlistresponse");
- ClientResponse response =
- resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
- .post(new GenericEntity<List<Person>>(source) {
- });
- List<Person> responseEntity = response.getEntity(new EntityType<List<Person>>() {
- });
-
- verifyResponse(responseEntity, Person.class);
- }
-
- public void testXMLRootNoObjectFactoryJAXBElement() throws Exception {
- List<Person> source = getPersonSource();
- Resource resource = client.resource(BASE_URI + "/personlistjaxbelement");
- ClientResponse response =
- resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
- .post(new GenericEntity<List<Person>>(source) {
- });
- List<Person> responseEntity = response.getEntity(new EntityType<List<Person>>() {
- });
-
- verifyResponse(responseEntity, Person.class);
- }
-
- private List<Book> getBookSource() {
- List<Book> source = new ArrayList<Book>();
- Book book = new Book();
- Author author = new Author();
- author.setFirstName("Eddie");
- author.setLastName("Vedder");
- book.setAuthor(author);
- book.setTitle("Vitalogy");
- source.add(book);
- book = new Book();
- author = new Author();
- author.setFirstName("Stone");
- author.setLastName("Gossard");
- book.setAuthor(author);
- book.setTitle("Ten");
- source.add(book);
- return source;
- }
-
- @SuppressWarnings("unchecked")
- private <T> void verifyResponse(Object response, Class<T> type) {
- List<?> expected = null;
- List<Object> actual = null;
- if(type == Book.class) {
- expected = getBookSource();
- actual = new ArrayList();
- } else {
- expected = getPersonSource();
- actual = new ArrayList();
- }
- if(response.getClass().isArray()) {
- for(int i = 0; i < ((T[])response).length; ++i)
- actual.add(((T[])response)[i]);
- } else
- actual = (List)response;
- for(Object o : expected) {
- if(type == Book.class) {
- Book b = (Book)o;
- Author author = b.getAuthor();
- author.setFirstName("echo " + author.getFirstName());
- author.setLastName("echo " + author.getLastName());
- b.setTitle("echo " + b.getTitle());
- } else {
- Person person = (Person)o;
- person.setName("echo " + person.getName());
- person.setDesc("echo " + person.getDesc());
- }
- }
- assertEquals(expected, actual);
- }
-
- private List<Person> getPersonSource() {
- List<Person> people = new ArrayList<Person>();
- Person person = new Person();
- person.setName("Eddie Vedder");
- person.setDesc("Author of Vitalogy");
- people.add(person);
- person = new Person();
- person.setName("Stone Gossard");
- person.setDesc("Author of Ten");
- people.add(person);
- return people;
- }
-}
+/*******************************************************************************
+ * 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 org.apache.wink.jaxrs.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.core.GenericEntity;
+import javax.ws.rs.core.MediaType;
+
+import junit.framework.TestCase;
+
+import org.apache.wink.client.ClientConfig;
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.EntityType;
+import org.apache.wink.client.Resource;
+import org.apache.wink.client.RestClient;
+import org.apache.wink.jaxrs.test.jaxb.book.Author;
+import org.apache.wink.jaxrs.test.jaxb.book.Book;
+import org.apache.wink.jaxrs.test.jaxb.person.Person;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+
+public class JAXBCollectionTest extends TestCase {
+
+ private static String BASE_URI =
+ ServerEnvironmentInfo.getBaseURI() + "/optionalproviders/jaxbresource";
+ protected RestClient client;
+
+ static {
+ if (ServerEnvironmentInfo.isRestFilterUsed()) {
+ BASE_URI = ServerEnvironmentInfo.getBaseURI() + "/jaxbresource";
+ }
+ }
+
+ public void setUp() throws Exception {
+ ClientConfig config = new ClientConfig();
+ client = new RestClient(config);
+ }
+
+ public void testXMLRootWithObjectFactoryList() throws Exception {
+ List<Book> source = getBookSource();
+ Resource resource = client.resource(BASE_URI + "/booklist");
+ ClientResponse response =
+ resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
+ .post(new GenericEntity<List<Book>>(source) {
+ });
+ List<Book> responseEntity = response.getEntity(new EntityType<List<Book>>() {
+ });
+
+ verifyResponse(responseEntity, Book.class);
+ }
+
+ public void testXMLRootWithObjectFactoryArray() throws Exception {
+ Book[] source = getBookSource().toArray(new Book[]{});
+ Resource resource = client.resource(BASE_URI + "/bookarray");
+ ClientResponse response =
+ resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
+ .post(new GenericEntity<Book[]>(source) {
+ });
+ Book[] responseEntity = response.getEntity(new EntityType<Book[]>() {
+ });
+
+ verifyResponse(responseEntity, Book.class);
+ }
+
+ public void testXMLRootWithObjectFactoryListResponse() throws Exception {
+ List<Book> source = getBookSource();
+ Resource resource = client.resource(BASE_URI + "/booklistresponse");
+ ClientResponse response =
+ resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
+ .post(new GenericEntity<List<Book>>(source) {
+ });
+ List<Book> responseEntity = response.getEntity(new EntityType<List<Book>>() {
+ });
+
+ verifyResponse(responseEntity, Book.class);
+ }
+
+ public void testXMLRootWithObjectFactoryJAXBElement() throws Exception {
+ List<Book> source = getBookSource();
+ Resource resource = client.resource(BASE_URI + "/booklistjaxbelement");
+ ClientResponse response =
+ resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
+ .post(new GenericEntity<List<Book>>(source) {
+ });
+ List<Book> responseEntity = response.getEntity(new EntityType<List<Book>>() {
+ });
+
+ verifyResponse(responseEntity, Book.class);
+ }
+
+ public void testXMLRootNoObjectFactoryList() throws Exception {
+ List<Person> source = getPersonSource();
+ Resource resource = client.resource(BASE_URI + "/personlist");
+ ClientResponse response =
+ resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
+ .post(new GenericEntity<List<Person>>(source) {
+ });
+ List<Person> responseEntity = response.getEntity(new EntityType<List<Person>>() {
+ });
+
+ verifyResponse(responseEntity, Person.class);
+ }
+
+ public void testXMLRootNoObjectFactoryArray() throws Exception {
+ Person[] source = getPersonSource().toArray(new Person[]{});
+ Resource resource = client.resource(BASE_URI + "/personarray");
+ ClientResponse response =
+ resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
+ .post(new GenericEntity<Person[]>(source) {
+ });
+ Person[] responseEntity = response.getEntity(new EntityType<Person[]>() {
+ });
+
+ verifyResponse(responseEntity, Person.class);
+ }
+
+ public void testXMLRootNoObjectFactoryListResponse() throws Exception {
+ List<Person> source = getPersonSource();
+ Resource resource = client.resource(BASE_URI + "/personlistresponse");
+ ClientResponse response =
+ resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
+ .post(new GenericEntity<List<Person>>(source) {
+ });
+ List<Person> responseEntity = response.getEntity(new EntityType<List<Person>>() {
+ });
+
+ verifyResponse(responseEntity, Person.class);
+ }
+
+ public void testXMLRootNoObjectFactoryJAXBElement() throws Exception {
+ List<Person> source = getPersonSource();
+ Resource resource = client.resource(BASE_URI + "/personlistjaxbelement");
+ ClientResponse response =
+ resource.accept(MediaType.APPLICATION_XML).contentType(MediaType.APPLICATION_XML)
+ .post(new GenericEntity<List<Person>>(source) {
+ });
+ List<Person> responseEntity = response.getEntity(new EntityType<List<Person>>() {
+ });
+
+ verifyResponse(responseEntity, Person.class);
+ }
+
+ private List<Book> getBookSource() {
+ List<Book> source = new ArrayList<Book>();
+ Book book = new Book();
+ Author author = new Author();
+ author.setFirstName("Eddie");
+ author.setLastName("Vedder");
+ book.setAuthor(author);
+ book.setTitle("Vitalogy");
+ source.add(book);
+ book = new Book();
+ author = new Author();
+ author.setFirstName("Stone");
+ author.setLastName("Gossard");
+ book.setAuthor(author);
+ book.setTitle("Ten");
+ source.add(book);
+ return source;
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> void verifyResponse(Object response, Class<T> type) {
+ List<?> expected = null;
+ List<Object> actual = null;
+ if(type == Book.class) {
+ expected = getBookSource();
+ actual = new ArrayList();
+ } else {
+ expected = getPersonSource();
+ actual = new ArrayList();
+ }
+ if(response.getClass().isArray()) {
+ for(int i = 0; i < ((T[])response).length; ++i)
+ actual.add(((T[])response)[i]);
+ } else
+ actual = (List)response;
+ for(Object o : expected) {
+ if(type == Book.class) {
+ Book b = (Book)o;
+ Author author = b.getAuthor();
+ author.setFirstName("echo " + author.getFirstName());
+ author.setLastName("echo " + author.getLastName());
+ b.setTitle("echo " + b.getTitle());
+ } else {
+ Person person = (Person)o;
+ person.setName("echo " + person.getName());
+ person.setDesc("echo " + person.getDesc());
+ }
+ }
+ assertEquals(expected, actual);
+ }
+
+ private List<Person> getPersonSource() {
+ List<Person> people = new ArrayList<Person>();
+ Person person = new Person();
+ person.setName("Eddie Vedder");
+ person.setDesc("Author of Vitalogy");
+ people.add(person);
+ person = new Person();
+ person.setName("Stone Gossard");
+ person.setDesc("Author of Ten");
+ people.add(person);
+ return people;
+ }
+}