[jboss-cvs] JBossAS SVN: r109093 - in projects/ejb3/trunk/testsuite: src/test/java/org/jboss/ejb3/test and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 3 12:35:55 EDT 2010


Author: wolfc
Date: 2010-11-03 12:35:55 -0400 (Wed, 03 Nov 2010)
New Revision: 109093

Added:
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/Hello.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/HelloBean.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/MessageWrapper.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/unit/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/unit/IsolatedTimerTestCase.java
   projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree2193/
   projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree2193/META-INF/
   projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree2193/META-INF/application.xml
   projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree2193/META-INF/jboss-app.xml
Modified:
   projects/ejb3/trunk/testsuite/build-test.xml
Log:
EJBTHREE-2193: test case

Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml	2010-11-03 14:58:51 UTC (rev 109092)
+++ projects/ejb3/trunk/testsuite/build-test.xml	2010-11-03 16:35:55 UTC (rev 109093)
@@ -4224,6 +4224,21 @@
 		</jar>
 	</target>
 
+   <target name="ejbthree2193">
+      <mkdir dir="${build.lib}" />
+      <jar jarfile="${build.lib}/ejbthree2193.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/ejb3/test/ejbthree2193/*.class" />
+         </fileset>
+      </jar>
+      <jar jarfile="${build.lib}/ejbthree2193.ear">
+         <fileset dir="${build.lib}">
+            <include name="ejbthree2193.jar"/>
+         </fileset>
+         <fileset dir="${resources}/test/ejbthree2193" />
+      </jar>
+   </target>
+
    <target name="jars" depends="removedislocal, statelesscreation, defaultremotebindings, localfromremote, clusteredjms, concurrentnaming, propertyreplacement, persistenceunits, appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
       concurrent,
       circulardependency, jsp, timerdependency, servicedependency, stateless14, webservices, ear, ejbthree440,
@@ -4249,6 +4264,7 @@
       ejbthree1945,
       ejbthree1995,
       ejbthree2095,
