diff --git a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/RegistryUtil.java b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/RegistryUtil.java index b063ad16b7..1f2694a8fb 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/RegistryUtil.java +++ b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/RegistryUtil.java @@ -75,6 +75,7 @@ import com.raytheon.uf.common.util.ReflectionUtil; * Sep 07, 2012 1102 djohnson Check in hanging around encoding strategy code that will prove useful later. * Oct 05, 2012 1195 djohnson Don't persist slots for null values. * 4/9/2013 1802 bphillip Pulled constants out into existing constants package that was moved into common + * Jun 03, 2013 2038 djohnson Allow setting the same encoder strategy. * * * @@ -172,7 +173,7 @@ public final class RegistryUtil { * has been set */ public static void setEncoderStrategy(IRegistryEncoder encoder) { - if (ENCODER_STRATEGY != null) { + if (ENCODER_STRATEGY != null && !ENCODER_STRATEGY.equals(encoder)) { throw new IllegalStateException( "The encoder strategy is already set, you cannot change it on a running system!"); } diff --git a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/ContentSlotBasedEncoder.java b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/ContentSlotBasedEncoder.java index 048a7ad0fc..f6f0253446 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/ContentSlotBasedEncoder.java +++ b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/ContentSlotBasedEncoder.java @@ -25,6 +25,9 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SlotType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ValueType; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + import com.raytheon.uf.common.serialization.SerializationException; /** @@ -39,7 +42,8 @@ import com.raytheon.uf.common.serialization.SerializationException; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 7, 2012 1102 djohnson Initial creation + * Sep 07, 2012 1102 djohnson Initial creation + * Jun 03, 2013 2038 djohnson Add equals/hashcode. * * * @@ -54,7 +58,19 @@ abstract class ContentSlotBasedEncoder other = (ContentSlotBasedEncoder) obj; + + EqualsBuilder builder = new EqualsBuilder(); + builder.append(this.type, other.type); + return builder.isEquals(); + } + return super.equals(obj); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(type); + + return builder.toHashCode(); + } + /** * Create a new instance of the slot value type and place the encoded object * as the value. diff --git a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/DynamicSerializeEncoder.java b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/DynamicSerializeEncoder.java index 6f463b17a1..5d0c30e896 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/DynamicSerializeEncoder.java +++ b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/DynamicSerializeEncoder.java @@ -19,6 +19,8 @@ **/ package com.raytheon.uf.common.registry.ebxml.encoder; +import static com.raytheon.uf.common.registry.ebxml.encoder.RegistryEncoders.Type.DYNAMIC_SERIALIZE; + import org.apache.commons.codec.binary.Base64; import com.raytheon.uf.common.serialization.SerializationException; @@ -36,7 +38,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 7, 2012 1102 djohnson Initial creation + * Sep 07, 2012 1102 djohnson Initial creation + * Jun 03, 2013 2038 djohnson Add equals/hashcode. * * * @@ -45,13 +48,20 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; */ class DynamicSerializeEncoder extends StringBasedEncoder { + /** + * @param type + */ + DynamicSerializeEncoder() { + super(DYNAMIC_SERIALIZE); + } + /** * {@inheritDoc} */ @Override Object decodeContent(String content) throws SerializationException { - return SerializationUtil.transformFromThrift(Base64 - .decodeBase64(content)); + return SerializationUtil.transformFromThrift(Object.class, + Base64.decodeBase64(content)); } /** diff --git a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/JaxbEncoder.java b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/JaxbEncoder.java index da5ea1f482..3fae40334a 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/JaxbEncoder.java +++ b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/JaxbEncoder.java @@ -19,6 +19,8 @@ **/ package com.raytheon.uf.common.registry.ebxml.encoder; +import static com.raytheon.uf.common.registry.ebxml.encoder.RegistryEncoders.Type.JAXB; + import javax.xml.bind.JAXBException; import com.raytheon.uf.common.serialization.SerializationException; @@ -34,7 +36,8 @@ import com.raytheon.uf.common.serialization.SerializationUtil; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 7, 2012 1102 djohnson Initial creation + * Sep 07, 2012 1102 djohnson Initial creation + * Jun 03, 2013 2038 djohnson Add equals/hashcode. * * * @@ -44,13 +47,20 @@ import com.raytheon.uf.common.serialization.SerializationUtil; class JaxbEncoder extends StringBasedEncoder { + /** + * @param type + */ + JaxbEncoder() { + super(JAXB); + } + /** * {@inheritDoc} */ @Override Object decodeContent(String content) throws SerializationException { try { - return SerializationUtil.unmarshalFromXml(content); + return SerializationUtil.unmarshalFromXml(Object.class, content); } catch (JAXBException e) { throw new SerializationException("Unable to decode the object!", e); } diff --git a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/StringBasedEncoder.java b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/StringBasedEncoder.java index 24168de78c..21fadc16d6 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/StringBasedEncoder.java +++ b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/ebxml/encoder/StringBasedEncoder.java @@ -21,6 +21,8 @@ package com.raytheon.uf.common.registry.ebxml.encoder; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.StringValueType; +import com.raytheon.uf.common.registry.ebxml.encoder.RegistryEncoders.Type; + /** * A string-based encoding strategy. Package-private because we want the * encoding strategies to remain implementation details that are separate from @@ -32,7 +34,8 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.StringValueType; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 7, 2012 1102 djohnson Initial creation + * Sep 07, 2012 1102 djohnson Initial creation + * Jun 03, 2013 2038 djohnson Add equals/hashcode. * * * @@ -42,6 +45,16 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.StringValueType; abstract class StringBasedEncoder extends ContentSlotBasedEncoder { + /** + * Constructor. Intentionally package-private. + * + * @param type + * the type + */ + StringBasedEncoder(Type type) { + super(type); + } + /** * {@inheritDoc} */ diff --git a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/handler/RegistryObjectHandlers.java b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/handler/RegistryObjectHandlers.java index d0055b6d3d..b4710abbb7 100644 --- a/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/handler/RegistryObjectHandlers.java +++ b/edexOsgi/com.raytheon.uf.common.registry.ebxml/src/com/raytheon/uf/common/registry/handler/RegistryObjectHandlers.java @@ -19,11 +19,13 @@ **/ package com.raytheon.uf.common.registry.handler; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - import com.google.common.annotations.VisibleForTesting; import com.raytheon.uf.common.registry.annotations.RegistryObject; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.util.registry.GenericRegistry; +import com.raytheon.uf.common.util.registry.RegistryException; /** * Register or find {@link IRegistryObjectHandler} implementations. @@ -36,6 +38,7 @@ import com.raytheon.uf.common.registry.annotations.RegistryObject; * ------------ ---------- ----------- -------------------------- * Sep 17, 2012 1169 djohnson Initial creation * Oct 16, 2012 0726 djohnson Add the ability to use a pojo instance which delegates to static methods. + * Jun 03, 2013 2038 djohnson Change to use a {@link GenericRegistry}. * * * @@ -45,7 +48,11 @@ import com.raytheon.uf.common.registry.annotations.RegistryObject; public final class RegistryObjectHandlers { - private static final ConcurrentMap> handlers = new ConcurrentHashMap>(); + private static IUFStatusHandler statusHandler = UFStatus + .getHandler(RegistryObjectHandlers.class); + + private static final GenericRegistry> handlers = new GenericRegistry>() { + }; // Used to simplify the Spring files private static final RegistryObjectHandlers INSTANCE = new RegistryObjectHandlers(); @@ -87,8 +94,10 @@ public final class RegistryObjectHandlers { * the registry object handler interface * @param handler * the handler + * @throws IllegalArgumentException + * if the handlerInterface parameter is not an interface * @throws IllegalStateException - * if a second handler is registered for any interface + * on an error registering the handler */ public static > void register( Class handlerInterface, T handler) throws IllegalStateException { @@ -98,14 +107,16 @@ public final class RegistryObjectHandlers { "Implementations must be registered under their interfaces!"); } - IRegistryObjectHandler previous = handlers.putIfAbsent( - handlerInterface.getName(), handler); - if (previous != null) { - throw new IllegalStateException( - String.format( - "Attempt to associate handler [%s] with handler interface [%s] fails, because [%s] is already associated with it!", - handler.getClass().getName(), handlerInterface - .getName(), previous.getClass().getName())); + if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { + statusHandler.handle(Priority.DEBUG, String.format( + "Associating handler [%s] with handler interface [%s]", + handler.getClass().getName(), handlerInterface.getName())); + } + + try { + handlers.register(handlerInterface.getName(), handler); + } catch (RegistryException e) { + throw new IllegalStateException(e); } } @@ -114,7 +125,7 @@ public final class RegistryObjectHandlers { */ @VisibleForTesting static void clear() { - handlers.clear(); + handlers.getRegisteredObjects().clear(); } /** @@ -123,9 +134,10 @@ public final class RegistryObjectHandlers { * the handler interface * @return * the implementation + * @throws IllegalArgumentException if no handler is registered for the specific interface */ public static T get(Class handlerInterface) { - Object obj = handlers.get(handlerInterface.getName()); + Object obj = handlers.getRegisteredObject(handlerInterface.getName()); if (obj == null) { throw new IllegalArgumentException( diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java index c276abe089..2bbaac13a6 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/dao/DbInit.java @@ -45,13 +45,14 @@ import org.apache.commons.beanutils.PropertyUtils; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.jdbc.Work; -import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionCallbackWithoutResult; import org.springframework.transaction.support.TransactionTemplate; +import com.google.common.annotations.VisibleForTesting; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.registry.ebxml.RegistryUtil; @@ -89,9 +90,10 @@ import com.raytheon.uf.edex.registry.ebxml.init.RegistryInitializedListener; */ @Transactional public class DbInit extends com.raytheon.uf.edex.database.init.DbInit implements - ApplicationListener { + ApplicationListener { - private static volatile boolean INITIALIZED = false; + @VisibleForTesting + static volatile boolean INITIALIZED = false; /** The logger */ private static final IUFStatusHandler statusHandler = UFStatus @@ -317,7 +319,7 @@ public class DbInit extends com.raytheon.uf.edex.database.init.DbInit implements } @Override - public void onApplicationEvent(ApplicationEvent event) { + public void onApplicationEvent(ContextRefreshedEvent event) { if (!INITIALIZED) { txTemplate.execute(new TransactionCallbackWithoutResult() { @Override diff --git a/tests/build.properties b/tests/build.properties index 282b951748..e7046f1c3c 100644 --- a/tests/build.properties +++ b/tests/build.properties @@ -5,6 +5,13 @@ testTypes=unit,integration #testTypes=unit,integration,deploy TEST.INCLUSION.PATTERN=**/*Test.java +unit.FORK.TESTS=off +unit.FORK.MODE=perTest +unit.FORK.CLONEVM=false +# Fork the integration tests because they don't clean up as well as they should +integration.FORK.TESTS=on +integration.FORK.MODE=perTest +integration.FORK.CLONEVM=false # Important directories WORKING.DIR=${basedir}/tmp diff --git a/tests/build.xml b/tests/build.xml index db812f64b0..ad53340d50 100644 --- a/tests/build.xml +++ b/tests/build.xml @@ -13,6 +13,7 @@ + @@ -85,9 +86,13 @@ + + + + - - + + @@ -101,11 +106,8 @@ - - - - - + + diff --git a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/AbstractBandwidthManagerIntTest.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/AbstractBandwidthManagerIntTest.java index d33b526ad0..a6fdca7130 100644 --- a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/AbstractBandwidthManagerIntTest.java +++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/AbstractBandwidthManagerIntTest.java @@ -48,7 +48,6 @@ import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.common.time.util.TimeUtilTest; import com.raytheon.uf.common.util.PropertiesUtil; import com.raytheon.uf.common.util.SpringFiles; -import com.raytheon.uf.edex.database.dao.DatabaseUtil; import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao; import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager; import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan; @@ -78,7 +77,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil; * @version 1.0 */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML, +@ContextConfiguration(locations = { SpringFiles.UNIT_TEST_DB_BEANS_XML, SpringFiles.EVENTBUS_COMMON_XML, SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML, SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML, diff --git a/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/AbstractRegistryTest.java b/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/AbstractRegistryTest.java index 78e1435d9c..8e9e97d25c 100644 --- a/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/AbstractRegistryTest.java +++ b/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/AbstractRegistryTest.java @@ -47,6 +47,8 @@ import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType; import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseStatus; import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseType; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -58,7 +60,6 @@ import org.springframework.transaction.annotation.Transactional; import com.google.common.collect.Lists; import com.raytheon.uf.common.registry.ebxml.RegistryUtil; import com.raytheon.uf.common.util.SpringFiles; -import com.raytheon.uf.edex.database.dao.DatabaseUtil; import com.raytheon.uf.edex.registry.ebxml.services.query.QueryConstants; import com.raytheon.uf.edex.registry.ebxml.services.query.QueryManagerImpl.RETURN_TYPE; import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil; @@ -90,7 +91,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil; SpringFiles.EBXML_WEBSERVICES_XML, SpringFiles.EBXML_XACML_XML, SpringFiles.EBXML_VALIDATOR_PLUGINS_XML, SpringFiles.EBXML_SUBSCRIPTION_XML, SpringFiles.EVENTBUS_COMMON_XML, - DatabaseUtil.UNIT_TEST_DB_BEANS_XML, + SpringFiles.UNIT_TEST_DB_BEANS_XML, SpringFiles.UNIT_TEST_EBXML_BEANS_XML, SpringFiles.UNIT_TEST_LOCALIZATION_BEANS_XML }) @TransactionConfiguration(transactionManager = "metadataTxManager", defaultRollback = true) @@ -108,6 +109,12 @@ public class AbstractRegistryTest { @Autowired protected QueryManager queryManager; + @BeforeClass + @AfterClass + public static void resetDbInitialized() { + DbInit.INITIALIZED = false; + } + /** * Submits the registry object to the registry and verifies it was * successfully processed. diff --git a/tests/resources/schema.sql b/tests/resources/schema.sql new file mode 100644 index 0000000000..f28e65ba60 --- /dev/null +++ b/tests/resources/schema.sql @@ -0,0 +1 @@ +create schema IF NOT EXISTS ebxml; \ No newline at end of file diff --git a/tests/resources/unit-test-db-beans.properties b/tests/resources/unit-test-db-beans.properties deleted file mode 100644 index ffeb9d009e..0000000000 --- a/tests/resources/unit-test-db-beans.properties +++ /dev/null @@ -1 +0,0 @@ -unit.test.jdbc.url=jdbc:h2:mem:unit-testing \ No newline at end of file diff --git a/tests/resources/unit-test-db-beans.xml b/tests/resources/unit-test-db-beans.xml index e3504e2868..c7c46174d3 100644 --- a/tests/resources/unit-test-db-beans.xml +++ b/tests/resources/unit-test-db-beans.xml @@ -1,17 +1,46 @@ - - - - classpath:/unit-test-db-beans.properties + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/tx + http://www.springframework.org/schema/tx/spring-tx.xsd + http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd"> + + + + + + com.raytheon.uf.edex.datadelivery.bandwidth.dao + com.raytheon.uf.edex.datadelivery.retrieval.db + oasis.names.tc.ebxml.regrep.xsd.rim.v4 + + + + classpath:unit-test-hibernate.cfg.xml - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/resources/unit-test-db-beans2.properties b/tests/resources/unit-test-db-beans2.properties deleted file mode 100644 index 42de977f6e..0000000000 --- a/tests/resources/unit-test-db-beans2.properties +++ /dev/null @@ -1 +0,0 @@ -unit.test.jdbc.url=jdbc:h2:mem:unit-testing2 \ No newline at end of file diff --git a/tests/resources/unit-test-db-beans2.xml b/tests/resources/unit-test-db-beans2.xml deleted file mode 100644 index 3659363320..0000000000 --- a/tests/resources/unit-test-db-beans2.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - classpath:/unit-test-db-beans2.properties - - - - - - - \ No newline at end of file diff --git a/tests/resources/unit-test-db-session.xml b/tests/resources/unit-test-db-session.xml deleted file mode 100644 index b5141866d8..0000000000 --- a/tests/resources/unit-test-db-session.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - com.raytheon.uf.edex.datadelivery.bandwidth.dao - com.raytheon.uf.edex.datadelivery.retrieval.db - oasis.names.tc.ebxml.regrep.xsd.rim.v4 - - - - classpath:unit-test-hibernate.cfg.xml - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/runTests.sh b/tests/runTests.sh index 85c426abaa..64379170e1 100644 --- a/tests/runTests.sh +++ b/tests/runTests.sh @@ -10,5 +10,5 @@ then export MAX_PERMGEN_SIZE="192m" fi -export ANT_OPTS="-XX:PermSize=${INITIAL_PERMGEN_SIZE} -XX:MaxPermSize=${MAX_PERMGEN_SIZE}" +export ANT_OPTS="-XX:PermSize=${INITIAL_PERMGEN_SIZE} -XX:MaxPermSize=${MAX_PERMGEN_SIZE} $*" ant diff --git a/tests/unit/com/raytheon/uf/common/registry/handler/RegistryObjectHandlersTest.java b/tests/unit/com/raytheon/uf/common/registry/handler/RegistryObjectHandlersTest.java index 334b8715f1..146e89df8f 100644 --- a/tests/unit/com/raytheon/uf/common/registry/handler/RegistryObjectHandlersTest.java +++ b/tests/unit/com/raytheon/uf/common/registry/handler/RegistryObjectHandlersTest.java @@ -67,8 +67,8 @@ public class RegistryObjectHandlersTest { RegistryObjectHandlers.get(IMockRegistryObjectHandler.class)); } - @Test(expected = IllegalStateException.class) - public void testAssociatingTwoHandlersWithSameInterfaceThrowsException() { + @Test + public void testAssociatingTwoHandlersWithSameInterfaceDoesNotThrowException() { RegistryObjectHandlers.register(IMockRegistryObjectHandler.class, new MockRegistryObjectHandler()); RegistryObjectHandlers.register(IMockRegistryObjectHandler.class, diff --git a/tests/unit/com/raytheon/uf/common/util/SpringFiles.java b/tests/unit/com/raytheon/uf/common/util/SpringFiles.java index b4200983fa..7d819d21b7 100644 --- a/tests/unit/com/raytheon/uf/common/util/SpringFiles.java +++ b/tests/unit/com/raytheon/uf/common/util/SpringFiles.java @@ -93,6 +93,8 @@ public class SpringFiles { public static final String EVENTBUS_COMMON_XML = "/spring/eventbus-common.xml"; + public static final String UNIT_TEST_DB_BEANS_XML = "/unit-test-db-beans.xml"; + public static final String UNIT_TEST_LOCALIZATION_BEANS_XML = "/unit-test-localization-beans.xml"; public static final String UNIT_TEST_EBXML_BEANS_XML = "/ebxml/unit-test-ebxml-beans.xml"; diff --git a/tests/unit/com/raytheon/uf/edex/database/dao/DatabaseUtil.java b/tests/unit/com/raytheon/uf/edex/database/dao/DatabaseUtil.java deleted file mode 100644 index e3d017e769..0000000000 --- a/tests/unit/com/raytheon/uf/edex/database/dao/DatabaseUtil.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.edex.database.dao; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.edex.core.EDEXUtil; - -/** - * Utility class for test classes to start and stop an in-memory database. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Oct 10, 2012 0726       djohnson     Initial creation
- * Feb 27, 2013 1644       djohnson     Add constant for second in-memory database Spring file.
- * 
- * 
- * - * @author djohnson - * @version 1.0 - */ - -public final class DatabaseUtil { - - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(DatabaseUtil.class); - - public static final String UNIT_TEST_DB_BEANS_XML = "/unit-test-db-beans.xml"; - - public static final String UNIT_TEST_DB_BEANS2_XML = "/unit-test-db-beans2.xml"; - - private static ApplicationContext originalApplicationContext; - - private static ClassPathXmlApplicationContext applicationContext; - - /** - * No construction. - */ - private DatabaseUtil() { - } - - /** - * Start the in-memory database for unit testing code that utilizes the - * database. This should be called in the @Before section of a JUnit test, - * and {@link #shutdown()} should be called in the @After section. - */ - public static void start() { - statusHandler.debug("Starting the in-memory database."); - - originalApplicationContext = EDEXUtil.getSpringContext(); - applicationContext = new ClassPathXmlApplicationContext( - UNIT_TEST_DB_BEANS_XML, DatabaseUtil.class); - new EDEXUtil().setApplicationContext(applicationContext); - - statusHandler.debug("Started."); - } - - /** - * Shutdown the database. Should be called in the @After section of a JUnit - * test. - */ - public static void shutdown() { - statusHandler.debug("Stopping the in-memory database."); - - if (applicationContext != null) { - applicationContext.close(); - applicationContext = null; - } - new EDEXUtil().setApplicationContext(originalApplicationContext); - originalApplicationContext = null; - - statusHandler.debug("Stopped."); - } -} \ No newline at end of file diff --git a/tests/unit/com/raytheon/uf/edex/database/dao/SessionManagedServiceTest.java b/tests/unit/com/raytheon/uf/edex/database/dao/SessionManagedServiceTest.java index 2ca66c2f99..d381894184 100644 --- a/tests/unit/com/raytheon/uf/edex/database/dao/SessionManagedServiceTest.java +++ b/tests/unit/com/raytheon/uf/edex/database/dao/SessionManagedServiceTest.java @@ -54,7 +54,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrievalFixt * @version 1.0 */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML, +@ContextConfiguration(locations = { SpringFiles.UNIT_TEST_DB_BEANS_XML, SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML, SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML, "sessionManagedServiceTest.xml" }) diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/HibernateBandwidthDaoTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/HibernateBandwidthDaoTest.java index b039a83c17..d4d793f940 100644 --- a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/HibernateBandwidthDaoTest.java +++ b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/HibernateBandwidthDaoTest.java @@ -27,7 +27,6 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.raytheon.uf.common.util.SpringFiles; -import com.raytheon.uf.edex.database.dao.DatabaseUtil; import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao; import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao; @@ -49,7 +48,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthD * @version 1.0 */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML, +@ContextConfiguration(locations = { SpringFiles.UNIT_TEST_DB_BEANS_XML, SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML, SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML }) @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/retrieval/SubscriptionRetrievalAgentTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/retrieval/SubscriptionRetrievalAgentTest.java index f4b2c958ff..9c85d573a0 100644 --- a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/retrieval/SubscriptionRetrievalAgentTest.java +++ b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/retrieval/SubscriptionRetrievalAgentTest.java @@ -50,7 +50,6 @@ import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.util.SpringFiles; import com.raytheon.uf.edex.core.EdexException; import com.raytheon.uf.edex.database.DataAccessLayerException; -import com.raytheon.uf.edex.database.dao.DatabaseUtil; import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao; import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval; import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao; @@ -74,7 +73,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.Sta * @version 1.0 */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML, +@ContextConfiguration(locations = { SpringFiles.UNIT_TEST_DB_BEANS_XML, SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML, SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML }) public class SubscriptionRetrievalAgentTest { diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTaskTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTaskTest.java index 393e07d788..98c83d1a57 100644 --- a/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTaskTest.java +++ b/tests/unit/com/raytheon/uf/edex/datadelivery/retrieval/handlers/RetrievalTaskTest.java @@ -62,7 +62,6 @@ import com.raytheon.uf.common.util.SpringFiles; import com.raytheon.uf.common.util.TestUtil; import com.raytheon.uf.common.util.file.FilenameFilters; import com.raytheon.uf.edex.database.DataAccessLayerException; -import com.raytheon.uf.edex.database.dao.DatabaseUtil; import com.raytheon.uf.edex.datadelivery.retrieval.ServiceTypeFactory; import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter; import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao; @@ -93,7 +92,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse * @version 1.0 */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML, +@ContextConfiguration(locations = { SpringFiles.UNIT_TEST_DB_BEANS_XML, SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML }) @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) public class RetrievalTaskTest { diff --git a/tests/unit/com/raytheon/uf/edex/registry/ebxml/dao/HsqlEbxmlDbInit.java b/tests/unit/com/raytheon/uf/edex/registry/ebxml/dao/HsqlEbxmlDbInit.java index 948cdf6ba6..54292ae135 100644 --- a/tests/unit/com/raytheon/uf/edex/registry/ebxml/dao/HsqlEbxmlDbInit.java +++ b/tests/unit/com/raytheon/uf/edex/registry/ebxml/dao/HsqlEbxmlDbInit.java @@ -19,6 +19,8 @@ **/ package com.raytheon.uf.edex.registry.ebxml.dao; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; /** * Extends {@link DbInit} to load the database for HSQL. @@ -42,6 +44,7 @@ public class HsqlEbxmlDbInit extends DbInit { * {@inheritDoc} */ @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) public void initDb() throws Exception { populateDB(); }