You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by bl...@apache.org on 2009/07/19 01:11:08 UTC
svn commit: r795444 [1/2] - in /incubator/wink/trunk/wink-integration-test:
wink-server-integration-test-support/
wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/
wink-server-integration-test/ wink-server-integration...
Author: bluk
Date: Sat Jul 18 23:11:07 2009
New Revision: 795444
URL: http://svn.apache.org/viewvc?rev=795444&view=rev
Log:
Fix for Tomcat integration test issues
See [WINK-87]
Added:
incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerContainerAssertions.java
- copied, changed from r795243, incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerEnvironmentInfo.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ByteContentEncodedGZIPReader.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ByteContentEncodedGZIPWriter.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ContentEncodingApplication.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/MirrorResource.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/StringContentEncodedGzip.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/transferencoding/
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/transferencoding/ChunkedMirror.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/transferencoding/TransferEncodingApplication.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/contentencoding/
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/contentencoding/ContentEncodingTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/transferencoding/
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/transferencoding/TransferEncodingTest.java
Modified:
incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/pom.xml
incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerEnvironmentInfo.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/pom.xml
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/HeaderParamTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/QueryParamTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/SourceResource.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/mapped/JAXRSExceptionsMappedProvidersTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/nomapper/JAXRSExceptionsNoMapperTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/nullconditions/JAXRSExceptionsNullConditionsTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSSourceTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/writerexceptions/JAXRSMessageBodyWriterExceptionThrownTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/largeentity/LargeResource.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/lifecycles/MyMessageBodyReaderAndWriter.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/lifecycles/MyResource.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/sequence/SequenceSingletonResource.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/webapp/WEB-INF/web.xml
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/addressbook/StringTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/exceptions/ExceptionsWhileTargettingTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/exceptions/NullValuesDuringTargettingTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/exceptions/ValidationDuringTargettingTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/largeentity/LargeEntityTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/lifecycles/LifeCycleTest.java
incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/test/java/org/apache/wink/jaxrs/test/sequence/SequenceTest.java
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/pom.xml?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/pom.xml (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/pom.xml Sat Jul 18 23:11:07 2009
@@ -26,11 +26,13 @@
<version>0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.wink</groupId>
<artifactId>wink-server-integration-test-support</artifactId>
<name>Wink Server Integration Test Support</name>
- <version>0.1-SNAPSHOT</version>
- <properties>
- <wink-test-context-root>fdsfdsfds</wink-test-context-root>
- </properties>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
</project>
Copied: incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerContainerAssertions.java (from r795243, incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerEnvironmentInfo.java)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerContainerAssertions.java?p2=incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerContainerAssertions.java&p1=incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerEnvironmentInfo.java&r1=795243&r2=795444&rev=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerEnvironmentInfo.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerContainerAssertions.java Sat Jul 18 23:11:07 2009
@@ -19,32 +19,26 @@
package org.apache.wink.test.integration;
+import org.junit.Assert;
+
/**
- * This class provides some basic information for clients about the server.
+ * Assertions to deal with responses from various containers. Some containers
+ * like to have default error pages.
*/
-final public class ServerEnvironmentInfo {
-
- public static String getHostname() {
- return System.getProperty("wink-test-hostname");
- }
-
- public static String getPort() {
- return System.getProperty("wink-test-port");
- }
+final public class ServerContainerAssertions {
- public static String getContextRoot() {
- return System.getProperty("wink-test-context-root");
- }
-
- public static String getBaseURI() {
- String contextRoot = getContextRoot();
- if (contextRoot == null) {
- return "http://" + getHostname() + ":" + getPort();
+ /**
+ * For exceptions that are propagated to the container, verify that the
+ * exception has the expected information.
+ *
+ * @param statusCode
+ * @param responseBody
+ */
+ public static void assertExceptionBodyFromServer(int statusCode, String responseBody) {
+ if ("tomcat".equals(ServerEnvironmentInfo.getContainerName())) {
+ Assert.assertTrue(responseBody, responseBody.contains(Integer.toString(statusCode)));
+ return;
}
- return "http://" + getHostname() + ":" + getPort() + "/" + contextRoot;
- }
-
- public static String getWorkDir() {
- return System.getProperty("wink-test-work-dir");
+ Assert.assertTrue(responseBody, (responseBody == null) || ("".equals(responseBody)));
}
}
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerEnvironmentInfo.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerEnvironmentInfo.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerEnvironmentInfo.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test-support/src/main/java/org/apache/wink/test/integration/ServerEnvironmentInfo.java Sat Jul 18 23:11:07 2009
@@ -47,4 +47,11 @@
public static String getWorkDir() {
return System.getProperty("wink-test-work-dir");
}
+
+ static String getContainerName() {
+ /*
+ * tests should not use this
+ */
+ return System.getProperty("wink-test-container");
+ }
}
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/pom.xml?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/pom.xml (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/pom.xml Sat Jul 18 23:11:07 2009
@@ -16,7 +16,8 @@
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">
+-->
+<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-integration-test</artifactId>
<groupId>org.apache.wink</groupId>
@@ -174,6 +175,10 @@
<name>wink-test-work-dir</name>
<value>${project.build.directory}</value>
</property>
+ <property>
+ <name>wink-test-container</name>
+ <value>${assemblyId}</value>
+ </property>
</systemProperties>
</configuration>
</execution>
@@ -315,6 +320,36 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.10</version>
+ <configuration>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ <stopKey>foo</stopKey>
+ <stopPort>9999</stopPort>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-jetty</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ <daemon>true</daemon>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop-jetty</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</pluginManagement>
</build>
@@ -475,33 +510,7 @@
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
- <version>6.1.10</version>
<inherited>true</inherited>
- <configuration>
- <scanIntervalSeconds>10</scanIntervalSeconds>
- <stopKey>foo</stopKey>
- <stopPort>9999</stopPort>
- </configuration>
- <executions>
- <execution>
- <id>start-jetty</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <scanIntervalSeconds>0</scanIntervalSeconds>
- <daemon>true</daemon>
- </configuration>
- </execution>
- <execution>
- <id>stop-jetty</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>stop</goal>
- </goals>
- </execution>
- </executions>
</plugin>
</plugins>
</build>
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/HeaderParamTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/HeaderParamTest.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/HeaderParamTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/HeaderParamTest.java Sat Jul 18 23:11:07 2009
@@ -32,6 +32,7 @@
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wink.test.integration.ServerContainerAssertions;
import org.apache.wink.test.integration.ServerEnvironmentInfo;
/**
@@ -48,8 +49,8 @@
}
/**
- * Tests that a custom header is sent and received properly. Uses constructor, property, field,
- * and parameter parameters.
+ * Tests that a custom header is sent and received properly. Uses
+ * constructor, property, field, and parameter parameters.
*/
public void testCustomHeaderParam() {
HttpClient httpclient = new HttpClient();
@@ -174,7 +175,7 @@
int result = httpclient.executeMethod(getMethod);
String responseBody = getMethod.getResponseBodyAsString();
assertEquals(400, result);
- assertEquals("", responseBody);
+ ServerContainerAssertions.assertExceptionBodyFromServer(400, responseBody);
} finally {
getMethod.releaseConnection();
}
@@ -184,9 +185,10 @@
* Tests that a custom header with a custom constructor can be used.
* <ul>
* <li>If the header is not set, then the header parameter is set to null.</li>
- * <li>If the header constructor throws an exception, then 400 Bad Request status is returned.</li>
- * <li>If a <code>WebApplicationException</code> is thrown during parameter construction, then
- * use that.</li>
+ * <li>If the header constructor throws an exception, then 400 Bad Request
+ * status is returned.</li>
+ * <li>If a <code>WebApplicationException</code> is thrown during parameter
+ * construction, then use that.</li>
* </ul>
*/
public void testHeaderParamStringConstructorException() throws IOException, HttpException {
@@ -195,12 +197,14 @@
}
/**
- * Tests that a custom header with a custom static valueOf method can be used.
+ * Tests that a custom header with a custom static valueOf method can be
+ * used.
* <ul>
* <li>If the header is not set, then the header parameter is set to null.</li>
- * <li>If the header valueOf throws an exception, then 400 Bad Request status is returned.</li>
- * <li>If a <code>WebApplicationException</code> is thrown during parameter valueOf
- * construction, then use that.</li>
+ * <li>If the header valueOf throws an exception, then 400 Bad Request
+ * status is returned.</li>
+ * <li>If a <code>WebApplicationException</code> is thrown during parameter
+ * valueOf construction, then use that.</li>
* </ul>
*/
public void testHeaderParamValueOfException() throws IOException, HttpException {
@@ -208,13 +212,14 @@
}
/**
- * Tests that a custom header is set correctly in a List of a type with a custom static valueOf
- * method.
+ * Tests that a custom header is set correctly in a List of a type with a
+ * custom static valueOf method.
* <ul>
* <li>If the header is not set, then the header parameter is set to null.</li>
- * <li>If the header valueOf throws an exception, then 400 Bad Request status is returned.</li>
- * <li>If a <code>WebApplicationException</code> is thrown during parameter valueOf
- * construction, then use that.</li>
+ * <li>If the header valueOf throws an exception, then 400 Bad Request
+ * status is returned.</li>
+ * <li>If a <code>WebApplicationException</code> is thrown during parameter
+ * valueOf construction, then use that.</li>
* </ul>
*/
public void testHeaderParamListValueOfException() throws IOException {
@@ -223,13 +228,14 @@
}
/**
- * Tests that a custom header is set correctly in a Set of a type with a custom static valueOf
- * method.
+ * Tests that a custom header is set correctly in a Set of a type with a
+ * custom static valueOf method.
* <ul>
* <li>If the header is not set, then the header parameter is set to null.</li>
- * <li>If the header valueOf throws an exception, then 400 Bad Request status is returned.</li>
- * <li>If a <code>WebApplicationException</code> is thrown during parameter valueOf
- * construction, then use that.</li>
+ * <li>If the header valueOf throws an exception, then 400 Bad Request
+ * status is returned.</li>
+ * <li>If a <code>WebApplicationException</code> is thrown during parameter
+ * valueOf construction, then use that.</li>
* </ul>
*/
public void testHeaderParamSetValueOfException() throws IOException {
@@ -238,13 +244,14 @@
}
/**
- * Tests that a custom header is set correctly in a Set of a type with a custom static valueOf
- * method.
+ * Tests that a custom header is set correctly in a Set of a type with a
+ * custom static valueOf method.
* <ul>
* <li>If the header is not set, then the header parameter is set to null.</li>
- * <li>If the header valueOf throws an exception, then 400 Bad Request status is returned.</li>
- * <li>If a <code>WebApplicationException</code> is thrown during parameter valueOf
- * construction, then use that.</li>
+ * <li>If the header valueOf throws an exception, then 400 Bad Request
+ * status is returned.</li>
+ * <li>If a <code>WebApplicationException</code> is thrown during parameter
+ * valueOf construction, then use that.</li>
* </ul>
*/
public void testHeaderParamSortedSetValueOfException() throws IOException {
@@ -253,12 +260,14 @@
}
/**
- * Tests that a custom header is set correctly in a field with a String constructor type.
+ * Tests that a custom header is set correctly in a field with a String
+ * constructor type.
* <ul>
* <li>If the header is not set, then the header parameter is set to null.</li>
- * <li>If the header valueOf throws an exception, then 400 Bad Request status is returned.</li>
- * <li>If a <code>WebApplicationException</code> is thrown during parameter valueOf
- * construction, then use that.</li>
+ * <li>If the header valueOf throws an exception, then 400 Bad Request
+ * status is returned.</li>
+ * <li>If a <code>WebApplicationException</code> is thrown during parameter
+ * valueOf construction, then use that.</li>
* </ul>
*/
public void testHeaderFieldStringConstructorException() throws IOException {
@@ -267,12 +276,14 @@
}
/**
- * Tests that a custom header is set correctly in a field with a static valueOf method.
+ * Tests that a custom header is set correctly in a field with a static
+ * valueOf method.
* <ul>
* <li>If the header is not set, then the header parameter is set to null.</li>
- * <li>If the header valueOf throws an exception, then 400 Bad Request status is returned.</li>
- * <li>If a <code>WebApplicationException</code> is thrown during parameter valueOf
- * construction, then use that.</li>
+ * <li>If the header valueOf throws an exception, then 400 Bad Request
+ * status is returned.</li>
+ * <li>If a <code>WebApplicationException</code> is thrown during parameter
+ * valueOf construction, then use that.</li>
* </ul>
*/
public void testHeaderFieldValueOfException() throws IOException {
@@ -281,12 +292,14 @@
}
/**
- * Tests that a custom header is set correctly in a field with a string constructor.
+ * Tests that a custom header is set correctly in a field with a string
+ * constructor.
* <ul>
* <li>If the header is not set, then the header parameter is set to null.</li>
- * <li>If the header valueOf throws an exception, then 400 Bad Request status is returned.</li>
- * <li>If a <code>WebApplicationException</code> is thrown during parameter valueOf
- * construction, then use that.</li>
+ * <li>If the header valueOf throws an exception, then 400 Bad Request
+ * status is returned.</li>
+ * <li>If a <code>WebApplicationException</code> is thrown during parameter
+ * valueOf construction, then use that.</li>
* </ul>
*/
public void testHeaderPropertyStringConstructorException() throws IOException {
@@ -295,13 +308,14 @@
}
/**
- * Tests that a custom header is set correctly in a field with a type with a static valueOf
- * method.
+ * Tests that a custom header is set correctly in a field with a type with a
+ * static valueOf method.
* <ul>
* <li>If the header is not set, then the header parameter is set to null.</li>
- * <li>If the header valueOf throws an exception, then 400 Bad Request status is returned.</li>
- * <li>If a <code>WebApplicationException</code> is thrown during parameter valueOf
- * construction, then use that.</li>
+ * <li>If the header valueOf throws an exception, then 400 Bad Request
+ * status is returned.</li>
+ * <li>If a <code>WebApplicationException</code> is thrown during parameter
+ * valueOf construction, then use that.</li>
* </ul>
*/
public void testHeaderPropertyValueOfException() throws IOException {
@@ -364,7 +378,8 @@
try {
int result = httpclient.executeMethod(getMethod);
assertEquals(400, result);
- assertEquals("", getMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(400, getMethod
+ .getResponseBodyAsString());
} finally {
getMethod.releaseConnection();
}
@@ -375,7 +390,8 @@
try {
int result = httpclient.executeMethod(getMethod);
assertEquals(400, result);
- assertEquals("", getMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(400, getMethod
+ .getResponseBodyAsString());
} finally {
getMethod.releaseConnection();
}
@@ -437,7 +453,8 @@
try {
int result = httpclient.executeMethod(getMethod);
assertEquals(400, result);
- assertEquals("", getMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(400, getMethod
+ .getResponseBodyAsString());
} finally {
getMethod.releaseConnection();
}
@@ -448,7 +465,8 @@
try {
int result = httpclient.executeMethod(getMethod);
assertEquals(400, result);
- assertEquals("", getMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(400, getMethod
+ .getResponseBodyAsString());
} finally {
getMethod.releaseConnection();
}
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/QueryParamTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/QueryParamTest.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/QueryParamTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-params/src/test/java/org/apache/wink/jaxrs/test/params/QueryParamTest.java Sat Jul 18 23:11:07 2009
@@ -31,6 +31,7 @@
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.wink.test.integration.ServerContainerAssertions;
import org.apache.wink.test.integration.ServerEnvironmentInfo;
/**
@@ -243,7 +244,8 @@
try {
httpclient.executeMethod(httpMethod);
assertEquals(404, httpMethod.getStatusCode());
- assertEquals("", httpMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(404, httpMethod
+ .getResponseBodyAsString());
} finally {
httpMethod.releaseConnection();
}
@@ -254,7 +256,8 @@
try {
httpclient.executeMethod(httpMethod);
assertEquals(404, httpMethod.getStatusCode());
- assertEquals("", httpMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(404, httpMethod
+ .getResponseBodyAsString());
} finally {
httpMethod.releaseConnection();
}
@@ -279,7 +282,8 @@
try {
httpclient.executeMethod(httpMethod);
assertEquals(404, httpMethod.getStatusCode());
- assertEquals("", httpMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(404, httpMethod
+ .getResponseBodyAsString());
} finally {
httpMethod.releaseConnection();
}
@@ -290,7 +294,8 @@
try {
httpclient.executeMethod(httpMethod);
assertEquals(404, httpMethod.getStatusCode());
- assertEquals("", httpMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(404, httpMethod
+ .getResponseBodyAsString());
} finally {
httpMethod.releaseConnection();
}
@@ -315,7 +320,8 @@
try {
httpclient.executeMethod(httpMethod);
assertEquals(404, httpMethod.getStatusCode());
- assertEquals("", httpMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(404, httpMethod
+ .getResponseBodyAsString());
} finally {
httpMethod.releaseConnection();
}
@@ -326,7 +332,8 @@
try {
httpclient.executeMethod(httpMethod);
assertEquals(404, httpMethod.getStatusCode());
- assertEquals("", httpMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(404, httpMethod
+ .getResponseBodyAsString());
} finally {
httpMethod.releaseConnection();
}
@@ -351,7 +358,8 @@
try {
httpclient.executeMethod(httpMethod);
assertEquals(404, httpMethod.getStatusCode());
- assertEquals("", httpMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(404, httpMethod
+ .getResponseBodyAsString());
} finally {
httpMethod.releaseConnection();
}
@@ -362,7 +370,8 @@
try {
httpclient.executeMethod(httpMethod);
assertEquals(404, httpMethod.getStatusCode());
- assertEquals("", httpMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(404, httpMethod
+ .getResponseBodyAsString());
} finally {
httpMethod.releaseConnection();
}
@@ -373,7 +382,8 @@
try {
httpclient.executeMethod(httpMethod);
assertEquals(404, httpMethod.getStatusCode());
- assertEquals("", httpMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(404, httpMethod
+ .getResponseBodyAsString());
} finally {
httpMethod.releaseConnection();
}
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/SourceResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/SourceResource.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/SourceResource.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/main/java/org/apache/wink/jaxrs/test/providers/standard/SourceResource.java Sat Jul 18 23:11:07 2009
@@ -28,16 +28,17 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
@Path("providers/standard/source")
public class SourceResource {
- private Source source = null;
+ private static Source source = null;
@GET
@Produces("text/xml")
public Response getSource() {
- return Response.ok(source).build();
+ return Response.ok(source).type("text/xml").build();
}
@POST
@@ -66,7 +67,7 @@
}
@PUT
- public void putSource(Source source) throws IOException {
+ public void putSource(DOMSource source) throws IOException {
this.source = source;
}
}
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/mapped/JAXRSExceptionsMappedProvidersTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/mapped/JAXRSExceptionsMappedProvidersTest.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/mapped/JAXRSExceptionsMappedProvidersTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/mapped/JAXRSExceptionsMappedProvidersTest.java Sat Jul 18 23:11:07 2009
@@ -28,6 +28,7 @@
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.wink.test.integration.ServerContainerAssertions;
import org.apache.wink.test.integration.ServerEnvironmentInfo;
public class JAXRSExceptionsMappedProvidersTest extends TestCase {
@@ -76,7 +77,8 @@
client.executeMethod(postMethod);
assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), postMethod.getStatusCode());
assertEquals(getBaseURI(), postMethod.getResponseHeader("ExceptionPage").getValue());
- assertEquals("", postMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(500, postMethod
+ .getResponseBodyAsString());
}
/**
@@ -95,7 +97,9 @@
client.executeMethod(postMethod);
assertEquals(497, postMethod.getStatusCode());
assertEquals(getBaseURI(), postMethod.getResponseHeader("ExceptionPage").getValue());
- assertEquals("", postMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(497, postMethod
+ .getResponseBodyAsString());
+
}
/**
@@ -111,7 +115,8 @@
client.executeMethod(postMethod);
assertEquals(496, postMethod.getStatusCode());
assertEquals(getBaseURI(), postMethod.getResponseHeader("ExceptionPage").getValue());
- assertEquals("", postMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(496, postMethod
+ .getResponseBodyAsString());
}
/**
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/nomapper/JAXRSExceptionsNoMapperTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/nomapper/JAXRSExceptionsNoMapperTest.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/nomapper/JAXRSExceptionsNoMapperTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/nomapper/JAXRSExceptionsNoMapperTest.java Sat Jul 18 23:11:07 2009
@@ -29,6 +29,7 @@
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.wink.test.integration.ServerContainerAssertions;
import org.apache.wink.test.integration.ServerEnvironmentInfo;
/**
@@ -43,7 +44,7 @@
/**
* Test the positive workflow where a comment with a message and author is
* successfully posted to the Guestbook.
- *
+ *
* @throws Exception
*/
public void testRegularWorkflow() throws Exception {
@@ -52,124 +53,118 @@
PostMethod postMethod = new PostMethod(getBaseURI());
postMethod
- .setRequestEntity(new StringRequestEntity(
- "<comment><message>Hello World!</message><author>Anonymous</author></comment>",
- "text/xml", null));
+ .setRequestEntity(new StringRequestEntity(
+ "<comment><message>Hello World!</message><author>Anonymous</author></comment>",
+ "text/xml", null));
client.executeMethod(postMethod);
assertEquals(201, postMethod.getStatusCode());
- String newPostURILocation = postMethod.getResponseHeader("Location")
- .getValue();
+ String newPostURILocation = postMethod.getResponseHeader("Location").getValue();
GetMethod getMethod = new GetMethod(newPostURILocation);
client.executeMethod(getMethod);
assertEquals(200, getMethod.getStatusCode());
- assertEquals(
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><comment><author>Anonymous</author><id>1</id><message>Hello World!</message></comment>",
- getMethod.getResponseBodyAsString());
+ assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><comment><author>Anonymous</author><id>1</id><message>Hello World!</message></comment>",
+ getMethod.getResponseBodyAsString());
}
/**
* Tests a method that throws an emptily constructed
* <code>WebApplicationException</code>.
- *
+ *
* @throws Exception
*/
- public void testWebApplicationExceptionDefaultNoMappingProvider()
- throws Exception {
+ public void testWebApplicationExceptionDefaultNoMappingProvider() throws Exception {
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(getBaseURI());
- postMethod.setRequestEntity(new StringRequestEntity(
- "<comment></comment>", "text/xml", null));
+ postMethod
+ .setRequestEntity(new StringRequestEntity("<comment></comment>", "text/xml", null));
client.executeMethod(postMethod);
- assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), postMethod
- .getStatusCode());
- assertEquals("", postMethod.getResponseBodyAsString());
+ assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), postMethod.getStatusCode());
+ ServerContainerAssertions.assertExceptionBodyFromServer(500, postMethod
+ .getResponseBodyAsString());
}
/**
* Tests a method that throws a <code>WebApplicationException</code> with an
* integer status code.
- *
+ *
* @throws Exception
*/
- public void testWebApplicationExceptionStatusCodeSetNoMappingProvider()
- throws Exception {
+ public void testWebApplicationExceptionStatusCodeSetNoMappingProvider() throws Exception {
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(getBaseURI());
postMethod
- .setRequestEntity(new StringRequestEntity(
- "<comment><message>Suppose to fail with missing author.</message></comment>",
- "text/xml", null));
+ .setRequestEntity(new StringRequestEntity(
+ "<comment><message>Suppose to fail with missing author.</message></comment>",
+ "text/xml", null));
client.executeMethod(postMethod);
assertEquals(499, postMethod.getStatusCode());
- assertEquals("", postMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(499, postMethod
+ .getResponseBodyAsString());
+
}
/**
* Tests a method that throws a <code>WebApplicationException</code> with a
* Response.Status set.
- *
+ *
* @throws Exception
*/
- public void testWebApplicationExceptionResponseStatusSetNoMappingProvider()
- throws Exception {
+ public void testWebApplicationExceptionResponseStatusSetNoMappingProvider() throws Exception {
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(getBaseURI());
- postMethod.setRequestEntity(new StringRequestEntity("", "text/xml",
- null));
+ postMethod.setRequestEntity(new StringRequestEntity("", "text/xml", null));
client.executeMethod(postMethod);
- assertEquals(Status.BAD_REQUEST.getStatusCode(), postMethod
- .getStatusCode());
- assertEquals("", postMethod.getResponseBodyAsString());
+ assertEquals(Status.BAD_REQUEST.getStatusCode(), postMethod.getStatusCode());
+ ServerContainerAssertions.assertExceptionBodyFromServer(400, postMethod
+ .getResponseBodyAsString());
+
}
/**
* Tests a method that throws a <code>WebApplicationException</code> with a
* Response.
- *
+ *
* @throws Exception
*/
- public void testWebApplicationExceptionResponseSetNoMappingProvider()
- throws Exception {
+ public void testWebApplicationExceptionResponseSetNoMappingProvider() throws Exception {
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(getBaseURI());
- postMethod.setRequestEntity(new StringRequestEntity(
- "<comment><author>Anonymous</author></comment>", "text/xml",
- null));
- client.executeMethod(postMethod);
- assertEquals(Status.BAD_REQUEST.getStatusCode(), postMethod
- .getStatusCode());
- assertEquals(
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>Missing the message in the comment.</message></commenterror>",
- postMethod.getResponseBodyAsString());
+ postMethod
+ .setRequestEntity(new StringRequestEntity(
+ "<comment><author>Anonymous</author></comment>",
+ "text/xml", null));
+ client.executeMethod(postMethod);
+ assertEquals(Status.BAD_REQUEST.getStatusCode(), postMethod.getStatusCode());
+ assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>Missing the message in the comment.</message></commenterror>",
+ postMethod.getResponseBodyAsString());
}
/**
* Tests a method that throws a subclass of
* <code>WebApplicationException</code> with a Response.
- *
+ *
* @throws Exception
*/
- public void testCustomWebApplicationExceptionNoMappingProvider()
- throws Exception {
+ public void testCustomWebApplicationExceptionNoMappingProvider() throws Exception {
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(getBaseURI());
- postMethod.setRequestEntity(new StringRequestEntity(
- "<comment><message></message><author></author></comment>",
- "text/xml", null));
+ postMethod
+ .setRequestEntity(new StringRequestEntity(
+ "<comment><message></message><author></author></comment>",
+ "text/xml", null));
client.executeMethod(postMethod);
assertEquals(498, postMethod.getStatusCode());
- assertEquals(
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>Cannot post an invalid message.</message></commenterror>",
- postMethod.getResponseBodyAsString());
+ assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><commenterror><message>Cannot post an invalid message.</message></commenterror>",
+ postMethod.getResponseBodyAsString());
}
/**
* Tests a method that throws a runtime exception.
- *
+ *
* @throws Exception
*/
public void testRuntimeExceptionNoMappingProvider() throws Exception {
@@ -182,12 +177,13 @@
DeleteMethod postMethod = new DeleteMethod(getBaseURI() + "/abcd");
client.executeMethod(postMethod);
assertEquals(500, postMethod.getStatusCode());
-// assertLogContainsException("java.lang.NumberFormatException: For input string: \"abcd\"");
+
+ // assertLogContainsException("java.lang.NumberFormatException: For input string: \"abcd\"");
}
/**
* Tests a method that throws a NullPointerException inside a called method.
- *
+ *
* @throws Exception
*/
public void testNullPointerExceptionNoMappingProvider() throws Exception {
@@ -196,12 +192,13 @@
DeleteMethod postMethod = new DeleteMethod(getBaseURI() + "/10000");
client.executeMethod(postMethod);
assertEquals(500, postMethod.getStatusCode());
-// assertLogContainsException("java.lang.NullPointerException: The comment did not previously exist.");
+
+ // assertLogContainsException("java.lang.NullPointerException: The comment did not previously exist.");
}
/**
* Tests a method that throws an error.
- *
+ *
* @throws Exception
*/
public void testErrorNoMappingProvider() throws Exception {
@@ -210,12 +207,12 @@
DeleteMethod postMethod = new DeleteMethod(getBaseURI() + "/-99999");
client.executeMethod(postMethod);
assertEquals(500, postMethod.getStatusCode());
-// assertLogContainsException("java.lang.Error: Simulated error");
+ // assertLogContainsException("java.lang.Error: Simulated error");
}
/**
* Tests a method that throws a checked exception.
- *
+ *
* @throws Exception
*/
public void testCheckExceptionNoMappingProvider() throws Exception {
@@ -223,11 +220,11 @@
PutMethod putMethod = new PutMethod(getBaseURI() + "/-99999");
putMethod
- .setRequestEntity(new StringRequestEntity(
- "<comment><id></id><message></message><author></author></comment>",
- "text/xml", null));
+ .setRequestEntity(new StringRequestEntity(
+ "<comment><id></id><message></message><author></author></comment>",
+ "text/xml", null));
client.executeMethod(putMethod);
assertEquals(500, putMethod.getStatusCode());
-// assertLogContainsException("jaxrs.tests.exceptions.nomapping.server.GuestbookException: Unexpected ID.");
+ // assertLogContainsException("jaxrs.tests.exceptions.nomapping.server.GuestbookException: Unexpected ID.");
}
}
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/nullconditions/JAXRSExceptionsNullConditionsTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/nullconditions/JAXRSExceptionsNullConditionsTest.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/nullconditions/JAXRSExceptionsNullConditionsTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/exceptionmappers/nullconditions/JAXRSExceptionsNullConditionsTest.java Sat Jul 18 23:11:07 2009
@@ -28,6 +28,7 @@
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.wink.test.integration.ServerContainerAssertions;
import org.apache.wink.test.integration.ServerEnvironmentInfo;
/**
@@ -54,7 +55,8 @@
try {
client.executeMethod(getMethod);
assertEquals(500, getMethod.getStatusCode());
- assertEquals("", getMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(500, getMethod
+ .getResponseBodyAsString());
} finally {
getMethod.releaseConnection();
}
@@ -73,7 +75,8 @@
try {
client.executeMethod(getMethod);
assertEquals(500, getMethod.getStatusCode());
- assertEquals("", getMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(500, getMethod
+ .getResponseBodyAsString());
} finally {
getMethod.releaseConnection();
}
@@ -92,7 +95,8 @@
try {
client.executeMethod(postMethod);
assertEquals(499, postMethod.getStatusCode());
- assertEquals("", postMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(499, postMethod
+ .getResponseBodyAsString());
} finally {
postMethod.releaseConnection();
}
@@ -132,7 +136,8 @@
try {
client.executeMethod(deleteMethod);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), deleteMethod.getStatusCode());
- assertEquals("", deleteMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(400, deleteMethod
+ .getResponseBodyAsString());
} finally {
deleteMethod.releaseConnection();
}
@@ -171,7 +176,8 @@
client.executeMethod(postMethod);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), postMethod
.getStatusCode());
- assertEquals("", postMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(500, postMethod
+ .getResponseBodyAsString());
} finally {
postMethod.releaseConnection();
}
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSSourceTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSSourceTest.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSSourceTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/standard/JAXRSSourceTest.java Sat Jul 18 23:11:07 2009
@@ -185,7 +185,7 @@
+ "/providers/standard/source");
putMethod
.setRequestEntity(new StringRequestEntity(
- "<message><user>user1</user><password>user1pwd</password></message>",
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><message><user>user1</user><password>user1pwd</password></message>",
"application/xml", "UTF-8"));
try {
client.executeMethod(putMethod);
@@ -198,9 +198,10 @@
+ "/providers/standard/source");
try {
client.executeMethod(getMethod);
- assertEquals(200, getMethod.getStatusCode());
String str = getMethod.getResponseBodyAsString();
+ assertEquals(str, 200, getMethod.getStatusCode());
+
assertEquals(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><message><user>user1</user><password>user1pwd</password></message>",
str);
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/writerexceptions/JAXRSMessageBodyWriterExceptionThrownTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/writerexceptions/JAXRSMessageBodyWriterExceptionThrownTest.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/writerexceptions/JAXRSMessageBodyWriterExceptionThrownTest.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-providers/src/test/java/org/apache/wink/jaxrs/test/providers/writerexceptions/JAXRSMessageBodyWriterExceptionThrownTest.java Sat Jul 18 23:11:07 2009
@@ -31,6 +31,7 @@
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.wink.test.integration.ServerContainerAssertions;
import org.apache.wink.test.integration.ServerEnvironmentInfo;
public class JAXRSMessageBodyWriterExceptionThrownTest extends TestCase {
@@ -418,7 +419,8 @@
try {
client.executeMethod(getMethod);
assertEquals(500, getMethod.getStatusCode());
- assertEquals("", getMethod.getResponseBodyAsString());
+ ServerContainerAssertions.assertExceptionBodyFromServer(500, getMethod
+ .getResponseBodyAsString());
} finally {
getMethod.releaseConnection();
}
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ByteContentEncodedGZIPReader.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ByteContentEncodedGZIPReader.java?rev=795444&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ByteContentEncodedGZIPReader.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ByteContentEncodedGZIPReader.java Sat Jul 18 23:11:07 2009
@@ -0,0 +1,84 @@
+/*
+ * 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.contentencoding;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.Providers;
+
+@Provider
+public class ByteContentEncodedGZIPReader implements MessageBodyReader<byte[]> {
+
+ @Context
+ private HttpHeaders headers;
+
+ public boolean isReadable(Class<?> type,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType) {
+ if (type != byte[].class || !MediaType.TEXT_PLAIN_TYPE.isCompatible(mediaType)) {
+ return false;
+ }
+ List<String> contentEncodingValues = headers.getRequestHeader("Content-Encoding");
+ String contentEncoding = null;
+ if (contentEncodingValues.size() == 1) {
+ contentEncoding = contentEncodingValues.get(0);
+ }
+ if (contentEncoding != null && "gzip".equals(contentEncoding)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Context
+ private Providers providers;
+
+ public byte[] readFrom(Class<byte[]> type,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType,
+ MultivaluedMap<String, String> httpHeaders,
+ final InputStream entityStream) throws IOException, WebApplicationException {
+ MessageBodyReader<byte[]> strReader =
+ providers.getMessageBodyReader(byte[].class,
+ byte[].class,
+ annotations,
+ MediaType.APPLICATION_XML_TYPE);
+ return strReader.readFrom(type,
+ genericType,
+ annotations,
+ mediaType,
+ httpHeaders,
+ new GZIPInputStream(entityStream));
+ }
+
+}
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ByteContentEncodedGZIPWriter.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ByteContentEncodedGZIPWriter.java?rev=795444&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ByteContentEncodedGZIPWriter.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ByteContentEncodedGZIPWriter.java Sat Jul 18 23:11:07 2009
@@ -0,0 +1,99 @@
+/*
+ * 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.contentencoding;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.zip.GZIPOutputStream;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.Providers;
+
+@Provider
+public class ByteContentEncodedGZIPWriter implements MessageBodyWriter<byte[]> {
+
+ @Context
+ private HttpHeaders headers;
+
+ public long getSize(byte[] t,
+ Class<?> type,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType) {
+ return -1;
+ }
+
+ public boolean isWriteable(Class<?> type,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType) {
+ if (type != byte[].class || !MediaType.TEXT_PLAIN_TYPE.equals(mediaType)) {
+ return false;
+ }
+
+ List<String> contentEncodingValues = headers.getRequestHeader("Accept-Encoding");
+ if (contentEncodingValues != null && contentEncodingValues.contains("gzip")) {
+ /*
+ * this in real code should check lower and uppercase gzip with
+ * quality factors in play
+ */
+ return true;
+ }
+ return false;
+ }
+
+ @Context
+ private Providers providers;
+
+ public void writeTo(byte[] t,
+ Class<?> type,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders,
+ OutputStream entityStream) throws IOException, WebApplicationException {
+ httpHeaders.putSingle("Content-Encoding", "gzip");
+ MessageBodyWriter<byte[]> strReader =
+ providers.getMessageBodyWriter(byte[].class,
+ byte[].class,
+ annotations,
+ MediaType.APPLICATION_XML_TYPE);
+ GZIPOutputStream gzipOut = new GZIPOutputStream(entityStream);
+ strReader.writeTo(t,
+ byte[].class,
+ byte[].class,
+ annotations,
+ mediaType,
+ httpHeaders,
+ gzipOut);
+ gzipOut.finish();
+ gzipOut.flush();
+ }
+
+}
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ContentEncodingApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ContentEncodingApplication.java?rev=795444&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ContentEncodingApplication.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/ContentEncodingApplication.java Sat Jul 18 23:11:07 2009
@@ -0,0 +1,39 @@
+/*
+ * 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.contentencoding;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class ContentEncodingApplication extends Application {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(MirrorResource.class);
+ classes.add(StringContentEncodedGzip.class);
+ classes.add(ByteContentEncodedGZIPReader.class);
+ classes.add(ByteContentEncodedGZIPWriter.class);
+ return classes;
+ }
+
+}
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/MirrorResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/MirrorResource.java?rev=795444&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/MirrorResource.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/MirrorResource.java Sat Jul 18 23:11:07 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.contentencoding;
+
+import java.io.UnsupportedEncodingException;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+@Path("/bigbook")
+public class MirrorResource {
+
+ @POST
+ @Consumes("text/plain")
+ @Produces("text/plain")
+ public String postBigBook(String postingBigBook) throws UnsupportedEncodingException {
+ return postingBigBook + "helloworld";
+ }
+
+ @POST
+ @Path("/mirror")
+ @Produces("text/plain")
+ public byte[] postBigBook(byte[] postingBigBook) throws UnsupportedEncodingException {
+ return postingBigBook;
+ }
+}
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/StringContentEncodedGzip.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/StringContentEncodedGzip.java?rev=795444&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/StringContentEncodedGzip.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/contentencoding/StringContentEncodedGzip.java Sat Jul 18 23:11:07 2009
@@ -0,0 +1,84 @@
+/*
+ * 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.contentencoding;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.Providers;
+
+@Provider
+public class StringContentEncodedGzip implements MessageBodyReader<String> {
+
+ @Context
+ private HttpHeaders headers;
+
+ public boolean isReadable(Class<?> type,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType) {
+ if (type != String.class || !MediaType.TEXT_PLAIN_TYPE.isCompatible(mediaType)) {
+ return false;
+ }
+ List<String> contentEncodingValues = headers.getRequestHeader("Content-Encoding");
+ String contentEncoding = null;
+ if (contentEncodingValues.size() == 1) {
+ contentEncoding = contentEncodingValues.get(0);
+ }
+ if (contentEncoding != null && "gzip".equals(contentEncoding)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Context
+ private Providers providers;
+
+ public String readFrom(Class<String> type,
+ Type genericType,
+ Annotation[] annotations,
+ MediaType mediaType,
+ MultivaluedMap<String, String> httpHeaders,
+ InputStream entityStream) throws IOException, WebApplicationException {
+ MessageBodyReader<String> strReader =
+ providers.getMessageBodyReader(String.class,
+ String.class,
+ annotations,
+ MediaType.APPLICATION_XML_TYPE);
+ return strReader.readFrom(type,
+ genericType,
+ annotations,
+ mediaType,
+ httpHeaders,
+ new GZIPInputStream(entityStream));
+ }
+
+}
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/largeentity/LargeResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/largeentity/LargeResource.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/largeentity/LargeResource.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/largeentity/LargeResource.java Sat Jul 18 23:11:07 2009
@@ -20,6 +20,7 @@
package org.apache.wink.jaxrs.test.largeentity;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -35,22 +36,31 @@
public class LargeResource {
@POST
- public Response appendStrings(String input) {
- StringBuffer sb = new StringBuffer(input);
+ public Response appendStrings(byte[] input) throws UnsupportedEncodingException {
+ final int maxHeaderLength = 100;
+ int headerLength = (input.length < maxHeaderLength) ? input.length : maxHeaderLength;
+ byte[] headerBytes = new byte[headerLength];
+ for (int c = 0; c < headerLength; ++c) {
+ headerBytes[c] = input[c];
+ }
+
+ StringBuffer sb = new StringBuffer();
+ for (int c = 0; c < 50; ++c) {
+ sb.append("abcdefghijklmnopqrstuvwxyz");
+ }
+ // String headerValue = new String(headerBytes, "UTF-8");
+
/*
* 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();
+ return Response.status(277).entity(input).header("appendStringsHeader", sb).build();
}
@POST
@Path("zip")
- public Response findFirstEntry(JarInputStream jarInputStream)
- throws IOException {
+ public Response findFirstEntry(JarInputStream jarInputStream) throws IOException {
if (jarInputStream == null) {
return Response.status(Status.BAD_REQUEST).entity("no jar").build();
}
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/lifecycles/MyMessageBodyReaderAndWriter.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/lifecycles/MyMessageBodyReaderAndWriter.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/lifecycles/MyMessageBodyReaderAndWriter.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/lifecycles/MyMessageBodyReaderAndWriter.java Sat Jul 18 23:11:07 2009
@@ -27,6 +27,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
@@ -40,7 +41,8 @@
@Provider
@Produces("text/plain")
@Consumes("text/plain")
-public class MyMessageBodyReaderAndWriter implements MessageBodyWriter<Object>, MessageBodyReader<Object> {
+public class MyMessageBodyReaderAndWriter implements MessageBodyWriter<Object>,
+ MessageBodyReader<Object> {
public static AtomicInteger readFromCounter = new AtomicInteger(0);
@@ -95,4 +97,10 @@
return strReader.readFrom(String.class, String.class, arg2, arg3, arg4, arg5);
}
+ @DELETE
+ public void resetMethodCounters() {
+ writeToCounter.set(0);
+ readFromCounter.set(0);
+ }
+
}
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/lifecycles/MyResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/lifecycles/MyResource.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/lifecycles/MyResource.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/lifecycles/MyResource.java Sat Jul 18 23:11:07 2009
@@ -21,6 +21,7 @@
import java.util.concurrent.atomic.AtomicInteger;
+import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -60,4 +61,13 @@
+ invokedCounterMethod.get();
}
+ @DELETE
+ public void resetMethodCounters() {
+ invokedMethod.set(0);
+ invokedCounterMethod.set(0);
+ constructorCounter.set(0);
+ MyMessageBodyReaderAndWriter.readFromCounter.set(0);
+ MyMessageBodyReaderAndWriter.writeToCounter.set(0);
+ }
+
}
Modified: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/sequence/SequenceSingletonResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/sequence/SequenceSingletonResource.java?rev=795444&r1=795443&r2=795444&view=diff
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/sequence/SequenceSingletonResource.java (original)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/sequence/SequenceSingletonResource.java Sat Jul 18 23:11:07 2009
@@ -31,9 +31,9 @@
@Path("/singletonsequence")
public class SequenceSingletonResource {
- private int hits = 0;
+ private int hits = 0;
- private static int staticHitCount = 0;
+ private static int staticHitCount = 0;
private static int constructorHitCount = 0;
@@ -55,6 +55,11 @@
}
@DELETE
+ public void clearHits() {
+ hits = 0;
+ }
+
+ @DELETE
@Path("/static")
public void clearStaticHitCount() {
staticHitCount = 0;
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/transferencoding/ChunkedMirror.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/transferencoding/ChunkedMirror.java?rev=795444&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/transferencoding/ChunkedMirror.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/transferencoding/ChunkedMirror.java Sat Jul 18 23:11:07 2009
@@ -0,0 +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.transferencoding;
+
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+@Path("/chunkedbook")
+public class ChunkedMirror {
+
+ @POST
+ public byte[] postSomething(byte[] b) {
+ return b;
+ }
+}
Added: incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/transferencoding/TransferEncodingApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/transferencoding/TransferEncodingApplication.java?rev=795444&view=auto
==============================================================================
--- incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/transferencoding/TransferEncodingApplication.java (added)
+++ incubator/wink/trunk/wink-integration-test/wink-server-integration-test/wink-jaxrs-test-targetting/src/main/java/org/apache/wink/jaxrs/test/transferencoding/TransferEncodingApplication.java Sat Jul 18 23:11:07 2009
@@ -0,0 +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.jaxrs.test.transferencoding;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class TransferEncodingApplication extends Application {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(ChunkedMirror.class);
+ return classes;
+ }
+
+}