http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/entity/lifecycle/ServiceStateLogicTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/entity/lifecycle/ServiceStateLogicTest.java b/core/src/test/java/org/apache/brooklyn/entity/lifecycle/ServiceStateLogicTest.java deleted file mode 100644 index aa6d235..0000000 --- a/core/src/test/java/org/apache/brooklyn/entity/lifecycle/ServiceStateLogicTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.brooklyn.entity.lifecycle; - -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.api.entity.EntitySpec; -import org.apache.brooklyn.api.location.Location; -import org.apache.brooklyn.api.sensor.AttributeSensor; -import org.apache.brooklyn.api.sensor.Enricher; -import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport; -import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.core.test.entity.TestEntityImpl.TestEntityWithoutEnrichers; -import org.apache.brooklyn.entity.core.Attributes; -import org.apache.brooklyn.entity.core.Entities; -import org.apache.brooklyn.entity.core.EntityAdjuncts; -import org.apache.brooklyn.entity.core.EntityInternal; -import org.apache.brooklyn.entity.group.DynamicCluster; -import org.apache.brooklyn.entity.lifecycle.Lifecycle; -import org.apache.brooklyn.entity.lifecycle.ServiceStateLogic; -import org.apache.brooklyn.entity.lifecycle.ServiceStateLogic.ComputeServiceIndicatorsFromChildrenAndMembers; -import org.apache.brooklyn.entity.lifecycle.ServiceStateLogic.ServiceNotUpLogic; -import org.apache.brooklyn.entity.lifecycle.ServiceStateLogic.ServiceProblemsLogic; -import org.apache.brooklyn.sensor.core.Sensors; -import org.apache.brooklyn.test.EntityTestUtils; -import org.apache.brooklyn.util.collections.QuorumCheck.QuorumChecks; -import org.apache.brooklyn.util.exceptions.Exceptions; -import org.apache.brooklyn.util.time.Duration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -@Test -public class ServiceStateLogicTest extends BrooklynAppUnitTestSupport { - - private static final Logger log = LoggerFactory.getLogger(ServiceStateLogicTest.class); - - final static String INDICATOR_KEY_1 = "test-indicator-1"; - final static String INDICATOR_KEY_2 = "test-indicator-2"; - - protected TestEntity entity; - - @Override - protected void setUpApp() { - super.setUpApp(); - entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); - } - - - public void testManuallySettingIndicatorsOnEntities() { - // if we set a not up indicator, entity service up should become false - ServiceNotUpLogic.updateNotUpIndicator(entity, INDICATOR_KEY_1, "We're pretending to block service up"); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false); - - // but state will not change unless we also set either a problem or expected state - assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, null); - ServiceProblemsLogic.updateProblemsIndicator(entity, INDICATOR_KEY_1, "We're pretending to block service state also"); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); - - // and if we clear the not up indicator, service up becomes true, but there is a problem, so it shows on-fire - ServiceNotUpLogic.clearNotUpIndicator(entity, INDICATOR_KEY_1); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); - - // if we then clear the problem also, state goes to RUNNING - ServiceProblemsLogic.clearProblemsIndicator(entity, INDICATOR_KEY_1); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - - // now add not-up indicator again, and it reverts to up=false, state=stopped - ServiceNotUpLogic.updateNotUpIndicator(entity, INDICATOR_KEY_1, "We're again pretending to block service up"); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); - - // but if we expect it to be running it will show on fire (because service is not up) - ServiceStateLogic.setExpectedState(entity, Lifecycle.RUNNING); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); - - // and if we again clear the not up indicator it will deduce up=true and state=running - ServiceNotUpLogic.clearNotUpIndicator(entity, INDICATOR_KEY_1); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - } - - public void testAppStoppedAndEntityNullBeforeStarting() { - // AbstractApplication has default logic to ensure service is not up if it hasn't been started, - // (this can be removed by updating the problem indicator associated with the SERVICE_STATE_ACTUAL sensor) - assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, false); - // and from that it imputes stopped state - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); - - // TestEntity has no such indicators however - assertAttributeEquals(entity, Attributes.SERVICE_UP, null); - assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, null); - } - - public void testAllUpAndRunningAfterStart() { - app.start(ImmutableList.<Location>of()); - - assertAttributeEquals(app, Attributes.SERVICE_UP, true); - assertAttributeEquals(entity, Attributes.SERVICE_UP, true); - // above should be immediate, entity should then derive RUNNING from expected state, and then so should app from children - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - } - - public void testStopsNicelyToo() { - app.start(ImmutableList.<Location>of()); - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - - app.stop(); - - assertAttributeEquals(app, Attributes.SERVICE_UP, false); - assertAttributeEquals(entity, Attributes.SERVICE_UP, false); - // above should be immediate, app and entity should then derive STOPPED from the expected state - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); - } - - public void testTwoIndicatorsAreBetterThanOne() { - // if we set a not up indicator, entity service up should become false - ServiceNotUpLogic.updateNotUpIndicator(entity, INDICATOR_KEY_1, "We're pretending to block service up"); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false); - ServiceNotUpLogic.updateNotUpIndicator(entity, INDICATOR_KEY_2, "We're also pretending to block service up"); - ServiceNotUpLogic.clearNotUpIndicator(entity, INDICATOR_KEY_1); - // clearing one indicator is not sufficient - assertAttributeEquals(entity, Attributes.SERVICE_UP, false); - - // but it does not become true when both are cleared - ServiceNotUpLogic.clearNotUpIndicator(entity, INDICATOR_KEY_2); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true); - } - - @Test(invocationCount=100, groups="Integration") - public void testManuallySettingIndicatorsOnApplicationsManyTimes() throws Exception { - testManuallySettingIndicatorsOnApplications(); - } - - public void testManuallySettingIndicatorsOnApplications() throws Exception { - // indicators on application are more complicated because it is configured with additional indicators from its children - // test a lot of situations, including reconfiguring some of the quorum config - - // to begin with, an entity has not reported anything, so the ComputeServiceIndicatorsFromChildren ignores it - // but the AbstractApplication has emitted a not-up indicator because it has not been started - // both as asserted by this other test: - testAppStoppedAndEntityNullBeforeStarting(); - - // if we clear the not up indicator, the app will show as up, and as running, because it has no reporting children - ServiceNotUpLogic.clearNotUpIndicator(app, Attributes.SERVICE_STATE_ACTUAL); - assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true); - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - - // if we then put a not-up indicator on the TestEntity, it publishes false, but app is still up. State - // won't propagate due to it's SERVICE_STATE_ACTUAL (null) being in IGNORE_ENTITIES_WITH_THESE_SERVICE_STATES - ServiceNotUpLogic.updateNotUpIndicator(entity, INDICATOR_KEY_1, "We're also pretending to block service up"); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false); - assertAttributeEqualsContinually(app, Attributes.SERVICE_UP, true); - assertAttributeEqualsContinually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - // the entity still has no opinion about its state - assertAttributeEqualsContinually(entity, Attributes.SERVICE_STATE_ACTUAL, null); - - // switching the entity state to one not in IGNORE_ENTITIES_WITH_THESE_SERVICE_STATES will propagate the up state - ServiceStateLogic.setExpectedState(entity, Lifecycle.RUNNING); - assertAttributeEqualsContinually(entity, Attributes.SERVICE_UP, false); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); - assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, false); - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); - - - // if the entity expects to be stopped, it will report stopped - ServiceStateLogic.setExpectedState(entity, Lifecycle.STOPPED); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); - // and the app will ignore the entity state, so becomes running - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true); - - // if we clear the not-up indicator, both the entity and the app report service up (with the entity first) - ServiceNotUpLogic.clearNotUpIndicator(entity, INDICATOR_KEY_1); - assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true); - // but entity is still stopped because that is what is expected there, and that's okay even if service is apparently up - assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); - // the app however is running, because the default state quorum check is "all are healthy" - assertAttributeEqualsContinually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - assertAttributeEqualsContinually(app, Attributes.SERVICE_UP, true); - - // if we change the state quorum check for the app to be "all are healthy and at least one running" *then* it shows stopped - // (normally this would be done in `initEnrichers` of course) - Enricher appChildrenBasedEnricher = EntityAdjuncts.tryFindWithUniqueTag(app.getEnrichers(), ComputeServiceIndicatorsFromChildrenAndMembers.DEFAULT_UNIQUE_TAG).get(); - appChildrenBasedEnricher.config().set(ComputeServiceIndicatorsFromChildrenAndMembers.RUNNING_QUORUM_CHECK, QuorumChecks.allAndAtLeastOne()); - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); - - // if entity is expected running, then it will show running because service is up; this is reflected at app and at entity - ServiceStateLogic.setExpectedState(entity, Lifecycle.RUNNING); - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true); - assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - - // now, when the entity is unmanaged, the app goes on fire because don't have "at least one running" - Entities.unmanage(entity); - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); - // but UP_QUORUM_CHECK is still the default atLeastOneUnlessEmpty; so serviceUp=true - assertAttributeEqualsContinually(app, Attributes.SERVICE_UP, true); - - // if we change its up-quorum to atLeastOne then state becomes stopped (because there is no expected state; has not been started) - appChildrenBasedEnricher.config().set(ComputeServiceIndicatorsFromChildrenAndMembers.UP_QUORUM_CHECK, QuorumChecks.atLeastOne()); - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); - assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, false); - - // if we now start it will successfully start (because unlike entities it does not wait for service up) - // but will remain down and will go on fire - app.start(ImmutableList.<Location>of()); - assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, false); - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); - - // restoring up-quorum to "atLeastOneUnlessEmpty" causes it to become RUNNING, because happy with empty - appChildrenBasedEnricher.config().set(ComputeServiceIndicatorsFromChildrenAndMembers.UP_QUORUM_CHECK, QuorumChecks.atLeastOneUnlessEmpty()); - assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true); - // but running-quorum is still allAndAtLeastOne, so remains on-fire - assertAttributeEqualsContinually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); - - // now add a child, it's still up and running because null values are ignored by default (i.e. we're still "empty") - entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); - assertAttributeEqualsContinually(app, Attributes.SERVICE_UP, true); - assertAttributeEqualsContinually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); - - // tell it not to ignore null values for children states, and it will go onfire (but still be service up) - appChildrenBasedEnricher.config().set(ComputeServiceIndicatorsFromChildrenAndMembers.IGNORE_ENTITIES_WITH_THESE_SERVICE_STATES, - ImmutableSet.<Lifecycle>of()); - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); - assertAttributeEquals(app, Attributes.SERVICE_UP, true); - - // tell it not to ignore null values for service up and it will go service down - appChildrenBasedEnricher.config().set(ComputeServiceIndicatorsFromChildrenAndMembers.IGNORE_ENTITIES_WITH_SERVICE_UP_NULL, false); - assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, false); - - // set the entity to RUNNING and the app will be healthy again - ServiceNotUpLogic.clearNotUpIndicator(entity, INDICATOR_KEY_1); - ServiceStateLogic.setExpectedState(entity, Lifecycle.RUNNING); - assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true); - assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - assertAttributeEquals(entity, Attributes.SERVICE_UP, true); - assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - } - - @Test - public void testQuorumWithStringStates() { - final DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class) - .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(TestEntityWithoutEnrichers.class)) - .configure(DynamicCluster.INITIAL_SIZE, 1)); - - cluster.start(ImmutableList.of(app.newSimulatedLocation())); - EntityTestUtils.assertGroupSizeEqualsEventually(cluster, 1); - - //manually set state to healthy as enrichers are disabled - EntityInternal child = (EntityInternal) cluster.getMembers().iterator().next(); - child.setAttribute(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - child.setAttribute(Attributes.SERVICE_UP, Boolean.TRUE); - - EntityTestUtils.assertAttributeEqualsEventually(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - - //set untyped service state, the quorum check should be able to handle coercion - AttributeSensor<Object> stateSensor = Sensors.newSensor(Object.class, Attributes.SERVICE_STATE_ACTUAL.getName()); - child.setAttribute(stateSensor, "running"); - - EntityTestUtils.assertAttributeEqualsContinually(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); - } - - private static <T> void assertAttributeEqualsEventually(Entity x, AttributeSensor<T> sensor, T value) { - try { - EntityTestUtils.assertAttributeEqualsEventually(ImmutableMap.of("timeout", Duration.seconds(3)), x, sensor, value); - } catch (Throwable e) { - log.warn("Expected "+x+" eventually to have "+sensor+" = "+value+"; instead:"); - Entities.dumpInfo(x); - throw Exceptions.propagate(e); - } - } - private static <T> void assertAttributeEqualsContinually(Entity x, AttributeSensor<T> sensor, T value) { - try { - EntityTestUtils.assertAttributeEqualsContinually(ImmutableMap.of("timeout", Duration.millis(25)), x, sensor, value); - } catch (Throwable e) { - log.warn("Expected "+x+" continually to have "+sensor+" = "+value+"; instead:"); - Entities.dumpInfo(x); - throw Exceptions.propagate(e); - } - } - private static <T> void assertAttributeEquals(Entity x, AttributeSensor<T> sensor, T value) { - try { - EntityTestUtils.assertAttributeEquals(x, sensor, value); - } catch (Throwable e) { - log.warn("Expected "+x+" to have "+sensor+" = "+value+"; instead:"); - Entities.dumpInfo(x); - throw Exceptions.propagate(e); - } - } - -}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/entity/proxying/ApplicationBuilderOverridingTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/entity/proxying/ApplicationBuilderOverridingTest.java b/core/src/test/java/org/apache/brooklyn/entity/proxying/ApplicationBuilderOverridingTest.java deleted file mode 100644 index 412bf20..0000000 --- a/core/src/test/java/org/apache/brooklyn/entity/proxying/ApplicationBuilderOverridingTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.brooklyn.entity.proxying; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import org.apache.brooklyn.api.entity.Application; -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.api.entity.EntitySpec; -import org.apache.brooklyn.api.mgmt.ManagementContext; -import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; -import org.apache.brooklyn.core.objs.proxy.EntityProxy; -import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.core.test.entity.TestApplication; -import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.entity.core.AbstractEntity; -import org.apache.brooklyn.entity.core.Entities; -import org.apache.brooklyn.entity.core.EntityInternal; -import org.apache.brooklyn.entity.core.StartableApplication; -import org.apache.brooklyn.entity.factory.ApplicationBuilder; -import org.apache.brooklyn.entity.stock.BasicApplication; -import org.apache.brooklyn.util.exceptions.Exceptions; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -public class ApplicationBuilderOverridingTest { - - private static final long TIMEOUT_MS = 10*1000; - - private ManagementContext spareManagementContext; - private Application app; - private ExecutorService executor; - - @BeforeMethod(alwaysRun=true) - public void setUp() throws Exception { - spareManagementContext = new LocalManagementContextForTests(); - executor = Executors.newCachedThreadPool(); - } - - @AfterMethod(alwaysRun=true) - public void tearDown() { - if (app != null) Entities.destroyAll(app.getManagementContext()); - app = null; - if (spareManagementContext != null) Entities.destroyAll(spareManagementContext); - spareManagementContext = null; - } - - @Test - public void testUsesDefaultBasicApplicationClass() { - app = new ApplicationBuilder() { - @Override public void doBuild() {} - }.manage(); - - assertEquals(app.getEntityType().getName(), BasicApplication.class.getCanonicalName()); - assertIsProxy(app); - } - - @Test - public void testUsesSuppliedApplicationClass() { - app = new ApplicationBuilder(EntitySpec.create(TestApplication.class)) { - @Override public void doBuild() {} - }.manage(); - - assertEquals(app.getEntityType().getName(), TestApplication.class.getName()); - } - - @Test - public void testUsesSuppliedManagementContext() { - app = new ApplicationBuilder() { - @Override public void doBuild() {} - }.manage(spareManagementContext); - - assertEquals(app.getManagementContext(), spareManagementContext); - } - - @Test - public void testCreatesChildEntity() { - final AtomicReference<TestEntity> expectedChild = new AtomicReference<TestEntity>(); - app = new ApplicationBuilder() { - @Override public void doBuild() { - expectedChild.set(addChild(EntitySpec.create(TestEntity.class))); - } - }.manage(); - - assertIsProxy(expectedChild.get()); - assertEquals(ImmutableSet.copyOf(app.getChildren()), ImmutableSet.of(expectedChild.get())); - assertEquals(expectedChild.get().getParent(), app); - } - - @Test - public void testAppHierarchyIsManaged() { - app = new ApplicationBuilder() { - @Override public void doBuild() { - Entity entity = addChild(EntitySpec.create(TestEntity.class)); - assertFalse(getManagementContext().getEntityManager().isManaged(entity)); - } - }.manage(); - - assertIsManaged(app); - assertIsManaged(Iterables.get(app.getChildren(), 0)); - } - - @Test(expectedExceptions=IllegalStateException.class) - public void testRentrantCallToManageForbidden() { - ManagementContext secondManagementContext = new LocalManagementContext(); - try { - app = new ApplicationBuilder() { - @Override public void doBuild() { - manage(spareManagementContext); - } - }.manage(secondManagementContext); - } finally { - Entities.destroyAll(secondManagementContext); - } - } - - @Test(expectedExceptions=IllegalStateException.class) - public void testMultipleCallsToManageForbidden() { - ApplicationBuilder appBuilder = new ApplicationBuilder() { - @Override public void doBuild() { - } - }; - app = appBuilder.manage(); - - appBuilder.manage(spareManagementContext); - } - - @Test(expectedExceptions=IllegalStateException.class) - public void testCallToConfigureAfterManageForbidden() { - ApplicationBuilder appBuilder = new ApplicationBuilder() { - @Override public void doBuild() { - } - }; - app = appBuilder.manage(); - appBuilder.configure(ImmutableMap.of()); - } - - @Test(expectedExceptions=IllegalStateException.class) - public void testCallToSetDisplayNameAfterManageForbidden() { - ApplicationBuilder appBuilder = new ApplicationBuilder() { - @Override public void doBuild() { - } - }; - app = appBuilder.manage(spareManagementContext); - appBuilder.appDisplayName("myname"); - } - - @Test - public void testConcurrentCallToManageForbidden() throws Exception { - final CountDownLatch inbuildLatch = new CountDownLatch(1); - final CountDownLatch continueLatch = new CountDownLatch(1); - final ApplicationBuilder builder = new ApplicationBuilder() { - @Override public void doBuild() { - try { - inbuildLatch.countDown(); - continueLatch.await(); - } catch (InterruptedException e) { - throw Exceptions.propagate(e); - } - } - }; - Future<StartableApplication> future = executor.submit(new Callable<StartableApplication>() { - public StartableApplication call() { - return builder.manage(); - } - }); - - inbuildLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS); - - try { - app = builder.manage(spareManagementContext); - fail(); - } catch (IllegalStateException e) { - // expected - } - - continueLatch.countDown(); - app = future.get(TIMEOUT_MS, TimeUnit.MILLISECONDS); - } - - private void assertIsProxy(Entity e) { - assertFalse(e instanceof AbstractEntity, "e="+e+";e.class="+e.getClass()); - assertTrue(e instanceof EntityProxy, "e="+e+";e.class="+e.getClass()); - } - - private void assertIsManaged(Entity e) { - assertTrue(((EntityInternal)e).getManagementSupport().isDeployed(), "e="+e); - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/entity/proxying/BasicEntityTypeRegistryTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/entity/proxying/BasicEntityTypeRegistryTest.java b/core/src/test/java/org/apache/brooklyn/entity/proxying/BasicEntityTypeRegistryTest.java deleted file mode 100644 index ebca849..0000000 --- a/core/src/test/java/org/apache/brooklyn/entity/proxying/BasicEntityTypeRegistryTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.brooklyn.entity.proxying; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; - -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.api.entity.ImplementedBy; -import org.apache.brooklyn.core.objs.BasicEntityTypeRegistry; -import org.apache.brooklyn.entity.core.AbstractEntity; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class BasicEntityTypeRegistryTest { - - private BasicEntityTypeRegistry registry; - - @BeforeMethod(alwaysRun=true) - public void setUp() { - registry = new BasicEntityTypeRegistry(); - } - - @AfterMethod - public void tearDown(){ - // nothing to tear down; no management context created - } - - @Test - public void testRegisterAllowsOverridingKey() { - registry.registerImplementation(MyEntity.class, MyEntityImpl.class); - registry.registerImplementation(MyEntity.class, MyEntityImpl2.class); - assertEquals(registry.getImplementedBy(MyEntity.class), MyEntityImpl2.class); - } - - @Test - public void testRegisterForbidsDuplicateValues() { - registry.registerImplementation(MyEntity.class, MyEntityImpl2.class); - try { - registry.registerImplementation(MyEntity2.class, MyEntityImpl2.class); - } catch (IllegalArgumentException e) { - if (!e.toString().contains("already registered against type")) throw e; - } - } - - @Test - public void testGetImplementionLooksUpAnnotations() { - assertEquals(registry.getImplementedBy(MyEntity.class), MyEntityImpl.class); - } - - @Test - public void testGetImplementionUsesRegistryFirst() { - registry.registerImplementation(MyEntity.class, MyEntityImpl2.class); - assertEquals(registry.getImplementedBy(MyEntity.class), MyEntityImpl2.class); - } - - @Test - public void testGetImplementionThrowsIfNoRegistryOrAnnotation() { - try { - Class<?> result = registry.getImplementedBy(MyEntityWithoutAnnotation.class); - fail("result="+result); - } catch (IllegalArgumentException e) { - if (!e.toString().contains("MyEntityWithoutAnnotation is not annotated")) throw e; - } - } - - @Test - public void testGetEntityTypeOfLooksUpAnnotation() { - assertEquals(registry.getEntityTypeOf(MyEntityImpl.class), MyEntity.class); - } - - @Test - public void testGetEntityTypeOfLooksUpRegistry() { - registry.registerImplementation(MyEntity.class, MyEntityImpl2.class); - assertEquals(registry.getEntityTypeOf(MyEntityImpl2.class), MyEntity.class); - } - - @Test - public void testGetEntityTypeOfThrowsIfNoRegistryOrAnnotation() { - try { - Class<?> result = registry.getEntityTypeOf(MyEntityImpl2.class); - fail("result="+result); - } catch (IllegalArgumentException e) { - if (!e.toString().matches(".*Interfaces of .* not annotated.*")) throw e; - } - } - - @Test - public void testGetEntityTypeOfLooksUpAnnotationOnIndirectlyImplementedClasses() { - assertEquals(registry.getEntityTypeOf(MyIndirectEntityImpl.class), MyIndirectEntity.class); - } - - public interface MyEntityWithoutAnnotation extends Entity { - } - - @ImplementedBy(MyEntityImpl.class) - public interface MyEntity extends Entity { - } - - public interface MyEntity2 extends Entity { - } - - public static class MyEntityImpl extends AbstractEntity implements MyEntity { - } - - public static class MyEntityImpl2 extends AbstractEntity implements MyEntity, MyEntity2 { - } - - @ImplementedBy(MyIndirectEntityImpl.class) - public interface MyIndirectEntity extends Entity { - } - - public interface MyIndirectEntitySub extends MyIndirectEntity { - } - - public static class MyIndirectEntityImpl extends AbstractEntity implements MyIndirectEntitySub { - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/entity/proxying/EntityManagerTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/entity/proxying/EntityManagerTest.java b/core/src/test/java/org/apache/brooklyn/entity/proxying/EntityManagerTest.java deleted file mode 100644 index 36b84d9..0000000 --- a/core/src/test/java/org/apache/brooklyn/entity/proxying/EntityManagerTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.brooklyn.entity.proxying; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import org.apache.brooklyn.api.entity.EntitySpec; -import org.apache.brooklyn.api.mgmt.EntityManager; -import org.apache.brooklyn.core.objs.proxy.EntityProxy; -import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport; -import org.apache.brooklyn.core.test.entity.TestApplication; -import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.core.test.entity.TestEntityImpl; -import org.apache.brooklyn.entity.factory.ApplicationBuilder; -import org.apache.brooklyn.test.Asserts; -import org.apache.brooklyn.util.collections.MutableMap; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableList; - -public class EntityManagerTest extends BrooklynAppUnitTestSupport { - - private EntityManager entityManager; - - @BeforeMethod(alwaysRun=true) - @Override - public void setUp() throws Exception { - super.setUp(); - entityManager = mgmt.getEntityManager(); - } - - @Test - public void testCreateEntityUsingSpec() { - TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); - TestEntity child = entity.addChild(EntitySpec.create(TestEntity.class).displayName("mychildname")); - assertTrue(child instanceof EntityProxy, "child="+child); - assertFalse(child instanceof TestEntityImpl, "child="+child); - assertTrue(entity.getChildren().contains(child), "child="+child+"; children="+entity.getChildren()); - assertEquals(child.getDisplayName(), "mychildname"); - } - - @Test - public void testCreateEntityUsingMapAndType() { - TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); - TestEntity child = entity.addChild(EntitySpec.create(MutableMap.of("displayName", "mychildname"), TestEntity.class)); - assertTrue(child instanceof EntityProxy, "child="+child); - assertFalse(child instanceof TestEntityImpl, "child="+child); - assertTrue(entity.getChildren().contains(child), "child="+child+"; children="+entity.getChildren()); - assertEquals(child.getDisplayName(), "mychildname"); - } - - @Test - public void testGetEntities() { - TestApplication app2 = ApplicationBuilder.newManagedApp(TestApplication.class, mgmt); - TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); - TestEntity child = entity.createAndManageChild(EntitySpec.create(TestEntity.class)); - - Asserts.assertEqualsIgnoringOrder(entityManager.getEntitiesInApplication(app), ImmutableList.of(app, entity, child)); - Asserts.assertEqualsIgnoringOrder(entityManager.getEntities(), ImmutableList.of(app, entity, child, app2)); - Asserts.assertEqualsIgnoringOrder(entityManager.findEntities(Predicates.instanceOf(TestApplication.class)), ImmutableList.of(app, app2)); - Asserts.assertEqualsIgnoringOrder(entityManager.findEntitiesInApplication(app, Predicates.instanceOf(TestApplication.class)), ImmutableList.of(app)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/entity/proxying/EntityProxyTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/entity/proxying/EntityProxyTest.java b/core/src/test/java/org/apache/brooklyn/entity/proxying/EntityProxyTest.java deleted file mode 100644 index ea00936..0000000 --- a/core/src/test/java/org/apache/brooklyn/entity/proxying/EntityProxyTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.brooklyn.entity.proxying; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.util.Collection; -import java.util.Set; - -import org.apache.brooklyn.api.entity.Application; -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.api.entity.EntitySpec; -import org.apache.brooklyn.api.mgmt.EntityManager; -import org.apache.brooklyn.api.mgmt.Task; -import org.apache.brooklyn.core.mgmt.BrooklynTaskTags; -import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal; -import org.apache.brooklyn.core.objs.proxy.EntityProxy; -import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport; -import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.entity.core.AbstractEntity; -import org.apache.brooklyn.entity.core.Entities; -import org.apache.brooklyn.entity.core.StartableApplication; -import org.apache.brooklyn.entity.factory.ApplicationBuilder; -import org.apache.brooklyn.util.collections.MutableMap; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -public class EntityProxyTest extends BrooklynAppUnitTestSupport { - - private TestEntity entity; - - @BeforeMethod(alwaysRun=true) - @Override - public void setUp() throws Exception { - super.setUp(); - entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); - } - - @Test - public void testBuiltAppGivesProxies() { - assertIsProxy(entity); - assertIsProxy(app); - } - - @Test - public void testGetChildrenAndParentsReturnsProxies() { - TestEntity child = (TestEntity) Iterables.get(app.getChildren(), 0); - Application parent = (Application) child.getParent(); - - assertIsProxy(child); - assertIsProxy(parent); - } - - @Test - public void testEffectorOnProxyIsRecorded() { - Object result = entity.identityEffector("abc"); - assertEquals(result, "abc"); - - Set<Task<?>> tasks = mgmt.getExecutionManager().getTasksWithAllTags( - ImmutableList.of(ManagementContextInternal.EFFECTOR_TAG, - BrooklynTaskTags.tagForContextEntity(entity))); - Task<?> task = Iterables.get(tasks, 0); - assertEquals(tasks.size(), 1, "tasks="+tasks); - assertTrue(task.getDescription().contains("identityEffector")); - } - - @Test - public void testEntityManagerQueriesGiveProxies() { - EntityManager entityManager = mgmt.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)); - } - - @Test - public void testCreateAndManageChild() { - TestEntity result = entity.createAndManageChild(EntitySpec.create(TestEntity.class)); - assertIsProxy(result); - assertIsProxy(Iterables.get(entity.getChildren(), 0)); - assertIsProxy(result.getParent()); - assertIsProxy(mgmt.getEntityManager().getEntity(result.getId())); - } - - @Test - public void testDisplayName() { - TestEntity result = entity.createAndManageChild(EntitySpec.create(TestEntity.class).displayName("Boo")); - assertIsProxy(result); - assertEquals(result.getDisplayName(), "Boo"); - } - - @Test - public void testCreateRespectsFlags() { - TestEntity entity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class). - configure("confName", "boo")); - assertEquals(entity2.getConfig(TestEntity.CONF_NAME), "boo"); - } - - @Test - public void testCreateRespectsConfigKey() { - TestEntity entity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class). - configure(TestEntity.CONF_NAME, "foo")); - assertEquals(entity2.getConfig(TestEntity.CONF_NAME), "foo"); - } - - @Test - public void testCreateRespectsConfInMap() { - TestEntity entity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class). - configure(MutableMap.of(TestEntity.CONF_NAME, "bar"))); - assertEquals(entity2.getConfig(TestEntity.CONF_NAME), "bar"); - } - - @Test - public void testCreateRespectsFlagInMap() { - TestEntity entity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class). - configure(MutableMap.of("confName", "baz"))); - assertEquals(entity2.getConfig(TestEntity.CONF_NAME), "baz"); - } - - @Test - public void testCreateInAppWithClassAndMap() { - StartableApplication app2 = null; - try { - ApplicationBuilder appB = new ApplicationBuilder() { - @Override - protected void doBuild() { - addChild(MutableMap.of("confName", "faz"), TestEntity.class); - } - }; - app2 = appB.manage(); - assertEquals(Iterables.getOnlyElement(app2.getChildren()).getConfig(TestEntity.CONF_NAME), "faz"); - } finally { - if (app2 != null) Entities.destroyAll(app2.getManagementContext()); - } - } - - private void assertIsProxy(Entity e) { - assertFalse(e instanceof AbstractEntity, "e="+e+";e.class="+(e != null ? e.getClass() : null)); - assertTrue(e instanceof EntityProxy, "e="+e+";e.class="+(e != null ? e.getClass() : null)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/entity/proxying/InternalEntityFactoryTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/entity/proxying/InternalEntityFactoryTest.java b/core/src/test/java/org/apache/brooklyn/entity/proxying/InternalEntityFactoryTest.java deleted file mode 100644 index 11ea473..0000000 --- a/core/src/test/java/org/apache/brooklyn/entity/proxying/InternalEntityFactoryTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.brooklyn.entity.proxying; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -import org.apache.brooklyn.api.entity.Application; -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.api.entity.EntitySpec; -import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal; -import org.apache.brooklyn.core.objs.proxy.EntityProxy; -import org.apache.brooklyn.core.objs.proxy.InternalEntityFactory; -import org.apache.brooklyn.core.objs.proxy.InternalPolicyFactory; -import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.core.test.entity.TestApplication; -import org.apache.brooklyn.core.test.entity.TestApplicationImpl; -import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.core.test.entity.TestEntityImpl; -import org.apache.brooklyn.entity.core.AbstractApplication; -import org.apache.brooklyn.entity.core.Entities; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class InternalEntityFactoryTest { - - private ManagementContextInternal managementContext; - private InternalEntityFactory factory; - - @BeforeMethod(alwaysRun=true) - public void setUp() throws Exception { - managementContext = new LocalManagementContextForTests(); - InternalPolicyFactory policyFactory = new InternalPolicyFactory(managementContext); - factory = new InternalEntityFactory(managementContext, managementContext.getEntityManager().getEntityTypeRegistry(), policyFactory); - } - - @AfterMethod(alwaysRun=true) - public void tearDown() throws Exception { - if (managementContext != null) Entities.destroyAll(managementContext); - } - - @Test - public void testCreatesEntity() throws Exception { - EntitySpec<TestApplication> spec = EntitySpec.create(TestApplication.class); - TestApplicationImpl app = (TestApplicationImpl) factory.createEntity(spec); - - Entity proxy = app.getProxy(); - assertTrue(proxy instanceof Application, "proxy="+app); - assertFalse(proxy instanceof TestApplicationImpl, "proxy="+app); - - assertEquals(proxy.getParent(), null); - assertSame(proxy.getApplication(), proxy); - } - - @Test - public void testCreatesProxy() throws Exception { - TestApplicationImpl app = new TestApplicationImpl(); - EntitySpec<Application> spec = EntitySpec.create(Application.class).impl(TestApplicationImpl.class); - Application proxy = factory.createEntityProxy(spec, app); - - assertFalse(proxy instanceof TestApplicationImpl, "proxy="+app); - assertTrue(proxy instanceof EntityProxy, "proxy="+app); - } - - @Test - public void testSetsEntityIsLegacyConstruction() throws Exception { - TestEntity legacy = new TestEntityImpl(); - assertTrue(legacy.isLegacyConstruction()); - - TestEntity entity = factory.createEntity(EntitySpec.create(TestEntity.class)); - assertFalse(entity.isLegacyConstruction()); - } - - @Test - public void testCreatesProxyImplementingAdditionalInterfaces() throws Exception { - MyApplicationImpl app = new MyApplicationImpl(); - EntitySpec<Application> spec = EntitySpec.create(Application.class).impl(MyApplicationImpl.class).additionalInterfaces(MyInterface.class); - Application proxy = factory.createEntityProxy(spec, app); - - assertFalse(proxy instanceof MyApplicationImpl, "proxy="+app); - assertTrue(proxy instanceof MyInterface, "proxy="+app); - assertTrue(proxy instanceof EntityProxy, "proxy="+app); - } - - public interface MyInterface { - } - - public static class MyApplicationImpl extends AbstractApplication implements MyInterface { - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/entity/stock/BasicStartableTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/entity/stock/BasicStartableTest.java b/core/src/test/java/org/apache/brooklyn/entity/stock/BasicStartableTest.java index 0f64426..e88695c 100644 --- a/core/src/test/java/org/apache/brooklyn/entity/stock/BasicStartableTest.java +++ b/core/src/test/java/org/apache/brooklyn/entity/stock/BasicStartableTest.java @@ -30,14 +30,14 @@ import org.apache.brooklyn.api.entity.EntitySpec; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.location.LocationSpec; import org.apache.brooklyn.api.mgmt.ManagementContext; +import org.apache.brooklyn.core.entity.Attributes; +import org.apache.brooklyn.core.entity.Entities; +import org.apache.brooklyn.core.entity.RecordingSensorEventListener; +import org.apache.brooklyn.core.entity.factory.ApplicationBuilder; +import org.apache.brooklyn.core.entity.lifecycle.Lifecycle; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; import org.apache.brooklyn.core.test.entity.TestApplication; import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.entity.core.Attributes; -import org.apache.brooklyn.entity.core.Entities; -import org.apache.brooklyn.entity.core.RecordingSensorEventListener; -import org.apache.brooklyn.entity.factory.ApplicationBuilder; -import org.apache.brooklyn.entity.lifecycle.Lifecycle; import org.apache.brooklyn.entity.stock.BasicEntity; import org.apache.brooklyn.entity.stock.BasicStartable; import org.apache.brooklyn.util.collections.MutableSet; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/entity/stock/DataEntityTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/entity/stock/DataEntityTest.java b/core/src/test/java/org/apache/brooklyn/entity/stock/DataEntityTest.java index a177a1b..e64a353 100644 --- a/core/src/test/java/org/apache/brooklyn/entity/stock/DataEntityTest.java +++ b/core/src/test/java/org/apache/brooklyn/entity/stock/DataEntityTest.java @@ -27,10 +27,10 @@ import org.apache.brooklyn.api.entity.EntitySpec; import org.apache.brooklyn.api.location.LocationSpec; import org.apache.brooklyn.api.mgmt.ManagementContext; import org.apache.brooklyn.api.sensor.AttributeSensor; +import org.apache.brooklyn.core.entity.Entities; +import org.apache.brooklyn.core.entity.factory.ApplicationBuilder; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; import org.apache.brooklyn.core.test.entity.TestApplication; -import org.apache.brooklyn.entity.core.Entities; -import org.apache.brooklyn.entity.factory.ApplicationBuilder; import org.apache.brooklyn.entity.stock.DataEntity; import org.apache.brooklyn.sensor.core.Sensors; import org.apache.brooklyn.test.Asserts; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/entity/trait/FailingEntity.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/entity/trait/FailingEntity.java b/core/src/test/java/org/apache/brooklyn/entity/trait/FailingEntity.java deleted file mode 100644 index ca1e713..0000000 --- a/core/src/test/java/org/apache/brooklyn/entity/trait/FailingEntity.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.brooklyn.entity.trait; - -import java.util.List; - -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.api.entity.ImplementedBy; -import org.apache.brooklyn.config.ConfigKey; -import org.apache.brooklyn.core.config.ConfigKeys; -import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.util.core.flags.SetFromFlag; - -import com.google.common.base.Function; -import com.google.common.base.Functions; -import com.google.common.base.Predicate; -import com.google.common.collect.Lists; - -@ImplementedBy(FailingEntityImpl.class) -public interface FailingEntity extends TestEntity { - - @SetFromFlag("failInSubTask") - ConfigKey<Boolean> FAIL_IN_SUB_TASK = ConfigKeys.newBooleanConfigKey("failInSubTask", "Whether to throw exception in a sub-task (if true) or in current thread (if false)", false); - - @SetFromFlag("listener") - ConfigKey<EventListener> LISTENER = ConfigKeys.newConfigKey(EventListener.class, "listener", "Whether to throw exception on call to start", EventListener.NOOP); - - @SetFromFlag("failOnStart") - ConfigKey<Boolean> FAIL_ON_START = ConfigKeys.newBooleanConfigKey("failOnStart", "Whether to throw exception on call to start", false); - - @SetFromFlag("failOnStop") - ConfigKey<Boolean> FAIL_ON_STOP = ConfigKeys.newBooleanConfigKey("failOnStop", "Whether to throw exception on call to stop", false); - - @SetFromFlag("failOnRestart") - ConfigKey<Boolean> FAIL_ON_RESTART = ConfigKeys.newBooleanConfigKey("failOnRestart", "Whether to throw exception on call to restart", false); - - @SetFromFlag("failOnStartCondition") - ConfigKey<Predicate<? super FailingEntity>> FAIL_ON_START_CONDITION = (ConfigKey) ConfigKeys.newConfigKey(Predicate.class, "failOnStartCondition", "Whether to throw exception on call to start", null); - - @SetFromFlag("failOnStopCondition") - ConfigKey<Predicate<? super FailingEntity>> FAIL_ON_STOP_CONDITION = (ConfigKey) ConfigKeys.newConfigKey(Predicate.class, "failOnStopCondition", "Whether to throw exception on call to stop", null); - - @SetFromFlag("failOnRestartCondition") - ConfigKey<Predicate<? super FailingEntity>> FAIL_ON_RESTART_CONDITION = (ConfigKey) ConfigKeys.newConfigKey(Predicate.class, "failOnRestartCondition", "Whether to throw exception on call to restart", null); - - @SetFromFlag("exceptionClazz") - ConfigKey<Class<? extends RuntimeException>> EXCEPTION_CLAZZ = (ConfigKey) ConfigKeys.newConfigKey(Class.class, "exceptionClazz", "Type of exception to throw", IllegalStateException.class); - - @SetFromFlag("execOnFailure") - ConfigKey<Function<? super FailingEntity,?>> EXEC_ON_FAILURE = (ConfigKey) ConfigKeys.newConfigKey(Function.class, "execOnFailure", "Callback to execute before throwing an exception, on any failure", Functions.identity()); - - public interface EventListener { - public static final EventListener NOOP = new EventListener() { - @Override public void onEvent(Entity entity, String action, Object[] args) {} - }; - - public void onEvent(Entity entity, String action, Object[] args); - } - - public static class RecordingEventListener implements EventListener { - public final List<Object[]> events = Lists.newCopyOnWriteArrayList(); - - @Override - public void onEvent(Entity entity, String action, Object[] args) { - events.add(new Object[] {entity, action, args}); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/entity/trait/FailingEntityImpl.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/entity/trait/FailingEntityImpl.java b/core/src/test/java/org/apache/brooklyn/entity/trait/FailingEntityImpl.java deleted file mode 100644 index a41fa8f..0000000 --- a/core/src/test/java/org/apache/brooklyn/entity/trait/FailingEntityImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.brooklyn.entity.trait; - -import java.util.Collection; - -import org.apache.brooklyn.api.location.Location; -import org.apache.brooklyn.api.mgmt.Task; -import org.apache.brooklyn.core.test.entity.TestEntityImpl; -import org.apache.brooklyn.entity.core.Entities; -import org.apache.brooklyn.util.core.task.Tasks; -import org.apache.brooklyn.util.exceptions.Exceptions; -import org.testng.Assert; - -public class FailingEntityImpl extends TestEntityImpl implements FailingEntity { - - public FailingEntityImpl() { - } - - @Override - public void start(Collection<? extends Location> locs) { - getConfig(LISTENER).onEvent(this, "start", new Object[] {locs}); - if (getConfig(FAIL_ON_START) || (getConfig(FAIL_ON_START_CONDITION) != null && getConfig(FAIL_ON_START_CONDITION).apply(this))) { - callHistory.add("start"); - getConfig(EXEC_ON_FAILURE).apply(this); - throw fail("Simulating entity start failure for test"); - } - super.start(locs); - } - - @Override - public void stop() { - getConfig(LISTENER).onEvent(this, "stop", new Object[0]); - if (getConfig(FAIL_ON_STOP) || (getConfig(FAIL_ON_STOP_CONDITION) != null && getConfig(FAIL_ON_STOP_CONDITION).apply(this))) { - callHistory.add("stop"); - getConfig(EXEC_ON_FAILURE).apply(this); - throw fail("Simulating entity stop failure for test"); - } - super.stop(); - } - - @Override - public void restart() { - getConfig(LISTENER).onEvent(this, "restart", new Object[0]); - if (getConfig(FAIL_ON_RESTART) || (getConfig(FAIL_ON_RESTART_CONDITION) != null && getConfig(FAIL_ON_RESTART_CONDITION).apply(this))) { - callHistory.add("restart"); - getConfig(EXEC_ON_FAILURE).apply(this); - throw fail("Simulating entity restart failure for test"); - } - super.restart(); - } - - private RuntimeException fail(final String msg) { - if (getConfig(FAIL_IN_SUB_TASK)) { - Task<?> task = Tasks.builder().name(msg).body(new Runnable() { public void run() { throw newException(msg); } }).build(); - Entities.submit(this, task).getUnchecked(); - Assert.fail("Should have thrown exception on task.getUnchecked"); - throw new IllegalStateException("unreachable code"); - } else { - throw newException(msg); - } - } - - private RuntimeException newException(String msg) { - try { - return getConfig(EXCEPTION_CLAZZ).getConstructor(String.class).newInstance("Simulating entity stop failure for test"); - } catch (Exception e) { - throw Exceptions.propagate(e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/entity/trait/StartableMethodsTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/entity/trait/StartableMethodsTest.java b/core/src/test/java/org/apache/brooklyn/entity/trait/StartableMethodsTest.java deleted file mode 100644 index 8a099c6..0000000 --- a/core/src/test/java/org/apache/brooklyn/entity/trait/StartableMethodsTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.brooklyn.entity.trait; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; - -import org.apache.brooklyn.api.entity.EntitySpec; -import org.apache.brooklyn.api.mgmt.Task; -import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport; -import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.entity.core.Entities; -import org.apache.brooklyn.entity.trait.StartableMethods; -import org.apache.brooklyn.entity.trait.FailingEntity.RecordingEventListener; -import org.apache.brooklyn.util.core.task.Tasks; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -import org.apache.brooklyn.location.core.SimulatedLocation; - -import com.google.common.collect.ImmutableList; - -public class StartableMethodsTest extends BrooklynAppUnitTestSupport { - - private SimulatedLocation loc; - private TestEntity entity; - private TestEntity entity2; - private RecordingEventListener listener; - - @BeforeMethod(alwaysRun=true) - @Override - public void setUp() throws Exception { - super.setUp(); - loc = new SimulatedLocation(); - listener = new RecordingEventListener(); - } - - @Test - public void testStopSequentially() { - entity = app.createAndManageChild(EntitySpec.create(FailingEntity.class) - .configure(FailingEntity.LISTENER, listener)); - entity2 = app.createAndManageChild(EntitySpec.create(FailingEntity.class) - .configure(FailingEntity.LISTENER, listener)); - app.start(ImmutableList.of(loc)); - listener.events.clear(); - - StartableMethods.stopSequentially(ImmutableList.of(entity, entity2)); - - assertEquals(listener.events.get(0)[0], entity); - assertEquals(listener.events.get(1)[0], entity2); - } - - @Test - public void testStopSequentiallyContinuesOnFailure() { - try { - entity = app.createAndManageChild(EntitySpec.create(FailingEntity.class) - .configure(FailingEntity.FAIL_ON_STOP, true) - .configure(FailingEntity.LISTENER, listener)); - entity2 = app.createAndManageChild(EntitySpec.create(FailingEntity.class) - .configure(FailingEntity.LISTENER, listener)); - app.start(ImmutableList.of(loc)); - listener.events.clear(); - - try { - StartableMethods.stopSequentially(ImmutableList.of(entity, entity2)); - fail(); - } catch (Exception e) { - // success; expected exception to be propagated - } - - assertEquals(listener.events.get(0)[0], entity); - assertEquals(listener.events.get(1)[0], entity2); - } finally { - // get rid of entity that will fail on stop, so that tearDown won't encounter exception - Entities.unmanage(entity); - } - } - - @Test - public void testStopSequentiallyContinuesOnFailureInSubTask() throws Exception { - try { - entity = app.createAndManageChild(EntitySpec.create(FailingEntity.class) - .configure(FailingEntity.FAIL_ON_STOP, true) - .configure(FailingEntity.FAIL_IN_SUB_TASK, true) - .configure(FailingEntity.LISTENER, listener)); - entity2 = app.createAndManageChild(EntitySpec.create(FailingEntity.class) - .configure(FailingEntity.LISTENER, listener)); - app.start(ImmutableList.of(loc)); - listener.events.clear(); - - try { - Task<?> task = Tasks.builder().name("stopSequentially") - .body(new Runnable() { - @Override public void run() { - StartableMethods.stopSequentially(ImmutableList.of(entity, entity2)); - }}) - .build(); - Entities.submit(app, task).getUnchecked(); - fail(); - } catch (Exception e) { - // success; expected exception to be propagated - if (!(e.toString().contains("Error stopping"))) throw e; - } - - assertEquals(listener.events.get(0)[0], entity); - assertEquals(listener.events.get(1)[0], entity2); - } finally { - // get rid of entity that will fail on stop, so that tearDown won't encounter exception - Entities.unmanage(entity); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/access/BrooklynAccessUtilsTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/access/BrooklynAccessUtilsTest.java b/core/src/test/java/org/apache/brooklyn/location/access/BrooklynAccessUtilsTest.java index 91e06f8..7889ad7 100644 --- a/core/src/test/java/org/apache/brooklyn/location/access/BrooklynAccessUtilsTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/access/BrooklynAccessUtilsTest.java @@ -27,9 +27,9 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.brooklyn.api.entity.EntitySpec; import org.apache.brooklyn.api.location.LocationSpec; +import org.apache.brooklyn.core.entity.Attributes; import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport; import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.entity.core.Attributes; import org.apache.brooklyn.location.core.SupportsPortForwarding; import org.apache.brooklyn.location.ssh.SshMachineLocation; import org.apache.brooklyn.util.net.Cidr; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerLocationResolverTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerLocationResolverTest.java b/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerLocationResolverTest.java index 6a4b8f0..165af22 100644 --- a/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerLocationResolverTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerLocationResolverTest.java @@ -19,9 +19,9 @@ package org.apache.brooklyn.location.access; import org.apache.brooklyn.api.location.Location; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.entity.core.Entities; import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerTest.java b/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerTest.java index 1017828..4a7274b 100644 --- a/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerTest.java @@ -31,10 +31,10 @@ import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.apache.brooklyn.api.location.LocationSpec; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.internal.BrooklynProperties; import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.entity.core.Entities; import org.apache.brooklyn.location.ssh.SshMachineLocation; import com.google.common.base.Predicate; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/byon/ByonLocationResolverTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/byon/ByonLocationResolverTest.java b/core/src/test/java/org/apache/brooklyn/location/byon/ByonLocationResolverTest.java index 8d89a40..5ea58fc 100644 --- a/core/src/test/java/org/apache/brooklyn/location/byon/ByonLocationResolverTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/byon/ByonLocationResolverTest.java @@ -34,10 +34,10 @@ import org.apache.brooklyn.api.location.MachineLocation; import org.apache.brooklyn.api.location.MachineProvisioningLocation; import org.apache.brooklyn.api.location.NoMachinesAvailableException; import org.apache.brooklyn.core.config.ConfigKeys; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.internal.BrooklynProperties; import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.entity.core.Entities; import org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation; import org.apache.brooklyn.location.core.BasicLocationRegistry; import org.apache.brooklyn.location.core.LocationConfigKeys; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocationRebindTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocationRebindTest.java b/core/src/test/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocationRebindTest.java index 3068115..c8dd237 100644 --- a/core/src/test/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocationRebindTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocationRebindTest.java @@ -27,10 +27,10 @@ import javax.annotation.Nullable; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.mgmt.ManagementContext; +import org.apache.brooklyn.core.entity.Entities; +import org.apache.brooklyn.core.entity.factory.ApplicationBuilder; import org.apache.brooklyn.core.mgmt.rebind.RebindTestUtils; import org.apache.brooklyn.core.test.entity.TestApplication; -import org.apache.brooklyn.entity.core.Entities; -import org.apache.brooklyn.entity.factory.ApplicationBuilder; import org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation; import org.apache.brooklyn.location.core.LocationConfigKeys; import org.apache.brooklyn.location.ssh.SshMachineLocation; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocationTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocationTest.java b/core/src/test/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocationTest.java index f36ab1e..a272084 100644 --- a/core/src/test/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocationTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/byon/FixedListMachineProvisioningLocationTest.java @@ -33,9 +33,9 @@ import org.apache.brooklyn.api.location.MachineLocation; import org.apache.brooklyn.api.location.NoMachinesAvailableException; import org.apache.brooklyn.config.ConfigKey; import org.apache.brooklyn.core.config.ConfigKeys; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.entity.core.Entities; import org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation; import org.apache.brooklyn.location.core.RecordingMachineLocationCustomizer; import org.apache.brooklyn.location.core.RecordingMachineLocationCustomizer.Call; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/byon/HostLocationResolverTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/byon/HostLocationResolverTest.java b/core/src/test/java/org/apache/brooklyn/location/byon/HostLocationResolverTest.java index 24427f6..2c3b1b0 100644 --- a/core/src/test/java/org/apache/brooklyn/location/byon/HostLocationResolverTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/byon/HostLocationResolverTest.java @@ -26,10 +26,10 @@ import java.util.Map; import java.util.NoSuchElementException; import org.apache.brooklyn.api.location.MachineProvisioningLocation; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.internal.BrooklynProperties; import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.entity.core.Entities; import org.apache.brooklyn.location.ssh.SshMachineLocation; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/byon/SingleMachineLocationResolverTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/byon/SingleMachineLocationResolverTest.java b/core/src/test/java/org/apache/brooklyn/location/byon/SingleMachineLocationResolverTest.java index 8fbca63..ae39e91 100644 --- a/core/src/test/java/org/apache/brooklyn/location/byon/SingleMachineLocationResolverTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/byon/SingleMachineLocationResolverTest.java @@ -25,10 +25,10 @@ import java.net.InetAddress; import java.util.Map; import java.util.NoSuchElementException; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.internal.BrooklynProperties; import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.entity.core.Entities; import org.apache.brooklyn.location.byon.SingleMachineProvisioningLocation; import org.apache.brooklyn.location.ssh.SshMachineLocation; import org.testng.annotations.AfterMethod; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/cloud/CloudMachineNamerTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/cloud/CloudMachineNamerTest.java b/core/src/test/java/org/apache/brooklyn/location/cloud/CloudMachineNamerTest.java index e36e85d..9294e27 100644 --- a/core/src/test/java/org/apache/brooklyn/location/cloud/CloudMachineNamerTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/cloud/CloudMachineNamerTest.java @@ -22,11 +22,11 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import org.apache.brooklyn.api.entity.EntitySpec; +import org.apache.brooklyn.core.entity.Entities; +import org.apache.brooklyn.core.entity.factory.ApplicationBuilder; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; import org.apache.brooklyn.core.test.entity.TestApplication; import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.entity.core.Entities; -import org.apache.brooklyn.entity.factory.ApplicationBuilder; import org.apache.brooklyn.location.cloud.names.AbstractCloudMachineNamer; import org.apache.brooklyn.location.cloud.names.CloudMachineNamer; import org.apache.brooklyn.util.core.config.ConfigBag; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/cloud/CustomMachineNamerTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/cloud/CustomMachineNamerTest.java b/core/src/test/java/org/apache/brooklyn/location/cloud/CustomMachineNamerTest.java index b58dae1..3ca0358 100644 --- a/core/src/test/java/org/apache/brooklyn/location/cloud/CustomMachineNamerTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/cloud/CustomMachineNamerTest.java @@ -19,11 +19,11 @@ package org.apache.brooklyn.location.cloud; import org.apache.brooklyn.api.entity.EntitySpec; +import org.apache.brooklyn.core.entity.Entities; +import org.apache.brooklyn.core.entity.factory.ApplicationBuilder; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; import org.apache.brooklyn.core.test.entity.TestApplication; import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.entity.core.Entities; -import org.apache.brooklyn.entity.factory.ApplicationBuilder; import org.apache.brooklyn.util.core.config.ConfigBag; import org.testng.Assert; import org.testng.annotations.AfterMethod; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/core/AbstractLocationTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/core/AbstractLocationTest.java b/core/src/test/java/org/apache/brooklyn/location/core/AbstractLocationTest.java index eb9c906..c3e8554 100644 --- a/core/src/test/java/org/apache/brooklyn/location/core/AbstractLocationTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/core/AbstractLocationTest.java @@ -29,8 +29,8 @@ import java.util.Map; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.location.LocationSpec; import org.apache.brooklyn.api.mgmt.ManagementContext; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.entity.core.Entities; import org.apache.brooklyn.location.core.AbstractLocation; import org.apache.brooklyn.location.core.internal.LocationInternal; import org.apache.brooklyn.util.collections.MutableMap; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/core/AggregatingMachineProvisioningLocationTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/core/AggregatingMachineProvisioningLocationTest.java b/core/src/test/java/org/apache/brooklyn/location/core/AggregatingMachineProvisioningLocationTest.java index be85699..0e2a4d4 100644 --- a/core/src/test/java/org/apache/brooklyn/location/core/AggregatingMachineProvisioningLocationTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/core/AggregatingMachineProvisioningLocationTest.java @@ -27,9 +27,9 @@ import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.location.LocationSpec; import org.apache.brooklyn.api.location.MachineProvisioningLocation; import org.apache.brooklyn.api.location.NoMachinesAvailableException; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.entity.core.Entities; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/core/LocationConfigTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/core/LocationConfigTest.java b/core/src/test/java/org/apache/brooklyn/location/core/LocationConfigTest.java index 3a953f7..8001b0e 100644 --- a/core/src/test/java/org/apache/brooklyn/location/core/LocationConfigTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/core/LocationConfigTest.java @@ -24,8 +24,8 @@ import org.apache.brooklyn.api.location.LocationSpec; import org.apache.brooklyn.api.mgmt.ManagementContext; import org.apache.brooklyn.config.ConfigKey; import org.apache.brooklyn.core.config.ConfigKeys; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.entity.core.Entities; import org.apache.brooklyn.location.core.AbstractLocation; import org.apache.brooklyn.location.core.internal.LocationInternal; import org.apache.brooklyn.util.core.flags.SetFromFlag; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/core/LocationExtensionsTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/core/LocationExtensionsTest.java b/core/src/test/java/org/apache/brooklyn/location/core/LocationExtensionsTest.java index 3b784e2..8c76231 100644 --- a/core/src/test/java/org/apache/brooklyn/location/core/LocationExtensionsTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/core/LocationExtensionsTest.java @@ -26,8 +26,8 @@ import static org.testng.Assert.fail; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.location.LocationSpec; import org.apache.brooklyn.api.mgmt.ManagementContext; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.entity.core.Entities; import org.apache.brooklyn.location.core.AbstractLocation; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c27cf1d0/core/src/test/java/org/apache/brooklyn/location/core/LocationPredicatesTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/location/core/LocationPredicatesTest.java b/core/src/test/java/org/apache/brooklyn/location/core/LocationPredicatesTest.java index d63aaac..570071b 100644 --- a/core/src/test/java/org/apache/brooklyn/location/core/LocationPredicatesTest.java +++ b/core/src/test/java/org/apache/brooklyn/location/core/LocationPredicatesTest.java @@ -23,10 +23,10 @@ import static org.testng.Assert.assertTrue; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.location.LocationSpec; +import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; import org.apache.brooklyn.core.test.entity.TestEntity; -import org.apache.brooklyn.entity.core.Entities; import org.apache.brooklyn.location.core.LocationPredicates; import org.apache.brooklyn.location.core.Locations; import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
