Search in sources :

Example 1 with Status

use of org.candlepin.model.Status in project candlepin by candlepin.

the class StatusResourceTest method status.

@Test
public void status() throws Exception {
    PrintStream ps = new PrintStream(new File(this.getClass().getClassLoader().getResource("version.properties").toURI()));
    ps.println("version=${version}");
    ps.println("release=${release}");
    StatusResource sr = new StatusResource(rulesCurator, config, jsProvider, candlepinCache, modeManager);
    Status s = sr.status();
    ps.close();
    assertNotNull(s);
    assertEquals("${release}", s.getRelease());
    assertEquals("${version}", s.getVersion());
    assertTrue(s.getResult());
}
Also used : Status(org.candlepin.model.Status) PrintStream(java.io.PrintStream) File(java.io.File) Test(org.junit.Test)

Example 2 with Status

use of org.candlepin.model.Status in project candlepin by candlepin.

the class StatusResourceTest method testDBDown.

@Test
public void testDBDown() throws Exception {
    PrintStream ps = new PrintStream(new File(this.getClass().getClassLoader().getResource("version.properties").toURI()));
    ps.println("version=${version}");
    ps.println("release=${release}");
    when(rulesCurator.getUpdatedFromDB()).thenThrow(new RuntimeException());
    StatusResource sr = new StatusResource(rulesCurator, config, jsProvider, candlepinCache, modeManager);
    Status s = sr.status();
    ps.close();
    assertNotNull(s);
    assertEquals("${release}", s.getRelease());
    assertEquals("${version}", s.getVersion());
    assertFalse(s.getResult());
}
Also used : Status(org.candlepin.model.Status) PrintStream(java.io.PrintStream) File(java.io.File) Test(org.junit.Test)

Example 3 with Status

use of org.candlepin.model.Status in project candlepin by candlepin.

the class StatusCacheTest method setAndGet.

@Test
public void setAndGet() {
    StatusCache cache = new StatusCache();
    Status status = new Status(true, "2.0", "2.0", false, "4.2", Rules.RulesSourceEnum.DATABASE, CandlepinModeChange.Mode.NORMAL, CandlepinModeChange.Reason.STARTUP, new Date());
    cache.setStatus(status);
    assertEquals(status, cache.getStatus());
}
Also used : Status(org.candlepin.model.Status) Date(java.util.Date) Test(org.junit.Test)

Example 4 with Status

use of org.candlepin.model.Status in project candlepin by candlepin.

the class StatusCacheTest method multipleInstancesShareSameStatus.

@Test
public void multipleInstancesShareSameStatus() {
    StatusCache cache1 = new StatusCache();
    Status status = new Status(true, "2.0", "2.0", false, "4.2", Rules.RulesSourceEnum.DATABASE, CandlepinModeChange.Mode.NORMAL, CandlepinModeChange.Reason.STARTUP, new Date());
    cache1.setStatus(status);
    StatusCache cache2 = new StatusCache();
    assertEquals(cache1.getStatus(), cache2.getStatus());
}
Also used : Status(org.candlepin.model.Status) Date(java.util.Date) Test(org.junit.Test)

Example 5 with Status

use of org.candlepin.model.Status in project candlepin by candlepin.

the class StatusCacheTest method testExpiresAfter5Seconds.

@Test
public void testExpiresAfter5Seconds() throws Exception {
    StatusCache cache = new StatusCache();
    Status status = new Status(true, "2.0", "2.0", false, "4.2", Rules.RulesSourceEnum.DATABASE, CandlepinModeChange.Mode.NORMAL, CandlepinModeChange.Reason.STARTUP, new Date());
    cache.setStatus(status);
    assertEquals(status, cache.getStatus());
    Thread.sleep(6000L);
    assertNull(cache.getStatus());
}
Also used : Status(org.candlepin.model.Status) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Status (org.candlepin.model.Status)8 Test (org.junit.Test)7 File (java.io.File)4 PrintStream (java.io.PrintStream)4 Date (java.util.Date)3 Logger (ch.qos.logback.classic.Logger)1 LoggerContext (ch.qos.logback.classic.LoggerContext)1 LoggingEvent (ch.qos.logback.classic.spi.LoggingEvent)1 Appender (ch.qos.logback.core.Appender)1 ApiOperation (io.swagger.annotations.ApiOperation)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 StatusCache (org.candlepin.cache.StatusCache)1 SecurityHole (org.candlepin.common.auth.SecurityHole)1 CandlepinModeChange (org.candlepin.model.CandlepinModeChange)1