diff --git a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/notification/EmailSender.java b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/notification/EmailSender.java index 265b5b013a..7d97a4528b 100644 --- a/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/notification/EmailSender.java +++ b/edexOsgi/com.raytheon.uf.edex.registry.ebxml/src/com/raytheon/uf/edex/registry/ebxml/services/notification/EmailSender.java @@ -40,6 +40,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import oasis.names.tc.ebxml.regrep.xsd.rim.v4.ExtrinsicObjectType; import oasis.names.tc.ebxml.regrep.xsd.rim.v4.NotificationType; import com.raytheon.uf.common.localization.PathManagerFactory; @@ -48,6 +49,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.common.util.PropertiesUtil; +import com.raytheon.uf.edex.registry.ebxml.dao.ExtrinsicObjectDao; import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; /** @@ -63,6 +65,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 4/9/2013 1905 bphillip Initial implementation + * Apr 17, 2013 1914 djohnson Now has reference to extrinsic object dao. * * * @author bphillip @@ -74,7 +77,7 @@ public class EmailSender { private static final IUFStatusHandler statusHandler = UFStatus .getHandler(EmailSender.class); - private boolean emailEnabled; + private final boolean emailEnabled; /** The subject prefix attached to all email notifications */ private static final String SUBJECT_PREFIX = "Registry Event Notification for Subscription: "; @@ -92,7 +95,10 @@ public class EmailSender { private JAXBManager jaxbManager; /** Factory for generating XSLT transformations */ - private final TransformerFactory factory = TransformerFactory.newInstance();; + private final TransformerFactory factory = TransformerFactory.newInstance(); + + /** Data access object for extrinsic objects */ + private final ExtrinsicObjectDao extrinsicObjectDao; /** * Creates a new EmailSender object @@ -102,8 +108,11 @@ public class EmailSender { * @throws JAXBException * If problems occur initializing the JAXBManager */ - public EmailSender(boolean emailEnabled) throws IOException, JAXBException { + public EmailSender(boolean emailEnabled, + ExtrinsicObjectDao extrinsicObjectDao) throws IOException, + JAXBException { this.emailEnabled = emailEnabled; + this.extrinsicObjectDao = extrinsicObjectDao; if (emailEnabled) { statusHandler.debug("Loading email properties..."); File emailPropertiesFile = PathManagerFactory.getPathManager() @@ -210,4 +219,15 @@ public class EmailSender { return emailEnabled; } + /** + * Get a style sheet by its id. + * + * @param styleSheetId + * the style sheet id + * @return the extrinsic object + */ + public ExtrinsicObjectType getStyleSheetById(String styleSheetId) { + return extrinsicObjectDao.getById(styleSheetId); + } + } diff --git a/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/LifecycleManagerSubmitObjectsTest.java b/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/LifecycleManagerSubmitObjectsTest.java index 1e4b5edb55..bc13184576 100644 --- a/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/LifecycleManagerSubmitObjectsTest.java +++ b/tests/integration/com/raytheon/uf/edex/registry/ebxml/dao/LifecycleManagerSubmitObjectsTest.java @@ -69,7 +69,7 @@ import com.raytheon.uf.edex.database.dao.DatabaseUtil; @ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML, "/spring/ebxml.xml", "/spring/ebxml-impl.xml", "/spring/ebxml-querytypes.xml", "/spring/ebxml-registry-dao.xml", - "/ebxml/unit-test-ebxml-beans.xml" }) + "/ebxml/unit-test-ebxml-beans.xml", "/unit-test-localization-beans.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) public class LifecycleManagerSubmitObjectsTest extends AbstractRegistryTest { diff --git a/tests/resources/ebxml/unit-test-ebxml-beans.xml b/tests/resources/ebxml/unit-test-ebxml-beans.xml index 75da6f9a06..5f23ef6448 100644 --- a/tests/resources/ebxml/unit-test-ebxml-beans.xml +++ b/tests/resources/ebxml/unit-test-ebxml-beans.xml @@ -9,15 +9,4 @@ - - - com.raytheon.uf.common.localization.PathManagerFactoryTest - - - - initLocalization - - - \ No newline at end of file diff --git a/tests/resources/unit-test-localization-beans.xml b/tests/resources/unit-test-localization-beans.xml new file mode 100644 index 0000000000..2e22c3b515 --- /dev/null +++ b/tests/resources/unit-test-localization-beans.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/tests/unit/com/raytheon/uf/common/localization/PathManagerFactoryTest.java b/tests/unit/com/raytheon/uf/common/localization/PathManagerFactoryTest.java index 3e44b3f7e6..ea5d25f951 100644 --- a/tests/unit/com/raytheon/uf/common/localization/PathManagerFactoryTest.java +++ b/tests/unit/com/raytheon/uf/common/localization/PathManagerFactoryTest.java @@ -25,6 +25,9 @@ import java.io.File; import org.junit.Before; import org.junit.Test; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; @@ -43,6 +46,7 @@ import com.raytheon.uf.common.util.TestUtil; * ------------ ---------- ----------- -------------------------- * Jul 18, 2012 740 djohnson Initial creation * Oct 23, 2012 1286 djohnson Handle executing tests in Eclipse/command-line transparently. + * Apr 18, 2013 1914 djohnson Allow initializing test localization support from Spring. * * * @@ -50,7 +54,7 @@ import com.raytheon.uf.common.util.TestUtil; * @version 1.0 */ -public class PathManagerFactoryTest { +public class PathManagerFactoryTest implements BeanFactoryPostProcessor { private static File savedLocalizationFileDir; @@ -93,6 +97,21 @@ public class PathManagerFactoryTest { return new File("..", "edexOsgi").isDirectory(); } + /** + * Initializes test localization support before any Spring beans are + * created. + * + * @param beanFactory + * the bean factory + * @throws BeansException + * shouldn't happen + */ + @Override + public void postProcessBeanFactory( + ConfigurableListableBeanFactory beanFactory) throws BeansException { + PathManagerFactoryTest.initLocalization(); + } + @Before public void setUp() { PathManagerFactoryTest.initLocalization(); @@ -153,4 +172,5 @@ public class PathManagerFactoryTest { file.getParentFile().getAbsolutePath() .startsWith(savedLocalizationFileDir.getAbsolutePath())); } + } 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 index ac1cbba585..e1acfa51d8 100644 --- a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializerTest.java +++ b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/hibernate/HibernateBandwidthInitializerTest.java @@ -41,6 +41,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Feb 18, 2013 1543 djohnson Initial creation + * Apr 18, 2013 1914 djohnson Fix broken test. * * * @@ -60,8 +61,10 @@ public class HibernateBandwidthInitializerTest { IBandwidthManager bandwidthManager = mock(IBandwidthManager.class); IBandwidthDbInit dbInit = mock(IBandwidthDbInit.class); - new HibernateBandwidthInitializer(strategy).init(bandwidthManager, + final HibernateBandwidthInitializer initializer = new HibernateBandwidthInitializer(strategy); + initializer.init(bandwidthManager, dbInit); + initializer.executeAfterRegistryInit(); verify(bandwidthManager).schedule(subscription); }