@Test public void testEntityManagerQueriesGiveProxies() { EntityManager entityManager = managementContext.getEntityManager(); Application retrievedApp = (Application) entityManager.getEntity(app.getId()); TestEntity retrievedEntity = (TestEntity) entityManager.getEntity(entity.getId()); assertIsProxy(retrievedApp); assertIsProxy(retrievedEntity); Collection<Entity> entities = entityManager.getEntities(); for (Entity e : entities) { assertIsProxy(e); } assertEquals(ImmutableSet.copyOf(entities), ImmutableSet.of(app, entity)); }
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; }