+      ejbthree2193,
    	  jaxws, jbas4489, epcpropagation, aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
       securitydomain, enventry, security5,
       jms/managed, naming, bmt, jca/inflowmdb, pool, jms, security, reference21_30, factory, dd/web, txexceptions,

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/Hello.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/Hello.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/Hello.java	2010-11-03 16:35:55 UTC (rev 109093)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree2193;
+
+import java.util.List;
+
+/**
+ * @author Mike Clark <miclark at redhat.com>
+ * @author Carlo de Wolf <cdewolf at redhat.com>
+ */
+public interface Hello
+{
+   boolean awaitResult() throws InterruptedException;
+   List<String> getResults();
+   String sayHello();
+   void startTimer();
+   void stopTimer();
+}
\ No newline at end of file

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/HelloBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/HelloBean.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/HelloBean.java	2010-11-03 16:35:55 UTC (rev 109093)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree2193;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+
+import javax.annotation.Resource;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Mike Clark <miclark at redhat.com>
+ * @author Carlo de Wolf <cdewolf at redhat.com>
+ */
+ at Stateless
+ at Remote(Hello.class)
+ at RemoteBinding(jndiBinding="HelloBean")
+public class HelloBean implements Hello
+{
+   @Resource
+   TimerService timerService;
+
+   private static List<String> results = new ArrayList<String>();
+   private static List<String> threadSafeResults = Collections.synchronizedList(results);
+   private static List<String> unmodifiableResults = Collections.unmodifiableList(results);
+   private static Semaphore resultsTracker = new Semaphore(0);
+
+   public boolean awaitResult() throws InterruptedException
+   {
+      return resultsTracker.tryAcquire(5, TimeUnit.SECONDS);
+   }
+
+   public List<String> getResults()
+   {
+      return unmodifiableResults;
+   }
+
+   @Timeout
+   public void sayAgain(Timer timer)
+   {
+      MessageWrapper wrapper = (MessageWrapper) timer.getInfo();
+      String message;
+      if (wrapper == null)
+      {
+         message = "Null Timer Info";
+      }
+      else
+      {
+         message = wrapper.getMessage();
+      }
+
+      threadSafeResults.add(message);
+      resultsTracker.release();
+      
+      System.out.println("Hello World: " + message);
+   }
+
+   public String sayHello()
+   {
+      MessageWrapper wrapper = new MessageWrapper("Hello World!");
+      System.out.println(wrapper.getMessage());
+      return wrapper.getMessage();
+   }
+
+   public void startTimer()
+   {
+      long initialDuration = 1000;
+      long repeateDuration = 1000;
+      Serializable timerInfo = new MessageWrapper("Timer Info");
+      timerService.createTimer(initialDuration, repeateDuration, timerInfo);
+   }
+
+   public void stopTimer()
+   {
+      Collection<Timer> timers = timerService.getTimers();
+      if (!timers.isEmpty())
+      {
+         for (Timer t : timers)
+         {
+            System.out.println("cancelling timer: handle=" + t.getHandle().toString());
+            t.cancel();
+         }
+      } else
+      {
+         System.out.println("no existing timers to cancel");
+      }
+
+   }
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/MessageWrapper.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/MessageWrapper.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/MessageWrapper.java	2010-11-03 16:35:55 UTC (rev 109093)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree2193;
+
+import java.io.Serializable;
+
+/**
+ * @author Mike Clark <miclark at redhat.com>
+ */
+class MessageWrapper implements Serializable
+{
+   private String mesg = "default";
+
+   public MessageWrapper(String message)
+   {
+      super();
+      mesg = message;
+   }
+
+   public String getMessage()
+   {
+      return mesg;
+   }
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/unit/IsolatedTimerTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/unit/IsolatedTimerTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree2193/unit/IsolatedTimerTestCase.java	2010-11-03 16:35:55 UTC (rev 109093)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree2193.unit;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import org.jboss.ejb3.test.common.EJB3TestCase;
+import org.jboss.ejb3.test.ejbthree2193.Hello;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class IsolatedTimerTestCase extends EJB3TestCase
+{
+   public IsolatedTimerTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testSanity() throws Exception
+   {
+      Hello bean = lookup("ejbthree2193/HelloBean/remote", Hello.class);
+      bean.sayHello();
+   }
+   
+   public void testTimeout() throws Exception
+   {
+      Hello bean = lookup("ejbthree2193/HelloBean/remote", Hello.class);
+
+      bean.startTimer();
+      try
+      {
+         redeploy("ejbthree2193.ear");
+         //Thread.sleep(3000);
+         // I'm an impatient bugger
+         bean.awaitResult();
+      }
+      finally
+      {
+         bean.stopTimer();
+      }
+
+      for(String result : bean.getResults())
+      {
+         assertEquals("Timer Info", result);
+      }
+   }
+
+   public static Test suite() throws Exception
+   {
+      return new TestSetup(getDeploySetup(IsolatedTimerTestCase.class, "ejbthree2193.ear"));
+   }
+}

Added: projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree2193/META-INF/application.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree2193/META-INF/application.xml	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree2193/META-INF/application.xml	2010-11-03 16:35:55 UTC (rev 109093)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ JBoss, Home of Professional Open Source
+  ~ Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+  ~ by the @authors tag. See the copyright.txt in the distribution for a
+  ~ full listing of individual contributors.
+  ~
+  ~ This is free software; you can redistribute it and/or modify it
+  ~ under the terms of the GNU Lesser General Public License as
+  ~ published by the Free Software Foundation; either version 2.1 of
+  ~ the License, or (at your option) any later version.
+  ~
+  ~ This software is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  ~ Lesser General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU Lesser General Public
+  ~ License along with this software; if not, write to the Free
+  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  -->
+<application xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd" version="1.4">
+   <display-name>timer-ear</display-name>
+   <module>
+      <java>ejbthree2193.jar</java>
+   </module>
+</application>
+

Added: projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree2193/META-INF/jboss-app.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree2193/META-INF/jboss-app.xml	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree2193/META-INF/jboss-app.xml	2010-11-03 16:35:55 UTC (rev 109093)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ JBoss, Home of Professional Open Source
+  ~ Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+  ~ by the @authors tag. See the copyright.txt in the distribution for a
+  ~ full listing of individual contributors.
+  ~
+  ~ This is free software; you can redistribute it and/or modify it
+  ~ under the terms of the GNU Lesser General Public License as
+  ~ published by the Free Software Foundation; either version 2.1 of
+  ~ the License, or (at your option) any later version.
+  ~
+  ~ This software is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  ~ Lesser General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU Lesser General Public
+  ~ License along with this software; if not, write to the Free
+  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  -->
+<!DOCTYPE jboss-app
+    PUBLIC "-//JBoss//DTD J2EE Application 5.0//EN"
+    "http://www.jboss.org/j2ee/dtd/jboss-app_5_0.dtd">
+<jboss-app>
+   <loader-repository> 
+      example:loader=helloTimer 
+   </loader-repository> 
+</jboss-app>



More information about the jboss-cvs-commits mailing list