Пример #1
0
 public static ProfileBuilders getProfileBuilders() {
   ProfileBuilders builders;
   if (RuntimeLocator.getRuntime() != null) {
     builders = ServiceLocator.getRequiredService(ProfileBuilders.class);
   } else {
     try {
       ClassLoader classLoader = ProfileBuilders.class.getClassLoader();
       builders =
           (ProfileBuilders)
               classLoader.loadClass("io.fabric8.internal.DefaultProfileBuilders").newInstance();
     } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
       throw new IllegalStateException(ex);
     }
   }
   return builders;
 }
  @Test
  public void testModuleLifecycle() throws Exception {

    Module modA = RuntimeLocator.getRuntime().getModule(getClass().getClassLoader());
    Assert.assertEquals(Module.State.ACTIVE, modA.getState());

    ModuleContext context = modA.getModuleContext();
    ServiceRegistration<String> sreg =
        context.registerService(String.class, new String("Hello"), null);
    Assert.assertNotNull("Null sreg", sreg);

    String service = context.getService(sreg.getReference());
    Assert.assertEquals("Hello", service);

    modA.stop();
    Assert.assertEquals(Module.State.RESOLVED, modA.getState());

    modA.uninstall();
    Assert.assertEquals(Module.State.UNINSTALLED, modA.getState());
  }