wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jra...@apache.org
Subject svn commit: r1026141 - in /incubator/wink/trunk/wink-itests/wink-itest: ./ wink-itest-jsr250-lifecycle/ wink-itest-jsr250-lifecycle/src/ wink-itest-jsr250-lifecycle/src/main/ wink-itest-jsr250-lifecycle/src/main/java/ wink-itest-jsr250-lifecycle/src/ma...
Date Thu, 21 Oct 2010 20:59:51 GMT
Author: jramos
Date: Thu Oct 21 20:59:50 2010
New Revision: 1026141

URL: http://svn.apache.org/viewvc?rev=1026141&view=rev
Log:
Add itests for JSR250 lifecycle management

Added:
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/pom.xml
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MessageAccess.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MyPOJO.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MyPOJOApplication.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/geronimo-web.xml
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/web.filter.xml
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/web.servlet.xml
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/org/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/org/apache/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/org/apache/wink/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/org/apache/wink/itest/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/org/apache/wink/itest/pojo/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/org/apache/wink/itest/pojo/lifecycle/
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/org/apache/wink/itest/pojo/lifecycle/POJOLifecycleTest.java
Modified:
    incubator/wink/trunk/wink-itests/wink-itest/pom.xml

Modified: incubator/wink/trunk/wink-itests/wink-itest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/pom.xml?rev=1026141&r1=1026140&r2=1026141&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/pom.xml (original)
+++ incubator/wink/trunk/wink-itests/wink-itest/pom.xml Thu Oct 21 20:59:50 2010
@@ -41,6 +41,7 @@
         <module>wink-example-helloworld</module>
         <module>wink-itest-client-timeout</module>
         <module>wink-itest-contentencode</module>
