[jboss-cvs] JBossAS SVN: r91178 - in projects/jboss-jca/trunk: common/src/main/java/org/jboss/jca/common/util and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jul 13 16:27:08 EDT 2009
Author: jesper.pedersen
Date: 2009-07-13 16:27:07 -0400 (Mon, 13 Jul 2009)
New Revision: 91178
Added:
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ClassUtil.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/package.html
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/api/
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/api/WorkContextProviderGetWorkContextsTestCase.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/api/package.html
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateHintContextWork.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateSecurityContextWork.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateTransactionContextWork.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/HintContextCustom.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/SecurityContextCustomFirst.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/SecurityContextCustomSecond.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/TransactionContextCustom.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/TransactionContextWork.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/UnsupportedWork.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/package.html
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/package.html
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section4/
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section4/subsection3/
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section4/subsection3/WorkContextHandlingAssignmentTestCase.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section4/subsection3/package.html
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section5/
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section5/TransactionContextTestCase.java
projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section5/package.html
Modified:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/WorkWrapper.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java
Log:
[JBJCA-112] Adding Partial Implementation for Specification Chapter11. Patch by Gurkan Erdogdu
Added: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ClassUtil.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ClassUtil.java (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ClassUtil.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.common.util;
+
+/**
+ * Utility for class related operations.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class ClassUtil
+{
+ // Not-instantiate me
+ private ClassUtil()
+ {
+ // Empty
+ }
+
+ /**
+ * Returns true if <b>from</b> is assignable to <b>to</b>, false otherwise.
+ *
+ * @param from assignable class
+ * @param to assigned class
+ * @return true if <b>from</b> is assignable to <b>to</b>, false ow.
+ */
+ public static boolean isClassAssignable(Class<?> from, Class<?> to)
+ {
+ if (from == null)
+ {
+ throw new IllegalArgumentException("from is null");
+ }
+
+ if (to == null)
+ {
+ throw new IllegalArgumentException("to is null");
+ }
+
+ return to.isAssignableFrom(from);
+ }
+
+}
Added: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/package.html
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/package.html (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/package.html 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,3 @@
+<body>
+This package contains the several utility classes.
+</body>
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/WorkWrapper.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/WorkWrapper.java 2009-07-13 20:08:30 UTC (rev 91177)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/WorkWrapper.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -22,9 +22,13 @@
package org.jboss.jca.core.api;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.resource.spi.work.ExecutionContext;
import javax.resource.spi.work.Work;
import javax.resource.spi.work.WorkCompletedException;
+import javax.resource.spi.work.WorkContext;
import javax.resource.spi.work.WorkEvent;
import javax.resource.spi.work.WorkException;
import javax.resource.spi.work.WorkListener;
@@ -55,6 +59,10 @@
/** The execution context */
private ExecutionContext executionContext;
+
+ /**If work is an instance of WorkContextProvider, it may containt WorkContext instance*/
+ private Map<Class<? extends WorkContext>, WorkContext> workContexts =
+ new HashMap<Class<? extends WorkContext>, WorkContext>();
/** the work listener */
private WorkListener workListener;
@@ -110,7 +118,28 @@
setTask(this);
}
+
+ /**
+ * Adds new work context.
+ *
+ * @param workContext new work context
+ * @param workContextClass work context class
+ */
+ public void addWorkContext(Class<? extends WorkContext> workContextClass, WorkContext workContext)
+ {
+ if (workContextClass == null)
+ {
+ throw new IllegalArgumentException("Work context class is null");
+ }
+ if (workContext == null)
+ {
+ throw new IllegalArgumentException("Work context is null");
+ }
+
+ this.workContexts.put(workContextClass, workContext);
+ }
+
/**
* Get the work manager
*
@@ -150,7 +179,26 @@
{
return executionContext;
}
+
+ /**
+ * Returns work context instance.
+ *
+ * @param <T> class type info
+ * @param workContextClass work context type
+ * @return work context instance
+ */
+ public <T> T getWorkContext(Class<T> workContextClass)
+ {
+ T instance = null;
+ if (this.workContexts.containsKey(workContextClass))
+ {
+ instance = workContextClass.cast(this.workContexts.get(workContextClass));
+ }
+
+ return instance;
+ }
+
/**
* Retrieve the time blocked
*
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java 2009-07-13 20:08:30 UTC (rev 91177)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -27,11 +27,22 @@
import org.jboss.jca.core.api.WorkWrapper;
import java.lang.reflect.Modifier;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.HintsContext;
+import javax.resource.spi.work.SecurityContext;
+import javax.resource.spi.work.TransactionContext;
import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkCompletedException;
+import javax.resource.spi.work.WorkContext;
+import javax.resource.spi.work.WorkContextErrorCodes;
+import javax.resource.spi.work.WorkContextProvider;
import javax.resource.spi.work.WorkException;
import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkRejectedException;
import javax.transaction.xa.Xid;
import org.jboss.logging.Logger;
@@ -45,6 +56,10 @@
{
/** The logger */
private static Logger log = Logger.getLogger(WorkManagerImpl.class);
+
+ /**Supported work context set*/
+ private static final Set<Class<? extends WorkContext>> SUPPORTED_WORK_CONTEXT_CLASSES =
+ new HashSet<Class<? extends WorkContext>>();
/** Whether trace is enabled */
private boolean trace = log.isTraceEnabled();
@@ -58,6 +73,14 @@
/** The XA terminator */
private JBossXATerminator xaTerminator;
+ /**Default supported workcontext types*/
+ static
+ {
+ SUPPORTED_WORK_CONTEXT_CLASSES.add(TransactionContext.class);
+ SUPPORTED_WORK_CONTEXT_CLASSES.add(SecurityContext.class);
+ SUPPORTED_WORK_CONTEXT_CLASSES.add(HintsContext.class);
+ }
+
/**
* Default constructor
*/
@@ -142,13 +165,32 @@
if (specCompliant)
verifyWork(work);
-
+
+ boolean isWorkContextProvider = false;
+ if (work instanceof WorkContextProvider)
+ {
+ //Implements WorkContextProvider and not-null ExecutionContext
+ if (execContext != null)
+ {
+ throw new WorkRejectedException("Work execution context must be null because " +
+ "work instance implements WorkContextProvider!");
+ }
+
+ isWorkContextProvider = true;
+ }
+
if (execContext == null)
execContext = new ExecutionContext();
WorkWrapper wrapper =
new WorkWrapper(this, work, Task.WAIT_FOR_COMPLETE, startTimeout, execContext, workListener);
+ //Check workcontexts
+ if (isWorkContextProvider)
+ {
+ setupWorkContextProviders(wrapper);
+ }
+
importWork(wrapper);
executeWork(wrapper);
@@ -179,11 +221,29 @@
if (specCompliant)
verifyWork(work);
+ boolean isWorkContextProvider = false;
+ if (work instanceof WorkContextProvider)
+ {
+ //Implements WorkContextProvider and not-null ExecutionContext
+ if (execContext != null)
+ {
+ throw new WorkRejectedException("Work execution context must be null because " +
+ "work instance implements WorkContextProvider!");
+ }
+
+ isWorkContextProvider = true;
+ }
+
if (execContext == null)
execContext = new ExecutionContext();
WorkWrapper wrapper = new WorkWrapper(this, work, Task.WAIT_FOR_START, startTimeout, execContext, workListener);
-
+
+ if (isWorkContextProvider)
+ {
+ setupWorkContextProviders(wrapper);
+ }
+
importWork(wrapper);
executeWork(wrapper);
@@ -216,11 +276,30 @@
if (specCompliant)
verifyWork(work);
+
+ boolean isWorkContextProvider = false;
+ if (work instanceof WorkContextProvider)
+ {
+ //Implements WorkContextProvider and not-null ExecutionContext
+ if (execContext != null)
+ {
+ throw new WorkRejectedException("Work execution context must be null " +
+ "because work instance implements WorkContextProvider!");
+ }
+
+ isWorkContextProvider = true;
+ }
+
if (execContext == null)
execContext = new ExecutionContext();
WorkWrapper wrapper = new WorkWrapper(this, work, Task.WAIT_NONE, startTimeout, execContext, workListener);
-
+
+ if (isWorkContextProvider)
+ {
+ setupWorkContextProviders(wrapper);
+ }
+
importWork(wrapper);
executeWork(wrapper);
@@ -359,7 +438,7 @@
*/
private void verifyWork(Work work) throws WorkException
{
- Class[] types = new Class[] {};
+ Class<?>[] types = new Class[] {};
try
{
@@ -380,5 +459,200 @@
{
throw new WorkException(work.getClass().getName() + ": Release method is not defined");
}
+
}
+
+ /**
+ * Setup work context's of the given work instance.
+ *
+ * @param work work instance
+ * @param executionContext execution context instance
+ * @throws WorkException if any exception occurs
+ */
+ private void setupWorkContextProviders(WorkWrapper wrapper) throws WorkException
+ {
+ if (trace)
+ {
+ log.trace("Starting checking work context providers");
+ }
+
+ Work work = wrapper.getWork();
+
+ WorkContextProvider wcProvider = (WorkContextProvider) work;
+ List<WorkContext> contexts = wcProvider.getWorkContexts();
+
+ if (contexts != null && contexts.size() > 0)
+ {
+ boolean isTransactionContext = false;
+ boolean isSecurityContext = false;
+ boolean isHintcontext = false;
+
+ for (WorkContext context : contexts)
+ {
+ Class<? extends WorkContext> contextType = null;
+
+ // Get supported work context class
+ contextType = getSupportedWorkContextClass(context.getClass());
+
+ // Not supported
+ if (contextType == null)
+ {
+ if (trace)
+ {
+ log.trace("Not supported work context class : " + context.getClass());
+ }
+ throw new WorkCompletedException("Unsupported WorkContext class : " + context.getClass(),
+ WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE);
+ }
+ // Duplicate checks
+ else
+ {
+ // TransactionContext duplicate
+ if (isTransactionContext(contextType))
+ {
+ if (isTransactionContext)
+ {
+ if (trace)
+ {
+ log.trace("Duplicate transaction work context : " + context.getClass());
+ }
+
+ throw new WorkCompletedException("Duplicate TransactionWorkContext class : " +
+ context.getClass(), WorkContextErrorCodes.DUPLICATE_CONTEXTS);
+ }
+ else
+ {
+ isTransactionContext = true;
+ }
+ }
+ // SecurityContext duplicate
+ else if (isSecurityContext(contextType))
+ {
+ if (isSecurityContext)
+ {
+ if (trace)
+ {
+ log.trace("Duplicate security work context : " + context.getClass());
+ }
+
+ throw new WorkCompletedException("Duplicate SecurityWorkContext class : " + context.getClass(),
+ WorkContextErrorCodes.DUPLICATE_CONTEXTS);
+ }
+ else
+ {
+ isSecurityContext = true;
+ }
+ }
+ // HintContext duplicate
+ else if (isHintContext(contextType))
+ {
+ if (isHintcontext)
+ {
+ if (trace)
+ {
+ log.trace("Duplicate hint work context : " + context.getClass());
+ }
+
+ throw new WorkCompletedException("Duplicate HintWorkContext class : " + context.getClass(),
+ WorkContextErrorCodes.DUPLICATE_CONTEXTS);
+ }
+ else
+ {
+ isHintcontext = true;
+ }
+ }
+ // Normally, this must not be happened!i just safe check!
+ else
+ {
+ throw new WorkCompletedException("Unsupported WorkContext class : " + context.getClass(),
+ WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE);
+ }
+ }
+
+ // Add workcontext instance to the work
+ wrapper.addWorkContext(contextType, context);
+ }
+ }
+ }
+
+ /**
+ * Returns work context class if given work context is supported by server,
+ * returns null instance otherwise.
+ *
+ * @param <T> work context class
+ * @param adaptorWorkContext adaptor supplied work context class
+ * @return work context class
+ */
+ @SuppressWarnings("unchecked")
+ private <T extends WorkContext> Class<T> getSupportedWorkContextClass(Class<T> adaptorWorkContext)
+ {
+ for (Class<? extends WorkContext> supportedWorkContext : SUPPORTED_WORK_CONTEXT_CLASSES)
+ {
+ // Assignable or not
+ if (supportedWorkContext.isAssignableFrom(adaptorWorkContext))
+ {
+ // Supported by the server
+ if (adaptorWorkContext.equals(supportedWorkContext))
+ {
+ return adaptorWorkContext;
+ }
+ else
+ {
+ // Fallback to super class
+ return (Class<T>) adaptorWorkContext.getSuperclass();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns true if contexts is a transaction context.
+ *
+ * @param workContextType context type
+ * @return true if contexts is a transaction context
+ */
+ private boolean isTransactionContext(Class<? extends WorkContext> workContextType)
+ {
+ if (workContextType.isAssignableFrom(TransactionContext.class))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns true if contexts is a security context.
+ *
+ * @param workContextType context type
+ * @return true if contexts is a security context
+ */
+ private boolean isSecurityContext(Class<? extends WorkContext> workContextType)
+ {
+ if (workContextType.isAssignableFrom(SecurityContext.class))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns true if contexts is a hint context.
+ *
+ * @param workContextType context type
+ * @return true if contexts is a hint context
+ */
+ private boolean isHintContext(Class<? extends WorkContext> workContextType)
+ {
+ if (workContextType.isAssignableFrom(HintsContext.class))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/api/WorkContextProviderGetWorkContextsTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/api/WorkContextProviderGetWorkContextsTestCase.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/api/WorkContextProviderGetWorkContextsTestCase.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.api;
+
+import org.jboss.jca.test.core.spec.chapter11.section4.subsection3.WorkContextHandlingAssignmentTestCase;
+
+import javax.resource.spi.work.WorkContextProvider;
+
+import org.jboss.ejb3.test.mc.bootstrap.EmbeddedTestMcBootstrap;
+
+import junit.framework.Assert;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+
+/**
+ * WorkContextProviderGetWorkContextsTestCase.
+ * @version $Rev$ $Date$
+ *
+ */
+public class WorkContextProviderGetWorkContextsTestCase
+{
+ private static EmbeddedTestMcBootstrap bootstrap = null;
+
+ /**
+ * Test api for {@link WorkContextProvider#getWorkContexts()}
+ */
+ @Test
+ public void testGetWorkContextsNumber()
+ {
+ org.jboss.jca.test.core.spec.chapter11.common.TransactionContextWork work =
+ new org.jboss.jca.test.core.spec.chapter11.common.TransactionContextWork();
+ Assert.assertNotNull(work.getWorkContexts());
+
+ Assert.assertEquals(1, work.getWorkContexts().size());
+ }
+
+ /**
+ * Before class.
+ */
+ @BeforeClass
+ public static void beforeClass()
+ {
+ bootstrap = EmbeddedTestMcBootstrap.createEmbeddedMcBootstrap();
+
+ // Deploy Naming, Transaction and WorkManager
+ bootstrap.deploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "naming-jboss-beans.xml");
+ bootstrap.deploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "transaction-jboss-beans.xml");
+ bootstrap.deploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "workmanager-jboss-beans.xml");
+
+ }
+
+ /**
+ * After class.
+ */
+ @AfterClass
+ public static void afterClass()
+ {
+ bootstrap.undeploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "workmanager-jboss-beans.xml");
+ bootstrap.shutdown();
+
+ bootstrap = null;
+ }
+
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/api/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/api/package.html (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/api/package.html 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,3 @@
+<body>
+JCA API common interfaces and classes for the JCA Chapter 11 test cases.
+</body>
\ No newline at end of file
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateHintContextWork.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateHintContextWork.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateHintContextWork.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.resource.spi.work.HintsContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkContext;
+import javax.resource.spi.work.WorkContextProvider;
+
+/**
+ * Duplicate hint context test.
+ * @version $Rev$ $Date$
+ */
+public class DuplicateHintContextWork implements Work, WorkContextProvider
+{
+ private static final long serialVersionUID = -7379301655105077202L;
+
+ public void release()
+ {
+ }
+
+ public void run()
+ {
+ }
+
+ public List<WorkContext> getWorkContexts()
+ {
+ List<WorkContext> ctxs = new ArrayList<WorkContext>();
+ ctxs.add(new HintContextCustom());
+ ctxs.add(new HintsContext());
+
+ return ctxs;
+ }
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateSecurityContextWork.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateSecurityContextWork.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateSecurityContextWork.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkContext;
+import javax.resource.spi.work.WorkContextProvider;
+
+/**
+ * DuplicateSecurityContextWork.
+ * @version $Rev$ $Date$
+ *
+ */
+public class DuplicateSecurityContextWork implements Work, WorkContextProvider
+{
+ private static final long serialVersionUID = -4200424222059459329L;
+
+ public void release()
+ {
+ }
+
+ public void run()
+ {
+ }
+
+ public List<WorkContext> getWorkContexts()
+ {
+ List<WorkContext> ctxs = new ArrayList<WorkContext>();
+ ctxs.add(new SecurityContextCustomFirst());
+ ctxs.add(new SecurityContextCustomSecond());
+
+ return ctxs;
+ }
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateTransactionContextWork.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateTransactionContextWork.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/DuplicateTransactionContextWork.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.resource.spi.work.TransactionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkContext;
+import javax.resource.spi.work.WorkContextProvider;
+
+/**
+ * DuplicateTransactionContextWork.
+ * @version $Rev$ $Date$
+ *
+ */
+public class DuplicateTransactionContextWork implements Work, WorkContextProvider
+{
+ private static final long serialVersionUID = -2434540676749291894L;
+
+ public void release()
+ {
+ }
+
+ public void run()
+ {
+ }
+
+ public List<WorkContext> getWorkContexts()
+ {
+ List<WorkContext> ctxs = new ArrayList<WorkContext>();
+ ctxs.add(new TransactionContext());
+ ctxs.add(new TransactionContextCustom());
+
+ return ctxs;
+ }
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/HintContextCustom.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/HintContextCustom.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/HintContextCustom.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.common;
+
+import javax.resource.spi.work.HintsContext;
+
+/**
+ * HintContextCustom.
+ * @version $Rev$ $Date$
+ *
+ */
+public class HintContextCustom extends HintsContext
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1278012837500293279L;
+
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/SecurityContextCustomFirst.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/SecurityContextCustomFirst.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/SecurityContextCustomFirst.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.common;
+
+import javax.resource.spi.work.SecurityContext;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+
+/**
+ * SecurityContextCustomFirst.
+ * @version $Rev$ $Date$
+ *
+ */
+public class SecurityContextCustomFirst extends SecurityContext
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 9210146619488074381L;
+
+ @Override
+ public void setupSecurityContext(CallbackHandler handler, Subject executionSubject, Subject serviceSubject)
+ {
+
+ }
+
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/SecurityContextCustomSecond.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/SecurityContextCustomSecond.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/SecurityContextCustomSecond.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.common;
+
+import javax.resource.spi.work.SecurityContext;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+
+/**
+ * SecurityContextCustomSecond.
+ * @version $Rev$ $Date$
+ *
+ */
+public class SecurityContextCustomSecond extends SecurityContext
+{
+
+ private static final long serialVersionUID = -8116907768298086829L;
+
+ @Override
+ public void setupSecurityContext(CallbackHandler handler, Subject executionSubject, Subject serviceSubject)
+ {
+
+ }
+
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/TransactionContextCustom.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/TransactionContextCustom.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/TransactionContextCustom.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.common;
+
+import javax.resource.spi.work.TransactionContext;
+
+/**
+ * TransactionContextCustom.
+ * @version $Rev$ $Date$
+ *
+ */
+public class TransactionContextCustom extends TransactionContext
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3841107265829832325L;
+
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/TransactionContextWork.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/TransactionContextWork.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/TransactionContextWork.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkContext;
+import javax.resource.spi.work.WorkContextProvider;
+
+/**
+ * TransactionContextWork.
+ * @version $Rev$ $Date$
+ *
+ */
+public class TransactionContextWork implements Work, WorkContextProvider
+{
+ /** Serial version uid */
+ private static final long serialVersionUID = 2855367727578670465L;
+
+ public void release()
+ {
+ }
+
+ public void run()
+ {
+ }
+
+ public List<WorkContext> getWorkContexts()
+ {
+ List<WorkContext> ctxts = new ArrayList<WorkContext>();
+ ctxts.add(new TransactionContextCustom());
+
+ return ctxts;
+ }
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/UnsupportedWork.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/UnsupportedWork.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/UnsupportedWork.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkContext;
+import javax.resource.spi.work.WorkContextProvider;
+
+/**
+ * UnsupportedWork.
+ * @version $Rev$ $Date$
+ *
+ */
+public class UnsupportedWork implements WorkContextProvider, Work
+{
+ private static final long serialVersionUID = 374498650817259220L;
+
+ /**
+ * UnsupportedWorkContext.
+ */
+ public static class UnsupportedWorkContext implements WorkContext
+ {
+ private static final long serialVersionUID = -8190869774358035401L;
+
+ public String getDescription()
+ {
+ return "Unsupported Description";
+ }
+
+ public String getName()
+ {
+ return "Unsupported Name";
+ }
+ }
+
+ public List<WorkContext> getWorkContexts()
+ {
+ List<WorkContext> ctxs = new ArrayList<WorkContext>();
+ ctxs.add(new UnsupportedWorkContext());
+
+ return ctxs;
+ }
+
+ public void release()
+ {
+ }
+
+ public void run()
+ {
+ }
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/package.html (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/common/package.html 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,3 @@
+<body>
+Common interfaces and classes for the JCA Chapter 11 test cases.
+</body>
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/package.html (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/package.html 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,4 @@
+<body>
+This package contains interfaces and classes common to all test cases for the
+chapter 11 of the JCA specification.
+</body>
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section4/subsection3/WorkContextHandlingAssignmentTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section4/subsection3/WorkContextHandlingAssignmentTestCase.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section4/subsection3/WorkContextHandlingAssignmentTestCase.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.section4.subsection3;
+
+import org.jboss.jca.test.core.spec.chapter11.common.DuplicateHintContextWork;
+import org.jboss.jca.test.core.spec.chapter11.common.DuplicateSecurityContextWork;
+import org.jboss.jca.test.core.spec.chapter11.common.DuplicateTransactionContextWork;
+import org.jboss.jca.test.core.spec.chapter11.common.UnsupportedWork;
+
+import javax.resource.spi.work.WorkCompletedException;
+import javax.resource.spi.work.WorkManager;
+
+import org.jboss.ejb3.test.mc.bootstrap.EmbeddedTestMcBootstrap;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * WorkContextHandlingAssignmentTestCase.
+ * @version $Rev$ $Date$
+ *
+ */
+public class WorkContextHandlingAssignmentTestCase
+{
+ private static EmbeddedTestMcBootstrap bootstrap = null;
+
+ /**
+ * Test unsupported context.
+ * @throws Throwable if duplicate exist
+ */
+ @Test(expected = WorkCompletedException.class)
+ public void testUnsupportedType() throws Throwable
+ {
+ WorkManager manager = bootstrap.lookup("WorkManager", WorkManager.class);
+ manager.doWork(new UnsupportedWork());
+ }
+
+ /**
+ * Test duplicate transaction context.
+ * @throws Throwable if duplicate exist
+ */
+ @Test(expected = WorkCompletedException.class)
+ public void testTransactionContextDuplicate() throws Throwable
+ {
+ WorkManager manager = bootstrap.lookup("WorkManager", WorkManager.class);
+ manager.doWork(new DuplicateTransactionContextWork());
+ }
+
+ /**
+ * Test duplicate security context.
+ * @throws Throwable if duplicate exist
+ */
+ @Test(expected = WorkCompletedException.class)
+ public void testSecurityContextDuplicate() throws Throwable
+ {
+ WorkManager manager = bootstrap.lookup("WorkManager", WorkManager.class);
+ manager.doWork(new DuplicateSecurityContextWork());
+ }
+
+ /**
+ * Test duplicate hint context.
+ * @throws Throwable if duplicate exist
+ */
+ @Test(expected = WorkCompletedException.class)
+ public void testHintContextDuplicate() throws Throwable
+ {
+ WorkManager manager = bootstrap.lookup("WorkManager", WorkManager.class);
+ manager.doWork(new DuplicateHintContextWork());
+ }
+
+ /**
+ * Before class.
+ */
+ @BeforeClass
+ public static void beforeClass()
+ {
+ bootstrap = EmbeddedTestMcBootstrap.createEmbeddedMcBootstrap();
+
+ // Deploy Naming, Transaction and WorkManager
+ bootstrap.deploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "naming-jboss-beans.xml");
+ bootstrap.deploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "transaction-jboss-beans.xml");
+ bootstrap.deploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "workmanager-jboss-beans.xml");
+
+ }
+
+ /**
+ * After class.
+ */
+ @AfterClass
+ public static void afterClass()
+ {
+ bootstrap.undeploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "workmanager-jboss-beans.xml");
+ bootstrap.undeploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "transaction-jboss-beans.xml");
+ bootstrap.undeploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "naming-jboss-beans.xml");
+ bootstrap.shutdown();
+
+ bootstrap = null;
+ }
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section4/subsection3/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section4/subsection3/package.html (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section4/subsection3/package.html 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,3 @@
+<body>
+Test cases covering Chapter 11 Section 4 of the JCA specification.
+</body>
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section5/TransactionContextTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section5/TransactionContextTestCase.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section5/TransactionContextTestCase.java 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.jca.test.core.spec.chapter11.section5;
+
+import org.jboss.jca.test.core.spec.chapter11.common.TransactionContextWork;
+import org.jboss.jca.test.core.spec.chapter11.section4.subsection3.WorkContextHandlingAssignmentTestCase;
+
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.WorkContextProvider;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.WorkRejectedException;
+
+import org.jboss.ejb3.test.mc.bootstrap.EmbeddedTestMcBootstrap;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * TransactionContextTestCase.
+ * @version $Rev$ $Date$
+ *
+ */
+public class TransactionContextTestCase
+{
+ private static EmbeddedTestMcBootstrap bootstrap = null;
+
+ /**
+ * Test whether or not work contains both execution context and implement {@link WorkContextProvider}.
+ * @throws Throwable if work contains both execution context and implement {@link WorkContextProvider}
+ */
+ @Test(expected = WorkRejectedException.class)
+ public void testNotBothExecutionContext() throws Throwable
+ {
+ WorkManager manager = bootstrap.lookup("WorkManager", WorkManager.class);
+ manager.doWork(new TransactionContextWork(), WorkManager.INDEFINITE, new ExecutionContext(), null);
+
+ }
+
+ /**
+ * Before class.
+ */
+ @BeforeClass
+ public static void beforeClass()
+ {
+ bootstrap = EmbeddedTestMcBootstrap.createEmbeddedMcBootstrap();
+
+ // Deploy Naming, Transaction and WorkManager
+ bootstrap.deploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "naming-jboss-beans.xml");
+ bootstrap.deploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "transaction-jboss-beans.xml");
+ bootstrap.deploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "workmanager-jboss-beans.xml");
+
+ }
+
+ /**
+ * After class.
+ */
+ @AfterClass
+ public static void afterClass()
+ {
+ bootstrap.undeploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "workmanager-jboss-beans.xml");
+ bootstrap.undeploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "transaction-jboss-beans.xml");
+ bootstrap.undeploy(WorkContextHandlingAssignmentTestCase.class.getClassLoader(), "naming-jboss-beans.xml");
+ bootstrap.shutdown();
+
+ bootstrap = null;
+ }
+
+}
Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section5/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section5/package.html (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/core/spec/chapter11/section5/package.html 2009-07-13 20:27:07 UTC (rev 91178)
@@ -0,0 +1,3 @@
+<body>
+Test cases covering Chapter 11 Section 5 of the JCA specification.
+</body>
More information about the jboss-cvs-commits
mailing list