Merge "Issue #1914 Add email notification as a notification listener" into development

Former-commit-id: b593a2581c [formerly b593a2581c [formerly 1c6174bde3598fbe3b22aefb1c36a3a49968466b]]
Former-commit-id: 4f60e45094
Former-commit-id: 2c28b53ea4
This commit is contained in:
Dustin Johnson 2013-04-18 13:25:57 -05:00 committed by Gerrit Code Review
commit 1b83f30cdb
6 changed files with 58 additions and 17 deletions

View file

@ -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.
* </pre>
*
* @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);
}
}

View file

@ -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 {

View file

@ -9,15 +9,4 @@
<bean id="registrySubscriptionManagerInvoker"
class="com.raytheon.uf.edex.registry.ebxml.dao.DirectlyInvokeRegistrySubscriptionManager" />
<bean
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass">
<value>com.raytheon.uf.common.localization.PathManagerFactoryTest
</value>
</property>
<property name="targetMethod">
<value>initLocalization</value>
</property>
</bean>
</beans>

View file

@ -0,0 +1,9 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<!-- Spring BeanFactoryPostProcessor to add localization support -->
<bean class="com.raytheon.uf.common.localization.PathManagerFactoryTest" />
</beans>

View file

@ -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.
*
* </pre>
*
@ -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()));
}
}

View file

@ -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.
*
* </pre>
*
@ -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);
}