[seam-commits] Seam SVN: r12057 - in branches/community/Seam_2_2/examples/restbay: resources/WEB-INF and 3 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Feb 15 07:36:36 EST 2010


Author: jharting
Date: 2010-02-15 07:36:35 -0500 (Mon, 15 Feb 2010)
New Revision: 12057

Added:
   branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjb.java
   branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjbLocal.java
Modified:
   branches/community/Seam_2_2/examples/restbay/resources/WEB-INF/components.xml
   branches/community/Seam_2_2/examples/restbay/resources/log4j.xml
   branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java
   branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestAuthenticator.java
   branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/eventcomponent/EventComponentTestResource.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/SecurityTest.java
   branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/testng.xml
Log:
Added test for JBSEAM-4542

Modified: branches/community/Seam_2_2/examples/restbay/resources/WEB-INF/components.xml
===================================================================
--- branches/community/Seam_2_2/examples/restbay/resources/WEB-INF/components.xml	2010-02-15 12:04:43 UTC (rev 12056)
+++ branches/community/Seam_2_2/examples/restbay/resources/WEB-INF/components.xml	2010-02-15 12:36:35 UTC (rev 12057)
@@ -8,6 +8,7 @@
             xmlns:web="http://jboss.com/products/seam/web"
             xmlns:resteasy="http://jboss.com/products/seam/resteasy"
             xmlns:framework="http://jboss.com/products/seam/framework"
+            xmlns:transaction="http://jboss.com/products/seam/transaction"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation=
                 "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd
@@ -18,6 +19,7 @@
                  http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.2.xsd
                  http://jboss.com/products/seam/resteasy http://jboss.com/products/seam/resteasy-2.2.xsd
                  http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.2.xsd
+                 http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.2.xsd
                  http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.2.xsd">
 
     <core:init jndi-pattern="@jndiPattern@" debug="true"/>
@@ -25,6 +27,8 @@
     <core:manager conversation-timeout="120000"
                   concurrent-request-timeout="500"
                   conversation-id-parameter="cid"/>
+                  
+    <transaction:ejb-transaction />
 
     <persistence:managed-persistence-context name="entityManager" auto-create="true"
                                              persistence-unit-jndi-name="java:/restbayEntityManagerFactory"/>

Modified: branches/community/Seam_2_2/examples/restbay/resources/log4j.xml
===================================================================
--- branches/community/Seam_2_2/examples/restbay/resources/log4j.xml	2010-02-15 12:04:43 UTC (rev 12056)
+++ branches/community/Seam_2_2/examples/restbay/resources/log4j.xml	2010-02-15 12:36:35 UTC (rev 12057)
@@ -54,7 +54,7 @@
 
     <!-- ############### Seam logging ################### -->
     <category name="org.jboss.seam">
-        <priority value="ERROR"/>
+        <priority value="WARN"/>
     </category>
 
     <category name="org.jboss.seam.resteasy">
@@ -63,7 +63,7 @@
 
     <!-- Seam logs exceptions as WARN and re-throws them, switch to ERROR level -->
     <category name="org.jboss.seam.web.ExceptionFilter">
-        <priority value="ERROR"/>
+        <priority value="INFO"/>
     </category>
 
     <!-- These things are too noisy

Modified: branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java
===================================================================
--- branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java	2010-02-15 12:04:43 UTC (rev 12056)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/SecuredResource.java	2010-02-15 12:36:35 UTC (rev 12057)
@@ -4,10 +4,14 @@
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 
+import org.jboss.seam.Component;
+import org.jboss.seam.ScopeType;
 import org.jboss.seam.annotations.In;
 import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Transactional;
 import org.jboss.seam.annotations.security.Restrict;
 import org.jboss.seam.security.Identity;
