Search in sources :

Example 16 with Configuration

use of org.candlepin.common.config.Configuration in project candlepin by candlepin.

the class PoolHelperTest method init.

@Before
public void init() {
    pm = mock(PoolManager.class);
    psa = mock(ProductServiceAdapter.class);
    ent = mock(Entitlement.class);
    productCurator = Mockito.mock(ProductCurator.class);
    Configuration config = mock(Configuration.class);
    when(config.getInt(eq(ConfigProperties.PRODUCT_CACHE_MAX))).thenReturn(100);
    owner = TestUtil.createOwner();
}
Also used : Configuration(org.candlepin.common.config.Configuration) ProductCurator(org.candlepin.model.ProductCurator) Entitlement(org.candlepin.model.Entitlement) PoolManager(org.candlepin.controller.PoolManager) ProductServiceAdapter(org.candlepin.service.ProductServiceAdapter) Before(org.junit.Before)

Example 17 with Configuration

use of org.candlepin.common.config.Configuration in project candlepin by candlepin.

the class CandlepinModule method configureJPA.

protected void configureJPA() {
    Configuration jpaConfig = config.strippedSubset(ConfigurationPrefixes.JPA_CONFIG_PREFIX);
    install(new JpaPersistModule("default").properties(jpaConfig.toProperties()));
    bind(JPAInitializer.class).asEagerSingleton();
}
Also used : Configuration(org.candlepin.common.config.Configuration) JPAInitializer(org.candlepin.common.guice.JPAInitializer) JpaPersistModule(com.google.inject.persist.jpa.JpaPersistModule)

Example 18 with Configuration

use of org.candlepin.common.config.Configuration in project candlepin by candlepin.

the class QpidQmfTest method liveTest.

@Ignore("This test requires running qpid broker and is useful only for development")
@Test
public void liveTest() throws URISyntaxException, JMSException, InterruptedException {
    Configuration config = new CandlepinCommonTestConfig();
    config.setProperty("trust_store", "/etc/candlepin/certs/amqp/candlepin.truststore");
    config.setProperty("trust_store_password", "password");
    config.setProperty("key_store", "/etc/candlepin/certs/amqp/candlepin.jks");
    config.setProperty("key_store_password", "password");
    config.setProperty("retries", "0");
    config.setProperty("connectdelay", "1");
// QpidConnection connection = new QpidConnection(new QpidConfigBuilder(config));
// QpidQmf qmf = new QpidQmf(connection, config);
// System.out.println(qmf.getStatus());
}
Also used : Configuration(org.candlepin.common.config.Configuration) CandlepinCommonTestConfig(org.candlepin.config.CandlepinCommonTestConfig) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with Configuration

use of org.candlepin.common.config.Configuration in project candlepin by candlepin.

the class ProductResourceTest method testRefreshPoolsByProduct.

@Test
public void testRefreshPoolsByProduct() {
    Configuration config = new MapConfiguration(this.config);
    config.setProperty(ConfigProperties.STANDALONE, "false");
    ProductResource productResource = new ProductResource(this.productCurator, this.ownerCurator, this.productCertificateCurator, config, this.i18n, this.modelTranslator);
    List<Owner> owners = this.setupDBForOwnerProdTests();
    Owner owner1 = owners.get(0);
    Owner owner2 = owners.get(1);
    Owner owner3 = owners.get(2);
    JobDetail[] jobs;
    jobs = productResource.refreshPoolsForProduct(Arrays.asList("p1"), true);
    assertNotNull(jobs);
    assertEquals(2, jobs.length);
    this.verifyRefreshPoolsJobs(jobs, Arrays.asList(owner1, owner2), true);
    jobs = productResource.refreshPoolsForProduct(Arrays.asList("p1", "p2"), false);
    assertNotNull(jobs);
    assertEquals(3, jobs.length);
    this.verifyRefreshPoolsJobs(jobs, Arrays.asList(owner1, owner2, owner3), false);
    jobs = productResource.refreshPoolsForProduct(Arrays.asList("p3"), false);
    assertNotNull(jobs);
    assertEquals(1, jobs.length);
    this.verifyRefreshPoolsJobs(jobs, Arrays.asList(owner3), false);
    jobs = productResource.refreshPoolsForProduct(Arrays.asList("nope"), false);
    assertNotNull(jobs);
    assertEquals(0, jobs.length);
}
Also used : Owner(org.candlepin.model.Owner) JobDetail(org.quartz.JobDetail) MapConfiguration(org.candlepin.common.config.MapConfiguration) Configuration(org.candlepin.common.config.Configuration) MapConfiguration(org.candlepin.common.config.MapConfiguration) Test(org.junit.Test)

