You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/01/13 19:06:03 UTC

[4/6] incubator-brooklyn git commit: fixes for restructured directory

fixes for restructured directory


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/eb541cf5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/eb541cf5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/eb541cf5

Branch: refs/heads/master
Commit: eb541cf56e0baaf83b59b4b43308f5d2f6c24873
Parents: 25ead1d
Author: Graeme-Miller <gr...@cloudsoftcorp.com>
Authored: Thu Jan 7 17:01:30 2016 +0000
Committer: Graeme-Miller <gr...@cloudsoftcorp.com>
Committed: Thu Jan 7 17:01:30 2016 +0000

----------------------------------------------------------------------
 .../framework/LoopOverGroupMembersTestCase.java |  45 -------
 .../LoopOverGroupMembersTestCaseImpl.java       | 134 -------------------
 .../test/framework/TargetableTestComponent.java |  53 --------
 .../framework/TargetableTestComponentImpl.java  |  83 ------------
 4 files changed, 315 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/eb541cf5/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCase.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCase.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCase.java
deleted file mode 100644
index 4e76604..0000000
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCase.java
+++ /dev/null
@@ -1,45 +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.test.framework;
-
-import com.google.common.reflect.TypeToken;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-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.entity.trait.Startable;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-
-/**
- * Created by graememiller on 11/12/2015.
- */
-@ImplementedBy(value = LoopOverGroupMembersTestCaseImpl.class)
-public interface LoopOverGroupMembersTestCase extends TargetableTestComponent {
-
-    /**
-     * The test spec that will be run against each member of the group
-     */
-    @SetFromFlag("testSpec")
-    ConfigKey<EntitySpec<? extends TargetableTestComponent>> TEST_SPEC = ConfigKeys.newConfigKey(
-            new TypeToken<EntitySpec<? extends TargetableTestComponent>>(){},
-            "test.spec",
-            "Test spec. The test case will create one of these per child");
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/eb541cf5/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseImpl.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseImpl.java
deleted file mode 100644
index f4bb06d..0000000
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseImpl.java
+++ /dev/null
@@ -1,134 +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.test.framework;
-
-import java.util.Collection;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Lists;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.entity.Group;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.annotation.EffectorParam;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-
-/**
- * Created by graememiller on 11/12/2015.
- */
-public class LoopOverGroupMembersTestCaseImpl extends TargetableTestComponentImpl implements LoopOverGroupMembersTestCase {
-
-    private static final Logger logger = LoggerFactory.getLogger(LoopOverGroupMembersTestCaseImpl.class);
-
-    @Override
-    public void start(@EffectorParam(name = "locations") Collection<? extends Location> locations) {
-        // Let everyone know we're starting up (so that the GUI shows the correct icon).
-        sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STARTING);
-
-        Entity target = resolveTarget();
-        if (target == null) {
-            logger.debug("Tasks NOT successfully run. LoopOverGroupMembersTestCaseImpl group not set");
-            setServiceState(false, Lifecycle.ON_FIRE);
-            return;
-        }
-
-        if (!(target instanceof Group)) {
-            logger.debug("Tasks NOT successfully run. LoopOverGroupMembersTestCaseImpl target is not a group");
-            setServiceState(false, Lifecycle.ON_FIRE);
-            return;
-        }
-
-        EntitySpec<? extends TargetableTestComponent> testSpec = config().get(TEST_SPEC);
-        if (testSpec == null) {
-            logger.debug("Tasks NOT successfully run. LoopOverGroupMembersTestCaseImpl test spec not set");
-            setServiceState(false, Lifecycle.ON_FIRE);
-            return;
-        }
-
-        Group group = (Group) target;
-
-        Collection<Entity> children = group.getMembers();
-        boolean allSuccesful = true;
-        for (Entity child : children) {
-            testSpec.configure(TestCase.TARGET_ENTITY, child);
-
-            try {
-                TargetableTestComponent targetableTestComponent = this.addChild(testSpec);
-                targetableTestComponent.start(locations);
-            } catch (Throwable t) {
-                allSuccesful = false;
-            }
-        }
-
-        if (allSuccesful) {
-            // Let everyone know we've started up successfully (changes the icon in the GUI).
-            logger.debug("Tasks successfully run. Update state of {} to RUNNING.", this);
-            setServiceState(true, Lifecycle.RUNNING);
-        } else {
-            // Let everyone know we've npt started up successfully (changes the icon in the GUI).
-            logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this);
-            setServiceState(false, Lifecycle.ON_FIRE);
-        }
-
-    }
-
-    @Override
-    public void stop() {
-        // Let everyone know we're stopping (so that the GUI shows the correct icon).
-        sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPING);
-
-        try {
-            for (Entity child : this.getChildren()) {
-                if (child instanceof Startable) ((Startable) child).stop();
-            }
-
-            // Let everyone know we've stopped successfully (changes the icon in the GUI).
-            logger.debug("Tasks successfully run. Update state of {} to STOPPED.", this);
-            setServiceState(false, Lifecycle.STOPPED);
-        } catch (Throwable t) {
-            logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this);
-            setServiceState(false, Lifecycle.ON_FIRE);
-            throw Exceptions.propagate(t);
-        }
-    }
-
-    @Override
-    public void restart() {
-        final Collection<Location> locations = Lists.newArrayList(getLocations());
-        stop();
-        start(locations);
-    }
-
-    /**
-     * Sets the state of the Entity. Useful so that the GUI shows the correct icon.
-     *
-     * @param serviceUpState     Whether or not the entity is up.
-     * @param serviceStateActual The actual state of the entity.
-     */
-    private void setServiceState(final boolean serviceUpState, final Lifecycle serviceStateActual) {
-        sensors().set(SERVICE_UP, serviceUpState);
-        sensors().set(Attributes.SERVICE_STATE_ACTUAL, serviceStateActual);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/eb541cf5/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java
deleted file mode 100644
index 8ae44ad..0000000
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java
+++ /dev/null
@@ -1,53 +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.test.framework;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
-
-/**
- * Entity that can target another entity for the purpouse of testing
- *
- * @author m4rkmckenna
- */
-@ImplementedBy(value = TargetableTestComponentImpl.class)
-public interface TargetableTestComponent extends Entity, Startable {
-
-    /**
-     * The target entity to test (optional, use either this or targetId).
-     */
-    AttributeSensorAndConfigKey<Entity, Entity> TARGET_ENTITY = ConfigKeys.newSensorAndConfigKey(Entity.class, "target", "Entity under test");
-
-    /**
-     * Id of the target entity to test (optional, use either this or target).
-     */
-    AttributeSensorAndConfigKey<String, String> TARGET_ID = ConfigKeys.newStringSensorAndConfigKey("targetId", "Id of the entity under test");
-
-    /**
-     * Get the target of the test.
-     *
-     * @return The target.
-     * @throws IllegalArgumentException if the target cannot be found.
-     */
-    Entity resolveTarget();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/eb541cf5/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java
deleted file mode 100644
index 5b133bd..0000000
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.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.test.framework;
-
-import java.util.concurrent.ExecutionException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.mgmt.ExecutionContext;
-import org.apache.brooklyn.api.mgmt.Task;
-import org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent;
-import org.apache.brooklyn.core.entity.AbstractEntity;
-import org.apache.brooklyn.util.core.task.Tasks;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-
-/**
- * Class that can resolve the target for a test component
- */
-public abstract class TargetableTestComponentImpl extends AbstractEntity implements TargetableTestComponent {
-
-    private static final Logger LOG = LoggerFactory.getLogger(TargetableTestComponentImpl.class);
-
-    /**
-     * Find the target entity using "target" config key, if entity provided directly in config, or by doing an implicit
-     * lookup using DSL ($brooklyn:component("myNginX")), if id of entity provided as "targetId" config key.
-     *
-     * @return The target entity.
-     * @throws @RuntimeException if no target can be determined.
-     */
-    public Entity resolveTarget() {
-        return resolveTarget(getExecutionContext(), this);
-    }
-
-    /**
-     * Find the target entity in the given execution context.
-     *
-     * @see {@link #resolveTarget()}.
-     */
-    public static Entity resolveTarget(ExecutionContext executionContext, Entity entity) {
-        Entity target = entity.getConfig(TARGET_ENTITY);
-        if (null == target) {
-            target = getTargetById(executionContext, entity);
-        }
-        return target;
-    }
-
-    private static Entity getTargetById(ExecutionContext executionContext, Entity entity) {
-        String targetId = entity.getConfig(TARGET_ID);
-
-        if(targetId == null){
-            return null;
-        }
-
-        final Task<Entity> targetLookup = new DslComponent(targetId).newTask();
-        Entity target = null;
-        try {
-            target = Tasks.resolveValue(targetLookup, Entity.class, executionContext, "Finding entity " + targetId);
-            LOG.debug("Found target by id {}", targetId);
-        } catch (final ExecutionException | InterruptedException e) {
-            LOG.error("Error finding target {}", targetId);
-            Exceptions.propagate(e);
-        }
-        return target;
-    }
-}