activeForRoutes = DataDeliveryHandlers
+ .getSubscriptionHandler().getActiveForRoutes(routes);
+ return Sets.newHashSet(activeForRoutes);
+ }
+
+}
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/utility/common_static/base/datadelivery/bandwidthmap.xml b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/utility/common_static/base/datadelivery/bandwidthmap.xml
index 0760676f36..ca5e4b1254 100644
--- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/utility/common_static/base/datadelivery/bandwidthmap.xml
+++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/utility/common_static/base/datadelivery/bandwidthmap.xml
@@ -2,4 +2,6 @@
+
+
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 6db3d47b5c..8f1dd04136 100644
--- a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/AbstractBandwidthManagerIntTest.java
+++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/AbstractBandwidthManagerIntTest.java
@@ -19,6 +19,11 @@
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+
import java.io.IOException;
import java.util.Properties;
@@ -39,6 +44,7 @@ import com.raytheon.uf.common.time.util.TimeUtilTest;
import com.raytheon.uf.common.util.PropertiesUtil;
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;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
/**
@@ -55,6 +61,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* Dec 11, 2012 1286 djohnson Use a synchronous event bus for tests.
* Dec 11, 2012 1403 djohnson No longer valid to run without bandwidth management.
* Feb 07, 2013 1543 djohnson Remove unnecessary test setup methods.
+ * Feb 20, 2013 1543 djohnson Delegate to sub-classes for which route to create subscriptions for.
*
*
*
@@ -118,7 +125,8 @@ public abstract class AbstractBandwidthManagerIntTest {
bandwidthDao = IBandwidthDao.class
.cast(context.getBean("bandwidthDao"));
- fullBucketSize = retrievalManager.getPlan(Network.OPSNET)
+ fullBucketSize = retrievalManager
+ .getPlan(getRouteToUseForSubscription())
.getBucket(TimeUtil.currentTimeMillis()).getBucketSize();
halfBucketSize = fullBucketSize / 2;
thirdBucketSizeInBytes = fullBucketSize / 3;
@@ -186,6 +194,41 @@ public abstract class AbstractBandwidthManagerIntTest {
.get(subscriptionSeed++);
subscription.setDataSetSize(BandwidthUtil
.convertBytesToKilobytes(bytes));
+ subscription.setRoute(getRouteToUseForSubscription());
+
return subscription;
}
+
+ /**
+ * Retrieve the {@link Network} that subscriptions should be created for.
+ *
+ * @return the {@link Network}
+ */
+ protected abstract Network getRouteToUseForSubscription();
+
+ /**
+ * Verify the bandwidth manager has a retrieval plan configured for the
+ * specified route.
+ *
+ * @param route
+ */
+ protected void verifyRetrievalPlanExistsForRoute(Network route) {
+ final RetrievalPlan retrievalPlan = EdexBandwidthContextFactory
+ .getInstance().retrievalManager.getPlan(route);
+
+ assertThat(retrievalPlan, is(notNullValue(RetrievalPlan.class)));
+ }
+
+ /**
+ * Verify the bandwidth manager does not have a retrieval plan configured
+ * for the specified route.
+ *
+ * @param route
+ */
+ protected void verifyRetrievalPlanDoesNotExistForRoute(Network route) {
+ final RetrievalPlan retrievalPlan = EdexBandwidthContextFactory
+ .getInstance().retrievalManager.getPlan(route);
+
+ assertThat(retrievalPlan, is(nullValue(RetrievalPlan.class)));
+ }
}
diff --git a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManagerIntTest.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManagerIntTest.java
index 33b92dfc76..3d8a5912bf 100644
--- a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManagerIntTest.java
+++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManagerIntTest.java
@@ -110,8 +110,10 @@ import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
+ SpringFiles.BANDWIDTH_DATADELIVERY_XML,
+ SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
- SpringFiles.BANDWIDTH_DATADELIVERY_XML })
+ SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_WFO_XML })
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
@@ -993,4 +995,12 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
return allocations;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Network getRouteToUseForSubscription() {
+ return Network.OPSNET;
+ }
+
}
diff --git a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java
index 038212274c..7016cf217c 100644
--- a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java
+++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java
@@ -75,6 +75,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* Oct 22, 2012 1286 djohnson Initial creation
* Nov 20, 2012 1286 djohnson Add tests for proposeSchedule methods.
* Dec 06, 2012 1397 djohnson Add tests for getting bandwidth graph data.
+ * Feb 20, 2013 1543 djohnson Use WFO bandwidth manager.
*
*
*
@@ -85,8 +86,10 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
+ SpringFiles.BANDWIDTH_DATADELIVERY_XML,
+ SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML,
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
- SpringFiles.BANDWIDTH_DATADELIVERY_XML })
+ SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_WFO_XML })
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
@@ -633,4 +636,12 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
subscription.getName(), unscheduledSubscriptions.iterator()
.next());
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Network getRouteToUseForSubscription() {
+ return Network.OPSNET;
+ }
}
diff --git a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestBandwidthContextFactory.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestBandwidthContextFactory.java
index ce296f4d66..2a04eeb644 100644
--- a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestBandwidthContextFactory.java
+++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestBandwidthContextFactory.java
@@ -24,9 +24,6 @@ import java.io.File;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthContextFactory;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
-import com.raytheon.uf.edex.datadelivery.bandwidth.interfaces.BandwidthInitializer;
-import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
-import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
/**
* The {@link BandwidthContextFactory} implementation for integration tests.
@@ -38,6 +35,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 24, 2012 1286 djohnson Initial creation
+ * Feb 20, 2013 1543 djohnson Pass additional super-class constructor arguments.
*
*
*
@@ -53,8 +51,10 @@ public class IntegrationTestBandwidthContextFactory extends
* @param bandwidthDao
* the bandwidthDao
*/
- IntegrationTestBandwidthContextFactory(IBandwidthDao bandwidthDao) {
- super(bandwidthDao);
+ IntegrationTestBandwidthContextFactory(IBandwidthDao bandwidthDao,
+ IEdexBandwidthManagerCreator bandwidthManagerCreator) {
+ super(bandwidthDao, new IntegrationTestBandwidthInitializer(),
+ bandwidthManagerCreator);
}
/**
@@ -65,32 +65,14 @@ public class IntegrationTestBandwidthContextFactory extends
return new IntegrationTestDbInit();
}
- /**
- * {@inheritDoc}
- */
- @Override
- public BandwidthInitializer getBandwidthInitializer() {
- return new IntegrationTestBandwidthInitializer();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IBandwidthManager getBandwidthManager(IBandwidthDbInit dbInit,
- IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
- BandwidthDaoUtil bandwidthDaoUtil) {
- return new IntegrationTestBandwidthManager(dbInit, bandwidthDao,
- retrievalManager, bandwidthDaoUtil);
- }
-
/**
* Get the integration test bandwidth map config file.
*
* @return the file
*/
public static File getIntegrationTestBandwidthMapConfigFile() {
- return new IntegrationTestBandwidthContextFactory((IBandwidthDao) null)
+ return new IntegrationTestBandwidthContextFactory((IBandwidthDao) null,
+ (IEdexBandwidthManagerCreator) null)
.getBandwidthMapConfigFile();
}
}
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/EdexBandwidthManager.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestNcfBandwidthManager.java
similarity index 69%
rename from edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/EdexBandwidthManager.java
rename to tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestNcfBandwidthManager.java
index d6626989c7..e2f291a8a9 100644
--- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/EdexBandwidthManager.java
+++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestNcfBandwidthManager.java
@@ -19,15 +19,16 @@
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
-import com.raytheon.uf.common.util.JarUtil;
+import com.raytheon.uf.common.util.SpringFiles;
+import com.raytheon.uf.common.util.TestUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
/**
- * {@link IBandwidthManager} implementation that runs in EDEX. Intentionally
- * package-private to hide implementation details.
+ * An NCF {@link IBandwidthManager} that runs as an integration test, outside of
+ * the EDEX container.
*
*
*
@@ -35,7 +36,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Oct 30, 2012 1286 djohnson Initial creation
+ * Feb 18, 2013 1543 djohnson Initial creation
*
*
*
@@ -43,12 +44,12 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
* @version 1.0
*/
-class EdexBandwidthManager extends BandwidthManager {
+public class IntegrationTestNcfBandwidthManager extends BandwidthManager {
- private static final String[] EDEX_BANDWIDTH_MANAGER_FILES = new String[] {
- JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-edex-impl.xml"),
- JarUtil.getResResourcePath("/spring/bandwidth-datadelivery.xml"),
- JarUtil.getResResourcePath("/spring/thrift-bandwidth.xml") };
+ static final String[] INTEGRATION_TEST_SPRING_FILES = new String[] {
+ "/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml",
+ TestUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_XML),
+ TestUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_NCF_XML) };
/**
* Constructor.
@@ -58,14 +59,17 @@ class EdexBandwidthManager extends BandwidthManager {
* @param retrievalManager
* @param bandwidthDaoUtil
*/
- public EdexBandwidthManager(IBandwidthDbInit dbInit,
+ public IntegrationTestNcfBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected String[] getSpringFilesForNewInstance() {
- return EDEX_BANDWIDTH_MANAGER_FILES;
+ return INTEGRATION_TEST_SPRING_FILES;
}
}
diff --git a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestNcfBandwidthManagerCreator.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestNcfBandwidthManagerCreator.java
new file mode 100644
index 0000000000..33865f06c1
--- /dev/null
+++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestNcfBandwidthManagerCreator.java
@@ -0,0 +1,57 @@
+/**
+ * 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.datadelivery.bandwidth;
+
+import com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory.IEdexBandwidthManagerCreator;
+import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
+import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
+import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
+import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
+
+/**
+ * Creates {@link IntegrationTestNcfBandwidthManager} instances.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 20, 2013 1543 djohnson Initial creation
+ *
+ *
+ *
+ * @author djohnson
+ * @version 1.0
+ */
+public class IntegrationTestNcfBandwidthManagerCreator implements
+ IEdexBandwidthManagerCreator {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IBandwidthManager getBandwidthManager(IBandwidthDbInit dbInit,
+ IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
+ BandwidthDaoUtil bandwidthDaoUtil) {
+ return new IntegrationTestNcfBandwidthManager(dbInit, bandwidthDao,
+ retrievalManager, bandwidthDaoUtil);
+ }
+}
diff --git a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestBandwidthManager.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestWfoBandwidthManager.java
similarity index 81%
rename from tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestBandwidthManager.java
rename to tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestWfoBandwidthManager.java
index 04eed298a9..ceaf4f248b 100644
--- a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestBandwidthManager.java
+++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestWfoBandwidthManager.java
@@ -19,6 +19,7 @@
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
+import com.raytheon.uf.common.util.SpringFiles;
import com.raytheon.uf.common.util.TestUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
@@ -26,8 +27,8 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
/**
- * An {@link IBandwidthManager} that runs as an integration test, outside of the
- * EDEX container.
+ * A WFO {@link IBandwidthManager} that runs as an integration test, outside of
+ * the EDEX container.
*
*
*
@@ -43,11 +44,12 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
* @version 1.0
*/
-public class IntegrationTestBandwidthManager extends BandwidthManager {
+public class IntegrationTestWfoBandwidthManager extends BandwidthManager {
static final String[] INTEGRATION_TEST_SPRING_FILES = new String[] {
"/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml",
- TestUtil.getResResourcePath("/spring/bandwidth-datadelivery.xml") };
+ TestUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_XML),
+ TestUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML) };
/**
* Constructor.
@@ -57,7 +59,7 @@ public class IntegrationTestBandwidthManager extends BandwidthManager {
* @param retrievalManager
* @param bandwidthDaoUtil
*/
- public IntegrationTestBandwidthManager(IBandwidthDbInit dbInit,
+ public IntegrationTestWfoBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil bandwidthDaoUtil) {
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil);
diff --git a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestWfoBandwidthManagerCreator.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestWfoBandwidthManagerCreator.java
new file mode 100644
index 0000000000..f7f2833095
--- /dev/null
+++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/IntegrationTestWfoBandwidthManagerCreator.java
@@ -0,0 +1,57 @@
+/**
+ * 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.datadelivery.bandwidth;
+
+import com.raytheon.uf.edex.datadelivery.bandwidth.EdexBandwidthContextFactory.IEdexBandwidthManagerCreator;
+import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
+import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
+import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
+import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
+
+/**
+ * Creates {@link IntegrationTestWfoBandwidthManager} instances.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 20, 2013 1543 djohnson Initial creation
+ *
+ *
+ *
+ * @author djohnson
+ * @version 1.0
+ */
+public class IntegrationTestWfoBandwidthManagerCreator implements
+ IEdexBandwidthManagerCreator {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IBandwidthManager getBandwidthManager(IBandwidthDbInit dbInit,
+ IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
+ BandwidthDaoUtil bandwidthDaoUtil) {
+ return new IntegrationTestWfoBandwidthManager(dbInit, bandwidthDao,
+ retrievalManager, bandwidthDaoUtil);
+ }
+}
diff --git a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/NcfBandwidthManagerIntTest.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/NcfBandwidthManagerIntTest.java
new file mode 100644
index 0000000000..2a60c01640
--- /dev/null
+++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/NcfBandwidthManagerIntTest.java
@@ -0,0 +1,118 @@
+/**
+ * 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.datadelivery.bandwidth;
+
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+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.IBandwidthRequest;
+import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest.RequestType;
+import com.raytheon.uf.common.datadelivery.registry.Network;
+import com.raytheon.uf.common.datadelivery.registry.Subscription;
+import com.raytheon.uf.common.util.SpringFiles;
+import com.raytheon.uf.edex.database.dao.DatabaseUtil;
+import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
+import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
+
+/**
+ * Test an NCF {@link BandwidthManager}.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 19, 2013 1543 djohnson Initial creation
+ *
+ *
+ *
+ * @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_XML,
+ SpringFiles.BANDWIDTH_DATADELIVERY_NCF_XML,
+ SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
+ SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_NCF_XML })
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+public class NcfBandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
+
+ @Test
+ public void testSchedulesSbnSubscriptionForRetrieval() {
+ Subscription subscription = createSubscriptionThatFillsAThirdOfABucket();
+
+ bandwidthManager.schedule(subscription);
+
+ final List subRetrievals = bandwidthDao
+ .getSubscriptionRetrievals(subscription.getProvider(),
+ subscription.getDataSetName());
+ assertThat(subRetrievals, is(not(empty())));
+
+ for (SubscriptionRetrieval subRetrieval : subRetrievals) {
+ assertThat(subRetrieval.getStatus(), is(RetrievalStatus.SCHEDULED));
+ }
+ }
+
+ @Test
+ public void testDoesNotScheduleOpsnetSubscriptionForRetrieval() {
+ Subscription subscription = createSubscriptionThatFillsAThirdOfABucket();
+ subscription.setRoute(Network.OPSNET);
+
+ bandwidthManager.schedule(subscription);
+
+ final List subRetrievals = bandwidthDao
+ .getSubscriptionRetrievals(subscription.getProvider(),
+ subscription.getDataSetName());
+ assertThat(subRetrievals, is(empty()));
+ }
+
+ @Test
+ public void testReinitializeUsesCorrectSpringFiles() throws Exception {
+ final IBandwidthRequest request = new IBandwidthRequest();
+ request.setRequestType(RequestType.REINITIALIZE);
+ bandwidthManager.handleRequest(request);
+
+ verifyRetrievalPlanDoesNotExistForRoute(Network.OPSNET);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Network getRouteToUseForSubscription() {
+ return Network.SBN;
+ }
+
+}
diff --git a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/WfoBandwidthManagerIntTest.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/WfoBandwidthManagerIntTest.java
new file mode 100644
index 0000000000..4fe349865d
--- /dev/null
+++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/WfoBandwidthManagerIntTest.java
@@ -0,0 +1,122 @@
+/**
+ * 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.datadelivery.bandwidth;
+
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+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.IBandwidthRequest;
+import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest.RequestType;
+import com.raytheon.uf.common.datadelivery.registry.Network;
+import com.raytheon.uf.common.datadelivery.registry.Subscription;
+import com.raytheon.uf.common.util.SpringFiles;
+import com.raytheon.uf.edex.database.dao.DatabaseUtil;
+import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
+import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
+
+/**
+ * Test a WFO {@link BandwidthManager}.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 19, 2013 1543 djohnson Initial creation
+ *
+ *
+ *
+ * @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_XML,
+ SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML,
+ SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
+ SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_WFO_XML })
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+public class WfoBandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
+
+ @Test
+ public void testSchedulesSbnSubscriptionForRetrieval() {
+ Subscription subscription = createSubscriptionThatFillsAThirdOfABucket();
+ subscription.setRoute(Network.SBN);
+
+ bandwidthManager.schedule(subscription);
+
+ final List subRetrievals = bandwidthDao
+ .getSubscriptionRetrievals(subscription.getProvider(),
+ subscription.getDataSetName());
+ assertThat(subRetrievals, is(not(empty())));
+
+ for (SubscriptionRetrieval subRetrieval : subRetrievals) {
+ assertThat(subRetrieval.getStatus(), is(RetrievalStatus.SCHEDULED));
+ }
+ }
+
+ @Test
+ public void testSchedulesOpsnetSubscriptionForRetrieval() {
+ Subscription subscription = createSubscriptionThatFillsAThirdOfABucket();
+
+ bandwidthManager.schedule(subscription);
+
+ final List subRetrievals = bandwidthDao
+ .getSubscriptionRetrievals(subscription.getProvider(),
+ subscription.getDataSetName());
+ assertThat(subRetrievals, is(not(empty())));
+
+ for (SubscriptionRetrieval subRetrieval : subRetrievals) {
+ assertThat(subRetrieval.getStatus(), is(RetrievalStatus.SCHEDULED));
+ }
+ }
+
+ @Test
+ public void testReinitializeUsesCorrectSpringFiles() throws Exception {
+ final IBandwidthRequest request = new IBandwidthRequest();
+ request.setRequestType(RequestType.REINITIALIZE);
+ bandwidthManager.handleRequest(request);
+
+ verifyRetrievalPlanExistsForRoute(Network.OPSNET);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Network getRouteToUseForSubscription() {
+ return Network.OPSNET;
+ }
+
+}
diff --git a/tests/resources/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml b/tests/resources/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml
index 60de63072b..2400beae35 100644
--- a/tests/resources/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml
+++ b/tests/resources/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml
@@ -1,12 +1,11 @@
+ 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">
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/resources/bandwidth/bandwidth-datadelivery-integrationtest-wfo-impl.xml b/tests/resources/bandwidth/bandwidth-datadelivery-integrationtest-wfo-impl.xml
new file mode 100644
index 0000000000..8426002260
--- /dev/null
+++ b/tests/resources/bandwidth/bandwidth-datadelivery-integrationtest-wfo-impl.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/unit/com/raytheon/uf/common/datadelivery/registry/handlers/BaseMemorySubscriptionHandler.java b/tests/unit/com/raytheon/uf/common/datadelivery/registry/handlers/BaseMemorySubscriptionHandler.java
index 31823e9ad2..d0625d5b96 100644
--- a/tests/unit/com/raytheon/uf/common/datadelivery/registry/handlers/BaseMemorySubscriptionHandler.java
+++ b/tests/unit/com/raytheon/uf/common/datadelivery/registry/handlers/BaseMemorySubscriptionHandler.java
@@ -24,6 +24,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
@@ -37,6 +38,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 17, 2012 0726 djohnson Initial creation
+ * Feb 20, 2013 1543 djohnson Implement route filtering.
*
*
*
@@ -138,4 +140,30 @@ public class BaseMemorySubscriptionHandler extends
return retVal;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List getActiveForRoute(Network route)
+ throws RegistryHandlerException {
+ return getActiveForRoutes(new Network[] { route });
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List getActiveForRoutes(Network... routes)
+ throws RegistryHandlerException {
+ List retVal = new ArrayList();
+ for (T obj : getActive()) {
+ for (Network route : routes) {
+ if (route == obj.getRoute()) {
+ retVal.add(obj);
+ }
+ }
+ }
+ return retVal;
+ }
}
diff --git a/tests/unit/com/raytheon/uf/common/util/SpringFiles.java b/tests/unit/com/raytheon/uf/common/util/SpringFiles.java
index a237f08fcb..3464bbe948 100644
--- a/tests/unit/com/raytheon/uf/common/util/SpringFiles.java
+++ b/tests/unit/com/raytheon/uf/common/util/SpringFiles.java
@@ -52,5 +52,13 @@ public class SpringFiles {
public static final String BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML = "/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml";
+ public static final String BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_NCF_XML = "/bandwidth/bandwidth-datadelivery-integrationtest-ncf-impl.xml";
+
+ public static final String BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_WFO_XML = "/bandwidth/bandwidth-datadelivery-integrationtest-wfo-impl.xml";
+
public static final String BANDWIDTH_DATADELIVERY_XML = "/spring/bandwidth-datadelivery.xml";
-}
+
+ public static final String BANDWIDTH_DATADELIVERY_NCF_XML = "/spring/bandwidth-datadelivery-ncf.xml";
+
+ public static final String BANDWIDTH_DATADELIVERY_WFO_XML = "/spring/bandwidth-datadelivery-wfo.xml";
+}
\ No newline at end of file
diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializerTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializerTest.java
new file mode 100644
index 0000000000..ac1cbba585
--- /dev/null
+++ b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializerTest.java
@@ -0,0 +1,69 @@
+/**
+ * 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.datadelivery.bandwidth.hibernate;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+
+import com.google.common.collect.Sets;
+import com.raytheon.uf.common.datadelivery.registry.Subscription;
+import com.raytheon.uf.common.datadelivery.registry.SubscriptionFixture;
+import com.raytheon.uf.edex.datadelivery.bandwidth.IBandwidthManager;
+import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
+
+/**
+ * Test {@link HibernateBandwidthInitializer}.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 18, 2013 1543 djohnson Initial creation
+ *
+ *
+ *
+ * @author djohnson
+ * @version 1.0
+ */
+public class HibernateBandwidthInitializerTest {
+
+ @Test
+ public void testSchedulesAllSubscriptionReturnedFromIFindSubscriptions()
+ throws Exception {
+ final Subscription subscription = SubscriptionFixture.INSTANCE.get();
+
+ IFindSubscriptionsForScheduling strategy = mock(IFindSubscriptionsForScheduling.class);
+ when(strategy.findSubscriptionsToSchedule()).thenReturn(
+ Sets.newHashSet(subscription));
+ IBandwidthManager bandwidthManager = mock(IBandwidthManager.class);
+ IBandwidthDbInit dbInit = mock(IBandwidthDbInit.class);
+
+ new HibernateBandwidthInitializer(strategy).init(bandwidthManager,
+ dbInit);
+
+ verify(bandwidthManager).schedule(subscription);
+ }
+
+}
diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/util/FindActiveSubscriptionsForRouteTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/util/FindActiveSubscriptionsForRouteTest.java
new file mode 100644
index 0000000000..7cfdc0f56d
--- /dev/null
+++ b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/util/FindActiveSubscriptionsForRouteTest.java
@@ -0,0 +1,101 @@
+/**
+ * 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.datadelivery.bandwidth.util;
+
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Set;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.raytheon.uf.common.datadelivery.registry.Network;
+import com.raytheon.uf.common.datadelivery.registry.Subscription;
+import com.raytheon.uf.common.datadelivery.registry.SubscriptionBuilder;
+import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
+import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
+import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
+import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
+
+/**
+ * Test {@link FindActiveSubscriptionsForRoute}.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 19, 2013 1543 djohnson Initial creation
+ *
+ *
+ *
+ * @author djohnson
+ * @version 1.0
+ */
+
+public class FindActiveSubscriptionsForRouteTest {
+
+ @BeforeClass
+ public static void classSetUp() throws RegistryHandlerException {
+ RegistryObjectHandlersUtil.initMemory();
+ final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
+ .getSubscriptionHandler();
+
+ // Two OPSNET subscriptions
+ final Subscription opsnetSub1 = new SubscriptionBuilder()
+ .withName("opsnetSub1").withRoute(Network.OPSNET).build();
+ final Subscription opsnetSub2 = new Subscription(opsnetSub1,
+ "opsnetSub2");
+
+ // Two SBN subscriptions
+ final Subscription sbnSub1 = new SubscriptionBuilder()
+ .withName("sbnSub1").withRoute(Network.SBN).build();
+ final Subscription sbnSub2 = new Subscription(sbnSub1, "sbnSub2");
+
+ // Store all subscriptions
+ for (Subscription sub : new Subscription[] { opsnetSub1, opsnetSub2,
+ sbnSub1, sbnSub2 }) {
+ subscriptionHandler.store(sub);
+ }
+ }
+
+ @Test
+ public void findsSubscriptionForSingleRoute()
+ throws RegistryHandlerException {
+ final Set subscriptions = new FindActiveSubscriptionsForRoute(
+ Network.SBN).findSubscriptionsToSchedule();
+ assertThat(subscriptions, hasSize(2));
+ for (Subscription subscription : subscriptions) {
+ assertThat(subscription.getRoute(), is(Network.SBN));
+ }
+ }
+
+ @Test
+ public void findsSubscriptionsForMultipleRoutes()
+ throws RegistryHandlerException {
+ final Set subscriptions = new FindActiveSubscriptionsForRoute(
+ Network.OPSNET, Network.SBN).findSubscriptionsToSchedule();
+ assertThat(subscriptions, hasSize(4));
+ }
+
+}
diff --git a/tests/utility/common_static/base/datadelivery/bandwidthmap.xml b/tests/utility/common_static/base/datadelivery/bandwidthmap.xml
index 86b38937be..03122377a1 100644
--- a/tests/utility/common_static/base/datadelivery/bandwidthmap.xml
+++ b/tests/utility/common_static/base/datadelivery/bandwidthmap.xml
@@ -1,4 +1,5 @@
+