Example 20 with Configuration

use of org.candlepin.common.config.Configuration in project candlepin by candlepin.

the class PinsetterKernelTest method updateMultipleSchedules.

@Test
public void updateMultipleSchedules() throws Exception {
    Map<String, String> props = new HashMap<>();
    props.put(ConfigProperties.DEFAULT_TASKS, JobCleaner.class.getName());
    props.put("org.quartz.jobStore.isClustered", "true");
    props.put("pinsetter.org.candlepin.pinsetter.tasks." + "JobCleaner.schedule", "*/1 * * * * ?");
    Configuration config = new MapConfiguration(props);
    JobDetail jobDetail = mock(JobDetail.class);
    // Hack multiple job schedules for same job:
    String crongrp = "cron group";
    Set<JobKey> jobs = new HashSet<>();
    JobKey key = jobKey("org.candlepin.pinsetter.tasks.JobCleaner");
    jobs.add(key);
    JobKey key2 = jobKey("org.candlepin.pinsetter.tasks.JobCleaner2");
    jobs.add(key2);
    CronTrigger cronTrigger = mock(CronTrigger.class);
    when(cronTrigger.getJobKey()).thenReturn(key);
    when(cronTrigger.getCronExpression()).thenReturn("*/7 * * * * ?");
    when(sched.getJobKeys(eq(jobGroupEquals(crongrp)))).thenReturn(jobs);
    when(sched.getTrigger(any(TriggerKey.class))).thenReturn(cronTrigger);
    when(sched.getJobDetail(any(JobKey.class))).thenReturn(jobDetail);
    doReturn(JobCleaner.class).when(jobDetail).getJobClass();
    pk = new PinsetterKernel(config, jfactory, jlistener, jcurator, sfactory, triggerListener, modeManager);
    pk.startup();
    verify(sched, times(2)).deleteJob(any(JobKey.class));
    verify(jcurator).create(any(JobStatus.class));
}
Also used : CronTrigger(org.quartz.CronTrigger) MapConfiguration(org.candlepin.common.config.MapConfiguration) Configuration(org.candlepin.common.config.Configuration) HashMap(java.util.HashMap) MapConfiguration(org.candlepin.common.config.MapConfiguration) TriggerKey(org.quartz.TriggerKey) JobStatus(org.candlepin.pinsetter.core.model.JobStatus) JobDetail(org.quartz.JobDetail) JobKey(org.quartz.JobKey) JobCleaner(org.candlepin.pinsetter.tasks.JobCleaner) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Configuration (org.candlepin.common.config.Configuration)20 MapConfiguration (org.candlepin.common.config.MapConfiguration)9 Test (org.junit.Test)9 Before (org.junit.Before)7 JobDetail (org.quartz.JobDetail)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 CandlepinCommonTestConfig (org.candlepin.config.CandlepinCommonTestConfig)3 JobCleaner (org.candlepin.pinsetter.tasks.JobCleaner)3 CronTrigger (org.quartz.CronTrigger)3 Date (java.util.Date)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ServletContext (javax.servlet.ServletContext)2 Target (org.candlepin.audit.Event.Target)2 Type (org.candlepin.audit.Event.Type)2 ConfigurationException (org.candlepin.common.config.ConfigurationException)2 PropertiesFileConfiguration (org.candlepin.common.config.PropertiesFileConfiguration)2 StandardTranslator (org.candlepin.dto.StandardTranslator)2 Consumer (org.candlepin.model.Consumer)2