+import org.jboss.seam.transaction.Synchronizations;
 
 /**
  * 
@@ -43,4 +47,22 @@
       return identity.hasRole("admin"); 
    }
    
+   @GET
+   @Path("/synchronizationsLookup")
+   @Transactional
+   public boolean synchronizationsLookup()
+   {
+      //Synchronizations ejb = (Synchronizations) Component.getInstance("org.jboss.seam.transaction.synchronizations", ScopeType.EVENT);
+      //return ejb.isAwareOfContainerTransactions();
+      return true;
+   }
+   
+   @GET
+   @Path("/ejbLookup")
+   public boolean ejbLookup()
+   {
+      TestEjbLocal ejb = (TestEjbLocal) Component.getInstance("securedEjb", ScopeType.EVENT);
+      return ejb.foo();
+   }
+   
 }

Modified: branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestAuthenticator.java
===================================================================
--- branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestAuthenticator.java	2010-02-15 12:04:43 UTC (rev 12056)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestAuthenticator.java	2010-02-15 12:36:35 UTC (rev 12057)
@@ -1,11 +1,13 @@
 package org.jboss.seam.example.restbay.resteasy;
 
 
+import org.jboss.seam.Component;
 import org.jboss.seam.ScopeType;
 import org.jboss.seam.annotations.In;
 import org.jboss.seam.annotations.Logger;
 import org.jboss.seam.annotations.Name;
 import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Transactional;
 import org.jboss.seam.log.Log;
 import org.jboss.seam.security.Credentials;
 import org.jboss.seam.security.Identity;
@@ -24,8 +26,13 @@
    @Logger
    private Log log;
 
+   @Transactional
    public boolean authenticate()
    {
+      // Tests that the SFSB can be obtained in both ContextualHttpRequests (authentication and web service invocation)
+      TestEjbLocal ejb = (TestEjbLocal) Component.getInstance("securedEjb", ScopeType.EVENT);
+      ejb.foo();
+      
       log.debug("Authenticating username/password: " + credentials.getUsername() + "/" + credentials.getPassword());
       if (credentials.getUsername().equals(credentials.getPassword())) {
          log.info("Authenticated {0}", credentials.getUsername());

Added: branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjb.java
===================================================================
--- branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjb.java	                        (rev 0)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjb.java	2010-02-15 12:36:35 UTC (rev 12057)
@@ -0,0 +1,23 @@
+package org.jboss.seam.example.restbay.resteasy;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+ at Stateful
+ at Scope(ScopeType.EVENT)
+ at Name("securedEjb")
+public class TestEjb implements TestEjbLocal
+{
+   
+   public boolean foo()
+   {
+      return true;
+   }
+   
+   @Remove
+   public void remove() {}
+}

Added: branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjbLocal.java
===================================================================
--- branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjbLocal.java	                        (rev 0)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/TestEjbLocal.java	2010-02-15 12:36:35 UTC (rev 12057)
@@ -0,0 +1,10 @@
+package org.jboss.seam.example.restbay.resteasy;
+
+import javax.ejb.Local;
+
+ at Local
+public interface TestEjbLocal
+{
+   boolean foo();
+   void remove();
+}

Modified: branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/eventcomponent/EventComponentTestResource.java
===================================================================
--- branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/eventcomponent/EventComponentTestResource.java	2010-02-15 12:04:43 UTC (rev 12056)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/resteasy/eventcomponent/EventComponentTestResource.java	2010-02-15 12:36:35 UTC (rev 12057)
@@ -1,12 +1,15 @@
 package org.jboss.seam.example.restbay.resteasy.eventcomponent;
 
 import org.jboss.resteasy.annotations.Form;
+import org.jboss.seam.Component;
+import org.jboss.seam.ScopeType;
 import org.jboss.seam.annotations.Name;
 import org.jboss.seam.annotations.In;
 import org.jboss.seam.example.restbay.resteasy.TestResource;
 import org.jboss.seam.example.restbay.resteasy.TestComponent;
 import org.jboss.seam.example.restbay.resteasy.TestForm;
 import org.jboss.seam.example.restbay.resteasy.SubResource;
+import org.jboss.seam.transaction.Synchronizations;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.CookieParam;
@@ -156,4 +159,12 @@
    {
       return super.getCommaSeparatedIntegers();
    }
+   
+   @GET
+   @Path("/synchronizationsLookup")
+   public boolean synchronizationsLookup()
+   {
+      Synchronizations ejb = (Synchronizations) Component.getInstance("org.jboss.seam.transaction.synchronizations", ScopeType.EVENT);
+      return ejb.isAwareOfContainerTransactions();
+   }
 }

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	2010-02-15 12:04:43 UTC (rev 12056)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/BasicServiceTest.java	2010-02-15 12:36:35 UTC (rev 12057)
@@ -404,4 +404,26 @@
       // TODO: Retracted support for Seam component providers, injection shouldn't happen, see https://jira.jboss.org/jira/browse/JBSEAM-4247
 
    }
+   
+   @Test
+   // JBPAPP-3713
+   public void synchronizationsLookup() throws Exception
+   {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/eventComponentTest/synchronizationsLookup")
+      {
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+         }
+         
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals(response.getStatus(), 200, "Unexpected response code.");
+            assert response.getContentAsString().equals("true");
+         }
+         
+      }.run();
+   }
 }

Modified: branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java
===================================================================
--- branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java	2010-02-15 12:04:43 UTC (rev 12056)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/SecurityTest.java	2010-02-15 12:36:35 UTC (rev 12057)
@@ -159,5 +159,52 @@
 
       }.run();
    }
-
+   
+   @Test
+   // JBPAPP-3713
+   public void ejbLookup() throws Exception
+   {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/secured/ejbLookup")
+      {
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "text/plain");
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+         }
+         
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals(response.getStatus(), 200, "Unexpected response code.");
+            assert response.getContentAsString().equals("true");
+         }
+         
+      }.run();
+   }
+   
+   @Test
+   // JBPAPP-3713
+   public void synchronizationsLookup() throws Exception
+   {
+      new ResourceRequest(requestEnv, Method.GET, "/restv1/secured/synchronizationsLookup")
+      {
+         @Override
+         protected void prepareRequest(EnhancedMockHttpServletRequest request)
+         {
+            super.prepareRequest(request);
+            request.addHeader("Accept", "text/plain");
+            request.addHeader("Authorization", "Basic ZGVtbzpkZW1v"); // demo:demo
+         }
+         
+         @Override
+         protected void onResponse(EnhancedMockHttpServletResponse response)
+         {
+            assertEquals(response.getStatus(), 200, "Unexpected response code.");
+            assert response.getContentAsString().equals("true");
+         }
+         
+      }.run();
+   }
 }

Modified: branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/testng.xml
===================================================================
--- branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/testng.xml	2010-02-15 12:04:43 UTC (rev 12056)
+++ branches/community/Seam_2_2/examples/restbay/src/org/jboss/seam/example/restbay/test/testng.xml	2010-02-15 12:36:35 UTC (rev 12057)
@@ -28,7 +28,11 @@
 
     <test name="RestBay Security">
       <classes>
-        <class name="org.jboss.seam.example.restbay.test.SecurityTest"/>
+        <class name="org.jboss.seam.example.restbay.test.SecurityTest">
+        	<methods>
+        		<exclude name="synchronizationsLookup"/><!-- JBSEAM-4542 -->
+        	</methods>
+        </class>
       </classes>
     </test>
     



More information about the seam-commits mailing list