private TestApplication rebind() throws Exception { RebindTestUtils.waitForPersisted(app); TestApplication result = (TestApplication) RebindTestUtils.rebind(mementoDir, getClass().getClassLoader()); newManagementContext = result.getManagementContext(); return result; }
@BeforeMethod(alwaysRun = true) @Override public void setUp() throws Exception { mementoDir = Files.createTempDir(); mgmt = RebindTestUtils.newPersistingManagementContext(mementoDir, classLoader); super.setUp(); }
protected ManagementContext newPersistingManagementContext() { mementoDir = Os.newTempDir(JavaClassNames.cleanSimpleClassName(this)); Os.deleteOnExitRecursively(mementoDir); return RebindTestUtils.managementContextBuilder( classLoader, new FileBasedObjectStore(mementoDir)) .persistPeriod(Duration.millis(10)) .buildStarted(); }
@AfterMethod(alwaysRun = true) @Override public void tearDown() throws Exception { super.tearDown(); if (newApp != null) Entities.destroyAll(newApp.getManagementContext()); if (newManagementContext != null) Entities.destroyAll(newManagementContext); if (mementoDir != null) RebindTestUtils.deleteMementoDir(mementoDir); }
protected BrooklynMemento loadMemento() throws IOException, InterruptedException, TimeoutException { RebindTestUtils.waitForPersisted(localManagementContext); RecordingRebindExceptionHandler failFast = new RecordingRebindExceptionHandler( RebindFailureMode.FAIL_FAST, RebindFailureMode.FAIL_FAST); RebindContextImpl rebindContext = new RebindContextImpl(classLoader); RebindContextLookupContext lookupContext = new RebindContextLookupContext(localManagementContext, rebindContext, failFast); // here we force these two to be reegistered in order to resolve the enricher and policy // (normally rebind will do that after loading the manifests, but in this test we are just // looking at persistence/manifest) rebindContext.registerEntity(app.getId(), app); rebindContext.registerEntity(entity.getId(), entity); BrooklynMemento reloadedMemento = persister.loadMemento(lookupContext, failFast); return reloadedMemento; }