[jboss-cvs] JBossAS SVN: r64732 - in trunk/ejb3: src/main/org/jboss/ejb3 and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 21 10:05:07 EDT 2007
Author: wolfc
Date: 2007-08-21 10:05:07 -0400 (Tue, 21 Aug 2007)
New Revision: 64732
Added:
trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java
trunk/ejb3/src/resources/test/statelesscreation/
trunk/ejb3/src/resources/test/statelesscreation/statelesscreation-connectors-service.xml
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBeanContext.java
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java
Removed:
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBeanContext.java
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java
Modified:
trunk/ejb3/build-test.xml
trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java
Log:
EJBTHREE-1031: merged from Branch_4_2
Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml 2007-08-21 13:55:13 UTC (rev 64731)
+++ trunk/ejb3/build-test.xml 2007-08-21 14:05:07 UTC (rev 64732)
@@ -1002,6 +1002,9 @@
</jar>
</target>
+ <target name="threadlocal" depends="compile-classes">
+ </target>
+
<target name="timer"
description="Builds all jar files."
depends="compile-classes">
@@ -3058,6 +3061,25 @@
<copy file="${build.lib}/stateless-test.jar" tofile="${build.lib}/stateless-test.ejb3"/>
</target>
+ <target name="statelesscreation"
+ description="Builds all jar files."
+ depends="compile-classes">
+
+ <mkdir dir="${build.lib}"/>
+
+ <jar jarfile="${build.lib}/statelesscreation-test.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/statelesscreation/*.class"/>
+ </fileset>
+ </jar>
+
+ <copy todir="${build.lib}">
+ <fileset dir="${resources}/test/statelesscreation">
+ <include name="*.xml"/>
+ </fileset>
+ </copy>
+ </target>
+
<target name="defaultremotebindings"
description="Builds all jar files."
depends="compile-classes">
@@ -3551,7 +3573,7 @@
</fileset>
</copy>
</target>
-
+
<target name="jars" depends="defaultremotebindings, localfromremote, clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440,
ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree832, ejbthree921, ejbthree936,
@@ -3566,7 +3588,8 @@
entityexception, asynchronous, consumer, clusteredentity, secondary, stateful, service, lob, cache, initial,
timer, benchmark, entity, joininheritance, singletable, tableperclass, dependent, mdb, manytomany, regression,
composite, composite2, entitycallback, relationships, ssl, ssladvanced, clusteredsession, strictpool, jacc,
- localcall, interceptors, interceptors2, interceptors3, iiop, clientinterceptor"/>
+ localcall, interceptors, interceptors2, interceptors3, iiop, clientinterceptor,
+ statelesscreation"/>
<target name="test" depends="init" if="test"
description="Execute all tests in the given test directory.">
@@ -3601,6 +3624,9 @@
<condition property="client.run.classpath" value="iiop.client.classpath">
<equals arg1="${test}" arg2="iiop"/>
</condition>
+ <condition property="client.run.classpath" value="dd.classpath">
+ <equals arg1="${test}" arg2="threadlocal"/>
+ </condition>
<condition property="client.run.classpath" value="client.classpath">
<not>
<isset property="client.run.classpath"/>
@@ -4128,6 +4154,7 @@
<target name="tests" depends="init" description="Execute all tests">
<!--antcall target="standalone-tests" inheritRefs="true"/-->
+ <antcall target="simple-tests" inheritRefs="true"/>
<antcall target="ejb-tests" inheritRefs="true"/>
<antcall target="entity-tests" inheritRefs="true"/>
<antcall target="ssl-simple-test" inheritRefs="true"/>
@@ -4165,7 +4192,13 @@
<param name="test" value="standalone/servicepojo"/>
</antcall>
</target>
-
+
+ <target name="simple-tests" depends="init">
+ <antcall target="test" inheritRefs="true">
+ <param name="test" value="threadlocal"/>
+ </antcall>
+ </target>
+
<target name="ejb-tests" depends="init" description="Execute all tests">
<server:start name="all"/>
<antcall target="no-start-jboss-ejb-tests" inheritRefs="true"/>
@@ -4449,6 +4482,9 @@
<antcall target="test" inheritRefs="true">
<param name="test" value="ejbthree1023"/>
</antcall>
+ <antcall target="test" inheritRefs="true">
+ <param name="test" value="statelesscreation"/>
+ </antcall>
</target>
<target name="entity-tests" depends="init" description="Execute all tests">
Copied: trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java (from rev 64706, branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/InfinitePool.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * A pool that has no constraints.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class InfinitePool extends AbstractPool
+{
+ private List<BeanContext> active = new LinkedList<BeanContext>();
+
+ public void destroy()
+ {
+ for(BeanContext ctx : active)
+ {
+ // call super.remove or else get concurrent modification
+ super.remove(ctx);
+ }
+ active = null;
+ }
+
+ public BeanContext<?> get()
+ {
+ return get(null, null);
+ }
+
+ public BeanContext<?> get(Class[] initTypes, Object[] initValues)
+ {
+ BeanContext ctx = create(initTypes, initValues);
+ synchronized(active)
+ {
+ active.add(ctx);
+ }
+ return ctx;
+ }
+
+ public int getAvailableCount()
+ {
+ return -1;
+ }
+
+ public int getCurrentSize()
+ {
+ return active.size();
+ }
+
+ public int getMaxSize()
+ {
+ return -1;
+ }
+
+ public void release(BeanContext ctx)
+ {
+ remove(ctx);
+ }
+
+ public void remove(BeanContext ctx)
+ {
+ synchronized(active)
+ {
+ active.remove(ctx);
+ }
+
+ super.remove(ctx);
+ }
+
+ public void setMaxSize(int maxSize)
+ {
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java 2007-08-21 13:55:13 UTC (rev 64731)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -21,6 +21,7 @@
*/
package org.jboss.ejb3;
+import org.jboss.injection.Injector;
import org.jboss.lang.ref.WeakThreadLocal;
import org.jboss.logging.Logger;
@@ -31,30 +32,48 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public class ThreadlocalPool extends AbstractPool
+public class ThreadlocalPool implements Pool
{
private static final Logger log = Logger.getLogger(ThreadlocalPool.class);
- protected WeakThreadLocal<BeanContext> pool = new WeakThreadLocal<BeanContext>();
+ protected Pool delegate = new InfinitePool();
+ protected WeakThreadLocal<BeanContext> currentBeanContext = new WeakThreadLocal<BeanContext>();
public ThreadlocalPool()
{
}
+ protected BeanContext create()
+ {
+ return delegate.get();
+ }
+
+ protected BeanContext create(Class[] initTypes, Object[] initValues)
+ {
+ return delegate.get(initTypes, initValues);
+ }
+
+ public void discard(BeanContext obj)
+ {
+ delegate.discard(obj);
+ }
+
public void destroy()
{
log.trace("destroying pool");
+ delegate.destroy();
+
// This really serves little purpose, because we want the whole thread local map to die
- pool.remove();
+ currentBeanContext.remove();
}
public BeanContext<?> get()
{
- BeanContext ctx = pool.get();
+ BeanContext ctx = currentBeanContext.get();
if (ctx != null)
{
- pool.set(null);
+ currentBeanContext.set(null);
return ctx;
}
@@ -64,10 +83,10 @@
public BeanContext<?> get(Class[] initTypes, Object[] initValues)
{
- BeanContext ctx = pool.get();
+ BeanContext ctx = currentBeanContext.get();
if (ctx != null)
{
- pool.set(null);
+ currentBeanContext.set(null);
return ctx;
}
@@ -75,15 +94,54 @@
return ctx;
}
+ public void initialize(Container container, int maxSize, long timeout)
+ {
+ delegate.initialize(container, maxSize, timeout);
+ }
+
public void release(BeanContext ctx)
{
- if (pool.get() != null)
+ if (currentBeanContext.get() != null)
remove(ctx);
else
- pool.set(ctx);
+ currentBeanContext.set(ctx);
}
+
+ public void remove(BeanContext ctx)
+ {
+ delegate.remove(ctx);
+ }
+
+ public int getCurrentSize()
+ {
+ return -1;
+ }
+
+ public int getAvailableCount()
+ {
+ return -1;
+ }
+
+ public int getCreateCount()
+ {
+ return delegate.getCreateCount();
+ }
+
+ public int getMaxSize()
+ {
+ return -1;
+ }
- @Override
+ public int getRemoveCount()
+ {
+ return delegate.getRemoveCount();
+ }
+
+ public void setInjectors(Injector[] injectors)
+ {
+ delegate.setInjectors(injectors);
+ }
+
public void setMaxSize(int maxSize)
{
}
Added: trunk/ejb3/src/resources/test/statelesscreation/statelesscreation-connectors-service.xml
===================================================================
--- trunk/ejb3/src/resources/test/statelesscreation/statelesscreation-connectors-service.xml (rev 0)
+++ trunk/ejb3/src/resources/test/statelesscreation/statelesscreation-connectors-service.xml 2007-08-21 14:05:07 UTC (rev 64732)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss EJB3Deployer
+
+ $Id$
+-->
+<server>
+
+ <mbean code="org.jboss.remoting.transport.Connector"
+ name="jboss.remoting:type=Connector,name=StatelessCreationConnector,handler=ejb3">
+ <!--attribute name="InvokerLocator">socket://${jboss.bind.address}:3873</attribute-->
+ <attribute name="Configuration">
+ <config>
+ <invoker transport="socket">
+ <attribute name="numAcceptThreads">1</attribute>
+ <attribute name="maxPoolSize">30</attribute>
+ <attribute name="clientMaxPoolSize" isParam="true">50</attribute>
+ <attribute name="timeout" isParam="true">60000</attribute>
+ <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
+ <attribute name="serverBindPort">3875</attribute>
+ <attribute name="backlog">200</attribute>
+ </invoker>
+ <handlers>
+ <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
+ </handlers>
+ </config>
+ </attribute>
+ </mbean>
+
+</server>
Property changes on: trunk/ejb3/src/resources/test/statelesscreation/statelesscreation-connectors-service.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation (from rev 64666, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation)
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java 2007-08-17 19:23:23 UTC (rev 64666)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.statelesscreation;
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- */
-public interface DestroyRemote
-{
- int getBeanCount();
-}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java (from rev 64666, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.statelesscreation;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface DestroyRemote
+{
+ int getBeanCount();
+}
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java 2007-08-17 19:23:23 UTC (rev 64666)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.statelesscreation;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.ejb.Stateless;
-import javax.ejb.Remote;
-import org.jboss.logging.Logger;
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- */
- at Stateless
- at Remote(DestroyRemote.class)
-public class DestroyStatelessBean implements DestroyRemote
-{
- private static final Logger log = Logger.getLogger(DestroyStatelessBean.class);
-
- private static int beanCount = 0;
-
- public int getBeanCount()
- {
- return beanCount;
- }
-
- @PostConstruct
- public void construct()
- {
- ++beanCount;
- }
-
- @PreDestroy
- public void destroy()
- {
- --beanCount;
- }
-}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java (from rev 64666, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.statelesscreation;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateless;
+import javax.ejb.Remote;
+
+import org.jboss.annotation.ejb.RemoteBinding;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless
+ at Remote(DestroyRemote.class)
+ at RemoteBinding(clientBindUrl="socket://0.0.0.0:3875")
+public class DestroyStatelessBean implements DestroyRemote
+{
+ private static final Logger log = Logger.getLogger(DestroyStatelessBean.class);
+
+ private static int beanCount = 0;
+
+ public int getBeanCount()
+ {
+ return beanCount;
+ }
+
+ @PostConstruct
+ public void construct()
+ {
+ ++beanCount;
+ log.trace("construct");
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ --beanCount;
+ log.trace("destroy");
+ }
+}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit (from rev 64666, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit)
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java 2007-08-17 19:23:23 UTC (rev 64666)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -1,106 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.statelesscreation.unit;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.naming.InitialContext;
-
-import org.jboss.ejb3.test.statelesscreation.DestroyRemote;
-import org.jboss.logging.Logger;
-import org.jboss.test.JBossTestCase;
-import junit.framework.Test;
-
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- */
-public class MetricsUnitTestCase
-extends JBossTestCase
-{
- private static final Logger log = Logger.getLogger(MetricsUnitTestCase.class);
-
- public MetricsUnitTestCase(String name)
- {
- super(name);
- }
-
- public void testSLSBCount() throws Exception
- {
- DestroyRemote slsb = (DestroyRemote)getInitialContext().lookup("DestroyStatelessBean/remote");
- assertNotNull(slsb);
- assertEquals(1, slsb.getBeanCount());
-
- for (int i = 0 ; i < 50 ; ++i)
- {
- Runnable r = new Runnable()
- {
- public void run()
- {
- try
- {
- InitialContext jndiContext = getInitialContext();
- for (int i = 0 ; i < 100 ; ++i)
- {
- DestroyRemote slsb = (DestroyRemote)jndiContext.lookup("DestroyStatelessBean/remote");
- slsb.getBeanCount();
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- };
-
- new Thread(r).start();
- }
-
- Thread.sleep(1 * 60 * 1000);
-
- MBeanServerConnection server = getServer();
- ObjectName testerName = new ObjectName("jboss.j2ee:jar=statelesscreation-test.jar,name=DestroyStatelessBean,service=EJB3");
-
- int size = (Integer)server.getAttribute(testerName, "CurrentSize");
- System.out.println("CurrentSize=" + size);
-
- size = (Integer)server.getAttribute(testerName, "AvailableCount");
- System.out.println("AvailableCount=" + size);
-
- size = (Integer)server.getAttribute(testerName, "MaxSize");
- System.out.println("MaxSize=" + size);
-
- size = (Integer)server.getAttribute(testerName, "RemoveCount");
- System.out.println("RemoveCount=" + size);
-
- size = (Integer)server.getAttribute(testerName, "CreateCount");
- System.out.println("CreateCount=" + size);
- assertEquals(30, size);
-
- }
-
- public static Test suite() throws Exception
- {
- return getDeploySetup(MetricsUnitTestCase.class, "statelesscreation-test.jar");
- }
-
-}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java (from rev 64666, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.statelesscreation.unit;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.test.statelesscreation.DestroyRemote;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MetricsUnitTestCase
+extends JBossTestCase
+{
+ @SuppressWarnings("unused")
+ private static final Logger log = Logger.getLogger(MetricsUnitTestCase.class);
+
+ public MetricsUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testSLSBCount() throws Exception
+ {
+ DestroyRemote slsb = (DestroyRemote)getInitialContext().lookup("DestroyStatelessBean/remote");
+ assertNotNull(slsb);
+ assertEquals(1, slsb.getBeanCount());
+
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ InitialContext jndiContext = getInitialContext();
+ for (int i = 0 ; i < 100 ; ++i)
+ {
+ DestroyRemote slsb = (DestroyRemote)jndiContext.lookup("DestroyStatelessBean/remote");
+ slsb.getBeanCount();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ };
+ Thread threads[] = new Thread[50];
+ for (int i = 0 ; i < threads.length ; ++i)
+ {
+ threads[i] = new Thread(r);
+ threads[i].start();
+ }
+
+ for(Thread t : threads)
+ {
+ t.join(1 * 60 * 1000);
+ }
+
+ MBeanServerConnection server = getServer();
+ ObjectName testerName = new ObjectName("jboss.j2ee:jar=statelesscreation-test.jar,name=DestroyStatelessBean,service=EJB3");
+
+ int size = (Integer)server.getAttribute(testerName, "CurrentSize");
+ System.out.println("CurrentSize=" + size);
+
+ size = (Integer)server.getAttribute(testerName, "AvailableCount");
+ System.out.println("AvailableCount=" + size);
+
+ size = (Integer)server.getAttribute(testerName, "MaxSize");
+ System.out.println("MaxSize=" + size);
+
+ size = (Integer)server.getAttribute(testerName, "RemoveCount");
+ System.out.println("RemoveCount=" + size);
+
+ size = (Integer)server.getAttribute(testerName, "CreateCount");
+ System.out.println("CreateCount=" + size);
+ assertEquals(30, size);
+
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(MetricsUnitTestCase.class, "statelesscreation-connectors-service.xml, statelesscreation-test.jar");
+ }
+
+}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal (from rev 64706, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/threadlocal)
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBean.java 2007-08-20 12:51:31 UTC (rev 64706)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBean.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, 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.threadlocal;
-
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class MockBean
-{
- private static final Logger log = Logger.getLogger(MockBean.class);
- public static int finalizers = 0;
-
- @Override
- protected void finalize() throws Throwable
- {
- log.info("finalize");
-
- finalizers++;
-
- super.finalize();
- }
-
- protected void postConstruct()
- {
- log.info("postConstruct");
- }
-
- protected void preDestroy()
- {
- log.info("preDestroy");
- }
-}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBean.java (from rev 64706, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBean.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBean.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.threadlocal;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MockBean
+{
+ private static final Logger log = Logger.getLogger(MockBean.class);
+ public static int finalizers = 0;
+
+ @Override
+ protected void finalize() throws Throwable
+ {
+ log.info("finalize");
+
+ finalizers++;
+
+ super.finalize();
+ }
+
+ protected void postConstruct()
+ {
+ log.info("postConstruct");
+ }
+
+ protected void preDestroy()
+ {
+ log.info("preDestroy");
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBeanContext.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBeanContext.java 2007-08-20 12:51:31 UTC (rev 64706)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBeanContext.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, 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.threadlocal;
-
-import javax.ejb.EJBContext;
-
-import org.jboss.aop.metadata.SimpleMetaData;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.interceptor.InterceptorInfo;
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class MockBeanContext implements BeanContext
-{
- private static Logger log = Logger.getLogger(MockBeanContext.class);
-
- private Object instance;
-
- @Override
- protected void finalize() throws Throwable
- {
- log.info("finalize");
- super.finalize();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.BeanContext#getContainer()
- */
- public Container getContainer()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.BeanContext#getEJBContext()
- */
- public EJBContext getEJBContext()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.BeanContext#getInstance()
- */
- public Object getInstance()
- {
- assert instance != null;
- return instance;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.BeanContext#getInterceptorInstances(org.jboss.ejb3.interceptor.InterceptorInfo[])
- */
- public Object[] getInterceptorInstances(InterceptorInfo[] interceptorInfos)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.BeanContext#getInvokedMethodKey()
- */
- public Object getInvokedMethodKey()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.BeanContext#getMetaData()
- */
- public SimpleMetaData getMetaData()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.BeanContext#initialiseInterceptorInstances()
- */
- public void initialiseInterceptorInstances()
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.BeanContext#remove()
- */
- public void remove()
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.BeanContext#setContainer(org.jboss.ejb3.Container)
- */
- public void setContainer(Container container)
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.BeanContext#setInstance(java.lang.Object)
- */
- public void setInstance(Object instance)
- {
- assert instance != null;
- this.instance = instance;
- }
-
-}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBeanContext.java (from rev 64706, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBeanContext.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBeanContext.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBeanContext.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.threadlocal;
+
+import javax.ejb.EJBContext;
+
+import org.jboss.aop.metadata.SimpleMetaData;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.interceptor.InterceptorInfo;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MockBeanContext implements BeanContext
+{
+ private static Logger log = Logger.getLogger(MockBeanContext.class);
+
+ private Object instance;
+
+ public MockBeanContext(Object instance)
+ {
+ assert instance != null;
+
+ this.instance = instance;
+ }
+
+ @Override
+ protected void finalize() throws Throwable
+ {
+ log.info("finalize");
+ super.finalize();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#getContainer()
+ */
+ public Container getContainer()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#getEJBContext()
+ */
+ public EJBContext getEJBContext()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#getInstance()
+ */
+ public Object getInstance()
+ {
+ assert instance != null;
+ return instance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#getInterceptorInstances(org.jboss.ejb3.interceptor.InterceptorInfo[])
+ */
+ public Object[] getInterceptorInstances(InterceptorInfo[] interceptorInfos)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#getInvokedMethodKey()
+ */
+ public Object getInvokedMethodKey()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#getMetaData()
+ */
+ public SimpleMetaData getMetaData()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#initialiseInterceptorInstances()
+ */
+ public void initialiseInterceptorInstances()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#remove()
+ */
+ public void remove()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#setContainer(org.jboss.ejb3.Container)
+ */
+ public void setContainer(Container container)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.BeanContext#setInstance(java.lang.Object)
+ */
+ public void setInstance(Object instance)
+ {
+ assert instance != null;
+ this.instance = instance;
+ }
+
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockBeanContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java 2007-08-20 12:51:31 UTC (rev 64706)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -1,259 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, 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.threadlocal;
-
-import java.util.Hashtable;
-
-import javax.ejb.TimerService;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.DependencyPolicy;
-import org.jboss.ejb3.Pool;
-import org.jboss.ejb3.statistics.InvocationStatistics;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class MockContainer implements Container
-{
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#construct()
- */
- public Object construct()
- {
- return new MockBean();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#create()
- */
- public void create() throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#destroy()
- */
- public void destroy() throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#getBeanClass()
- */
- public Class getBeanClass()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#getDependencyPolicy()
- */
- public DependencyPolicy getDependencyPolicy()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#getEjbName()
- */
- public String getEjbName()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#getEnc()
- */
- public Context getEnc()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#getInitialContext()
- */
- public InitialContext getInitialContext()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#getInitialContextProperties()
- */
- public Hashtable getInitialContextProperties()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#getInvokeStats()
- */
- public InvocationStatistics getInvokeStats()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#getObjectName()
- */
- public ObjectName getObjectName()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#getPool()
- */
- public Pool getPool()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#getTimerService()
- */
- public TimerService getTimerService()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#getTimerService(java.lang.Object)
- */
- public TimerService getTimerService(Object pKey)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#invokeInit(java.lang.Object)
- */
- public void invokeInit(Object bean)
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#invokeInit(java.lang.Object, java.lang.Class[], java.lang.Object[])
- */
- public void invokeInit(Object bean, Class[] initTypes, Object[] initValues)
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#invokePostActivate(org.jboss.ejb3.BeanContext)
- */
- public void invokePostActivate(BeanContext beanContext)
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#invokePostConstruct(org.jboss.ejb3.BeanContext)
- */
- public void invokePostConstruct(BeanContext beanContext)
- {
- ((MockBean) beanContext.getInstance()).postConstruct();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#invokePreDestroy(org.jboss.ejb3.BeanContext)
- */
- public void invokePreDestroy(BeanContext beanContext)
- {
- ((MockBean) beanContext.getInstance()).preDestroy();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#invokePrePassivate(org.jboss.ejb3.BeanContext)
- */
- public void invokePrePassivate(BeanContext beanContext)
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#isClustered()
- */
- public boolean isClustered()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#processMetadata(org.jboss.ejb3.DependencyPolicy)
- */
- public void processMetadata(DependencyPolicy dependencyPolicy)
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#start()
- */
- public void start() throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.Container#stop()
- */
- public void stop() throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
-}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java (from rev 64706, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -0,0 +1,286 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.threadlocal;
+
+import java.util.Hashtable;
+
+import javax.ejb.TimerService;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.Pool;
+import org.jboss.ejb3.statistics.InvocationStatistics;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MockContainer implements Container
+{
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#construct()
+ */
+ public Object construct()
+ {
+ return new MockBean();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#create()
+ */
+ public void create() throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public BeanContext<?> createBeanContext()
+ {
+ return new MockBeanContext(construct());
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#destroy()
+ */
+ public void destroy() throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getBeanClass()
+ */
+ public Class getBeanClass()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getDependencyPolicy()
+ */
+ public DependencyPolicy getDependencyPolicy()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getEjbName()
+ */
+ public String getEjbName()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getEnc()
+ */
+ public Context getEnc()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getInitialContext()
+ */
+ public InitialContext getInitialContext()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getInitialContextProperties()
+ */
+ public Hashtable getInitialContextProperties()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getInvokeStats()
+ */
+ public InvocationStatistics getInvokeStats()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getMBean()
+ {
+ throw new RuntimeException("mock");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getObjectName()
+ */
+ public ObjectName getObjectName()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getPool()
+ */
+ public Pool getPool()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public <T> T getSecurityManager(Class<T> type)
+ {
+ throw new RuntimeException("mock");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getTimerService()
+ */
+ public TimerService getTimerService()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#getTimerService(java.lang.Object)
+ */
+ public TimerService getTimerService(Object pKey)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#invokeInit(java.lang.Object)
+ */
+ public void invokeInit(Object bean)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#invokeInit(java.lang.Object, java.lang.Class[], java.lang.Object[])
+ */
+ public void invokeInit(Object bean, Class[] initTypes, Object[] initValues)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#invokePostActivate(org.jboss.ejb3.BeanContext)
+ */
+ public void invokePostActivate(BeanContext beanContext)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#invokePostConstruct(org.jboss.ejb3.BeanContext)
+ */
+ public void invokePostConstruct(BeanContext beanContext, Object[] params)
+ {
+ ((MockBean) beanContext.getInstance()).postConstruct();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#invokePreDestroy(org.jboss.ejb3.BeanContext)
+ */
+ public void invokePreDestroy(BeanContext beanContext)
+ {
+ ((MockBean) beanContext.getInstance()).preDestroy();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#invokePrePassivate(org.jboss.ejb3.BeanContext)
+ */
+ public void invokePrePassivate(BeanContext beanContext)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#isClustered()
+ */
+ public boolean isClustered()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public BeanContext<?> peekContext()
+ {
+ throw new RuntimeException("mock");
+ }
+
+ public BeanContext<?> popContext()
+ {
+ // do nothing
+ return null;
+ }
+
+ public void processMetadata()
+ {
+ throw new RuntimeException("mock");
+ }
+
+ public void pushContext(BeanContext<?> ctx)
+ {
+ // do nothing
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#start()
+ */
+ public void start() throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.Container#stop()
+ */
+ public void stop() throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit (from rev 64706, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit)
Deleted: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java 2007-08-20 12:51:31 UTC (rev 64706)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -1,245 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, 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.threadlocal.unit;
-
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.ThreadlocalPool;
-import org.jboss.ejb3.test.threadlocal.MockBean;
-import org.jboss.ejb3.test.threadlocal.MockBeanContext;
-import org.jboss.ejb3.test.threadlocal.MockContainer;
-
-import junit.framework.TestCase;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class ThreadLocalPoolUnitTestCase extends TestCase
-{
- int used = 0;
-
- private static void gc()
- {
- for(int i = 0; i < 3; i++)
- {
- System.gc();
- try
- {
- Thread.sleep(100);
- }
- catch (InterruptedException e)
- {
- // ignore
- }
- System.runFinalization();
- }
- }
-
- public void test1()
- {
- ThreadlocalPool pool = new ThreadlocalPool();
- Container container = new MockContainer();
- Class<? extends BeanContext> contextClass = MockBeanContext.class;
- Class<?> beanClass = null;
- int maxSize = -1;
- int timeout = -1;
- pool.initialize(container, contextClass, beanClass, maxSize, timeout);
- BeanContext ctx = pool.get();
- pool.release(ctx);
-
- ctx = null;
-
- gc();
- assertEquals(0, pool.getRemoveCount());
- assertEquals(0, MockBean.finalizers);
-
- pool.destroy();
-
- gc();
- assertEquals(1, pool.getRemoveCount());
- assertEquals(1, MockBean.finalizers);
- }
-
- public void testWithThreads() throws Exception
- {
- final ThreadlocalPool pool = new ThreadlocalPool();
- Container container = new MockContainer();
- Class<? extends BeanContext> contextClass = MockBeanContext.class;
- Class<?> beanClass = null;
- int maxSize = -1;
- int timeout = -1;
- pool.initialize(container, contextClass, beanClass, maxSize, timeout);
-
- Runnable r = new Runnable()
- {
- public void run()
- {
- BeanContext ctx = pool.get();
- pool.release(ctx);
-
- ctx = null;
- used++;
- }
- };
-
- Thread threads[] = new Thread[20];
- for(int i = 0; i < threads.length; i++)
- {
- threads[i] = new Thread(r);
- threads[i].start();
- }
-
- for(Thread t : threads)
- {
- t.join(1000);
- }
-
- gc();
- assertEquals(0, pool.getRemoveCount());
- assertEquals(0, MockBean.finalizers);
-
- pool.destroy();
-
- gc();
- assertEquals(20, pool.getRemoveCount());
- assertEquals(20, MockBean.finalizers);
-
- assertEquals(20, used);
- }
-
- public void testMultipleWithThreads() throws Exception
- {
- final ThreadlocalPool pool = new ThreadlocalPool();
- Container container = new MockContainer();
- Class<? extends BeanContext> contextClass = MockBeanContext.class;
- Class<?> beanClass = null;
- int maxSize = -1;
- int timeout = -1;
- pool.initialize(container, contextClass, beanClass, maxSize, timeout);
-
- Runnable r = new Runnable()
- {
- public void run()
- {
- for(int i = 0; i < 10; i++)
- {
- BeanContext ctx = pool.get();
- pool.release(ctx);
-
- ctx = null;
- used++;
- }
- }
- };
-
- Thread threads[] = new Thread[20];
- for(int i = 0; i < threads.length; i++)
- {
- threads[i] = new Thread(r);
- threads[i].start();
- }
-
- for(Thread t : threads)
- {
- t.join(1000);
- }
-
- gc();
- assertEquals(0, pool.getRemoveCount());
- assertEquals(0, MockBean.finalizers);
-
- pool.destroy();
-
- gc();
- assertEquals(20, pool.getRemoveCount());
- assertEquals(20, MockBean.finalizers);
-
- assertEquals(200, used);
- }
-
- public void testMultipleRecursiveWithThreads() throws Exception
- {
- final ThreadlocalPool pool = new ThreadlocalPool();
- Container container = new MockContainer();
- Class<? extends BeanContext> contextClass = MockBeanContext.class;
- Class<?> beanClass = null;
- int maxSize = -1;
- int timeout = -1;
- pool.initialize(container, contextClass, beanClass, maxSize, timeout);
-
- Runnable r = new Runnable()
- {
- public void run()
- {
- for(int i = 0; i < 10; i++)
- {
- BeanContext ctx = pool.get();
- BeanContext ctx2 = pool.get();
-
- pool.release(ctx2);
- ctx2 = null;
- used ++;
-
- pool.release(ctx);
- ctx = null;
- used ++;
- }
- }
- };
-
- Thread threads[] = new Thread[20];
- for(int i = 0; i < threads.length; i++)
- {
- threads[i] = new Thread(r);
- threads[i].start();
- }
-
- for(Thread t : threads)
- {
- t.join(1000);
- }
-
- gc();
- assertEquals(200, pool.getRemoveCount());
- assertEquals(200, MockBean.finalizers);
-
- pool.destroy();
-
- gc();
- assertEquals(220, pool.getRemoveCount());
- assertEquals(220, MockBean.finalizers);
-
- assertEquals(400, used);
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- MockBean.finalizers = 0;
- used = 0;
- }
-}
Copied: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java (from rev 64706, branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java)
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java 2007-08-21 14:05:07 UTC (rev 64732)
@@ -0,0 +1,237 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.threadlocal.unit;
+
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.ThreadlocalPool;
+import org.jboss.ejb3.test.threadlocal.MockBean;
+import org.jboss.ejb3.test.threadlocal.MockBeanContext;
+import org.jboss.ejb3.test.threadlocal.MockContainer;
+
+import junit.framework.TestCase;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ThreadLocalPoolUnitTestCase extends TestCase
+{
+ int used = 0;
+
+ private static void gc()
+ {
+ for(int i = 0; i < 3; i++)
+ {
+ System.gc();
+ try
+ {
+ Thread.sleep(100);
+ }
+ catch (InterruptedException e)
+ {
+ // ignore
+ }
+ System.runFinalization();
+ }
+ }
+
+ public void test1()
+ {
+ ThreadlocalPool pool = new ThreadlocalPool();
+ Container container = new MockContainer();
+ int maxSize = -1;
+ int timeout = -1;
+ pool.initialize(container, maxSize, timeout);
+ BeanContext ctx = pool.get();
+ pool.release(ctx);
+
+ ctx = null;
+
+ gc();
+ assertEquals(0, pool.getRemoveCount());
+ assertEquals(0, MockBean.finalizers);
+
+ pool.destroy();
+
+ gc();
+ assertEquals(1, pool.getRemoveCount());
+ assertEquals(1, MockBean.finalizers);
+ }
+
+ public void testWithThreads() throws Exception
+ {
+ final ThreadlocalPool pool = new ThreadlocalPool();
+ Container container = new MockContainer();
+ int maxSize = -1;
+ int timeout = -1;
+ pool.initialize(container, maxSize, timeout);
+
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ BeanContext ctx = pool.get();
+ pool.release(ctx);
+
+ ctx = null;
+ used++;
+ }
+ };
+
+ Thread threads[] = new Thread[20];
+ for(int i = 0; i < threads.length; i++)
+ {
+ threads[i] = new Thread(r);
+ threads[i].start();
+ }
+
+ for(Thread t : threads)
+ {
+ t.join(1000);
+ }
+
+ gc();
+ assertEquals(0, pool.getRemoveCount());
+ assertEquals(0, MockBean.finalizers);
+
+ pool.destroy();
+
+ gc();
+ assertEquals(20, pool.getRemoveCount());
+ assertEquals(20, MockBean.finalizers);
+
+ assertEquals(20, used);
+ }
+
+ public void testMultipleWithThreads() throws Exception
+ {
+ final ThreadlocalPool pool = new ThreadlocalPool();
+ Container container = new MockContainer();
+ int maxSize = -1;
+ int timeout = -1;
+ pool.initialize(container, maxSize, timeout);
+
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ for(int i = 0; i < 10; i++)
+ {
+ BeanContext ctx = pool.get();
+ pool.release(ctx);
+
+ ctx = null;
+ used++;
+ }
+ }
+ };
+
+ Thread threads[] = new Thread[20];
+ for(int i = 0; i < threads.length; i++)
+ {
+ threads[i] = new Thread(r);
+ threads[i].start();
+ }
+
+ for(Thread t : threads)
+ {
+ t.join(1000);
+ }
+
+ gc();
+ assertEquals(0, pool.getRemoveCount());
+ assertEquals(0, MockBean.finalizers);
+
+ pool.destroy();
+
+ gc();
+ assertEquals(20, pool.getRemoveCount());
+ assertEquals(20, MockBean.finalizers);
+
+ assertEquals(200, used);
+ }
+
+ public void testMultipleRecursiveWithThreads() throws Exception
+ {
+ final ThreadlocalPool pool = new ThreadlocalPool();
+ Container container = new MockContainer();
+ int maxSize = -1;
+ int timeout = -1;
+ pool.initialize(container, maxSize, timeout);
+
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ for(int i = 0; i < 10; i++)
+ {
+ BeanContext ctx = pool.get();
+ BeanContext ctx2 = pool.get();
+
+ pool.release(ctx2);
+ ctx2 = null;
+ used ++;
+
+ pool.release(ctx);
+ ctx = null;
+ used ++;
+ }
+ }
+ };
+
+ Thread threads[] = new Thread[20];
+ for(int i = 0; i < threads.length; i++)
+ {
+ threads[i] = new Thread(r);
+ threads[i].start();
+ }
+
+ for(Thread t : threads)
+ {
+ t.join(1000);
+ }
+
+ gc();
+ assertEquals(200, pool.getRemoveCount());
+ assertEquals(200, MockBean.finalizers);
+
+ pool.destroy();
+
+ gc();
+ assertEquals(220, pool.getRemoveCount());
+ assertEquals(220, MockBean.finalizers);
+
+ assertEquals(400, used);
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ MockBean.finalizers = 0;
+ used = 0;
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list