[jboss-svn-commits] JBL Code SVN: r27968 - in labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src: main/java/uk/ac/ncl/sdia/a8905943/ejb3 and 9 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jul 13 14:56:58 EDT 2009
Author: whitingjr
Date: 2009-07-13 14:56:57 -0400 (Mon, 13 Jul 2009)
New Revision: 27968
Added:
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/ejb3/
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/ejb3/persistence/
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/ejb3/persistence/STMPersistenceContext.java
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/spec/PersistenceContextHandle.java
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/STM.java
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/entitymanager/
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/entitymanager/JUnitTestSTMEntityManagerFactoryImpl.java
Removed:
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/impl/MVCCStore.java
Modified:
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerFactoryImpl.java
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/persistence/STMPersistenceProviderImpl.java
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/impl/JUTestMVCCStore.java
Log:
Added test case.
Added implementation to classes.
Added: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/ejb3/persistence/STMPersistenceContext.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/ejb3/persistence/STMPersistenceContext.java (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/ejb3/persistence/STMPersistenceContext.java 2009-07-13 18:56:57 UTC (rev 27968)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package uk.ac.ncl.sdia.a8905943.ejb3.persistence;
+
+import uk.ac.ncl.sdia.a8905943.spec.PersistenceContextHandle;
+import uk.ac.ncl.sdia.a8905943.stm.STM;
+
+/**
+ * This object needs to hang around in the VM and not be a candidate for garbage collection.
+ * To achieve this the persistence context (memory only) is attatched to the JNDI tree.
+ *
+ * @author <a href="whitingjr at hotmail.com">Jeremy Whiting</a>
+ * @version $Revision: 1.1 $
+ */
+public class STMPersistenceContext implements PersistenceContextHandle
+{
+ public static final String BYPASS_JNDI_BINDING = "BYPASS_JNDI_BINDING";
+ private static final STM stm = new STM();
+
+ public STM getSTM()
+ {
+ return stm;
+ }
+}
Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerFactoryImpl.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerFactoryImpl.java 2009-07-13 18:45:45 UTC (rev 27967)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerFactoryImpl.java 2009-07-13 18:56:57 UTC (rev 27968)
@@ -8,35 +8,86 @@
import java.util.Map;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.spi.PersistenceUnitTransactionType;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
+import org.jboss.cache.lock.IsolationLevel;
+import uk.ac.ncl.sdia.a8905943.ejb3.persistence.STMPersistenceContext;
import uk.ac.ncl.sdia.a8905943.spec.entitymanager.STMEntityManagerFactory;
+import uk.ac.ncl.sdia.a8905943.stm.persistence.STMPersistenceProviderImpl;
/**
* This object is responsible for choosing the transactional type, creating a persistence contxt, entity manager
* and providing the entity manager with the persistence context.
* This implemenation creates a new instance of EntityManager for each request.
+ * This factory will bind an object to the JNDI tree and remove it when asked to close.
*
+ * new STMEntityManagerFactoryImpl();
+ * initialise(...)
+ * create....(...)
+ *
* @author <a href="whitingjr at hotmail.com">Jeremy Whiting</a>
* @version $Revision: 1.1 $
*/
-public class STMEntityManagerFactoryImpl implements STMEntityManagerFactory
+public final class STMEntityManagerFactoryImpl implements STMEntityManagerFactory
{
- private Map properties ;
+ private volatile Map properties ;
private static final Logger logger = Logger.getLogger(STMEntityManagerFactoryImpl.class);
- private PersistenceUnitTransactionType transactionType ;
-
+ // this field is an enum field
+ private volatile PersistenceUnitTransactionType transactionType ;
+ // immutable field
+ private volatile static IsolationLevel isolationLevel ;
+ private volatile boolean isOpen = true;
+ private volatile STMPersistenceContext persistenceContext;
+ private volatile String persistenceContextName;
+
+ private static final String ERROR_MISSING_ISOLATION_LEVEL_PROPERTY = "Problem occured when creating an EntityManager. ISOLATION_LEVEL not configured.";
+ private static final String ERROR_NO_PROPERTIES_CONFIGURED ="Proplem occured when attempting to create an EntityManager, the persistence provider has no properties.";
+ private static final String ERROR_MISSING_PROPERTIES_OBJECT = "The properties given to EntityManagerFactory are null.";
+ private static final String ERROR_UNRECOGNISED_ISOLATION_LEVEL = "Unrecognised isolation level.";
+ private static final String ERROR_EMPTY_ISOLATION_LEVEL_VALUE = "Empty isolation value.";
+ private static final String ERROR_NULL_PERSISTENCE_CONTEXT = "Persistence Context object is null and will cause a problem.";
+ private static final String ERROR_NULL_PERSISTENCE_CONTEXT_NAME = "Persistence name is and will cause a problem.";
+ private static final String ERROR_FAILED_TO_BIND = "Failed to bind the persistence context to JNDI";
+ private static final String ERROR_FAILED_TO_UNBIND = "Failed to unbind the persistence context from JNDI";
+ private static final String WARN_PC_NOT_FOUND = "EntityManagerFactory attempted to unbind the Persistence Context and it could not be found.";
+ private static final String WARN_ALREADY_CLOSED = "EntityManagerFactory is already closed and is being closed again.";
+
@Override
/**
* Perform cleanup of factory.
*/
public void close()
{
- // FIXME close
-
+ // release the persistence context from the JNDI tree
+ try
+ {
+ InitialContext context = new InitialContext();
+ context.unbind(getBindingName(persistenceContextName));
+ }
+ catch (NameNotFoundException nnfe)
+ {
+ logger.warn(WARN_PC_NOT_FOUND);
+ }
+ catch (NamingException ne)
+ {
+ logger.error(ERROR_FAILED_TO_UNBIND);
+ }
+
+ if (!isOpen())
+ {// already closed, this is not expected to happen
+ logger.warn(WARN_ALREADY_CLOSED);
+ }
+ else
+ {
+ isOpen = false;
+ }
}
@Override
@@ -46,23 +97,66 @@
{
throw new UnsupportedOperationException("Please create an Entity Manager with properties map.");
}
-
return null;
}
@Override
/**
+ * This method checks for several things, if the properties have the required minimum
+ * number of properties for this entity manager, if the properties have been provided
+ * before then check the isolation level has not changed.
*
- * List of map entries checked for :
- * "ISOLATION_LEVEL"
+ * Map entries required: ISOLATION_LEVEL
*/
public EntityManager createEntityManager(Map map)
{
- // TODO: jrw complete method implementation, identify which properties will be used for creating an entity manager.
- // create transactional type, JTA
- // create persistence context
- // create entity manager
- // allocate persistence context to entity manager
+ if (null == properties)
+ {// properties are unitialised
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("Creating an EntityManager for thread ["+Thread.currentThread().getId()+"].");
+ }
+ if (null != map)
+ {// have been given something useful
+ if (notEmpty(map))
+ {// some properties have been configured, check for ISOLATION_LEVEL
+ if (containsRequiredConfiguration(map))
+ {// assumption the property values are string objects
+ this.isolationLevel = parseIsolationLevel((String)map.get(STMPersistenceProviderImpl.PROPERTY_ISOLATION_LEVEL));
+ properties = map;
+ if ( bindPersistenceContextToJNDI(map) )
+ {
+ try
+ {
+ InitialContext context = new InitialContext();
+ context.bind(this.persistenceContextName, this.persistenceContext);
+ }
+ catch (NamingException ne)
+ {
+ logger.error(ERROR_FAILED_TO_BIND, ne);
+ throw new RuntimeException(ERROR_FAILED_TO_BIND);
+ }
+ }
+ }
+ else
+ {// missing ISOLATION_LEVEL
+ throw new RuntimeException(ERROR_MISSING_ISOLATION_LEVEL_PROPERTY);
+ }
+ }
+ else
+ {// have been given an empty map of property configuration, this is a configuration mistake
+ throw new RuntimeException(ERROR_NO_PROPERTIES_CONFIGURED);
+ }
+ }
+ else
+ {
+ throw new RuntimeException(ERROR_MISSING_PROPERTIES_OBJECT);
+ }
+ }
+ else
+ {
+ // ignore this set of properties, the system uses the first configuration passed to the persistence provider
+ }
return null;
}
@@ -70,19 +164,104 @@
@Override
public boolean isOpen()
{
- // FIXME isOpen
- return false;
+ return this.isOpen;
}
- public void setMap(Map properties)
+
+ /**
+ * Create a new STMEntityManagerFactoryImpl. Needs initialising
+ *
+ */
+ public STMEntityManagerFactoryImpl()
{
- if (null != properties )
+
+ }
+
+ /**
+ * Parse the string for expected isolation level. no side effects
+ *
+ * @param value Isolation level
+ * @return IsolationLevel enum object or null if value does not meet validation
+ * preCondition: value is not null
+ * preCondition: value is not empty or whitespace
+ * postCondition: IsolationLevel is not null
+ */
+ private IsolationLevel parseIsolationLevel(String value)
+ {
+ IsolationLevel returnValue = null;
+ if (StringUtils.isNotEmpty(value))
{
- this.properties = properties;
+ if (StringUtils.equalsIgnoreCase( IsolationLevel.REPEATABLE_READ.toString(), value) )
+ {
+ returnValue = IsolationLevel.REPEATABLE_READ;
+ }
+ else if (StringUtils.equalsIgnoreCase( IsolationLevel.READ_COMMITTED.toString(), value))
+ {
+ returnValue = IsolationLevel.READ_COMMITTED;
+ }
+ else if (StringUtils.equalsIgnoreCase( IsolationLevel.SERIALIZABLE.toString(), value))
+ {
+ returnValue = IsolationLevel.SERIALIZABLE;
+ }
+ else
+ {
+ throw new RuntimeException(ERROR_UNRECOGNISED_ISOLATION_LEVEL);
+ }
}
else
{
- logger.error("Attempted to configure EntityManagerFactory with a null properties reference.");
+ throw new RuntimeException(ERROR_EMPTY_ISOLATION_LEVEL_VALUE);
}
+
+ return returnValue;
}
+
+ /**
+ * Initialise the factory object with persistence context details.
+ *
+ * @param persistenceName
+ * @param persistenceContext
+ */
+ public void initialise(String persistenceName, STMPersistenceContext persistenceContext)
+ {
+ //TODO: this method is not thread safe, needs changing to make it safe
+ if (StringUtils.isNotBlank( persistenceName))
+ {
+ this.persistenceContextName = persistenceName;
+ }
+ else
+ {
+ logger.error(ERROR_NULL_PERSISTENCE_CONTEXT_NAME);
+ }
+ if (null != persistenceContext)
+ {
+ this.persistenceContext = persistenceContext;
+ }
+ else
+ {
+ logger.error(ERROR_NULL_PERSISTENCE_CONTEXT);
+ }
+ }
+
+ private boolean notEmpty(Map map)
+ {
+ return !map.isEmpty();
+ }
+ private boolean containsRequiredConfiguration(Map map)
+ {
+ return map.containsKey(STMPersistenceProviderImpl.PROPERTY_ISOLATION_LEVEL);
+ }
+ private boolean bindPersistenceContextToJNDI(Map map)
+ {// the presence of the key disables binding to JNDI, useful for unit testing
+ return !map.containsKey(STMPersistenceContext.BYPASS_JNDI_BINDING);
+ }
+ private String getBindingName(String pcName)
+ {
+ return new StringBuffer().append("java/PersistenceContext/").append(pcName).toString();
+ }
+ @Override
+ protected Object clone() throws CloneNotSupportedException
+ {
+ throw new CloneNotSupportedException("Cloning of this object is not supported.");
+ }
}
Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java 2009-07-13 18:45:45 UTC (rev 27967)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java 2009-07-13 18:56:57 UTC (rev 27968)
@@ -85,7 +85,10 @@
@Override
public Query createQuery(String qlString)
{
- // FIXME createQuery
+ if (true)
+ {
+ throw new UnsupportedOperationException("Unsupported operation createNamedQuery(String)");
+ }
return null;
}
@@ -99,8 +102,10 @@
@Override
public void flush()
{
- // FIXME flush
-
+ if (true)
+ {
+ throw new UnsupportedOperationException("Unsupported operation createNamedQuery(String)");
+ }
}
@Override
@@ -187,4 +192,9 @@
}
+ public STMEntityManagerImpl()
+ {
+ // FIXME STMEntityManagerImpl constructor
+
+ }
}
Deleted: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/impl/MVCCStore.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/impl/MVCCStore.java 2009-07-13 18:45:45 UTC (rev 27967)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/impl/MVCCStore.java 2009-07-13 18:56:57 UTC (rev 27968)
@@ -1,25 +0,0 @@
-package uk.ac.ncl.sdia.a8905943.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import uk.ac.ncl.sdia.a8905943.spec.ObjectStoreManager;
-
-public class MVCCStore implements ObjectStoreManager {
-
- private Map<String, Map<Long, Object>> store = new HashMap<String, Map<Long,Object>>();
-
- @Override
- public Object find(Class type, Object identity)
- {
-
- return null;
- }
-
- @Override
- public void put(Object object)
- {
-
- }
-
-}
Added: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/spec/PersistenceContextHandle.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/spec/PersistenceContextHandle.java (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/spec/PersistenceContextHandle.java 2009-07-13 18:56:57 UTC (rev 27968)
@@ -0,0 +1,20 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package uk.ac.ncl.sdia.a8905943.spec;
+
+import uk.ac.ncl.sdia.a8905943.stm.STM;
+
+/**
+ * Behaviour for getting a reference to the STM PersistenceContext
+ *
+ * @author <a href="whitingjr at hotmail.com">Jeremy Whiting</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PersistenceContextHandle
+{
+ public STM getSTM();
+}
Copied: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/STM.java (from rev 27870, labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/impl/MVCCStore.java)
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/STM.java (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/STM.java 2009-07-13 18:56:57 UTC (rev 27968)
@@ -0,0 +1,21 @@
+package uk.ac.ncl.sdia.a8905943.stm;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class STM {
+
+ private Map<String, Map<Long, Object>> store = new HashMap<String, Map<Long,Object>>();
+
+ public Object find(Class type, Object identity)
+ {
+
+ return null;
+ }
+
+ public void put(Object object)
+ {
+
+ }
+
+}
Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/persistence/STMPersistenceProviderImpl.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/persistence/STMPersistenceProviderImpl.java 2009-07-13 18:45:45 UTC (rev 27967)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/stm/persistence/STMPersistenceProviderImpl.java 2009-07-13 18:56:57 UTC (rev 27968)
@@ -15,6 +15,7 @@
import org.apache.log4j.Logger;
+import uk.ac.ncl.sdia.a8905943.ejb3.persistence.STMPersistenceContext;
import uk.ac.ncl.sdia.a8905943.entitymanager.STMEntityManagerFactoryImpl;
/**
@@ -30,7 +31,7 @@
* @author <a href="whitingjr at hotmail.com">Jeremy Whiting</a>
* @version $Revision: 1.1 $
*/
-public class STMPersistenceProviderImpl implements PersistenceProvider
+public final class STMPersistenceProviderImpl implements PersistenceProvider
{
private static Logger logger = Logger.getLogger(STMPersistenceProviderImpl.class);
@@ -41,6 +42,7 @@
//TODO: jrw make factory a singleton and thread safe
private static final STMEntityManagerFactoryImpl factory = new STMEntityManagerFactoryImpl();
+ private static final STMPersistenceContext context = new STMPersistenceContext();
@Override
public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map map)
@@ -58,15 +60,13 @@
{
logger.trace("Creating EntityManagerFactory for thread with id ["+Thread.currentThread().getId()+"]");
}
-
+
if (PersistenceUnitTransactionType.JTA != info.getTransactionType())
{
throw new UnsupportedOperationException("Attempt to use resource-local persistence provider which is not supported. Only JTA is supported.");
}
+ factory.initialise(info.getPersistenceUnitName(), this.context);
- // currently this factory could be ready by concurrent thread without the properties map being set.
- //TODO:jrw to be finished
- factory.setMap(map);
returnValue = factory;
return returnValue;
Added: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/entitymanager/JUnitTestSTMEntityManagerFactoryImpl.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/entitymanager/JUnitTestSTMEntityManagerFactoryImpl.java (rev 0)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/entitymanager/JUnitTestSTMEntityManagerFactoryImpl.java 2009-07-13 18:56:57 UTC (rev 27968)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package uk.ac.ncl.sdia.a8905943.entitymanager;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.jboss.cache.lock.IsolationLevel;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import uk.ac.ncl.sdia.a8905943.ejb3.persistence.STMPersistenceContext;
+import uk.ac.ncl.sdia.a8905943.stm.persistence.STMPersistenceProviderImpl;
+
+public class JUnitTestSTMEntityManagerFactoryImpl
+{
+ private static final Logger logger = Logger.getLogger(JUnitTestSTMEntityManagerFactoryImpl.class);
+ private STMEntityManagerFactoryImpl factory ;
+
+ @Before
+ public void setUp()
+ {
+ factory = new STMEntityManagerFactoryImpl();
+ factory.initialise( "banking", new STMPersistenceContext());
+ }
+ @After
+ public void tearDown()
+ {
+ factory = null;
+ }
+
+
+ @Test(expected=RuntimeException.class)
+ public void testCheckExceptionThrownForMissingIsolationLevelConfig()
+ {
+ Map<String, String> conifguration= new HashMap<String, String>(1);
+ factory.createEntityManager(conifguration);
+ }
+
+ @Test
+ public void testCheckNoExceptionForValidConfig()
+ {
+ Map<String, String> configuration = new HashMap<String, String>(1);
+ configuration.put(STMPersistenceProviderImpl.PROPERTY_ISOLATION_LEVEL, IsolationLevel.REPEATABLE_READ.toString());
+ configuration.put(STMPersistenceContext.BYPASS_JNDI_BINDING, null);
+ Assert.assertNotNull(factory);
+ EntityManager manager = factory.createEntityManager(configuration);
+ Assert.assertNotNull(manager );
+ }
+
+ @Test(expected=RuntimeException.class)
+ public void testCheckExceptionForEmptyLEvel()
+ {
+ Map<String, String> conifguration= new HashMap<String, String>(1);
+ conifguration.put(STMPersistenceProviderImpl.PROPERTY_ISOLATION_LEVEL, StringUtils.EMPTY);
+ factory.createEntityManager(conifguration);
+ }
+
+ @Test(expected=RuntimeException.class)
+ public void testCheckExceptionWhenBindingWithoutContextAvailable()
+ {
+ Map<String, String> configuration = new HashMap<String, String>(1);
+ configuration.put(STMPersistenceProviderImpl.PROPERTY_ISOLATION_LEVEL, IsolationLevel.REPEATABLE_READ.toString());
+ //configuration.put(STMPersistenceContext.BYPASS_JNDI_BINDING, null);
+ Assert.assertNotNull(factory);
+ EntityManager manager = factory.createEntityManager(configuration);
+ }
+
+}
Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/impl/JUTestMVCCStore.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/impl/JUTestMVCCStore.java 2009-07-13 18:45:45 UTC (rev 27967)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/test/java/uk/ac/ncl/sdia/a8905943/impl/JUTestMVCCStore.java 2009-07-13 18:56:57 UTC (rev 27968)
@@ -3,6 +3,8 @@
import org.junit.Before;
import org.junit.Test;
+import uk.ac.ncl.sdia.a8905943.stm.STM;
+
public class JUTestMVCCStore {
@Before
@@ -13,7 +15,7 @@
@Test
public void testCheckObjectStored()
{
- MVCCStore store = new MVCCStore();
+ STM store = new STM();
}
More information about the jboss-svn-commits
mailing list