Issue #1914 Add email notification as a notification listener
Amend: Fix broken test Change-Id: I3b692255b5d84fffce174c0447970fe627f4a61e Former-commit-id:f3d53eb889
[formerly74a9b93d05
] [formerlyf3d53eb889
[formerly74a9b93d05
] [formerly067b20c684
[formerly 45b5a9cffd6c57dc8ea1355ee623fcf6014dd377]]] Former-commit-id:067b20c684
Former-commit-id:6ded48bcd8
[formerly7b09a0e477
] Former-commit-id:cf29290348
This commit is contained in:
parent
f38e3ba430
commit
e37b5f6fc0
6 changed files with 58 additions and 17 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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>
|
9
tests/resources/unit-test-localization-beans.xml
Normal file
9
tests/resources/unit-test-localization-beans.xml
Normal 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>
|
|
@ -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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue