Merge "Issue #1543 Clean up test files after changing to Spring transactions" into development
Former-commit-id:66da382ea6
[formerly9f5b5f5346
] [formerly5152c8f857
] [formerly583f76b366
[formerly5152c8f857
[formerly add04e9858bcbd7a503c11606e1d4a820885f980]]] Former-commit-id:583f76b366
Former-commit-id: 7c85db290f0825a127959e9d7bb64c59d7502fbf [formerlyf1f06d0b02
] Former-commit-id:85dfef2c57
This commit is contained in:
commit
e220a8a7bd
17 changed files with 190 additions and 107 deletions
|
@ -13,6 +13,7 @@
|
|||
<classpathentry exported="true" kind="lib" path="spring-jms.jar" sourcepath="spring-framework-2.5.6.zip"/>
|
||||
<classpathentry exported="true" kind="lib" path="spring-orm.jar" sourcepath="spring-framework-2.5.6.zip"/>
|
||||
<classpathentry exported="true" kind="lib" path="spring-tx.jar" sourcepath="spring-framework-2.5.6.zip"/>
|
||||
<classpathentry exported="true" kind="lib" path="spring-test.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
|
BIN
cots/org.springframework/spring-test.jar
Normal file
BIN
cots/org.springframework/spring-test.jar
Normal file
Binary file not shown.
|
@ -0,0 +1,25 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:amq="http://activemq.apache.org/schema/core"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean id="bandwidthAllocationDao"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthAllocationDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="bandwidthSubscriptionDao"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthSubscriptionDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="hibernateBandwidthDao"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
<property name="bandwidthAllocationDao" ref="bandwidthAllocationDao" />
|
||||
<property name="bandwidthSubscriptionDao" ref="bandwidthSubscriptionDao" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -3,7 +3,6 @@
|
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
|
||||
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<!-- Stores beans that are used in bandwidth-datadelivery.xml, but that
|
||||
|
@ -19,20 +18,6 @@
|
|||
<!-- Used as the context for creating the BandwidthManager -->
|
||||
<constructor-arg ref="hibernateBandwidthDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="bandwidthAllocationDao" class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthAllocationDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="bandwidthSubscriptionDao" class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthSubscriptionDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="hibernateBandwidthDao" class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
<property name="bandwidthAllocationDao" ref="bandwidthAllocationDao" />
|
||||
<property name="bandwidthSubscriptionDao" ref="bandwidthSubscriptionDao" />
|
||||
</bean>
|
||||
|
||||
<util:map id="retrievalAgents">
|
||||
<entry key="Retrievals-1" value-ref="subscriptionRetrievalAgentPrototype" />
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="res"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean id="retrievalDao"
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -13,10 +13,6 @@
|
|||
<constructor-arg ref="ddRetrievalDatabaseProperties"/>
|
||||
</bean>
|
||||
|
||||
<bean id="retrievalDao" class="com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="subNotifyTask" class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.SubscriptionNotifyTask" />
|
||||
|
||||
<!-- A RetrievalTask takes three constructor arguments:
|
||||
|
|
|
@ -27,8 +27,8 @@ import org.junit.AfterClass;
|
|||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
|
@ -37,8 +37,6 @@ import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
|||
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.edex.core.EDEXUtil;
|
||||
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.util.BandwidthUtil;
|
||||
|
@ -66,10 +64,13 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
@Ignore
|
||||
public abstract class AbstractBandwidthManagerIntTest {
|
||||
|
||||
@Autowired
|
||||
protected ApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
protected BandwidthManager bandwidthManager;
|
||||
|
||||
@Autowired
|
||||
protected RetrievalManager retrievalManager;
|
||||
|
||||
protected IBandwidthDao bandwidthDao;
|
||||
|
@ -97,6 +98,7 @@ public abstract class AbstractBandwidthManagerIntTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void staticSetup() throws IOException {
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
Properties properties = PropertiesUtil
|
||||
.read(AbstractBandwidthManagerIntTest.class
|
||||
.getResourceAsStream("/com.raytheon.uf.edex.datadelivery.bandwidth.properties"));
|
||||
|
@ -112,17 +114,9 @@ public abstract class AbstractBandwidthManagerIntTest {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
DatabaseUtil.start();
|
||||
context = new ClassPathXmlApplicationContext(
|
||||
IntegrationTestBandwidthManager.INTEGRATION_TEST_SPRING_FILES,
|
||||
BandwidthManagerIntTest.class, EDEXUtil.getSpringContext());
|
||||
bandwidthDao = (IBandwidthDao) context.getBean("bandwidthDao",
|
||||
IBandwidthDao.class);
|
||||
bandwidthManager = (BandwidthManager) context.getBean(
|
||||
"bandwidthManager",
|
||||
BandwidthManager.class);
|
||||
retrievalManager = bandwidthManager.retrievalManager;
|
||||
bandwidthDao = IBandwidthDao.class
|
||||
.cast(context.getBean("bandwidthDao"));
|
||||
|
||||
fullBucketSize = retrievalManager.getPlan(Network.OPSNET)
|
||||
.getBucket(TimeUtil.currentTimeMillis()).getBucketSize();
|
||||
|
@ -132,6 +126,7 @@ public abstract class AbstractBandwidthManagerIntTest {
|
|||
|
||||
@After
|
||||
public void tearDown() {
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
try {
|
||||
bandwidthManager.shutdown();
|
||||
} catch (IllegalArgumentException iae) {
|
||||
|
@ -139,7 +134,6 @@ public abstract class AbstractBandwidthManagerIntTest {
|
|||
// event bus handler
|
||||
iae.printStackTrace();
|
||||
}
|
||||
DatabaseUtil.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,6 +42,11 @@ import java.util.concurrent.BlockingQueue;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataDeliveryRegistryObjectTypes;
|
||||
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSetMetaData;
|
||||
|
@ -61,7 +66,9 @@ import com.raytheon.uf.common.serialization.SerializationException;
|
|||
import com.raytheon.uf.common.time.util.ImmutableDate;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.time.util.TimeUtilTest;
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.common.util.TestUtil;
|
||||
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
|
@ -94,6 +101,13 @@ import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
|
|||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_XML })
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
|
||||
|
||||
@Test
|
||||
|
|
|
@ -37,6 +37,11 @@ import java.util.Set;
|
|||
import java.util.SortedSet;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.BandwidthService;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest;
|
||||
|
@ -50,6 +55,8 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
|||
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.BandwidthMap;
|
||||
|
@ -74,7 +81,13 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_XML })
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
|
||||
|
||||
private static final int ONE_HUNDRED = 100;
|
||||
|
|
|
@ -40,30 +40,7 @@
|
|||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="bandwidthAllocationDao"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthAllocationDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="bandwidthSubscriptionDao"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthSubscriptionDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="hibernateBandwidthDao"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
<property name="bandwidthAllocationDao" ref="bandwidthAllocationDao" />
|
||||
<property name="bandwidthSubscriptionDao" ref="bandwidthSubscriptionDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="retrievalDao" class="com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="mockService" class="com.raytheon.uf.edex.database.dao.MockService">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
<property name="bandwidthService" ref="hibernateBandwidthDao" />
|
||||
</bean>
|
||||
<!-- Register the application context with EDEXUtil -->
|
||||
<bean class="com.raytheon.uf.edex.core.EDEXUtil" />
|
||||
|
||||
</beans>
|
56
tests/unit/com/raytheon/uf/common/util/SpringFiles.java
Normal file
56
tests/unit/com/raytheon/uf/common/util/SpringFiles.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* 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.common.util;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
* Utility class for Spring integration.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 12, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@Ignore
|
||||
public class SpringFiles {
|
||||
|
||||
/**
|
||||
* Disabled constructor.
|
||||
*/
|
||||
private SpringFiles() {
|
||||
}
|
||||
|
||||
public static final String RETRIEVAL_DATADELIVERY_DAOS_XML = "/spring/retrieval-datadelivery-daos.xml";
|
||||
|
||||
public static final String BANDWIDTH_DATADELIVERY_DAOS_XML = "/spring/bandwidth-datadelivery-daos.xml";
|
||||
|
||||
public static final String BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML = "/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml";
|
||||
|
||||
public static final String BANDWIDTH_DATADELIVERY_XML = "/spring/bandwidth-datadelivery.xml";
|
||||
}
|
|
@ -48,7 +48,7 @@ public final class DatabaseUtil {
|
|||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(DatabaseUtil.class);
|
||||
|
||||
private static final String UNIT_TEST_DB_BEANS_XML = "/unit-test-db-beans.xml";
|
||||
public static final String UNIT_TEST_DB_BEANS_XML = "/unit-test-db-beans.xml";
|
||||
|
||||
private static ApplicationContext originalApplicationContext;
|
||||
|
||||
|
|
|
@ -24,11 +24,13 @@ import static org.hamcrest.Matchers.is;
|
|||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDaoFixture;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
|
@ -51,6 +53,11 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthD
|
|||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
|
||||
"sessionManagedServiceTest.xml" })
|
||||
public class SessionManagedServiceTest {
|
||||
|
||||
private final BandwidthSubscription subscription = SubscriptionDaoFixture.INSTANCE
|
||||
|
@ -62,24 +69,12 @@ public class SessionManagedServiceTest {
|
|||
subscriptionRetrieval.setBandwidthSubscription(subscription);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private HibernateBandwidthDao bandwidthService;
|
||||
|
||||
@Autowired
|
||||
private MockService service;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseUtil.start();
|
||||
|
||||
service = (MockService) EDEXUtil.getESBComponent("mockService");
|
||||
bandwidthService = (HibernateBandwidthDao) EDEXUtil
|
||||
.getESBComponent("hibernateBandwidthDao");
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
DatabaseUtil.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exceptionThrownInDaoWillRollbackTransaction() {
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
|
||||
<bean id="mockService" class="com.raytheon.uf.edex.database.dao.MockService">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
<property name="bandwidthService" ref="hibernateBandwidthDao" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -19,10 +19,14 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao;
|
||||
|
||||
|
@ -43,32 +47,23 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthD
|
|||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML })
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class HibernateBandwidthDaoTest extends
|
||||
AbstractBandwidthDaoTest<HibernateBandwidthDao> {
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseUtil.start();
|
||||
|
||||
// The database must be started before constructing the DAO for
|
||||
// Hibernate
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
DatabaseUtil.shutdown();
|
||||
}
|
||||
@Autowired
|
||||
private HibernateBandwidthDao dao;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected HibernateBandwidthDao getDao() {
|
||||
return (HibernateBandwidthDao) EDEXUtil
|
||||
.getESBComponent("hibernateBandwidthDao");
|
||||
return dao;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,9 +29,12 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSetMetaDataFixture;
|
||||
|
@ -43,6 +46,7 @@ import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
|||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
|
||||
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;
|
||||
|
@ -68,11 +72,17 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.Sta
|
|||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML })
|
||||
public class SubscriptionRetrievalAgentTest {
|
||||
|
||||
@Autowired
|
||||
private RetrievalDao retrievalDao;
|
||||
|
||||
@Before
|
||||
public void setUp() throws RegistryHandlerException {
|
||||
DatabaseUtil.start();
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
RegistryObjectHandlersUtil.initMocks();
|
||||
when(DataDeliveryHandlers.getProviderHandler().getByName(anyString()))
|
||||
|
@ -83,11 +93,6 @@ public class SubscriptionRetrievalAgentTest {
|
|||
OpenDapGriddedDataSetMetaDataFixture.INSTANCE.get());
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
DatabaseUtil.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void opsnetRoutedSubscriptionsCreateRetrievalsInPendingState()
|
||||
throws EdexException, SerializationException {
|
||||
|
@ -120,8 +125,7 @@ public class SubscriptionRetrievalAgentTest {
|
|||
};
|
||||
agent.processAllocation(subscriptionRetrieval);
|
||||
|
||||
RetrievalDao dao = RetrievalDao.getInstance();
|
||||
final List<RetrievalRequestRecord> requests = dao
|
||||
final List<RetrievalRequestRecord> requests = retrievalDao
|
||||
.getRequests(subscription.getName());
|
||||
assertThat(requests,
|
||||
is(not(emptyCollectionOf(RetrievalRequestRecord.class))));
|
||||
|
|
Loading…
Add table
Reference in a new issue