Issue #2344 Fixed HibernateBandwidthInitializerTest.

Amend: Removed officeID change to BaseSubscriptionFixture.

Change-Id: Ib3065684aa88cdcde000239d9202d5d43259f43e

Former-commit-id: 69b7fc7281a4cc266b7e6ca6f0adff00b3658957
This commit is contained in:
Brad Gonzales 2013-09-09 10:13:39 -05:00
parent 111217764b
commit d0ccc11f58
4 changed files with 68 additions and 2 deletions

View file

@ -1,7 +1,7 @@
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -33,6 +33,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
* Apr 30, 2013 1960 djohnson just call init rather than drop/create tables explicitly.
* Jun 25, 2013 2106 djohnson init() now takes a {@link RetrievalManager} as well.
* Sep 05, 2013 2330 bgonzale On WFO registry init, only subscribe to local site subscriptions.
* Sep 06, 2013 2344 bgonzale Removed attempt to add to immutable empty set.
*
* </pre>
*
@ -83,7 +84,7 @@ public class HibernateBandwidthInitializer implements BandwidthInitializer {
*/
@Override
public void executeAfterRegistryInit() {
Set<Subscription> activeSubscriptions = Collections.emptySet();
Set<Subscription> activeSubscriptions = new HashSet<Subscription>();
try {
final String localOffice = SiteUtil.getSite();

View file

@ -155,5 +155,6 @@
<classpathentry kind="lib" path="lib/swt_gtk_linux_x86.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.wxmath"/>
<classpathentry kind="lib" path="lib/org.eclipse.jface_3.8.0.v20120912-135020.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.apache.commons.configuration"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,53 @@
/**
* 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.core.props;
import org.apache.commons.configuration.Configuration;
/**
* Inject attribute names, attribute values, and property values into the
* PropertiesFactory environment configuration.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 06, 2013 2344 bgonzale Initial creation
*
* </pre>
*
* @author bgonzale
* @version 1.0
*/
public class EnvAttributePropertyInjector {
public static void injectAttributeProperty(String attributeName,
String attributeValue, String propertyValue) {
Configuration attrNamesConfig = PropertiesFactory.getInstance()
.getEnvProperties().theAttrNamesConfiguration;
Configuration envConfig = PropertiesFactory.getInstance()
.getEnvProperties().theEnvConfiguration;
attrNamesConfig.setProperty(attributeName, attributeValue);
envConfig.setProperty(attributeValue, propertyValue);
}
}

View file

@ -23,11 +23,13 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import com.google.common.collect.Sets;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.edex.core.props.EnvAttributePropertyInjector;
import com.raytheon.uf.edex.datadelivery.bandwidth.IBandwidthManager;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
@ -44,6 +46,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
* Feb 18, 2013 1543 djohnson Initial creation
* Apr 18, 2013 1914 djohnson Fix broken test.
* Jun 25, 2013 2106 djohnson init() now takes a {@link RetrievalManager}.
* Sep 06, 2013 2344 bgonzale Added property injection of valid test value.
*
* </pre>
*
@ -52,11 +55,19 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager;
*/
public class HibernateBandwidthInitializerTest {
@Before
public void setup() {
System.setProperty("edex.home", "../edexOsgi/build.edex/esb/");
EnvAttributePropertyInjector.injectAttributeProperty("SITENAME",
"sitename", "OAX");
}
@Test
public void testSchedulesAllSubscriptionReturnedFromIFindSubscriptions()
throws Exception {
final Subscription subscription = SiteSubscriptionFixture.INSTANCE.get();
subscription.addOfficeID("OAX");
IFindSubscriptionsForScheduling strategy = mock(IFindSubscriptionsForScheduling.class);
when(strategy.findSubscriptionsToSchedule()).thenReturn(
Sets.newHashSet(subscription));