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 2015/11/23 19:29:38 UTC
[09/20] incubator-brooklyn git commit: Rename DEFAULT_COMMAND to
COMMAND.
Rename DEFAULT_COMMAND to COMMAND.
https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r44859961
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/f173ad31
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/f173ad31
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/f173ad31
Branch: refs/heads/master
Commit: f173ad31f2ec08ac3602d92d4c0a14cb71406f4b
Parents: f06fb74
Author: Geoff Macartney <ge...@cloudsoftcorp.com>
Authored: Tue Nov 17 12:31:58 2015 +0000
Committer: Geoff Macartney <ge...@cloudsoftcorp.com>
Committed: Tue Nov 17 12:31:58 2015 +0000
----------------------------------------------------------------------
.../brooklyn/test/framework/SimpleCommand.java | 9 +++++++--
.../brooklyn/test/framework/SimpleCommandImpl.java | 10 ++--------
.../SimpleCommandImplIntegrationTest.java | 6 +++---
.../SimpleCommandScriptIntegrationTest.java | 17 ++---------------
4 files changed, 14 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f173ad31/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleCommand.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleCommand.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleCommand.java
index 0a58fe2..3959b39 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleCommand.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleCommand.java
@@ -49,10 +49,15 @@ public interface SimpleCommand extends Entity, Startable {
}
+ /**
+ * Supply the command to invoke directly. Cannot be used together with {@link #DOWNLOAD_URL}.
+ */
@SetFromFlag(nullable = false)
- ConfigKey<String> DEFAULT_COMMAND = ConfigKeys.newConfigKey(String.class, "defaultCommand",
- "Command to invoke if no script is provided via a downloadUrl");
+ ConfigKey<String> COMMAND = ConfigKeys.newConfigKey(String.class, "command", "Command to invoke");
+ /**
+ * Download a script to invoke. Cannot be used together with {@link #COMMAND}.
+ */
@SetFromFlag("downloadUrl")
AttributeSensorAndConfigKey<String, String> DOWNLOAD_URL = SoftwareProcess.DOWNLOAD_URL;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f173ad31/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleCommandImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleCommandImpl.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleCommandImpl.java
index 8af801f..24f6903 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleCommandImpl.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleCommandImpl.java
@@ -25,16 +25,13 @@ import com.google.common.collect.ImmutableMap;
import org.apache.brooklyn.api.location.Location;
import org.apache.brooklyn.api.location.MachineLocation;
import org.apache.brooklyn.api.mgmt.TaskFactory;
-import org.apache.brooklyn.core.annotation.EffectorParam;
import org.apache.brooklyn.core.effector.ssh.SshEffectorTasks;
import org.apache.brooklyn.core.entity.AbstractEntity;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.location.Locations;
import org.apache.brooklyn.location.ssh.SshMachineLocation;
import org.apache.brooklyn.util.collections.MutableList;
-import org.apache.brooklyn.util.core.ResourceUtils;
import org.apache.brooklyn.util.core.task.DynamicTasks;
-import org.apache.brooklyn.util.core.task.ssh.SshPutTaskWrapper;
import org.apache.brooklyn.util.core.task.ssh.SshTasks;
import org.apache.brooklyn.util.core.task.system.ProcessTaskWrapper;
import org.apache.brooklyn.util.exceptions.Exceptions;
@@ -66,12 +63,9 @@ public class SimpleCommandImpl extends AbstractEntity implements SimpleCommand {
private static final String CD = "cd";
private static final String SHELL_AND = "&&";
- private ResourceUtils resourceUtils;
-
@Override
public void init() {
super.init();
- resourceUtils = ResourceUtils.create(this);
getLifecycleEffectorTasks().attachLifecycleEffectors(this);
}
@@ -137,10 +131,10 @@ public class SimpleCommandImpl extends AbstractEntity implements SimpleCommand {
SimpleCommand.Result result = null;
String downloadUrl = getConfig(DOWNLOAD_URL);
- String command = getConfig(DEFAULT_COMMAND);
+ String command = getConfig(COMMAND);
String downloadName = DOWNLOAD_URL.getName();
- String commandName = DEFAULT_COMMAND.getName();
+ String commandName = COMMAND.getName();
if (isNonBlank(downloadUrl) && isNonBlank(command)) {
throw illegal("Cannot specify both", downloadName, "and", commandName);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f173ad31/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleCommandImplIntegrationTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleCommandImplIntegrationTest.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleCommandImplIntegrationTest.java
index 9d261b8..dea50e9 100644
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleCommandImplIntegrationTest.java
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleCommandImplIntegrationTest.java
@@ -38,7 +38,7 @@ import org.testng.annotations.Test;
import java.util.UUID;
import static org.apache.brooklyn.test.framework.BaseTest.TARGET_ENTITY;
-import static org.apache.brooklyn.test.framework.SimpleCommand.DEFAULT_COMMAND;
+import static org.apache.brooklyn.test.framework.SimpleCommand.COMMAND;
import static org.apache.brooklyn.test.framework.SimpleCommandTest.*;
import static org.assertj.core.api.Assertions.assertThat;
@@ -76,7 +76,7 @@ public class SimpleCommandImplIntegrationTest {
SimpleCommandTest uptime = app.createAndManageChild(EntitySpec.create(SimpleCommandTest.class)
.configure(TARGET_ENTITY, testEntity)
- .configure(DEFAULT_COMMAND, "uptime")
+ .configure(COMMAND, "uptime")
.configure(ASSERT_STATUS, ImmutableMap.of(EQUALS, 0))
.configure(ASSERT_OUT, ImmutableMap.of(CONTAINS, UP)));
@@ -95,7 +95,7 @@ public class SimpleCommandImplIntegrationTest {
SimpleCommandTest uptime = app.createAndManageChild(EntitySpec.create(SimpleCommandTest.class)
.configure(TARGET_ENTITY, testEntity)
- .configure(DEFAULT_COMMAND, "uptime")
+ .configure(COMMAND, "uptime")
.configure(ASSERT_STATUS, ImmutableMap.of(EQUALS, 1)));
try {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f173ad31/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleCommandScriptIntegrationTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleCommandScriptIntegrationTest.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleCommandScriptIntegrationTest.java
index cb6c9ed..3b6b875 100644
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleCommandScriptIntegrationTest.java
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleCommandScriptIntegrationTest.java
@@ -18,16 +18,11 @@
*/
package org.apache.brooklyn.test.framework;
-import com.google.common.base.Joiner;
-import com.google.common.base.Splitter;
-import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
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.mgmt.Task;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
@@ -36,27 +31,19 @@ import org.apache.brooklyn.core.test.entity.TestEntity;
import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
import org.apache.brooklyn.test.http.TestHttpRequestHandler;
import org.apache.brooklyn.test.http.TestHttpServer;
-import org.apache.brooklyn.util.core.task.Tasks;
-import org.apache.brooklyn.util.core.task.system.internal.SystemProcessTaskFactory;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.exceptions.FatalRuntimeException;
import org.apache.brooklyn.util.http.HttpAsserts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.*;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.nio.file.attribute.FileAttribute;
-import java.util.Iterator;
import java.util.Random;
import java.util.UUID;
import static org.apache.brooklyn.test.framework.BaseTest.TARGET_ENTITY;
-import static org.apache.brooklyn.test.framework.SimpleCommand.DEFAULT_COMMAND;
+import static org.apache.brooklyn.test.framework.SimpleCommand.COMMAND;
import static org.apache.brooklyn.test.framework.SimpleCommandTest.*;
import static org.assertj.core.api.Assertions.assertThat;
@@ -146,7 +133,7 @@ public class SimpleCommandScriptIntegrationTest {
String remoteTmp = randomName();
SimpleCommandTest uptime = app.createAndManageChild(EntitySpec.create(SimpleCommandTest.class)
.configure(TARGET_ENTITY, testEntity)
- .configure(DEFAULT_COMMAND, "mkdir " + remoteTmp)
+ .configure(COMMAND, "mkdir " + remoteTmp)
.configure(ASSERT_STATUS, ImmutableMap.of(EQUALS, 0)));
Path localTmpPath = Paths.get("/tmp/").resolve(randomName());