[seam-commits] Seam SVN: r14026 - in branches/community/Seam_2_2: examples/tasks/resources/WEB-INF and 2 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed Jan 26 09:52:41 EST 2011
Author: jharting
Date: 2011-01-26 09:52:40 -0500 (Wed, 26 Jan 2011)
New Revision: 14026
Modified:
branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/AuctionServiceTest.java
branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/BasicServiceTest.java
branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/ResourceHomeTest.java
branches/community/Seam_2_2/examples/tasks/resources/WEB-INF/components.xml
branches/community/Seam_2_2/src/main/org/jboss/seam/mock/SeamTest.java
branches/community/Seam_2_2/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java
Log:
JBSEAM-4770
Modified: branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/AuctionServiceTest.java
===================================================================
--- branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/AuctionServiceTest.java 2011-01-25 15:30:54 UTC (rev 14025)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/AuctionServiceTest.java 2011-01-26 14:52:40 UTC (rev 14026)
@@ -39,6 +39,8 @@
// Just verify we can do that, even if it doesn't make much sense
new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, "/restv1/category").run();
+
+ reset();
new ResourceRequest(requestEnv, Method.GET, "/restv1/category")
{
@@ -54,6 +56,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(requestEnv, Method.GET, "/restv1/category/1")
{
@@ -84,6 +88,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(requestEnv, Method.GET, "/restv1/auction/19264723")
{
Modified: branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/BasicServiceTest.java
===================================================================
--- branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/BasicServiceTest.java 2011-01-25 15:30:54 UTC (rev 14025)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/BasicServiceTest.java 2011-01-26 14:52:40 UTC (rev 14026)
@@ -161,6 +161,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echoquery")
{
@@ -181,6 +183,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echoheader")
{
@@ -199,6 +203,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echocookie")
{
@@ -217,6 +223,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/foo/bar/asdf")
{
@@ -230,6 +238,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echotwoparams/foo/bar")
{
@@ -282,6 +292,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(requestEnv, Method.POST, resourcePath + "/echoformparams2")
{
@@ -301,6 +313,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(requestEnv, Method.POST, resourcePath + "/echoformparams3")
{
@@ -321,6 +335,8 @@
}
}.run();
+
+ reset();
}
@@ -365,6 +381,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/commaSeparatedStrings")
{
@@ -383,6 +401,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/commaSeparatedIntegers")
{
Modified: branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/ResourceHomeTest.java
===================================================================
--- branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/ResourceHomeTest.java 2011-01-25 15:30:54 UTC (rev 14025)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/ResourceHomeTest.java 2011-01-26 14:52:40 UTC (rev 14026)
@@ -106,6 +106,8 @@
}
}.run();
+
+ reset();
new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, path)
{
@@ -144,7 +146,9 @@
}
}.run();
-
+
+ reset();
+
new ResourceRequest(new ResourceRequestEnvironment(this), Method.GET, path)
{
Modified: branches/community/Seam_2_2/examples/tasks/resources/WEB-INF/components.xml
===================================================================
--- branches/community/Seam_2_2/examples/tasks/resources/WEB-INF/components.xml 2011-01-25 15:30:54 UTC (rev 14025)
+++ branches/community/Seam_2_2/examples/tasks/resources/WEB-INF/components.xml 2011-01-26 14:52:40 UTC (rev 14026)
@@ -43,7 +43,7 @@
entity-class="org.jboss.seam.example.tasks.entity.Category"
media-types="application/xml application/json application/fastinfoset"/>
- <resteasy:application resource-path-prefix="/v1">
+ <resteasy:application resource-path-prefix="/v1" destroy-session-after-request="false">
<resteasy:media-type-mappings>
<key>xml</key>
<value>application/xml</value>
Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/mock/SeamTest.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/mock/SeamTest.java 2011-01-25 15:30:54 UTC (rev 14025)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/mock/SeamTest.java 2011-01-26 14:52:40 UTC (rev 14026)
@@ -19,6 +19,7 @@
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @author Mike Youngstrom
+ * @author <a href="http://community.jboss.org/people/jharting">Jozef Hartinger</a>
*/
public class SeamTest extends AbstractSeamTest
{
@@ -37,6 +38,16 @@
super.end();
}
+ /**
+ * Call this method within a test method to end the previous
+ * mock session and start another one.
+ */
+ public void reset()
+ {
+ end();
+ begin();
+ }
+
@Override
@BeforeClass
public void setupClass() throws Exception
Modified: branches/community/Seam_2_2/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java
===================================================================
--- branches/community/Seam_2_2/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java 2011-01-25 15:30:54 UTC (rev 14025)
+++ branches/community/Seam_2_2/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java 2011-01-26 14:52:40 UTC (rev 14026)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.resteasy;
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -44,6 +46,7 @@
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
@@ -62,6 +65,7 @@
@Scope(ScopeType.APPLICATION)
@Name("org.jboss.seam.resteasy.resourceAdapter")
@BypassInterceptors
+ at Install(precedence = BUILT_IN)
public class ResteasyResourceAdapter extends AbstractResource
{
@@ -118,34 +122,36 @@
@Override
public void process() throws ServletException, IOException
{
+ try
+ {
+ HttpHeaders headers = ServletUtil.extractHttpHeaders(request);
+ UriInfoImpl uriInfo = extractUriInfo(request, application.getResourcePathPrefix());
- HttpHeaders headers = ServletUtil.extractHttpHeaders(request);
- UriInfoImpl uriInfo = extractUriInfo(request, application.getResourcePathPrefix());
+ HttpResponse theResponse = new HttpServletResponseWrapper(
+ response,
+ dispatcher.getProviderFactory()
+ );
- HttpResponse theResponse = new HttpServletResponseWrapper(
- response,
- dispatcher.getProviderFactory()
- );
+ // TODO: This requires a SynchronousDispatcher
+ HttpRequest in = new HttpServletInputMessage(
+ request,
+ theResponse,
+ headers,
+ uriInfo,
+ request.getMethod().toUpperCase(),
+ (SynchronousDispatcher) dispatcher
+ );
- // TODO: This requires a SynchronousDispatcher
- HttpRequest in = new HttpServletInputMessage(
- request,
- theResponse,
- headers,
- uriInfo,
- request.getMethod().toUpperCase(),
- (SynchronousDispatcher) dispatcher
- );
-
- dispatcher.invoke(in, theResponse);
-
- // Prevent anemic sessions clog up the server
- if (request.getSession().isNew()
- && application.isDestroySessionAfterRequest()
- && !Session.instance().isInvalid())
+ dispatcher.invoke(in, theResponse);
+ }
+ finally
{
- log.debug("Destroying HttpSession after REST request");
- Session.instance().invalidate();
+ // Prevent anemic sessions clog up the server
+ if (application.isDestroySessionAfterRequest())
+ {
+ log.debug("Destroying HttpSession after REST request");
+ Session.instance().invalidate();
+ }
}
}
}.run();
More information about the seam-commits
mailing list