test_class.declarator: springStatusChecker
test_class.modifier: private
test_class.original_string: private SpringStatusChecker springStatusChecker;
test_class.type: SpringStatusChecker
test_class.var_name: springStatusChecker
test_class.declarator: applicationContext
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ApplicationContext applicationContext;
test_class.type: ApplicationContext
test_class.var_name: applicationContext
test_class.file: dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/status/SpringStatusCheckerTest.java
test_class.identifier: SpringStatusCheckerTest
test_case.body: @Test
      public void testWithoutApplicationContext() {
          Status status = springStatusChecker.check();
  
          assertThat(status.getLevel(), is(Status.Level.UNKNOWN));
      }
test_case.class_method_signature: SpringStatusCheckerTest.testWithoutApplicationContext()
test_case.full_signature: @Test public void testWithoutApplicationContext()
test_case.identifier: testWithoutApplicationContext
test_case.invocations: check assertThat getLevel is
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testWithoutApplicationContext()
focal_class.declarator: logger = LoggerFactory.getLogger(SpringStatusChecker.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(SpringStatusChecker.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/status/SpringStatusChecker.java
focal_class.identifier: SpringStatusChecker
focal_class.interfaces: implements StatusChecker
focal_class.class_method_signature: SpringStatusChecker.check()
focal_class.full_signature: @Override public Status check()
focal_class.identifier: check
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Status
focal_class.signature: Status check()
focal_method.body: @Override
      public Status check() {
          ApplicationContext context = null;
          for (ApplicationContext c : SpringExtensionFactory.getContexts()) {
              // [Issue] SpringStatusChecker execute errors on non-XML Spring configuration
              // issue : https://github.com/apache/dubbo/issues/3615
              if(c instanceof GenericWebApplicationContext) { // ignore GenericXmlApplicationContext
                  continue;
              }
  
              if (c != null) {
                  context = c;
                  break;
              }
          }
  
          if (context == null) {
              return new Status(Status.Level.UNKNOWN);
          }
  
          Status.Level level;
          if (context instanceof Lifecycle) {
              if (((Lifecycle) context).isRunning()) {
                  level = Status.Level.OK;
              } else {
                  level = Status.Level.ERROR;
              }
          } else {
              level = Status.Level.UNKNOWN;
          }
          StringBuilder buf = new StringBuilder();
          try {
              Class<?> cls = context.getClass();
              Method method = null;
              while (cls != null && method == null) {
                  try {
                      method = cls.getDeclaredMethod("getConfigLocations", new Class<?>[0]);
                  } catch (NoSuchMethodException t) {
                      cls = cls.getSuperclass();
                  }
              }
              if (method != null) {
                  if (!method.isAccessible()) {
                      method.setAccessible(true);
                  }
                  String[] configs = (String[]) method.invoke(context, new Object[0]);
                  if (configs != null && configs.length > 0) {
                      for (String config : configs) {
                          if (buf.length() > 0) {
                              buf.append(",");
                          }
                          buf.append(config);
                      }
                  }
              }
          } catch (Throwable t) {
              logger.warn(t.getMessage(), t);
          }
          return new Status(level, buf.toString());
      }
focal_method.class_method_signature: SpringStatusChecker.check()
focal_method.full_signature: @Override public Status check()
focal_method.identifier: check
focal_method.invocations: getContexts isRunning getClass getDeclaredMethod getSuperclass isAccessible setAccessible invoke length append append warn getMessage toString
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: Status
focal_method.signature: Status check()