Search in sources :

Example 6 with Status

use of org.apache.dubbo.common.status.Status in project dubbo by alibaba.

the class LoadStatusCheckerTest method test.

@Test
public void test() throws Exception {
    LoadStatusChecker statusChecker = new LoadStatusChecker();
    Status status = statusChecker.check();
    assertThat(status, notNullValue());
    logger.info("load status level: " + status.getLevel());
    logger.info("load status message: " + status.getMessage());
}
Also used : Status(org.apache.dubbo.common.status.Status) Test(org.junit.jupiter.api.Test)

Example 7 with Status

use of org.apache.dubbo.common.status.Status in project dubbo by alibaba.

the class StatusUtilsTest method testGetSummaryStatus1.

@Test
public void testGetSummaryStatus1() throws Exception {
    Status status1 = new Status(Status.Level.ERROR);
    Status status2 = new Status(Status.Level.WARN);
    Status status3 = new Status(Status.Level.OK);
    Map<String, Status> statuses = new HashMap<String, Status>();
    statuses.put("status1", status1);
    statuses.put("status2", status2);
    statuses.put("status3", status3);
    Status status = StatusUtils.getSummaryStatus(statuses);
    assertThat(status.getLevel(), is(Status.Level.ERROR));
    assertThat(status.getMessage(), containsString("status1"));
    assertThat(status.getMessage(), containsString("status2"));
    assertThat(status.getMessage(), not(containsString("status3")));
}
Also used : Status(org.apache.dubbo.common.status.Status) HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Test(org.junit.jupiter.api.Test)

Example 8 with Status

use of org.apache.dubbo.common.status.Status in project dubbo by alibaba.

the class StatusUtilsTest method testGetSummaryStatus3.

@Test
public void testGetSummaryStatus3() throws Exception {
    Status status1 = new Status(Status.Level.OK);
    Map<String, Status> statuses = new HashMap<String, Status>();
    statuses.put("status1", status1);
    Status status = StatusUtils.getSummaryStatus(statuses);
    assertThat(status.getLevel(), is(Status.Level.OK));
    assertThat(status.getMessage(), isEmptyOrNullString());
}
Also used : Status(org.apache.dubbo.common.status.Status) HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Test(org.junit.jupiter.api.Test)

Example 9 with Status

use of org.apache.dubbo.common.status.Status in project dubbo by alibaba.

the class SpringStatusCheckerTest method testWithoutApplicationContext.

@Test
public void testWithoutApplicationContext() {
    Status status = springStatusChecker.check();
    assertThat(status.getLevel(), is(Status.Level.UNKNOWN));
}
Also used : Status(org.apache.dubbo.common.status.Status) Test(org.junit.jupiter.api.Test)

Example 10 with Status

use of org.apache.dubbo.common.status.Status in project dubbo by alibaba.

the class SpringStatusCheckerTest method testGenericWebApplicationContext.

@Test
public void testGenericWebApplicationContext() {
    SpringExtensionFactory.clearContexts();
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    SpringExtensionFactory.addApplicationContext(context);
    SpringStatusChecker checker = new SpringStatusChecker();
    Status status = checker.check();
    Assertions.assertEquals(Status.Level.UNKNOWN, status.getLevel());
}
Also used : Status(org.apache.dubbo.common.status.Status) GenericWebApplicationContext(org.springframework.web.context.support.GenericWebApplicationContext) Test(org.junit.jupiter.api.Test)

Aggregations

Status (org.apache.dubbo.common.status.Status)27 Test (org.junit.jupiter.api.Test)19 HashMap (java.util.HashMap)7 DataSource (javax.sql.DataSource)4 Connection (java.sql.Connection)3 Map (java.util.Map)3 Registry (org.apache.dubbo.registry.Registry)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)3 Method (java.lang.reflect.Method)2 StatusChecker (org.apache.dubbo.common.status.StatusChecker)2 RegistryStatusChecker (org.apache.dubbo.registry.status.RegistryStatusChecker)2 ApplicationContext (org.springframework.context.ApplicationContext)2 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)2 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExecutorService (java.util.concurrent.ExecutorService)1