use of org.candlepin.common.config.Configuration 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.Configuration 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;
}
};
}
use of org.candlepin.common.config.Configuration in project candlepin by candlepin.
the class CustomizableModulesTest method shouldFailWhenConfigurationContainsMissingClass.
// TODO: We should probably be more specific...
@Test(expected = RuntimeException.class)
public void shouldFailWhenConfigurationContainsMissingClass() throws Exception {
Configuration config = new PropertiesFileConfiguration(getAbsolutePath("customizable_modules_with_missing_class.conf"));
new CustomizableModules().load(config);
}
use of org.candlepin.common.config.Configuration in project candlepin by candlepin.
the class EventResourceTest method init.
@Before
public void init() {
Configuration config = mock(Configuration.class);
ec = mock(EventCurator.class);
translator = mock(ModelTranslator.class);
injector = Guice.createInjector(new TestingModules.MockJpaModule(), new TestingModules.StandardTest(config), new TestingModules.ServletEnvironmentModule());
}
use of org.candlepin.common.config.Configuration in project candlepin by candlepin.
the class HypervisorResourceTest method setupTest.
@Before
public void setupTest() {
Configuration config = new CandlepinCommonTestConfig();
testMigration = new GuestMigration(consumerCurator);
migrationProvider = Providers.of(testMigration);
this.i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
this.hypervisorType = new ConsumerType(ConsumerTypeEnum.HYPERVISOR);
this.hypervisorType.setId("test-hypervisor-ctype");
this.mockConsumerType(this.hypervisorType);
this.modelTranslator = new StandardTranslator(this.consumerTypeCurator, this.environmentCurator, this.ownerCurator);
this.consumerResource = new ConsumerResource(this.consumerCurator, this.consumerTypeCurator, null, this.subscriptionService, this.ownerService, null, this.idCertService, null, this.i18n, this.sink, this.eventFactory, null, null, this.userService, null, null, this.ownerCurator, this.activationKeyCurator, null, this.complianceRules, this.deletedConsumerCurator, null, null, config, null, null, null, this.consumerBindUtil, null, null, new FactValidator(config, this.i18n), null, consumerEnricher, migrationProvider, modelTranslator);
this.guestIdResource = new GuestIdResource(this.guestIdCurator, this.consumerCurator, this.consumerTypeCurator, this.consumerResource, this.i18n, this.eventFactory, this.sink, migrationProvider, modelTranslator);
this.hypervisorResource = new HypervisorResource(consumerResource, consumerCurator, consumerTypeCurator, i18n, ownerCurator, migrationProvider, modelTranslator, guestIdResource);
// Ensure that we get the consumer that was passed in back from the create call.
when(consumerCurator.create(any(Consumer.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArguments()[0];
}
});
when(consumerCurator.create(any(Consumer.class), any(Boolean.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArguments()[0];
}
});
when(complianceRules.getStatus(any(Consumer.class), any(Date.class), any(Boolean.class))).thenReturn(new ComplianceStatus(new Date()));
when(ownerCurator.lookupByKey(any(String.class))).thenReturn(new Owner());
when(eventFactory.getEventBuilder(any(Target.class), any(Type.class))).thenReturn(consumerEventBuilder);
when(consumerEventBuilder.setEventData(any(Consumer.class))).thenReturn(consumerEventBuilder);
}
Aggregations