use of org.candlepin.common.config.ConfigurationException in project candlepin by candlepin.
the class CandlepinContextListenerTest method tharSheBlows.
@Test(expected = RuntimeException.class)
public void tharSheBlows() {
listener = new CandlepinContextListener() {
protected List<Module> getModules(ServletContext context) {
return new LinkedList<>();
}
protected Configuration readConfiguration(ServletContext context) throws ConfigurationException {
throw new ConfigurationException("the ship is sinking");
}
};
prepareForInitialization();
listener.contextInitialized(evt);
}
use of org.candlepin.common.config.ConfigurationException in project candlepin by candlepin.
the class CandlepinContextListenerTest method init.
@Before
public void init() {
config = mock(Configuration.class);
when(config.subset(eq("org.quartz"))).thenReturn(new MapConfiguration(ConfigProperties.DEFAULT_PROPERTIES));
when(config.strippedSubset(eq(ConfigurationPrefixes.LOGGING_CONFIG_PREFIX))).thenReturn(new MapConfiguration());
hqlistener = mock(ActiveMQContextListener.class);
pinlistener = mock(PinsetterContextListener.class);
buspublisher = mock(AMQPBusPublisher.class);
executorService = mock(ScheduledExecutorService.class);
configRead = mock(VerifyConfigRead.class);
// for testing we override the getModules and readConfiguration methods
// so we can insert our mock versions of listeners to verify
// they are getting invoked properly.
listener = new CandlepinContextListener() {
@Override
protected List<Module> getModules(ServletContext context) {
List<Module> modules = new LinkedList<>();
// tried simply overriding CandlepinModule
// but that caused it to read the local config
// which means the test becomes non-deterministic.
// so just load the items we need to verify the
// functionality.
modules.add(new TestingModules.JpaModule());
modules.add(new TestingModules.StandardTest(config));
modules.add(new ContextListenerTestModule());
return modules;
}
@Override
protected Configuration readConfiguration(ServletContext context) throws ConfigurationException {
configRead.verify(context);
return config;
}
};
}
Aggregations