From 3c9eb145354c8901f62649d22021eaab7677a9f4 Mon Sep 17 00:00:00 2001 From: erik Date: Sat, 31 Jul 2010 17:33:39 +0000 Subject: [PATCH] --- .../java/org/wamblee/test/inject/Binding.java | 21 ++- .../test/inject/JavaEETestInjector.java | 22 ++- .../inject/JavaEETestInjectorFactory.java | 68 ++++---- .../wamblee/test/jndi/StubInitialContext.java | 8 +- .../test/jndi/StubInitialContextFactory.java | 13 +- .../org/wamblee/test/jndi/package-info.java | 2 +- .../test/persistence/AbstractDatabase.java | 27 +-- .../persistence/AbstractDatabaseProvider.java | 9 +- .../persistence/CompositeJpaCustomizer.java | 12 +- .../test/persistence/CompositeJpaTables.java | 12 +- .../wamblee/test/persistence/Database.java | 13 +- .../test/persistence/DatabaseBuilder.java | 8 +- .../test/persistence/DatabaseDescription.java | 4 +- .../test/persistence/DatabaseProvider.java | 2 +- .../test/persistence/DatabaseStarter.java | 2 +- .../test/persistence/DatabaseUtils.java | 164 +++++++++++------- .../persistence/DerbyDatabaseProvider.java | 4 +- .../test/persistence/ExternalDatabase.java | 3 +- .../persistence/ExternalDatabaseProvider.java | 4 +- .../wamblee/test/persistence/JpaBuilder.java | 7 +- .../test/persistence/JpaCustomizer.java | 16 +- .../persistence/JpaCustomizerBuilder.java | 13 +- .../wamblee/test/persistence/JpaTester.java | 36 ++-- .../LoggingTransactionResultCallback.java | 22 +-- .../PersistenceUnitDescription.java | 18 +- .../persistence/RequireTransactionStatus.java | 27 +-- .../TransactionResultCallback.java | 8 +- .../test/persistence/package-info.java | 3 +- .../DefaultUserTransactionFactory.java | 16 +- .../SimpleTransactionManager.java | 4 +- .../transactions/SimpleUserTransaction.java | 16 +- .../transactions/TransactionProxyFactory.java | 29 ++-- .../transactions/TransactionResource.java | 32 ++-- .../test/transactions/TransactionResult.java | 17 +- .../transactions/UserTransactionCallback.java | 4 +- .../transactions/UserTransactionFactory.java | 7 +- .../test/transactions/package-info.java | 2 +- .../inject/JavaEETestInjectorFactoryTest.java | 17 +- .../jndi/StubInitiaContextFactoryTest.java | 30 ++-- .../test/persistence/DatabaseBuilderTest.java | 6 +- .../persistence/DatabaseUtilsLeakTest.java | 23 ++- .../persistence/DatabaseUtilsTestBase.java | 5 +- .../test/persistence/DerbyDatabaseTest.java | 2 +- .../persistence/ExternalDatabaseTest.java | 2 +- .../wamblee/test/persistence/MyEntity.java | 2 +- .../test/persistence/MyPersistenceUnit.java | 2 +- .../wamblee/test/persistence/MyTables.java | 2 +- .../RequireTransactionStatusTest.java | 16 +- ...mpleTransactionManagerIntegrationTest.java | 17 +- .../SimpleTransactionManagerTest.java | 2 +- .../TransactionProxyFactoryTestBase.java | 16 +- 51 files changed, 459 insertions(+), 358 deletions(-) diff --git a/test/enterprise/src/main/java/org/wamblee/test/inject/Binding.java b/test/enterprise/src/main/java/org/wamblee/test/inject/Binding.java index 14e620a3..e9b27b98 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/inject/Binding.java +++ b/test/enterprise/src/main/java/org/wamblee/test/inject/Binding.java @@ -24,12 +24,13 @@ import org.wamblee.reflection.Accessor; import org.wamblee.reflection.AnnotationUtils; /** - * This class represents an injection binding. It provides injection of a defined object (typically mock or stub) - * into other objects. The binding is defined by the required annotation that must be on the field, the field type, - * and the object to be injected. + * This class represents an injection binding. It provides injection of a + * defined object (typically mock or stub) into other objects. The binding is + * defined by the required annotation that must be on the field, the field type, + * and the object to be injected. * * @author Erik Brakkee - * + * * @param */ public class Binding { @@ -39,10 +40,14 @@ public class Binding { private Map> accessorCache; /** - * Constructs the binding. - * @param aClass Required type of the field injected into. - * @param aAnnotation Annotation that must be present on the field. - * @param aValue Value of the annotation. + * Constructs the binding. + * + * @param aClass + * Required type of the field injected into. + * @param aAnnotation + * Annotation that must be present on the field. + * @param aValue + * Value of the annotation. */ public Binding(Class aClass, Class aAnnotation, Object aValue) { diff --git a/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjector.java b/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjector.java index 8fe52ac1..853d312c 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjector.java +++ b/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjector.java @@ -37,10 +37,11 @@ import org.wamblee.reflection.ObjectTraversal.ObjectVisitor; *

* *

- * It works by first delegating to the default injector (typically CDI). Afterwards it traverses the - * object graph of the injected object and performs custom injection of test objects as specified by the - * {@link Binding} class. This approach makes sure that test dependencies also find their way into - * objects that were created by the injection framework. + * It works by first delegating to the default injector (typically CDI). + * Afterwards it traverses the object graph of the injected object and performs + * custom injection of test objects as specified by the {@link Binding} class. + * This approach makes sure that test dependencies also find their way into + * objects that were created by the injection framework. *

* * @author Erik Brakkee @@ -50,37 +51,44 @@ public class JavaEETestInjector implements Injector { private class InjectionVisitor implements ObjectVisitor { @Override public boolean mustVisit(Class aClass) { - if (EntityManager.class.isAssignableFrom(aClass)) { + if (EntityManager.class.isAssignableFrom(aClass)) { return false; } return true; } + @Override public boolean mustVisit(Field aField) { // just process any field with annotations - return aField.getAnnotations().length > 0; + return aField.getAnnotations().length > 0; } + @Override public boolean mustVisit(Method aMethod) { return false; } + @Override public boolean visitArray(Object aArray) { return true; } + @Override public boolean visitList(List aObject) { return true; } + @Override public boolean visitMap(Map aObject) { return true; } + @Override public boolean visitPlainObject(Object aObject) { performTestInjections(aObject); return true; } + @Override public boolean visitSet(Set aSet) { return true; @@ -110,7 +118,7 @@ public class JavaEETestInjector implements Injector { public void inject(Object aComponent) { // basic injection delegate.inject(aComponent); - + // Now perform test injections. ObjectTraversal traversal = new ObjectTraversal(new InjectionVisitor()); traversal.accept(aComponent); diff --git a/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjectorFactory.java b/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjectorFactory.java index fdfb84a7..f5814981 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjectorFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/test/inject/JavaEETestInjectorFactory.java @@ -28,65 +28,76 @@ import org.wamblee.test.persistence.JpaBuilder; /** *

- * The test injector factory provides dependency injection of a contextual entity manager - * using the support/inject mini framework. It supports dependency injection of fields - * annoted with @PersistenceContext. It only supports one persistence context - * at the moment. This injector can be easily used together with {@link JpaBuilder#getContextualEntityManager()} - * for obtaining an entity manager in unit test. + * The test injector factory provides dependency injection of a contextual + * entity manager using the support/inject mini framework. It supports + * dependency injection of fields annoted with + * @PersistenceContext. It only supports one persistence + * context at the moment. This injector can be easily used together with + * {@link JpaBuilder#getContextualEntityManager()} for obtaining an entity + * manager in unit test. *

* *

- * The reason it is needed is because standard injection mechanisms (such as weld CDI) do not support - * entity manager injection in a Java SE environment out of the box. + * The reason it is needed is because standard injection mechanisms (such as + * weld CDI) do not support entity manager injection in a Java SE environment + * out of the box. *

- * + * *

- * To use it, construct the factory using one of the available constructors and set - * InjectorBuilder.setInjectorFactory(InjectorFactory). + * To use it, construct the factory using one of the available constructors and + * set InjectorBuilder.setInjectorFactory(InjectorFactory). *

* * @author Erik Brakkee - * + * */ public class JavaEETestInjectorFactory implements InjectorFactory { private List bindings; private InjectorFactory delegate; - + /** - * Constructs the factory. - * @param aInjectorFactory Injector factory to delegate to. + * Constructs the factory. + * + * @param aInjectorFactory + * Injector factory to delegate to. */ public JavaEETestInjectorFactory(InjectorFactory aInjectorFactory) { - bindings = new ArrayList(); + bindings = new ArrayList(); delegate = aInjectorFactory; } /** - * Adds default entity manager binding. Any field annotated with @PersistenceContext and of type - * entity manager will get injected. - * @param aEntityManager Entitymanager object to inject. + * Adds default entity manager binding. Any field annotated with @PersistenceContext + * and of type entity manager will get injected. + * + * @param aEntityManager + * Entitymanager object to inject. * @return Factory to allow chaining. */ - public JavaEETestInjectorFactory addEntityManagerBinding(EntityManager aEntityManager) { - Binding em = new Binding(EntityManager.class, PersistenceContext.class, aEntityManager); + public JavaEETestInjectorFactory addEntityManagerBinding( + EntityManager aEntityManager) { + Binding em = new Binding(EntityManager.class, PersistenceContext.class, + aEntityManager); addBinding(em); return this; } - + /** - * Adds another custom injection binding. - * @param aBinding Injection binding to use. + * Adds another custom injection binding. + * + * @param aBinding + * Injection binding to use. * @return the factoryto allow chaining. */ - public JavaEETestInjectorFactory addBinding(Binding aBinding) { + public JavaEETestInjectorFactory addBinding(Binding aBinding) { bindings.add(aBinding); - return this; + return this; } /** - * Constructs the factory with the default injector factory obtained from - * {@link InjectorBuilder#getInjector()}. + * Constructs the factory with the default injector factory obtained from + * {@link InjectorBuilder#getInjector()}. */ public JavaEETestInjectorFactory() { this(getDefaultInjectorFactory()); @@ -99,7 +110,6 @@ public class JavaEETestInjectorFactory implements InjectorFactory { @Override public Injector create(Class aClass) { - return new JavaEETestInjector(aClass, bindings, delegate - .create(aClass)); + return new JavaEETestInjector(aClass, bindings, delegate.create(aClass)); } } diff --git a/test/enterprise/src/main/java/org/wamblee/test/jndi/StubInitialContext.java b/test/enterprise/src/main/java/org/wamblee/test/jndi/StubInitialContext.java index f5277703..e185d506 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/jndi/StubInitialContext.java +++ b/test/enterprise/src/main/java/org/wamblee/test/jndi/StubInitialContext.java @@ -24,7 +24,7 @@ import javax.naming.NameNotFoundException; import javax.naming.NamingException; /** - * Initial context implementation. + * Initial context implementation. * * @author Erik Brakkee */ @@ -39,7 +39,7 @@ class StubInitialContext extends InitialContext { public void bind(String aName, Object aObj) throws NamingException { bindings.put(aName, aObj); } - + @Override public void unbind(String aName) throws NamingException { bindings.remove(aName); @@ -53,12 +53,12 @@ class StubInitialContext extends InitialContext { } return value; } - + @Override public void bind(Name aName, Object aObj) throws NamingException { bind(aName.toString(), aObj); } - + @Override public void unbind(Name aName) throws NamingException { unbind(aName.toString()); diff --git a/test/enterprise/src/main/java/org/wamblee/test/jndi/StubInitialContextFactory.java b/test/enterprise/src/main/java/org/wamblee/test/jndi/StubInitialContextFactory.java index 09389ef1..023e7777 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/jndi/StubInitialContextFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/test/jndi/StubInitialContextFactory.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.jndi; import java.util.Hashtable; @@ -27,17 +27,18 @@ import javax.naming.spi.InitialContextFactory; * * See {@link #bind(String, Object)} to resp. register the initial context. * - * To start mocking the JNDI tree, call {@link #register()}. + * To start mocking the JNDI tree, call {@link #register()}. + * + * To bind objects in the JNDI tree simply use the standard JNDI api: * - * To bind objects in the JNDI tree simply use the standard JNDI api: *
  *   InitialContext context = new InitialContext();
  *   MyClass myObj = ...; 
- *   context.bind("a/b", myObj); 
+ *   context.bind("a/b", myObj);
  * 
* - * When finished with a test case, call {@link #unregister()} to unregister the - * JNDI tree again. + * When finished with a test case, call {@link #unregister()} to unregister the + * JNDI tree again. */ public class StubInitialContextFactory implements InitialContextFactory { diff --git a/test/enterprise/src/main/java/org/wamblee/test/jndi/package-info.java b/test/enterprise/src/main/java/org/wamblee/test/jndi/package-info.java index 7fd7ddbc..acbc06e2 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/jndi/package-info.java +++ b/test/enterprise/src/main/java/org/wamblee/test/jndi/package-info.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * This package provides utilities for JNDI testing. * diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/AbstractDatabase.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/AbstractDatabase.java index df5cb75f..11fda933 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/AbstractDatabase.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/AbstractDatabase.java @@ -29,12 +29,12 @@ import org.apache.commons.dbcp.PoolingDataSource; import org.apache.commons.pool.impl.GenericObjectPool; /** - * Abstract database class providing the creation of the datasource, - * preventing duplicate starts of the same database, and checking - * for connection leaks when the database is stopped. + * Abstract database class providing the creation of the datasource, preventing + * duplicate starts of the same database, and checking for connection leaks when + * the database is stopped. * * @author Erik Brakkee - * + * */ public abstract class AbstractDatabase implements Database { @@ -56,19 +56,19 @@ public abstract class AbstractDatabase implements Database { private boolean started; /** - * Constructs the database. + * Constructs the database. */ protected AbstractDatabase() { started = false; } /** - * To be implemented by subclasses to start the database. + * To be implemented by subclasses to start the database. */ protected abstract void doStart(); /** - * To be implemented by subclasses to stop the database. + * To be implemented by subclasses to stop the database. */ protected abstract void doStop(); @@ -101,7 +101,7 @@ public abstract class AbstractDatabase implements Database { // / BELOW THIS LINE IS NOT OF INTEREST TO SUBCLASSES. /** - * Starts the database. + * Starts the database. */ public final DataSource start() { if (started) { @@ -113,9 +113,9 @@ public abstract class AbstractDatabase implements Database { } /** - * Stops the database and tests for connection leaks. - * In cast the system property with the name given by {@link #IGNORE_CONNECTION_LEAK_PROPERTY} - * is set then the connection leaks are not checked. + * Stops the database and tests for connection leaks. In cast the system + * property with the name given by {@link #IGNORE_CONNECTION_LEAK_PROPERTY} + * is set then the connection leaks are not checked. */ public final void stop() { if (!started) { @@ -127,8 +127,9 @@ public abstract class AbstractDatabase implements Database { String msg = "JDBC connection pool still has " + connectionPool.getNumActive() + " active connection(s), this is a potential resource leak in the code\n"; - // backdoor to ignore connection leaks. Use this system property only if you - // can safely ignore the connection leaks. + // backdoor to ignore connection leaks. Use this system property + // only if you + // can safely ignore the connection leaks. if (System.getProperty(IGNORE_CONNECTION_LEAK_PROPERTY) == null) { Assert.fail(msg); } diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/AbstractDatabaseProvider.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/AbstractDatabaseProvider.java index 9bfa30f1..321a8c1e 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/AbstractDatabaseProvider.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/AbstractDatabaseProvider.java @@ -12,24 +12,25 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import java.util.List; + /** - * Base class for database providers. + * Base class for database providers. * * @author Erik Brakkee */ public abstract class AbstractDatabaseProvider implements DatabaseProvider { /** - * @return List of database capabilities. + * @return List of database capabilities. */ protected abstract List getCapabilities(); /** - * Standard implementation of the capabalities check. + * Standard implementation of the capabalities check. */ public final boolean supportsCapabilities(String[] aCapabilities) { for (String capability : aCapabilities) { diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/CompositeJpaCustomizer.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/CompositeJpaCustomizer.java index 08de725c..e766b9fe 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/CompositeJpaCustomizer.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/CompositeJpaCustomizer.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import java.util.List; @@ -21,8 +21,8 @@ import java.util.Map; import org.dbunit.dataset.filter.ITableFilterSimple; /** - * Composite JPA customizer that applies the customizations from several - * JPA customizers. + * Composite JPA customizer that applies the customizations from several JPA + * customizers. * * @author Erik Brakkee */ @@ -32,8 +32,10 @@ public class CompositeJpaCustomizer implements JpaCustomizer { private CompositeJpaTables tables; /** - * Construcst the customizer. - * @param aCustomizers List of customizers. + * Construcst the customizer. + * + * @param aCustomizers + * List of customizers. */ public CompositeJpaCustomizer(List aCustomizers) { customizers = aCustomizers; diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/CompositeJpaTables.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/CompositeJpaTables.java index 23db6d29..d1d2d3ac 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/CompositeJpaTables.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/CompositeJpaTables.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import java.util.ArrayList; @@ -22,7 +22,7 @@ import org.dbunit.dataset.DataSetException; import org.dbunit.dataset.filter.ITableFilterSimple; /** - * Composite JPA tables. Implements the logical or of several table filters. + * Composite JPA tables. Implements the logical or of several table filters. * * @author Erik Brakkee */ @@ -31,15 +31,17 @@ public class CompositeJpaTables implements ITableFilterSimple { private List tables; /** - * Construcst the tables. + * Construcst the tables. */ public CompositeJpaTables() { tables = new ArrayList(); } /** - * Adds a table filter. - * @param aFilter filter. + * Adds a table filter. + * + * @param aFilter + * filter. */ public void add(ITableFilterSimple aFilter) { tables.add(aFilter); diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/Database.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/Database.java index da8ff158..66273432 100755 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/Database.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/Database.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import javax.sql.DataSource; @@ -29,13 +29,14 @@ public interface Database { * database has been started. */ DataSource start(); - + /** - * Gets the number of active connections from the pool. This is useful for - * determining resource leaks. - * @return Active connections. + * Gets the number of active connections from the pool. This is useful for + * determining resource leaks. + * + * @return Active connections. */ - int getActiveConnections(); + int getActiveConnections(); /** * Gets the Jdbc Url to connect to this database. diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseBuilder.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseBuilder.java index f8ae4a99..e966d456 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseBuilder.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseBuilder.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import java.util.ArrayList; @@ -62,11 +62,11 @@ public class DatabaseBuilder { */ public static final String DB_CAPABILITIES_PROP = "TEST_DB_CAPABILITIES"; - private static ServiceLoader LOADER = - ServiceLoader.load(DatabaseProvider.class); + private static ServiceLoader LOADER = ServiceLoader + .load(DatabaseProvider.class); /** - * Constructs the database builder. + * Constructs the database builder. */ private DatabaseBuilder() { // Empty. diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseDescription.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseDescription.java index 8f44094a..aa9966e7 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseDescription.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseDescription.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; /** @@ -52,7 +52,7 @@ public class DatabaseDescription { for (int i = 0; i < itsCapabilities.length; i++) { res.append(itsCapabilities[i]); if (i < itsCapabilities.length - 1) { - res.append(", "); + res.append(", "); } } return res.toString(); diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseProvider.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseProvider.java index 21699ed8..9b78363c 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseProvider.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseProvider.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; /** diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseStarter.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseStarter.java index 8be5ff7c..92b6a521 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseStarter.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseStarter.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; /** diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseUtils.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseUtils.java index c4e38f4d..dc7c0404 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseUtils.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/DatabaseUtils.java @@ -47,7 +47,7 @@ public class DatabaseUtils { /** * Represents a set of tables. - * + * * @author Erik Brakkee */ public static interface TableSet { @@ -58,29 +58,33 @@ public class DatabaseUtils { * Represents a unit of work (transaction). * * @author Erik Brakkee - * - * @param Type of return value. + * + * @param + * Type of return value. */ public static interface JdbcUnitOfWork { /** - * Executes statement within a transaction. - * @param aConnection Connection. - * @return Result of the work. + * Executes statement within a transaction. + * + * @param aConnection + * Connection. + * @return Result of the work. * @throws Exception */ T execute(Connection aConnection) throws Exception; } /** - * Operation to be executed on a set of tables for each table - * individually. + * Operation to be executed on a set of tables for each table individually. * * @author Erik Brakkee */ public static interface TableSetOperation { /** - * Executes on a table. - * @param aTable Table name. + * Executes on a table. + * + * @param aTable + * Table name. * @throws Exception */ void execute(String aTable) throws Exception; @@ -97,37 +101,39 @@ public class DatabaseUtils { private IDatabaseTester dbtester; /** - * List of connections that were created for dbtesters. - * This list will be closed in the {@link #stop()} method. + * List of connections that were created for dbtesters. This list will be + * closed in the {@link #stop()} method. */ - private List connections; - + private List connections; + /** - * Constructs the database utils. - * Before use, {@link #start()} must be called. - * @param aDataSource Datasource. + * Constructs the database utils. Before use, {@link #start()} must be + * called. + * + * @param aDataSource + * Datasource. */ public DatabaseUtils(DataSource aDataSource) { dataSource = aDataSource; dbtester = new DataSourceDatabaseTester(dataSource); - connections = new ArrayList(); + connections = new ArrayList(); } /** - * Starts the database utils. + * Starts the database utils. */ - public void start() { - // Empty. No operation currently. + public void start() { + // Empty. No operation currently. } /** * Stops the database utils, closing any JDBC connections that were created - * by this utility. Note that connections obtained from the datasource directly - * must still be closed by the user. The involved connections are only those that - * are created by this utility. + * by this utility. Note that connections obtained from the datasource + * directly must still be closed by the user. The involved connections are + * only those that are created by this utility. */ public void stop() { - for (IDatabaseConnection connection: connections) { + for (IDatabaseConnection connection : connections) { try { connection.close(); } catch (SQLException e) { @@ -138,19 +144,24 @@ public class DatabaseUtils { } /** - * Creates database tester. - * @param aTables Tables to create the tester for. - * @return Database tester. + * Creates database tester. + * + * @param aTables + * Tables to create the tester for. + * @return Database tester. * @throws Exception */ - public IDatabaseTester createDbTester(ITableFilterSimple aTables) throws Exception { + public IDatabaseTester createDbTester(ITableFilterSimple aTables) + throws Exception { return createDbTester(getTableNames(aTables)); } - + /** - * Creates database tester. - * @param aTables Tables to create the tester for. - * @return Database tester. + * Creates database tester. + * + * @param aTables + * Tables to create the tester for. + * @return Database tester. * @throws Exception */ public IDatabaseTester createDbTester(String[] aTables) throws Exception { @@ -161,9 +172,12 @@ public class DatabaseUtils { } /** - * Executes an operation on a set of tables. - * @param aTables Tables. - * @param aOperation Operation. + * Executes an operation on a set of tables. + * + * @param aTables + * Tables. + * @param aOperation + * Operation. * @throws Exception */ public void executeOnTables(ITableFilterSimple aTables, @@ -180,9 +194,12 @@ public class DatabaseUtils { } /** - * Cleans a number of database tables. This means deleting the content not dropping the tables. - * This may fail in case of cyclic dependencies between the tables (current limitation). - * @param aSelection Tables. + * Cleans a number of database tables. This means deleting the content not + * dropping the tables. This may fail in case of cyclic dependencies between + * the tables (current limitation). + * + * @param aSelection + * Tables. * @throws Exception */ public void cleanDatabase(ITableFilterSimple aSelection) throws Exception { @@ -205,14 +222,16 @@ public class DatabaseUtils { } /** - * Executes a unit of work within a transaction. - * @param Result type of th ework. - * @param aWork Unit of work. + * Executes a unit of work within a transaction. + * + * @param + * Result type of th ework. + * @param aWork + * Unit of work. * @return * @throws Exception */ - public T executeInTransaction(JdbcUnitOfWork aWork) - throws Exception { + public T executeInTransaction(JdbcUnitOfWork aWork) throws Exception { Connection connection = dataSource.getConnection(); connection.setAutoCommit(false); try { @@ -223,11 +242,13 @@ public class DatabaseUtils { connection.close(); } } - + /** - * Returns table names based on a table filter. - * @param aSelection Table filter. - * @return Table names. + * Returns table names based on a table filter. + * + * @param aSelection + * Table filter. + * @return Table names. * @throws Exception */ public String[] getTableNames(ITableFilterSimple aSelection) @@ -254,7 +275,7 @@ public class DatabaseUtils { } /** - * Use {@link #cleanDatabase(ITableFilterSimple)} instead. + * Use {@link #cleanDatabase(ITableFilterSimple)} instead. */ @Deprecated public void emptyTables(final ITableFilterSimple aSelection) @@ -267,7 +288,7 @@ public class DatabaseUtils { } /** - * User {@link #cleanDatabase(ITableFilterSimple)} instead. + * User {@link #cleanDatabase(ITableFilterSimple)} instead. */ @Deprecated public void emptyTable(String aTable) throws Exception { @@ -275,8 +296,11 @@ public class DatabaseUtils { } /** - * Drops tables. This only works if there are no cyclic dependencies between the tables. - * @param aTables Tables to drop. + * Drops tables. This only works if there are no cyclic dependencies between + * the tables. + * + * @param aTables + * Tables to drop. * @throws Exception */ public void dropTables(ITableFilterSimple aTables) throws Exception { @@ -299,8 +323,10 @@ public class DatabaseUtils { } /** - * Drops a table. - * @param aTable Table to drop. + * Drops a table. + * + * @param aTable + * Table to drop. * @throws Exception */ public void dropTable(final String aTable) throws Exception { @@ -413,11 +439,15 @@ public class DatabaseUtils { } /** - * Executes an update. - * @param aConnection Connection to use. - * @param aSql SQL update to use. - * @param aArgs Arguments to the update. - * @return Number of rows updated. + * Executes an update. + * + * @param aConnection + * Connection to use. + * @param aSql + * SQL update to use. + * @param aArgs + * Arguments to the update. + * @return Number of rows updated. */ public int executeUpdate(Connection aConnection, final String aSql, final Object... aArgs) { @@ -476,9 +506,11 @@ public class DatabaseUtils { } /** - * Gets the table size. - * @param aTable Table. - * @return Table size. + * Gets the table size. + * + * @param aTable + * Table. + * @return Table size. * @throws SQLException */ public int getTableSize(final String aTable) throws Exception { @@ -494,9 +526,11 @@ public class DatabaseUtils { } /** - * Counts the results in a result set. - * @param aResultSet Resultset. - * @return Number of rows in the set. + * Counts the results in a result set. + * + * @param aResultSet + * Resultset. + * @return Number of rows in the set. * @throws SQLException */ public int countResultSet(ResultSet aResultSet) throws SQLException { diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/DerbyDatabaseProvider.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/DerbyDatabaseProvider.java index 26387962..fdab8804 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/DerbyDatabaseProvider.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/DerbyDatabaseProvider.java @@ -12,14 +12,14 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import java.util.Arrays; import java.util.List; /** - * Derby database provider. + * Derby database provider. * * @author Erik Brakkee */ diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/ExternalDatabase.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/ExternalDatabase.java index a3044576..00ea47e4 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/ExternalDatabase.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/ExternalDatabase.java @@ -12,10 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; - /** * Database that encapsulates connection to an external database. Database * connection details can be configured through system properties and diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/ExternalDatabaseProvider.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/ExternalDatabaseProvider.java index cc54799b..a460cc52 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/ExternalDatabaseProvider.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/ExternalDatabaseProvider.java @@ -12,14 +12,14 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import java.util.Arrays; import java.util.List; /** - * Database provider for an external database. + * Database provider for an external database. * * @author Erik Brakkee */ diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaBuilder.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaBuilder.java index 223971c6..48556cfa 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaBuilder.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaBuilder.java @@ -153,7 +153,7 @@ public class JpaBuilder implements TransactionResource { * * This method requires the transaction to succeed. Otherwise the test will * fail. See {@link #execute(JpaUnitOfWork, TransactionResultCallback)} and - * {@link RequireTransactionStatus} for more possibilities. + * {@link RequireTransactionStatus} for more possibilities. * * @param aWork * Work to execute. @@ -161,9 +161,10 @@ public class JpaBuilder implements TransactionResource { * @return The return value of the execute method of the unit of work. */ public T execute(JpaUnitOfWork aWork) throws Exception { - return execute(aWork, new RequireTransactionStatus(TransactionResult.COMMIT)); + return execute(aWork, new RequireTransactionStatus( + TransactionResult.COMMIT)); } - + /** * Executes a unit of work. This creates an entitymanager and runs the * {@link JpaUnitOfWork#execute(EntityManager)} within a transaction, diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaCustomizer.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaCustomizer.java index dcafb426..b0222342 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaCustomizer.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaCustomizer.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import java.util.Map; @@ -33,16 +33,20 @@ import org.dbunit.dataset.filter.ITableFilterSimple; public interface JpaCustomizer { /** - * Customizes the persistence unit through properties. - * @param aPersistenceUnit Persistence unit. - * @param aJpaProperties Current properties. + * Customizes the persistence unit through properties. + * + * @param aPersistenceUnit + * Persistence unit. + * @param aJpaProperties + * Current properties. */ void customize(PersistenceUnitDescription aPersistenceUnit, Map aJpaProperties); /** - * Gets the tables specific to the JPA provider. - * @return Tables. + * Gets the tables specific to the JPA provider. + * + * @return Tables. */ ITableFilterSimple getJpaTables(); } diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaCustomizerBuilder.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaCustomizerBuilder.java index bd62c054..6eae6661 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaCustomizerBuilder.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaCustomizerBuilder.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import java.util.ArrayList; @@ -20,8 +20,8 @@ import java.util.List; import java.util.ServiceLoader; /** - * JPA customizer builder implements the {@link ServiceLoader} based mechanism for looking up - * JPA customizers. + * JPA customizer builder implements the {@link ServiceLoader} based mechanism + * for looking up JPA customizers. */ public class JpaCustomizerBuilder { @@ -29,9 +29,10 @@ public class JpaCustomizerBuilder { .load(JpaCustomizer.class); /** - * Gets the customizer to use. This is a composite customizer that combines all customizers that - * were found. - * @return JPA customizer. + * Gets the customizer to use. This is a composite customizer that combines + * all customizers that were found. + * + * @return JPA customizer. */ public static JpaCustomizer getCustomizer() { List customizers = new ArrayList(); diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaTester.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaTester.java index 27462fb0..650c55e8 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaTester.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/JpaTester.java @@ -62,7 +62,7 @@ public class JpaTester { private DataSource dataSource; private DatabaseUtils dbUtils; private JpaBuilder jpaBuilder; - + /** * Constructs the tester. * @@ -81,9 +81,9 @@ public class JpaTester { public void start() throws Exception { db = DatabaseBuilder.getDatabase(); dataSource = db.start(); - - // NOTE: adding datasource to JNDI is no longer needed for - // JPA testing, but is nice to have available for other uses. + + // NOTE: adding datasource to JNDI is no longer needed for + // JPA testing, but is nice to have available for other uses. StubInitialContextFactory.register(); try { InitialContext ctx = new InitialContext(); @@ -96,7 +96,8 @@ public class JpaTester { dbUtils.start(); dbUtils.dropTables(JpaCustomizerBuilder.getCustomizer().getJpaTables()); - jpaBuilder = new JpaBuilder(db.getJdbcUrl(), db.getUsername(), db.getPassword(), persistenceUnit); + jpaBuilder = new JpaBuilder(db.getJdbcUrl(), db.getUsername(), db + .getPassword(), persistenceUnit); jpaBuilder.start(); } @@ -116,40 +117,45 @@ public class JpaTester { } /** - * Gets the database. - * @return Database. + * Gets the database. + * + * @return Database. */ public Database getDb() { return db; } /** - * Gets the datasource. - * @return Datasource. + * Gets the datasource. + * + * @return Datasource. */ public DataSource getDataSource() { return dataSource; } /** - * Gets the database utilities. - * @return Database utilities. + * Gets the database utilities. + * + * @return Database utilities. */ public DatabaseUtils getDbUtils() { return dbUtils; } /** - * Gets the jpa builder. - * @return JPA builder. + * Gets the jpa builder. + * + * @return JPA builder. */ public JpaBuilder getJpaBuilder() { return jpaBuilder; } /** - * Gets the persistence unit. - * @return Persistence unit. + * Gets the persistence unit. + * + * @return Persistence unit. */ public PersistenceUnitDescription getPersistenceUnit() { return persistenceUnit; diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/LoggingTransactionResultCallback.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/LoggingTransactionResultCallback.java index 42d37e48..a46ca18b 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/LoggingTransactionResultCallback.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/LoggingTransactionResultCallback.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import java.util.logging.Level; @@ -22,22 +22,24 @@ import org.wamblee.test.transactions.TransactionResult; /** * Logging the result of a transaction. + * * @author Erik Brakkee - * + * */ public class LoggingTransactionResultCallback implements TransactionResultCallback { - - private static final Logger LOGGER = Logger.getLogger(LoggingTransactionResultCallback.class.getName()); - - private Level level; - - public LoggingTransactionResultCallback(Level aLevel) { - level = aLevel; + + private static final Logger LOGGER = Logger + .getLogger(LoggingTransactionResultCallback.class.getName()); + + private Level level; + + public LoggingTransactionResultCallback(Level aLevel) { + level = aLevel; } @Override public void status(TransactionResult aResult) { - LOGGER.log(level, "Transaction result " + aResult); + LOGGER.log(level, "Transaction result " + aResult); } } diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/PersistenceUnitDescription.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/PersistenceUnitDescription.java index 4a16dc06..dc9fca84 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/PersistenceUnitDescription.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/PersistenceUnitDescription.java @@ -12,12 +12,11 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; - /** - * Describes a persistence unit. + * Describes a persistence unit. * * @author Erik Brakkee */ @@ -27,9 +26,12 @@ public class PersistenceUnitDescription { private String unitName; /** - * Constructs the description. - * @param aJndiName Jndi name. - * @param aUnitName Persistence unit name. + * Constructs the description. + * + * @param aJndiName + * Jndi name. + * @param aUnitName + * Persistence unit name. */ public PersistenceUnitDescription(String aJndiName, String aUnitName) { jndiName = aJndiName; @@ -37,14 +39,14 @@ public class PersistenceUnitDescription { } /** - * @return JNDI name. + * @return JNDI name. */ public String getJndiName() { return jndiName; } /** - * Persistence unit name. + * Persistence unit name. */ public String getUnitName() { return unitName; diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/RequireTransactionStatus.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/RequireTransactionStatus.java index 338e41a1..14d871bf 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/RequireTransactionStatus.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/RequireTransactionStatus.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import org.wamblee.test.transactions.TransactionResult; @@ -20,26 +20,31 @@ import org.wamblee.test.transactions.TransactionResult; import static junit.framework.Assert.*; /** - * Specific transaction result callback to require a specific transaction result. + * Specific transaction result callback to require a specific transaction + * result. + * * @author Erik Brakkee - * + * */ public class RequireTransactionStatus implements TransactionResultCallback { - private TransactionResult result; - + private TransactionResult result; + /** - * Constructs the callback. - * @param aResult Required result. + * Constructs the callback. + * + * @param aResult + * Required result. */ - public RequireTransactionStatus(TransactionResult aResult) { + public RequireTransactionStatus(TransactionResult aResult) { result = aResult; } - + @Override public void status(TransactionResult aResult) { - if (!result.equals(aResult)) { - fail("Required transaction result was " + result + " but actual result was " + aResult); + if (!result.equals(aResult)) { + fail("Required transaction result was " + result + + " but actual result was " + aResult); } } diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/TransactionResultCallback.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/TransactionResultCallback.java index 64c787dd..cc5074b3 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/TransactionResultCallback.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/TransactionResultCallback.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import org.wamblee.test.transactions.TransactionResult; @@ -24,8 +24,10 @@ import org.wamblee.test.transactions.TransactionResult; */ public interface TransactionResultCallback { /** - * Result notification. - * @param aResult Transaction result. + * Result notification. + * + * @param aResult + * Transaction result. */ void status(TransactionResult aResult); } \ No newline at end of file diff --git a/test/enterprise/src/main/java/org/wamblee/test/persistence/package-info.java b/test/enterprise/src/main/java/org/wamblee/test/persistence/package-info.java index 54316666..7c7a4c4d 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/persistence/package-info.java +++ b/test/enterprise/src/main/java/org/wamblee/test/persistence/package-info.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** *

* This package provides test library for database testing in general and JPA testing @@ -265,4 +265,3 @@ */ package org.wamblee.test.persistence; - diff --git a/test/enterprise/src/main/java/org/wamblee/test/transactions/DefaultUserTransactionFactory.java b/test/enterprise/src/main/java/org/wamblee/test/transactions/DefaultUserTransactionFactory.java index 9d58546d..1fd0343f 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/transactions/DefaultUserTransactionFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/test/transactions/DefaultUserTransactionFactory.java @@ -20,24 +20,26 @@ import java.util.List; import javax.transaction.UserTransaction; /** - * Transaction factory implementation that creates {@link SimpleUserTransaction} objects. + * Transaction factory implementation that creates {@link SimpleUserTransaction} + * objects. * * @author Erik Brakkee - * + * */ public class DefaultUserTransactionFactory implements UserTransactionFactory { /** - * Constructs the factory. + * Constructs the factory. */ - public DefaultUserTransactionFactory() { - // Empty. + public DefaultUserTransactionFactory() { + // Empty. } - + @Override public UserTransaction create(UserTransactionCallback aCallback, List aResources) { - return new SimpleUserTransaction(aCallback, aResources.toArray(new TransactionResource[0])); + return new SimpleUserTransaction(aCallback, aResources + .toArray(new TransactionResource[0])); } } diff --git a/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleTransactionManager.java b/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleTransactionManager.java index a3d57102..7cb51431 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleTransactionManager.java +++ b/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleTransactionManager.java @@ -86,7 +86,7 @@ public class SimpleTransactionManager { transactionFInishedCallback = new UserTransactionCallback() { @Override public void transactionFinished() { - transaction.set(factory.create(this, resources)); + transaction.set(factory.create(this, resources)); } }; transaction = new ThreadSpecificProxyFactory( @@ -120,7 +120,7 @@ public class SimpleTransactionManager { public UserTransaction getTransaction() { return transaction.getProxy(); } - + /** * Gets the thread-specific transaction object. * diff --git a/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleUserTransaction.java b/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleUserTransaction.java index ffa8925a..99f7a6f9 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleUserTransaction.java +++ b/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleUserTransaction.java @@ -64,8 +64,9 @@ public class SimpleUserTransaction implements UserTransaction { @Override public void rollback() throws IllegalStateException, SecurityException, SystemException { - if ( status == Status.STATUS_NO_TRANSACTION) { - throw new IllegalStateException("Rollback while not in a transaction"); + if (status == Status.STATUS_NO_TRANSACTION) { + throw new IllegalStateException( + "Rollback while not in a transaction"); } try { for (int i = 0; i < resources.length; i++) { @@ -98,11 +99,11 @@ public class SimpleUserTransaction implements UserTransaction { resources[i].rollback(txStates[i]); } } catch (Exception e) { - committing = false; + committing = false; } } - - if (!committing) { + + if (!committing) { throw new HeuristicMixedException("Commit failed"); } } finally { @@ -118,8 +119,9 @@ public class SimpleUserTransaction implements UserTransaction { @Override public void setRollbackOnly() throws IllegalStateException, SystemException { - if ( status == Status.STATUS_NO_TRANSACTION) { - throw new IllegalStateException("setRollbackOnly() while not in a transaction"); + if (status == Status.STATUS_NO_TRANSACTION) { + throw new IllegalStateException( + "setRollbackOnly() while not in a transaction"); } status = Status.STATUS_MARKED_ROLLBACK; } diff --git a/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionProxyFactory.java b/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionProxyFactory.java index d6d47992..67f64bee 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionProxyFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionProxyFactory.java @@ -15,7 +15,6 @@ */ package org.wamblee.test.transactions; - import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -31,24 +30,27 @@ import org.wamblee.test.persistence.JpaBuilder.JpaUnitOfWork; /** * This utility makes sure that each invocation on a certain interface is - * carried out within a JPA unit of work. Note that this is equivalent - * to the sementics of a requiresNew transaction attribute. + * carried out within a JPA unit of work. Note that this is equivalent to the + * sementics of a requiresNew transaction attribute. * * Use {@link #getTransactionScopedEntityManager()} to get the transaction * scoped entity manager to pass to services. * * - * For example: + * For example: + * *

  *     JpaBuilder builder = ...
  *     TransactionProxyFactory factory = new TransactionProxyFactory(
  *           builder, Service.class);
  *     Service service = new JpaService(factory.getTransactionScopedEntityManager());
  *     Service proxy = factory.getProxy(service);
- *     proxy.executeMethod(...); 
+ *     proxy.executeMethod(...);
  * 
- * The above example executes the executeMethod() call on the service object within an active transaction. - * In the constructor of the service a transaction scoped entity manager is passed. + * + * The above example executes the executeMethod() call on the service object + * within an active transaction. In the constructor of the service a transaction + * scoped entity manager is passed. * * @param T * Type of interface to proxy. @@ -58,11 +60,12 @@ import org.wamblee.test.persistence.JpaBuilder.JpaUnitOfWork; public class TransactionProxyFactory { /** - * Executes the call on the service within a new transaction. + * Executes the call on the service within a new transaction. * * @author Erik Brakkee - * - * @param Type of the service interface. + * + * @param + * Type of the service interface. */ private class UnitOfWorkInvocationHandler implements InvocationHandler { @@ -75,11 +78,11 @@ public class TransactionProxyFactory { @Override public Object invoke(Object aProxy, final Method aMethod, final Object[] aArgs) throws Throwable { - return TransactionProxyFactory.this.jpaBuilder - .execute(new JpaUnitOfWork() { + return TransactionProxyFactory.this.jpaBuilder.execute( + new JpaUnitOfWork() { @Override public Object execute(EntityManager aEm) throws Exception { - EntityManager oldEm = ENTITY_MANAGER.get(); + EntityManager oldEm = ENTITY_MANAGER.get(); try { ENTITY_MANAGER.set(aEm); return aMethod.invoke(service, aArgs); diff --git a/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionResource.java b/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionResource.java index 1ab649ab..4770d788 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionResource.java +++ b/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionResource.java @@ -15,33 +15,37 @@ */ package org.wamblee.test.transactions; - /** - * Interfaces to be implemented by resources that want to participate in transactions - * managed through {@link SimpleTransactionManager}. + * Interfaces to be implemented by resources that want to participate in + * transactions managed through {@link SimpleTransactionManager}. * * @author Erik Brakkee - * + * * @param */ public interface TransactionResource { - + /** - * Begins a transaction. + * Begins a transaction. + * * @return Object that manages the transaction for the resource. */ - T begin(); - + T begin(); + /** * Rolls back a transaction. - * @param aT Object that manages the transaction for the resource. + * + * @param aT + * Object that manages the transaction for the resource. */ - TransactionResult rollback(T aT); - + TransactionResult rollback(T aT); + /** - * Commits the transaction. - * @param aT Object that manages the transaction for the resource. + * Commits the transaction. + * + * @param aT + * Object that manages the transaction for the resource. */ TransactionResult commit(T aT); - + } diff --git a/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionResult.java b/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionResult.java index 162d3704..82d01c3e 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionResult.java +++ b/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionResult.java @@ -16,22 +16,23 @@ package org.wamblee.test.transactions; /** - * Transaction result. + * Transaction result. * * @author Erik Brakkee */ -public enum TransactionResult { +public enum TransactionResult { /** - * Nothing was done. The transaction was committed or rolled back by the application. - * Most likely an exception occurred and the transaction was rolled back. + * Nothing was done. The transaction was committed or rolled back by the + * application. Most likely an exception occurred and the transaction was + * rolled back. */ - UNKNOWN, - + UNKNOWN, + /** - * Transaction was committed. + * Transaction was committed. */ COMMIT, - + /** * Tranasction was rolled back. */ diff --git a/test/enterprise/src/main/java/org/wamblee/test/transactions/UserTransactionCallback.java b/test/enterprise/src/main/java/org/wamblee/test/transactions/UserTransactionCallback.java index 09b656db..e4e85128 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/transactions/UserTransactionCallback.java +++ b/test/enterprise/src/main/java/org/wamblee/test/transactions/UserTransactionCallback.java @@ -15,6 +15,6 @@ */ package org.wamblee.test.transactions; -public interface UserTransactionCallback { - void transactionFinished(); +public interface UserTransactionCallback { + void transactionFinished(); } \ No newline at end of file diff --git a/test/enterprise/src/main/java/org/wamblee/test/transactions/UserTransactionFactory.java b/test/enterprise/src/main/java/org/wamblee/test/transactions/UserTransactionFactory.java index c1a08592..2de15aa0 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/transactions/UserTransactionFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/test/transactions/UserTransactionFactory.java @@ -20,12 +20,13 @@ import java.util.List; import javax.transaction.UserTransaction; /** - * Factory used to create transactions. + * Factory used to create transactions. * * @author Erik Brakkee - * + * */ public interface UserTransactionFactory { - UserTransaction create(UserTransactionCallback aCallback, List aResources); + UserTransaction create(UserTransactionCallback aCallback, + List aResources); } diff --git a/test/enterprise/src/main/java/org/wamblee/test/transactions/package-info.java b/test/enterprise/src/main/java/org/wamblee/test/transactions/package-info.java index b5e36109..812f67cd 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/transactions/package-info.java +++ b/test/enterprise/src/main/java/org/wamblee/test/transactions/package-info.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** *

* This package provides basic support utilities for testing with transactions. diff --git a/test/enterprise/src/test/java/org/wamblee/test/inject/JavaEETestInjectorFactoryTest.java b/test/enterprise/src/test/java/org/wamblee/test/inject/JavaEETestInjectorFactoryTest.java index 4ad8cad8..4e68bd69 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/inject/JavaEETestInjectorFactoryTest.java +++ b/test/enterprise/src/test/java/org/wamblee/test/inject/JavaEETestInjectorFactoryTest.java @@ -64,7 +64,8 @@ public class JavaEETestInjectorFactoryTest { @Test public void testXyz() { EntityManager em = mock(EntityManager.class); - InjectorBuilder.setInjectorFactory(new JavaEETestInjectorFactory().addEntityManagerBinding(em)); + InjectorBuilder.setInjectorFactory(new JavaEETestInjectorFactory() + .addEntityManagerBinding(em)); X x = new X(); @@ -80,13 +81,14 @@ public class JavaEETestInjectorFactoryTest { public static class Y { @PersistenceContext - Integer wrongType; + private Integer wrongType; } @Test public void testWrongType() { EntityManager em = mock(EntityManager.class); - InjectorBuilder.setInjectorFactory(new JavaEETestInjectorFactory().addEntityManagerBinding(em)); + InjectorBuilder.setInjectorFactory(new JavaEETestInjectorFactory() + .addEntityManagerBinding(em)); Y y = new Y(); InjectorBuilder.getInjector().inject(y); assertNull(y.wrongType); @@ -97,14 +99,14 @@ public class JavaEETestInjectorFactoryTest { public static @interface MyAnnotation { } - + public static class Z { @MyAnnotation private int x; - + // any annotation will force traversal. @Mock - private Z z; + private Z z; } @@ -121,6 +123,5 @@ public class JavaEETestInjectorFactoryTest { assertEquals(100, z.x); assertEquals(100, z.z.x); } - - + } diff --git a/test/enterprise/src/test/java/org/wamblee/test/jndi/StubInitiaContextFactoryTest.java b/test/enterprise/src/test/java/org/wamblee/test/jndi/StubInitiaContextFactoryTest.java index a0ae2d83..1960dac2 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/jndi/StubInitiaContextFactoryTest.java +++ b/test/enterprise/src/test/java/org/wamblee/test/jndi/StubInitiaContextFactoryTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.jndi; import static junit.framework.Assert.*; @@ -42,7 +42,7 @@ public class StubInitiaContextFactoryTest { InitialContext ctx = new InitialContext(); ctx.bind(JNDI_NAME, "hallo"); } - + // String based lookups. @Test @@ -57,15 +57,15 @@ public class StubInitiaContextFactoryTest { assertEquals("hallo", obj); } - + @Test(expected = NameNotFoundException.class) - public void testUnbind() throws Exception { - testLookup(); - InitialContext ctx = new InitialContext(); + public void testUnbind() throws Exception { + testLookup(); + InitialContext ctx = new InitialContext(); ctx.unbind(JNDI_NAME); ctx = new InitialContext(); ctx.lookup(JNDI_NAME); - + } @Test(expected = NameNotFoundException.class) @@ -73,11 +73,11 @@ public class StubInitiaContextFactoryTest { StubInitialContextFactory.register(); InitialContext ctx = new InitialContext(); - Object obj = ctx.lookup(JNDI_NAME); + ctx.lookup(JNDI_NAME); } - + // Name based lookups - + @Test public void testLookupName() throws Exception { StubInitialContextFactory.register(); @@ -90,11 +90,11 @@ public class StubInitiaContextFactoryTest { assertEquals("hallo", obj); } - + @Test(expected = NameNotFoundException.class) - public void testUnbindName() throws Exception { - testLookup(); - InitialContext ctx = new InitialContext(); + public void testUnbindName() throws Exception { + testLookup(); + InitialContext ctx = new InitialContext(); ctx.unbind(new CompositeName(JNDI_NAME)); ctx = new InitialContext(); ctx.lookup(new CompositeName(JNDI_NAME)); @@ -105,6 +105,6 @@ public class StubInitiaContextFactoryTest { StubInitialContextFactory.register(); InitialContext ctx = new InitialContext(); - Object obj = ctx.lookup(JNDI_NAME); + ctx.lookup(JNDI_NAME); } } diff --git a/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseBuilderTest.java b/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseBuilderTest.java index 9a8b205a..70c2c318 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseBuilderTest.java +++ b/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseBuilderTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import org.junit.Test; @@ -31,9 +31,9 @@ public class DatabaseBuilderTest { System.out.println(description); } } - + @Test - public void testConnectionLeak() { + public void testConnectionLeak() { Database db = DatabaseBuilder.getDatabase(); db.start(); assertEquals(0, db.getActiveConnections()); diff --git a/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseUtilsLeakTest.java b/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseUtilsLeakTest.java index a8ff4f41..fdc952bf 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseUtilsLeakTest.java +++ b/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseUtilsLeakTest.java @@ -14,27 +14,26 @@ import org.wamblee.test.persistence.DatabaseUtils; public class DatabaseUtilsLeakTest { private Database db; - private DatabaseUtils dbutils; - + private DatabaseUtils dbutils; + @Before - public void setUp() { + public void setUp() { db = DatabaseBuilder.getDatabase(); - DataSource ds = db.start(); - + DataSource ds = db.start(); + dbutils = new DatabaseUtils(ds); } - + @After - public void tearDown() { - db.stop(); + public void tearDown() { + db.stop(); } - + @Test public void testLeak() throws Exception { - assertEquals(0, db.getActiveConnections()); + assertEquals(0, db.getActiveConnections()); dbutils.dropTables(new MyTables()); assertEquals(0, db.getActiveConnections()); } - - + } diff --git a/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseUtilsTestBase.java b/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseUtilsTestBase.java index 12f3923c..e6ea7ceb 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseUtilsTestBase.java +++ b/test/enterprise/src/test/java/org/wamblee/test/persistence/DatabaseUtilsTestBase.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import static junit.framework.Assert.assertEquals; @@ -52,7 +52,8 @@ public class DatabaseUtilsTestBase { dbutils.dropTables(new MyTables()); dbutils.dropTables(JpaCustomizerBuilder.getCustomizer().getJpaTables()); - builder = new JpaBuilder(db.getJdbcUrl(), db.getUsername(), db.getPassword(), persistenceUnit); + builder = new JpaBuilder(db.getJdbcUrl(), db.getUsername(), db + .getPassword(), persistenceUnit); builder.start(); assertEquals(0, db.getActiveConnections()); diff --git a/test/enterprise/src/test/java/org/wamblee/test/persistence/DerbyDatabaseTest.java b/test/enterprise/src/test/java/org/wamblee/test/persistence/DerbyDatabaseTest.java index b7b31839..8a0b43c8 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/persistence/DerbyDatabaseTest.java +++ b/test/enterprise/src/test/java/org/wamblee/test/persistence/DerbyDatabaseTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import java.sql.Connection; diff --git a/test/enterprise/src/test/java/org/wamblee/test/persistence/ExternalDatabaseTest.java b/test/enterprise/src/test/java/org/wamblee/test/persistence/ExternalDatabaseTest.java index a1ad9823..39515909 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/persistence/ExternalDatabaseTest.java +++ b/test/enterprise/src/test/java/org/wamblee/test/persistence/ExternalDatabaseTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import java.sql.Connection; diff --git a/test/enterprise/src/test/java/org/wamblee/test/persistence/MyEntity.java b/test/enterprise/src/test/java/org/wamblee/test/persistence/MyEntity.java index 42c2378f..bffd5b9f 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/persistence/MyEntity.java +++ b/test/enterprise/src/test/java/org/wamblee/test/persistence/MyEntity.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import javax.persistence.Entity; diff --git a/test/enterprise/src/test/java/org/wamblee/test/persistence/MyPersistenceUnit.java b/test/enterprise/src/test/java/org/wamblee/test/persistence/MyPersistenceUnit.java index ca90304a..441af10c 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/persistence/MyPersistenceUnit.java +++ b/test/enterprise/src/test/java/org/wamblee/test/persistence/MyPersistenceUnit.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import org.wamblee.test.persistence.PersistenceUnitDescription; diff --git a/test/enterprise/src/test/java/org/wamblee/test/persistence/MyTables.java b/test/enterprise/src/test/java/org/wamblee/test/persistence/MyTables.java index 4fee6b25..750dfc87 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/persistence/MyTables.java +++ b/test/enterprise/src/test/java/org/wamblee/test/persistence/MyTables.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import org.dbunit.dataset.DataSetException; diff --git a/test/enterprise/src/test/java/org/wamblee/test/persistence/RequireTransactionStatusTest.java b/test/enterprise/src/test/java/org/wamblee/test/persistence/RequireTransactionStatusTest.java index 6f0049ee..179453c2 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/persistence/RequireTransactionStatusTest.java +++ b/test/enterprise/src/test/java/org/wamblee/test/persistence/RequireTransactionStatusTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.test.persistence; import junit.framework.AssertionFailedError; @@ -23,15 +23,17 @@ import org.wamblee.test.transactions.TransactionResult; public class RequireTransactionStatusTest { @Test - public void testResultOk() { - RequireTransactionStatus callback = new RequireTransactionStatus(TransactionResult.ROLLBACK); + public void testResultOk() { + RequireTransactionStatus callback = new RequireTransactionStatus( + TransactionResult.ROLLBACK); callback.status(TransactionResult.ROLLBACK); - // if we get here everything is ok. + // if we get here everything is ok. } - + @Test(expected = AssertionFailedError.class) - public void testResultWrong() { - RequireTransactionStatus callback = new RequireTransactionStatus(TransactionResult.COMMIT); + public void testResultWrong() { + RequireTransactionStatus callback = new RequireTransactionStatus( + TransactionResult.COMMIT); callback.status(TransactionResult.ROLLBACK); } } diff --git a/test/enterprise/src/test/java/org/wamblee/test/transactions/SimpleTransactionManagerIntegrationTest.java b/test/enterprise/src/test/java/org/wamblee/test/transactions/SimpleTransactionManagerIntegrationTest.java index f200de51..302911c7 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/transactions/SimpleTransactionManagerIntegrationTest.java +++ b/test/enterprise/src/test/java/org/wamblee/test/transactions/SimpleTransactionManagerIntegrationTest.java @@ -27,18 +27,17 @@ import org.junit.Test; public class SimpleTransactionManagerIntegrationTest { - private TransactionResource resource1; private TransactionResource resource2; private Object tx1; private Object tx2; - private SimpleTransactionManager manager; - + private SimpleTransactionManager manager; + @Before public void setUp() { - UserTransactionFactory factory = new DefaultUserTransactionFactory(); - manager = new SimpleTransactionManager(factory); + UserTransactionFactory factory = new DefaultUserTransactionFactory(); + manager = new SimpleTransactionManager(factory); resource1 = mock(TransactionResource.class); resource2 = mock(TransactionResource.class); tx1 = mock(Object.class); @@ -66,13 +65,13 @@ public class SimpleTransactionManagerIntegrationTest { } @Test - public void testTwoTransactions() throws Exception { + public void testTwoTransactions() throws Exception { UserTransaction transaction = manager.getTransaction(); transaction.begin(); transaction.commit(); - + transaction.begin(); - transaction.commit(); + transaction.commit(); } - + } diff --git a/test/enterprise/src/test/java/org/wamblee/test/transactions/SimpleTransactionManagerTest.java b/test/enterprise/src/test/java/org/wamblee/test/transactions/SimpleTransactionManagerTest.java index 1f7afc64..02934c8f 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/transactions/SimpleTransactionManagerTest.java +++ b/test/enterprise/src/test/java/org/wamblee/test/transactions/SimpleTransactionManagerTest.java @@ -92,7 +92,7 @@ public class SimpleTransactionManagerTest { public void testTransactionLifeCycle() throws Exception { manager.getTransaction().getStatus(); UserTransaction transaction = manager.getThreadSpecificTransaction(); - + assertNotNull(transaction); assertEquals(1, callbacks.size()); callbacks.get(0).transactionFinished(); diff --git a/test/enterprise/src/test/java/org/wamblee/test/transactions/TransactionProxyFactoryTestBase.java b/test/enterprise/src/test/java/org/wamblee/test/transactions/TransactionProxyFactoryTestBase.java index 22bb3ff9..d46ce2df 100644 --- a/test/enterprise/src/test/java/org/wamblee/test/transactions/TransactionProxyFactoryTestBase.java +++ b/test/enterprise/src/test/java/org/wamblee/test/transactions/TransactionProxyFactoryTestBase.java @@ -75,13 +75,13 @@ public class TransactionProxyFactoryTestBase { @Test public void testEntityManagerIsPassed() throws Exception { - - + final TransactionProxyFactory factory = new TransactionProxyFactory( jpaTester.getJpaBuilder(), Service.class); - Service service = new Service() { - private EntityManager em = factory.getTransactionScopedEntityManager(); - + Service service = new Service() { + private EntityManager em = factory + .getTransactionScopedEntityManager(); + @Override public int execute(int aValue) throws Exception { assertNotNull(em); @@ -89,14 +89,14 @@ public class TransactionProxyFactoryTestBase { return 0; } }; - + final Service proxy = factory.getProxy(service); jpaTester.getJpaBuilder().execute(new JpaUnitOfWork() { @Override public Void execute(EntityManager aEm) throws Exception { - assert(aEm != null); + assert (aEm != null); proxy.execute(10); - return null; + return null; } }); } -- 2.31.1