@Before
public void init() {
Module guiceOverrideModule = getGuiceOverrideModule();
CandlepinCommonTestConfig config = new CandlepinCommonTestConfig();
CandlepinCommonTestingModule testingModule = new CandlepinCommonTestingModule(config);
if (guiceOverrideModule == null) {
injector = Guice.createInjector(testingModule,
new CandlepinNonServletEnvironmentTestingModule());
}
else {
injector = Guice.createInjector(Modules.override(testingModule)
.with(guiceOverrideModule),
new CandlepinNonServletEnvironmentTestingModule());
}
insertValidationEventListeners(injector);
cpSingletonScope = injector.getInstance(CandlepinSingletonScope.class);
// Because all candlepin operations are running in the CandlepinSingletonScope
// we'll force the instance creations to be done inside the scope.
// Exit the scope to make sure that it is clean before starting the test.
cpSingletonScope.exit();
cpSingletonScope.enter();
injector.getInstance(EntityManagerFactory.class);
emf = injector.getProvider(EntityManagerFactory.class).get();
ownerCurator = injector.getInstance(OwnerCurator.class);
userCurator = injector.getInstance(UserCurator.class);
productCurator = injector.getInstance(ProductCurator.class);
productCertificateCurator = injector
.getInstance(ProductCertificateCurator.class);
consumerCurator = injector.getInstance(ConsumerCurator.class);
eventCurator = injector.getInstance(EventCurator.class);
permissionCurator = injector.getInstance(PermissionBlueprintCurator.class);
roleCurator = injector.getInstance(RoleCurator.class);
consumerTypeCurator = injector.getInstance(ConsumerTypeCurator.class);
consumerContentOverrideCurator = injector.getInstance(
ConsumerContentOverrideCurator.class);
activationKeyContentOverrideCurator = injector.getInstance(
ActivationKeyContentOverrideCurator.class);
certificateCurator = injector
.getInstance(SubscriptionsCertificateCurator.class);
poolCurator = injector.getInstance(PoolCurator.class);
poolAttributeCurator = injector.getInstance(PoolAttributeCurator.class);
productPoolAttributeCurator = injector
.getInstance(ProductPoolAttributeCurator.class);
entitlementCurator = injector.getInstance(EntitlementCurator.class);
attributeCurator = injector.getInstance(ProductAttributeCurator.class);
rulesCurator = injector.getInstance(RulesCurator.class);
subCurator = injector.getInstance(SubscriptionCurator.class);
activationKeyCurator = injector.getInstance(ActivationKeyCurator.class);
contentCurator = injector.getInstance(ContentCurator.class);
envCurator = injector.getInstance(EnvironmentCurator.class);
envContentCurator = injector.getInstance(EnvironmentContentCurator.class);
unitOfWork = injector.getInstance(UnitOfWork.class);
productAdapter = injector.getInstance(ProductServiceAdapter.class);
subAdapter = injector.getInstance(SubscriptionServiceAdapter.class);
ownerAdapter = injector.getInstance(OwnerServiceAdapter.class);
entCertCurator = injector
.getInstance(EntitlementCertificateCurator.class);
certSerialCurator = injector
.getInstance(CertificateSerialCurator.class);
entitlementCertService = injector
.getInstance(EntitlementCertServiceAdapter.class);
poolManager = injector.getInstance(CandlepinPoolManager.class);
statisticCurator = injector.getInstance(StatisticCurator.class);
i18n = injector.getInstance(I18n.class);
uniqueIdGenerator = injector.getInstance(UniqueIdGenerator.class);
ueberCertGenerator = injector.getInstance(UeberCertificateGenerator.class);
permFactory = injector.getInstance(PermissionFactory.class);
securityInterceptor = testingModule.securityInterceptor();
dateSource = (DateSourceForTesting) injector
.getInstance(DateSource.class);
dateSource.currentDate(TestDateUtil.date(2010, 1, 1));
serviceLevelValidator = injector.getInstance(ServiceLevelValidator.class);