コード例 #1
0
 /**
  * Dumps out the persisted mementos that are at the given directory.
  *
  * <p>Binds to the persisted state (as a "hot standby") to load the raw data (as strings), and to
  * write out the entity, location, policy, enricher, feed and catalog-item data.
  *
  * @param dir The directory containing the persisted state
  */
 public static void dumpMementoDir(File dir) {
   LocalManagementContextForTests mgmt =
       new LocalManagementContextForTests(BrooklynProperties.Factory.newEmpty());
   FileBasedObjectStore store = null;
   BrooklynMementoPersisterToObjectStore persister = null;
   try {
     store = new FileBasedObjectStore(dir);
     store.injectManagementContext(mgmt);
     store.prepareForSharedUse(PersistMode.AUTO, HighAvailabilityMode.HOT_STANDBY);
     persister =
         new BrooklynMementoPersisterToObjectStore(
             store, BrooklynProperties.Factory.newEmpty(), RebindTestUtils.class.getClassLoader());
     BrooklynMementoRawData data =
         persister.loadMementoRawData(RebindExceptionHandlerImpl.builder().build());
     List<BrooklynObjectType> types =
         ImmutableList.of(
             BrooklynObjectType.ENTITY,
             BrooklynObjectType.LOCATION,
             BrooklynObjectType.POLICY,
             BrooklynObjectType.ENRICHER,
             BrooklynObjectType.FEED,
             BrooklynObjectType.CATALOG_ITEM);
     for (BrooklynObjectType type : types) {
       LOG.info(type + " (" + data.getObjectsOfType(type).keySet() + "):");
       for (Map.Entry<String, String> entry : data.getObjectsOfType(type).entrySet()) {
         LOG.info("\t" + type + " " + entry.getKey() + ": " + entry.getValue());
       }
     }
   } finally {
     if (persister != null) persister.stop(false);
     if (store != null) store.close();
     mgmt.terminate();
   }
 }
コード例 #2
0
 @Test
 public void testAddUsageListenerViaProperties() throws Exception {
   BrooklynProperties brooklynProperties = BrooklynProperties.Factory.newEmpty();
   brooklynProperties.put(
       UsageManager.USAGE_LISTENERS, RecordingStaticUsageListener.class.getName());
   mgmt = LocalManagementContextForTests.newInstance(brooklynProperties);
   assertUsageListenerCalledWhenApplicationStarted();
 }
コード例 #3
0
  @Override
  protected LocalManagementContext newTestManagementContext() {
    ResourceUtils ru = new ResourceUtils(this);
    File jar = createJar(ru);
    File catalog = createCatalog(ru, jar);

    BrooklynProperties properties = BrooklynProperties.Factory.newEmpty();
    properties.put(BrooklynServerConfig.BROOKLYN_CATALOG_URL, catalog.toURI().toString());
    return LocalManagementContextForTests.builder(true)
        .useProperties(properties)
        .disableOsgi(false)
        .build();
  }
コード例 #4
0
 @Test(expectedExceptions = ClassCastException.class)
 public void testErrorWhenConfiguredClassIsNotAUsageListener() {
   BrooklynProperties brooklynProperties = BrooklynProperties.Factory.newEmpty();
   brooklynProperties.put(UsageManager.USAGE_LISTENERS, Integer.class.getName());
   mgmt = LocalManagementContextForTests.newInstance(brooklynProperties);
 }