+        <module>wink-itest-jsr250-lifecycle</module>
     </modules>
 
     <properties>

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/pom.xml?rev=1026141&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/pom.xml (added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/pom.xml Thu Oct
21 20:59:50 2010
@@ -0,0 +1,33 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>wink-itest</artifactId>
+        <groupId>org.apache.wink</groupId>
+        <version>1.1.2-incubating-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.wink</groupId>
+    <artifactId>wink-itest-jsr250-lifecycle</artifactId>
+    <version>1.1.2-incubating-SNAPSHOT</version>
+    <packaging>war</packaging>
+    <name>Apache Wink JSR-250 Lifecycle Tests</name>
+</project>
\ No newline at end of file

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MessageAccess.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MessageAccess.java?rev=1026141&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MessageAccess.java
(added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MessageAccess.java
Thu Oct 21 20:59:50 2010
@@ -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.itest.pojo.lifecycle;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+@Path("messageaccess")
+public class MessageAccess {
+
+    @GET
+    public String getMessage() {
+        String ret = MyPOJO.message;
+        return ret;
+    }
+    
+    @POST
+    public void resetMessage() {
+        MyPOJO.message = "";
+    }
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MyPOJO.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MyPOJO.java?rev=1026141&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MyPOJO.java
(added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MyPOJO.java
Thu Oct 21 20:59:50 2010
@@ -0,0 +1,59 @@
+/*
+ * 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.pojo.lifecycle;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.WebApplicationException;
+
+@Path("pojo")
+public class MyPOJO {
+    
+    public static String message = "";
+    
+    
+    public MyPOJO() {
+        message += "MyPOJO;";
+    }
+    
+    @PostConstruct
+    public void myPostConstructMethod() {
+        message += "myPostConstructMethod;";
+    }
+
+    @GET
+    @Path("message")
+    public void message() {
+        message += "message;";
+    }
+    
+    @GET
+    @Path("exception")
+    public void getWithException() {
+        throw new WebApplicationException();
+    }
+    
+    @PreDestroy
+    public void myPreDestoryMethod() {
+        message += "myPreDestroyMethod;";
+    }
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MyPOJOApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MyPOJOApplication.java?rev=1026141&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MyPOJOApplication.java
(added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/java/org/apache/wink/itest/pojo/lifecycle/MyPOJOApplication.java
Thu Oct 21 20:59:50 2010
@@ -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.itest.pojo.lifecycle;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public class MyPOJOApplication extends Application {
+
+    @Override
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(MyPOJO.class);
+        classes.add(MessageAccess.class);
+        return classes;
+    }
+}

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/geronimo-web.xml?rev=1026141&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/geronimo-web.xml
(added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/geronimo-web.xml
Thu Oct 21 20:59:50 2010
@@ -0,0 +1,39 @@
+<?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.
+-->
+<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1"
+    xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
+    xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
+
+    <sys:environment>
+        <sys:moduleId>
+            <sys:groupId>${groupId}</sys:groupId>
+            <sys:artifactId>${artifactId}</sys:artifactId>
+            <sys:version>${version}</sys:version>
+            <sys:type>war</sys:type>
+        </sys:moduleId>
+    </sys:environment>
+
+    <gbean name="DirectoryLog4jConfiguration"
+        class="org.apache.geronimo.system.logging.log4j.ApplicationLog4jConfigurationGBean">
+        <attribute name="log4jResource">META-INF/log4j.properties</attribute>
+    </gbean>
+
+    <context-root>${artifactId}</context-root>
+</web-app> 

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/web.filter.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/web.filter.xml?rev=1026141&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/web.filter.xml
(added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/web.filter.xml
Thu Oct 21 20:59:50 2010
@@ -0,0 +1,40 @@
+<?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.
+-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd" >
+
+<web-app>
+    <display-name>Archetype Created Web Application</display-name>
+    <servlet>
+        <servlet-name>MyPOJOApp</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.pojo.lifecycle.MyPOJOApplication</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>MyPOJOApp</servlet-name>
+        <url-pattern>/*</url-pattern>
+    </servlet-mapping>
+</web-app>

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/web.servlet.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/web.servlet.xml?rev=1026141&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/web.servlet.xml
(added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/main/webapp/WEB-INF/web.servlet.xml
Thu Oct 21 20:59:50 2010
@@ -0,0 +1,40 @@
+<?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.
+-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd" >
+
+<web-app>
+    <display-name>Archetype Created Web Application</display-name>
+    <servlet>
+        <servlet-name>MyPOJOApp</servlet-name>
+        <servlet-class>${wink.rest.servlet}</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.wink.itest.pojo.lifecycle.MyPOJOApplication</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>MyPOJOApp</servlet-name>
+        <url-pattern>/*</url-pattern>
+    </servlet-mapping>
+</web-app>

Added: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/org/apache/wink/itest/pojo/lifecycle/POJOLifecycleTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/org/apache/wink/itest/pojo/lifecycle/POJOLifecycleTest.java?rev=1026141&view=auto
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/org/apache/wink/itest/pojo/lifecycle/POJOLifecycleTest.java
(added)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-jsr250-lifecycle/src/test/java/org/apache/wink/itest/pojo/lifecycle/POJOLifecycleTest.java
Thu Oct 21 20:59:50 2010
@@ -0,0 +1,89 @@
+/*
+ * 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.pojo.lifecycle;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.wink.client.ClientResponse;
+import org.apache.wink.client.Resource;
+import org.apache.wink.client.RestClient;
+import org.apache.wink.test.integration.ServerEnvironmentInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+public class POJOLifecycleTest {
+
+    private RestClient client;
+
+    private String getBaseURI() {
+        return ServerEnvironmentInfo.getBaseURI();
+    }
+
+    @Before
+    public void setUp() {
+        client = new RestClient();
+        client.resource(getBaseURI() + "/messageaccess").post(null);
+    }
+
+    /**
+     * Test that the post-construct method is called after the constructor but
+     * before the GET method for a POJO resource. Also test that the pre-destroy
+     * method is called after the request is processed, and before the next
+     * request. Combining these into one test.
+     */
+    @Test
+    public void testPostConstructAndPreDestroy() {
+        Resource resource = client.resource(getBaseURI() + "/pojo/message");
+        ClientResponse response = resource.get();
+        assertEquals(204, response.getStatusCode());
+
+        resource = client.resource(getBaseURI() + "/messageaccess");
+        response = resource.get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("MyPOJO;myPostConstructMethod;message;myPreDestroyMethod;", response
+            .getEntity(String.class));
+
+        resource = client.resource(getBaseURI() + "/pojo/message");
+        response = resource.get();
+        assertEquals(204, response.getStatusCode());
+
+        resource = client.resource(getBaseURI() + "/messageaccess");
+        response = resource.get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("MyPOJO;myPostConstructMethod;message;myPreDestroyMethod;MyPOJO;myPostConstructMethod;message;myPreDestroyMethod;",
+                     response.getEntity(String.class));
+    }
+
+    /**
+     * Test things are called correctly in the Exception path.
+     */
+    @Test
+    public void testPostConstructAndPreDestroyWithException() {
+        Resource resource = client.resource(getBaseURI() + "/pojo/exception");
+        ClientResponse response = resource.get();
+        assertEquals(500, response.getStatusCode());
+
+        resource = client.resource(getBaseURI() + "/messageaccess");
+        response = resource.get();
+        assertEquals(200, response.getStatusCode());
+        assertEquals("MyPOJO;myPostConstructMethod;myPreDestroyMethod;", response
+            .getEntity(String.class));
+    }
+}



Mime
View raw message