Seam SVN: r14953 - in branches/community/Seam_2_3/seam-integration-tests: src/test/java/org/jboss/seam/test/integration and 1 other directories.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-06-26 09:37:56 -0400 (Tue, 26 Jun 2012)
New Revision: 14953
Added:
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/FactoryLockTest.java
branches/community/Seam_2_3/seam-integration-tests/src/test/resources/WEB-INF/real-web.xml
Modified:
branches/community/Seam_2_3/seam-integration-tests/pom.xml
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/Deployments.java
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/SFSBSynchronizationTest.java
Log:
add test for JBPAPP-8869 (JBSEAM-4943)
Modified: branches/community/Seam_2_3/seam-integration-tests/pom.xml
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/pom.xml 2012-06-26 10:57:58 UTC (rev 14952)
+++ branches/community/Seam_2_3/seam-integration-tests/pom.xml 2012-06-26 13:37:56 UTC (rev 14953)
@@ -146,6 +146,12 @@
<artifactId>validation-api</artifactId>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
Modified: branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/Deployments.java
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/Deployments.java 2012-06-26 10:57:58 UTC (rev 14952)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/Deployments.java 2012-06-26 13:37:56 UTC (rev 14953)
@@ -31,7 +31,32 @@
.addAsWebInfResource("WEB-INF/ejb-jar.xml", "ejb-jar.xml")
.addAsWebInfResource("WEB-INF/jboss-seam-integration-tests-hornetq-jms.xml", "jboss-seam-integration-tests-hornetq-jms.xml");
}
+
+ // Deployment that use the proper SeamListener instead of the MockSeamListener
+ public static WebArchive realSeamDeployment() {
+ return ShrinkWrap.create(ZipImporter.class, "test.war").importFrom(new File("target/seam-integration-tests.war")).as(WebArchive.class)
+ .addAsWebInfResource(new StringAsset(
+ "<jboss-deployment-structure>" +
+ "<deployment>" +
+ "<dependencies>" +
+ "<module name=\"org.javassist\"/>" +
+ "<module name=\"org.dom4j\"/>" +
+ "</dependencies>" +
+ "</deployment>" +
+ "</jboss-deployment-structure>"), "jboss-deployment-structure.xml")
+ .addAsResource("seam.properties")
+ .addAsResource("components.properties")
+ .addAsResource("messages_en.properties")
+ .addAsResource("META-INF/persistence.xml")
+ .addAsResource("hibernate.cfg.xml")
+ .addAsWebInfResource("WEB-INF/components.xml", "components.xml")
+ .addAsWebInfResource("WEB-INF/pages.xml", "pages.xml")
+ .addAsWebInfResource("WEB-INF/real-web.xml", "web.xml")
+ .addAsWebInfResource("WEB-INF/ejb-jar.xml", "ejb-jar.xml")
+ .addAsWebInfResource("WEB-INF/jboss-seam-integration-tests-hornetq-jms.xml", "jboss-seam-integration-tests-hornetq-jms.xml");
+ }
+
public static WebArchive jbpmSeamDeployment() {
return ShrinkWrap.create(ZipImporter.class, "test.war").importFrom(new File("target/seam-integration-tests.war")).as(WebArchive.class)
.addAsWebInfResource(new StringAsset(
Added: branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/FactoryLockTest.java
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/FactoryLockTest.java (rev 0)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/FactoryLockTest.java 2012-06-26 13:37:56 UTC (rev 14953)
@@ -0,0 +1,148 @@
+package org.jboss.seam.test.integration;
+
+import javax.ejb.Local;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.Component;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.JndiName;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertEquals;
+
+(a)RunWith(Arquillian.class)
+public class FactoryLockTest extends JUnitSeamTest
+{
+ private volatile boolean exceptionOccured = false;
+
+ @Deployment(name="FactoryLockTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ return Deployments.defaultSeamDeployment()
+ .addClasses(FactoryLockAction.class, FactoryLockLocal.class, TestProducer.class);
+ }
+
+ // JBSEAM-4993
+ // The test starts two threads, one evaluates #{factoryLock.test.test()} and the other #{factoryLock.testString} 200ms later
+ @Test
+ public void factoryLock()
+ throws Exception
+ {
+ exceptionOccured = false;
+ Thread thread1 = new Thread() {
+ @Override
+ public void run()
+ {
+ try
+ {
+ FactoryLockTest.this.factoryLockTestPart1();
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ FactoryLockTest.this.exceptionOccured = true;
+ }
+ }
+ };
+
+ Thread thread2 = new Thread() {
+ @Override
+ public void run()
+ {
+ try
+ {
+ FactoryLockTest.this.factoryLockTestPart2();
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ FactoryLockTest.this.exceptionOccured = true;
+ }
+ }
+ };
+
+ thread1.start();
+ thread2.start();
+
+ thread1.join();
+ thread2.join();
+
+ assert !exceptionOccured;
+ }
+
+ private void factoryLockTestPart1() throws Exception {
+ new ComponentTest() {
+ @Override
+ protected void testComponents() throws Exception {
+ assertEquals("test", invokeMethod("#{factoryLock.test.test()}"));
+ }
+ }.run();
+ }
+
+ private void factoryLockTestPart2() throws Exception {
+ new ComponentTest() {
+ @Override
+ protected void testComponents() throws Exception {
+ Thread.sleep(200);
+ assertEquals("testString", getValue("#{factoryLock.testString}"));
+ }
+ }.run();
+ }
+
+
+ @Local
+ public static interface FactoryLockLocal
+ {
+ public String getTestString();
+ public String test();
+ public void remove();
+ }
+
+
+ @Stateful
+ @Scope(ScopeType.SESSION)
+ @Name("factoryLock.test")
+ @JndiName("java:global/test/FactoryLockTest$FactoryLockAction")
+ public static class FactoryLockAction implements FactoryLockLocal
+ {
+ public String test() {
+ try
+ {
+ Thread.sleep(500);
+ }
+
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ Component.getInstance("factoryLock.foo", true);
+ return "test";
+ }
+
+ @Factory(value="factoryLock.testString", scope=ScopeType.EVENT)
+ public String getTestString() {
+ return "testString";
+ }
+ @Remove
+ public void remove() {}
+ }
+
+ @Name("factoryLock.testProducer")
+ public static class TestProducer {
+ @Factory(value="factoryLock.foo", scope=ScopeType.EVENT)
+ public String getFoo() {
+ return "foo";
+ }
+ }
+}
Modified: branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/SFSBSynchronizationTest.java
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/SFSBSynchronizationTest.java 2012-06-26 10:57:58 UTC (rev 14952)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/SFSBSynchronizationTest.java 2012-06-26 13:37:56 UTC (rev 14953)
@@ -1,146 +1,161 @@
package org.jboss.seam.test.integration;
+import java.net.URL;
+import java.net.URLConnection;
+
import javax.ejb.Local;
import javax.ejb.Remove;
import javax.ejb.Stateful;
+import org.apache.commons.io.IOUtils;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.Component;
+import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.JndiName;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.seam.annotations.Synchronized;
import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.junit.Assert.assertEquals;
-
+@RunAsClient
@RunWith(Arquillian.class)
-public class SFSBSynchronizationTest extends JUnitSeamTest
+public class SFSBSynchronizationTest
{
- private volatile boolean exceptionOccured = false;
-
@Deployment(name="SFSBSynchronizationTest")
@OverProtocol("Servlet 3.0")
public static Archive<?> createDeployment()
{
- return Deployments.defaultSeamDeployment()
- .addClasses(FactoryLockAction.class, FactoryLockLocal.class, TestProducer.class);
+ // This is a client test, use a real (non-mocked) Seam deployment
+ return Deployments.realSeamDeployment()
+ .addClasses(TestAction.class, TestLocal.class)
+ .addAsWebResource(new StringAsset(
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\"" +
+ " xmlns:s=\"http://jboss.org/schema/seam/taglib\"" +
+ " xmlns:h=\"http://java.sun.com/jsf/html\"" +
+ " xmlns:f=\"http://java.sun.com/jsf/core\">" +
+ "<h:head></h:head>" +
+ "<h:body>" +
+ "<h:outputText value=\"#{test.test1()} \" /><h:outputText value=\"#{test.test2()}\" />" +
+ "</h:body>" +
+ "</html>"), "test.xhtml");
}
- // JBSEAM-4993
- // The test starts two threads, one evaluates #{factoryLock.test.test()} and the other #{factoryLock.testString} 200ms later
- @Test
- public void factoryLock()
- throws Exception
- {
- Thread thread1 = new Thread() {
- @Override
- public void run()
+ @ArquillianResource
+ private URL deploymentUrl;
+
+ private volatile boolean exceptionOccured = false;
+
+ private class ClientThread extends Thread {
+
+ private String cookie;
+ private URL url;
+
+ private ClientThread(URL url, String cookie) {
+ this.url = url;
+ this.cookie = cookie;
+ }
+
+ @Override
+ public void run()
+ {
+ try
{
- try
- {
- SFSBSynchronizationTest.this.factoryLockTestPart1();
+ // 10 iterations are enough to be very likely to reproduce the lock and takes only 2 seconds
+ for (int i = 0; i < 10; ++i) {
+ URLConnection urlConn;
+ urlConn = url.openConnection();
+ urlConn.setRequestProperty("Cookie", cookie);
+ urlConn.connect();
+
+ String content = IOUtils.toString(urlConn.getInputStream());
+ assert content.contains("test1 test2");
}
- catch (Throwable e)
- {
- e.printStackTrace();
- SFSBSynchronizationTest.this.exceptionOccured = true;
- }
}
- };
-
- Thread thread2 = new Thread() {
- @Override
- public void run()
+ catch (Throwable e)
{
- try
- {
- SFSBSynchronizationTest.this.factoryLockTestPart2();
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- SFSBSynchronizationTest.this.exceptionOccured = true;
- }
+ e.printStackTrace();
+ exceptionOccured = true;
}
- };
-
+ }
+ }
+
+ // JBPAPP-8869
+ @Test
+ public void synchronizationInterceptor()
+ throws Exception
+ {
+ System.out.println(deploymentUrl.toString());
+
+ // Initial request to get the session
+ URL testUrl = new URL(deploymentUrl.toString() + "/test.seam");
+ URLConnection urlConn = testUrl.openConnection();
+ urlConn.connect();
+
+ String cookie = urlConn.getHeaderField("Set-Cookie");
+ assert cookie != null;
+ assert cookie.startsWith("JSESSIONID=");
+
+ Thread thread1 = new ClientThread(testUrl, cookie);
+ Thread thread2 = new ClientThread(testUrl, cookie);
+
thread1.start();
thread2.start();
-
+
thread1.join();
thread2.join();
assert !exceptionOccured;
}
- private void factoryLockTestPart1() throws Exception {
- new ComponentTest() {
- @Override
- protected void testComponents() throws Exception {
- assertEquals("test", invokeMethod("#{factoryLock.test.test()}"));
- }
- }.run();
- }
-
- private void factoryLockTestPart2() throws Exception {
- new ComponentTest() {
- @Override
- protected void testComponents() throws Exception {
- Thread.sleep(200);
- assertEquals("testString", getValue("#{factoryLock.testString}"));
- }
- }.run();
- }
-
@Local
- public static interface FactoryLockLocal
+ public static interface TestLocal
{
- public String getTestString();
- public String test();
+ public String test1();
+ public String test2();
public void remove();
}
@Stateful
@Scope(ScopeType.SESSION)
- @Name("factoryLock.test")
- @JndiName("java:global/test/SFSBSynchronizationTest$FactoryLockAction")
- public static class FactoryLockAction implements FactoryLockLocal
+ @Name("test")
+ @JndiName("java:global/test/SFSBSynchronizationTest$TestAction")
+ @Synchronized(timeout=10000)
+ public static class TestAction implements TestLocal
{
- public String test() {
+ public String test1() {
try
{
- Thread.sleep(500);
+ Thread.sleep(100);
}
+
catch (InterruptedException e)
{
e.printStackTrace();
}
- Component.getInstance("factoryLock.foo", true);
- return "test";
+ return "test1";
}
- @Factory(value="factoryLock.testString", scope=ScopeType.EVENT)
- public String getTestString() {
- return "testString";
+ public String test2() {
+ try
+ {
+ Thread.sleep(100);
+ }
+
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ return "test2";
}
-
+
@Remove
public void remove() {}
}
-
- @Name("factoryLock.testProducer")
- public static class TestProducer {
- @Factory(value="factoryLock.foo", scope=ScopeType.EVENT)
- public String getFoo() {
- return "foo";
- }
- }
}
Added: branches/community/Seam_2_3/seam-integration-tests/src/test/resources/WEB-INF/real-web.xml
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/src/test/resources/WEB-INF/real-web.xml (rev 0)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/resources/WEB-INF/real-web.xml 2012-06-26 13:37:56 UTC (rev 14953)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="3.0"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+
+ <listener>
+ <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
+ </listener>
+
+ <filter>
+ <filter-name>Seam Filter</filter-name>
+ <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>Seam Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <servlet>
+ <servlet-name>Seam Resource Servlet</servlet-name>
+ <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Seam Resource Servlet</servlet-name>
+ <url-pattern>/seam/resource/*</url-pattern>
+ </servlet-mapping>
+
+ <!-- Faces Servlet -->
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.seam</url-pattern>
+ </servlet-mapping>
+
+ <!-- JSF parameters -->
+
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+</web-app>
12 years, 8 months
Seam SVN: r14952 - branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-06-26 06:57:58 -0400 (Tue, 26 Jun 2012)
New Revision: 14952
Added:
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/SFSBSynchronizationTest.java
Log:
Integration test for JBSEAM-4993
Added: branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/SFSBSynchronizationTest.java
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/SFSBSynchronizationTest.java (rev 0)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/SFSBSynchronizationTest.java 2012-06-26 10:57:58 UTC (rev 14952)
@@ -0,0 +1,146 @@
+package org.jboss.seam.test.integration;
+
+import javax.ejb.Local;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.Component;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.JndiName;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertEquals;
+
+(a)RunWith(Arquillian.class)
+public class SFSBSynchronizationTest extends JUnitSeamTest
+{
+ private volatile boolean exceptionOccured = false;
+
+ @Deployment(name="SFSBSynchronizationTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ return Deployments.defaultSeamDeployment()
+ .addClasses(FactoryLockAction.class, FactoryLockLocal.class, TestProducer.class);
+ }
+
+ // JBSEAM-4993
+ // The test starts two threads, one evaluates #{factoryLock.test.test()} and the other #{factoryLock.testString} 200ms later
+ @Test
+ public void factoryLock()
+ throws Exception
+ {
+ Thread thread1 = new Thread() {
+ @Override
+ public void run()
+ {
+ try
+ {
+ SFSBSynchronizationTest.this.factoryLockTestPart1();
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ SFSBSynchronizationTest.this.exceptionOccured = true;
+ }
+ }
+ };
+
+ Thread thread2 = new Thread() {
+ @Override
+ public void run()
+ {
+ try
+ {
+ SFSBSynchronizationTest.this.factoryLockTestPart2();
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ SFSBSynchronizationTest.this.exceptionOccured = true;
+ }
+ }
+ };
+
+ thread1.start();
+ thread2.start();
+
+ thread1.join();
+ thread2.join();
+
+ assert !exceptionOccured;
+ }
+
+ private void factoryLockTestPart1() throws Exception {
+ new ComponentTest() {
+ @Override
+ protected void testComponents() throws Exception {
+ assertEquals("test", invokeMethod("#{factoryLock.test.test()}"));
+ }
+ }.run();
+ }
+
+ private void factoryLockTestPart2() throws Exception {
+ new ComponentTest() {
+ @Override
+ protected void testComponents() throws Exception {
+ Thread.sleep(200);
+ assertEquals("testString", getValue("#{factoryLock.testString}"));
+ }
+ }.run();
+ }
+
+ @Local
+ public static interface FactoryLockLocal
+ {
+ public String getTestString();
+ public String test();
+ public void remove();
+ }
+
+
+ @Stateful
+ @Scope(ScopeType.SESSION)
+ @Name("factoryLock.test")
+ @JndiName("java:global/test/SFSBSynchronizationTest$FactoryLockAction")
+ public static class FactoryLockAction implements FactoryLockLocal
+ {
+ public String test() {
+ try
+ {
+ Thread.sleep(500);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ Component.getInstance("factoryLock.foo", true);
+ return "test";
+ }
+
+ @Factory(value="factoryLock.testString", scope=ScopeType.EVENT)
+ public String getTestString() {
+ return "testString";
+ }
+
+ @Remove
+ public void remove() {}
+ }
+
+ @Name("factoryLock.testProducer")
+ public static class TestProducer {
+ @Factory(value="factoryLock.foo", scope=ScopeType.EVENT)
+ public String getFoo() {
+ return "foo";
+ }
+ }
+}
12 years, 8 months
Seam SVN: r14951 - branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-06-26 03:46:14 -0400 (Tue, 26 Jun 2012)
New Revision: 14951
Modified:
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/ConcurrentFactoryTest.java
Log:
fix ConcurrentFactoryTest
Modified: branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/ConcurrentFactoryTest.java
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/ConcurrentFactoryTest.java 2012-06-25 07:37:51 UTC (rev 14950)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/ConcurrentFactoryTest.java 2012-06-26 07:46:14 UTC (rev 14951)
@@ -2,75 +2,121 @@
import static org.jboss.seam.ScopeType.APPLICATION;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.container.test.api.OverProtocol;
-import org.jboss.arquillian.junit.Arquillian;
+import java.io.Serializable;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
-import org.jboss.seam.contexts.ServletLifecycle;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.core.Expressions;
import org.jboss.seam.mock.JUnitSeamTest;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.After;
-import org.junit.runner.RunWith;
+// JBSEAM-4669
public class ConcurrentFactoryTest
extends JUnitSeamTest
{
-
- // TODO: Implement a different way to run concurrent test for junit
- // @Test(threadPoolSize = 2, invocationCount = 2)
- @Test
- @Ignore
+ private volatile boolean exceptionOccured = false;
+ static AtomicInteger testSequence = new AtomicInteger(0);
+
+ private void concurrentFactoryCallTest() throws Exception {
+ new ComponentTest() {
+ @Override
+ protected void testComponents() throws Exception {
+ int myTestSequence;
+ myTestSequence = testSequence.getAndIncrement();
+ if (myTestSequence == 0) {
+ assert "TestString".equals(getValue("#{concurrentFactoryTest.LockHoldingComponent.string}"));
+ } else {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ assert "TestString".equals(getValue("#{concurrentFactoryTest.dependentString}"));
+ }
+ System.out.println(myTestSequence);
+
+ }
+ }.run();
+ }
+
+ private class ConcurrentFactoryCallTestThread extends Thread
+ {
+ public void run() {
+ try
+ {
+ ConcurrentFactoryTest.this.concurrentFactoryCallTest();
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ ConcurrentFactoryTest.this.exceptionOccured = true;
+ }
+ };
+ }
+
+ @Test(timeout=10000)
public void concurrentFactoryCall()
throws Exception
{
- new ComponentTest() {
- @Override
- protected void testComponents() throws Exception {
- assert "slowly created String".equals(getValue("#{concurrentFactoryTest.component.injectedString}"));
- }
- }.run();
+ Thread thread1 = new ConcurrentFactoryCallTestThread();
+ Thread thread2 = new ConcurrentFactoryCallTestThread();
+
+ thread1.start();
+ thread2.start();
+
+ thread1.join();
+ thread2.join();
+
+ assert !exceptionOccured;
}
- @After
- @Override
- public void end()
- {
- if (session != null) {
- // Because we run in threads. Only the first thread that finishes ends the session.
- ServletLifecycle.endSession(session);
+ @Name("concurrentFactoryTest.LockHoldingComponent")
+ @Scope(APPLICATION)
+ static public class LockHoldingComponent implements Serializable {
+ @In(value = "concurrentFactoryTest.slowlyCreatedComponent", create = true) SlowlyCreatedComponent slowlyCreatedComponent;
+
+ public String getString() {
+ return (String) Expressions.instance().createValueExpression("#{concurrentFactoryTest.plainFactoryGeneratedString}").getValue();
}
- session = null;
}
- @Name("concurrentFactoryTest.component")
- static public class Component {
- @In(value = "concurrentFactoryTest.slowlyCreatedString") String injectedString;
-
- public String getInjectedString() {
- return injectedString;
+ @Name("concurrentFactoryTest.slowlyCreatedComponent")
+ static public class SlowlyCreatedComponent {
+ @Create
+ public void slowlyCreate() {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
}
}
+
+ @Name("concurrentFactoryTest.dependentFactory")
+ static public class DependentFactory {
+ @Factory(value = "concurrentFactoryTest.dependentString", scope = APPLICATION, autoCreate = true)
+ public String createString() {
+ return (String) Expressions.instance().createValueExpression("#{concurrentFactoryTest.LockHoldingComponent.string}").getValue();
+ }
+ }
- @Name("concurrentFactoryTest.SlowFactory")
- static public class SlowFactory {
- @Factory(value = "concurrentFactoryTest.slowlyCreatedString", scope = APPLICATION, autoCreate = true)
- public String slowlyCreateString() {
- try
- {
- Thread.sleep(1000);
- return "slowly created String";
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- return null;
- }
- }
+ @Name("concurrentFactoryTest.plainFactory")
+ static public class PlainFactory {
+ @Factory(value = "concurrentFactoryTest.plainFactoryGeneratedString", scope = APPLICATION, autoCreate = true)
+ public String createPlainString() {
+ return "TestString";
+ }
}
-
-
+ @After
+ @Override
+ public void end()
+ {
+ // don't attempt to endSession, as it will block in the deadlocked org.jboss.seam.Component.getInstanceFromFactory lock
+ }
}
12 years, 8 months
Seam SVN: r14950 - in branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp: exp and 1 other directory.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2012-06-25 03:37:51 -0400 (Mon, 25 Jun 2012)
New Revision: 14950
Modified:
branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/WEB-INF/components.xml
branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/exp/loginExp.html
branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/exp/mainExp.html
Log:
fixed bz #830196 booking eclipse errors
Modified: branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/WEB-INF/components.xml
===================================================================
--- branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/WEB-INF/components.xml 2012-06-22 13:56:55 UTC (rev 14949)
+++ branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/WEB-INF/components.xml 2012-06-25 07:37:51 UTC (rev 14950)
@@ -10,7 +10,7 @@
http://jboss.org/schema/seam/security http://jboss.org/schema/seam/security-2.3.xsd
http://jboss.org/schema/seam/components http://jboss.org/schema/seam/components-2.3.xsd">
- <core:init jndi-pattern="${jndiPattern}" debug="true" distributable="${distributable}"/>
+ <core:init jndi-pattern="${jndiPattern}" debug="true" distributable="@distributable@"/>
<core:manager conversation-timeout="120000"
concurrent-request-timeout="500"
Modified: branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/exp/loginExp.html
===================================================================
--- branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/exp/loginExp.html 2012-06-22 13:56:55 UTC (rev 14949)
+++ branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/exp/loginExp.html 2012-06-25 07:37:51 UTC (rev 14950)
@@ -14,11 +14,11 @@
<div class="numbox">2</div>
<h2>What happens when you login?</h2>
<img src="../img/header_line.gif" />
-
+ <center>
<form>
- <input type="button" value="Close Window" onclick="window.close()"/>
+ <input type="button" value="Close Window" onclick="window.close()"></input>
</form>
-
+ </center>
<p>
The login page is defined using pure XHTML with JSF controls.
The form uses JSF EL value binding and method binding
@@ -30,7 +30,7 @@
<code class="block">
<div>
- <h:outputLabel for="username">Login Name</h:outputLabel>
+ <h:outputLabel for="username">Login Name</h:outputLabel>
<h:inputText id="username" value="#{identity.username}" />
</div>
<div>
Modified: branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/exp/mainExp.html
===================================================================
--- branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/exp/mainExp.html 2012-06-22 13:56:55 UTC (rev 14949)
+++ branches/enterprise/WFK-2_0/examples-ee6/booking/booking-web/src/main/webapp/exp/mainExp.html 2012-06-25 07:37:51 UTC (rev 14950)
@@ -91,7 +91,7 @@
public boolean isNextPageAvailable()
{
- return hotels!=null && hotels.size()==pageSize;
+ return hotels!=null && hotels.size()==pageSize;
}
public int getPageSize() {
@@ -137,7 +137,7 @@
<code class="block">
<h:outputText value="No Hotels Found"
rendered="#{hotels != null and hotels.rowCount==0}"/>
-<h:dataTable value="#{hotels}" var="hot" rendered="#{hotels.rowCount>0}">
+<h:dataTable value="#{hotels}" var="hot" rendered="#{hotels.rowCount>0}">
<h:column>
<f:facet name="header">Name</f:facet>
#{hot.name}
@@ -202,11 +202,11 @@
}
}
</code>
-
+ <center>
<form>
- <input type="button" value="Close Window" onclick="window.close()"/>
+ <input type="button" value="Close Window" onclick="window.close()"></input>
</form>
-
+ </center>
</div>
</div>
12 years, 8 months
Seam SVN: r14949 - branches/community/Seam_2_3/examples-ee6/ui.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-06-22 09:56:55 -0400 (Fri, 22 Jun 2012)
New Revision: 14949
Removed:
branches/community/Seam_2_3/examples-ee6/ui/ui-ds.cli
Log:
ui example remove ui-ds.cli
Deleted: branches/community/Seam_2_3/examples-ee6/ui/ui-ds.cli
===================================================================
--- branches/community/Seam_2_3/examples-ee6/ui/ui-ds.cli 2012-06-22 13:45:12 UTC (rev 14948)
+++ branches/community/Seam_2_3/examples-ee6/ui/ui-ds.cli 2012-06-22 13:56:55 UTC (rev 14949)
@@ -1,3 +0,0 @@
-connect
-data-source add --name=uiDS --jndi-name=java:/uiDatasource --connection-url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 --user-name=sa --password=sa --driver-name=h2
-/subsystem=datasources/data-source="uiDS":enable
12 years, 8 months
Seam SVN: r14948 - branches/community/Seam_2_3/examples-ee6/remoting/helloworld/helloworld-ear/src/main/application/META-INF.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-06-22 09:45:12 -0400 (Fri, 22 Jun 2012)
New Revision: 14948
Modified:
branches/community/Seam_2_3/examples-ee6/remoting/helloworld/helloworld-ear/src/main/application/META-INF/jboss-deployment-structure.xml
Log:
remoting helloworld example fix jboss-deployment-structure.xml to add javassist and dom4j
Modified: branches/community/Seam_2_3/examples-ee6/remoting/helloworld/helloworld-ear/src/main/application/META-INF/jboss-deployment-structure.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/remoting/helloworld/helloworld-ear/src/main/application/META-INF/jboss-deployment-structure.xml 2012-06-22 13:38:01 UTC (rev 14947)
+++ branches/community/Seam_2_3/examples-ee6/remoting/helloworld/helloworld-ear/src/main/application/META-INF/jboss-deployment-structure.xml 2012-06-22 13:45:12 UTC (rev 14948)
@@ -1,6 +1,8 @@
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<dependencies>
+ <module name="org.javassist" export="true"/>
+ <module name="org.dom4j" export="true"/>
<module name="javax.faces.api" export="true"/>
<module name="com.sun.jsf-impl" export="true"/>
</dependencies>
12 years, 8 months
Seam SVN: r14947 - branches/community/Seam_2_3/examples-ee6/remoting/gwt/gwt-ear/src/main/application/META-INF.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-06-22 09:38:01 -0400 (Fri, 22 Jun 2012)
New Revision: 14947
Modified:
branches/community/Seam_2_3/examples-ee6/remoting/gwt/gwt-ear/src/main/application/META-INF/jboss-deployment-structure.xml
Log:
gwt example fix jboss-deployment-structure.xml to include dom4j and javassist
Modified: branches/community/Seam_2_3/examples-ee6/remoting/gwt/gwt-ear/src/main/application/META-INF/jboss-deployment-structure.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/remoting/gwt/gwt-ear/src/main/application/META-INF/jboss-deployment-structure.xml 2012-06-22 13:37:24 UTC (rev 14946)
+++ branches/community/Seam_2_3/examples-ee6/remoting/gwt/gwt-ear/src/main/application/META-INF/jboss-deployment-structure.xml 2012-06-22 13:38:01 UTC (rev 14947)
@@ -1,6 +1,8 @@
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<dependencies>
+ <module name="org.javassist" export="true"/>
+ <module name="org.dom4j" export="true"/>
<module name="javax.faces.api" export="true"/>
<module name="com.sun.jsf-impl" export="true"/>
</dependencies>
12 years, 8 months
Seam SVN: r14946 - branches/community/Seam_2_3/examples-ee6/remoting/gwt/gwt-web.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-06-22 09:37:24 -0400 (Fri, 22 Jun 2012)
New Revision: 14946
Modified:
branches/community/Seam_2_3/examples-ee6/remoting/gwt/gwt-web/pom.xml
Log:
GWT example fix path to copy generated files to the web module
Modified: branches/community/Seam_2_3/examples-ee6/remoting/gwt/gwt-web/pom.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/remoting/gwt/gwt-web/pom.xml 2012-06-22 12:44:05 UTC (rev 14945)
+++ branches/community/Seam_2_3/examples-ee6/remoting/gwt/gwt-web/pom.xml 2012-06-22 13:37:24 UTC (rev 14946)
@@ -45,7 +45,7 @@
<outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
<resources>
<resource>
- <directory>${basedir}/../gwt-ejb/target/gwt-ejb/org.jboss.seam.example.remoting.gwt.HelloWorld</directory>
+ <directory>${basedir}/../gwt-ejb/target/gwt-ejb-${project.version}/org.jboss.seam.example.remoting.gwt.HelloWorld</directory>
<includes>
<include>**/*</include>
</includes>
12 years, 8 months
Seam SVN: r14945 - branches/community/Seam_2_3/examples-ee6/remoting/chatroom/chatroom-ear/src/main/application/META-INF.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-06-22 08:44:05 -0400 (Fri, 22 Jun 2012)
New Revision: 14945
Modified:
branches/community/Seam_2_3/examples-ee6/remoting/chatroom/chatroom-ear/src/main/application/META-INF/jboss-deployment-structure.xml
Log:
chatroom example, import javassist and dom4j from AS7
Modified: branches/community/Seam_2_3/examples-ee6/remoting/chatroom/chatroom-ear/src/main/application/META-INF/jboss-deployment-structure.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/remoting/chatroom/chatroom-ear/src/main/application/META-INF/jboss-deployment-structure.xml 2012-06-21 16:49:15 UTC (rev 14944)
+++ branches/community/Seam_2_3/examples-ee6/remoting/chatroom/chatroom-ear/src/main/application/META-INF/jboss-deployment-structure.xml 2012-06-22 12:44:05 UTC (rev 14945)
@@ -2,8 +2,10 @@
<deployment>
<dependencies>
<module name="javax.faces.api" export="true"/>
+ <module name="org.dom4j" export="true"/>
<module name="com.sun.jsf-impl" export="true"/>
<module name="org.hibernate" export="true"/>
+ <module name="org.javassist" export="true"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
12 years, 8 months