コード例 #1
0
ファイル: PluginContextTest.java プロジェクト: srajeev/hippo
  @Test
  public void testServiceIsInvisibleDuringConstruction() {
    ServiceTracker<ITestService> tracker =
        new ServiceTracker<ITestService>(ITestService.class) {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onServiceAdded(ITestService service, String name) {
            service.test();
          }
        };
    context.registerTracker(tracker, "service.test");

    JavaPluginConfig config = new JavaPluginConfig("test");
    config.put("plugin.class", TestSubclassingPlugin.class.getName());
    JavaClusterConfig cluster = new JavaClusterConfig();
    cluster.addPlugin(config);
    IClusterControl control = context.newCluster(cluster, new JavaPluginConfig());
    control.start();

    ITestService testService = context.getService("service.test", ITestService.class);
    assertNotNull(testService);
    testService.test();
  }