You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ha...@apache.org on 2015/08/07 03:09:47 UTC
[3/8] incubator-brooklyn git commit: brooklyn-launcher: add
org.apache package prefix
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/brooklyn/launcher/BrooklynLauncherTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/BrooklynLauncherTest.java b/usage/launcher/src/test/java/brooklyn/launcher/BrooklynLauncherTest.java
deleted file mode 100644
index 0886390..0000000
--- a/usage/launcher/src/test/java/brooklyn/launcher/BrooklynLauncherTest.java
+++ /dev/null
@@ -1,367 +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 brooklyn.launcher;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertSame;
-import static org.testng.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.net.URI;
-import java.nio.charset.Charset;
-import java.util.Properties;
-
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.catalog.internal.CatalogInitialization;
-import brooklyn.config.BrooklynProperties;
-import brooklyn.config.BrooklynServerConfig;
-import brooklyn.entity.Application;
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.rebind.RebindTestUtils;
-import brooklyn.location.Location;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.management.ManagementContext;
-import brooklyn.management.internal.LocalManagementContext;
-import brooklyn.management.internal.ManagementContextInternal;
-import brooklyn.test.HttpTestUtils;
-import brooklyn.test.entity.LocalManagementContextForTests;
-import brooklyn.test.entity.TestApplication;
-import brooklyn.test.entity.TestApplicationImpl;
-import brooklyn.test.entity.TestEntity;
-import brooklyn.util.exceptions.FatalRuntimeException;
-import brooklyn.util.io.FileUtil;
-import brooklyn.util.net.Urls;
-import brooklyn.util.os.Os;
-import brooklyn.util.text.StringFunctions;
-import brooklyn.util.text.Strings;
-
-import com.google.api.client.util.Preconditions;
-import com.google.common.base.Charsets;
-import com.google.common.base.Function;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-import com.google.common.io.Files;
-
-public class BrooklynLauncherTest {
-
- private BrooklynLauncher launcher;
- private File persistenceDir;
-
- @AfterMethod(alwaysRun=true)
- public void tearDown() throws Exception {
- if (launcher != null) launcher.terminate();
- if (persistenceDir != null) RebindTestUtils.deleteMementoDir(persistenceDir);
- launcher = null;
- }
-
- // Integration because takes a few seconds to start web-console
- @Test(groups="Integration")
- public void testStartsWebServerOnExpectectedPort() throws Exception {
- launcher = newLauncherForTests(true)
- .webconsolePort("10000+")
- .start();
-
- String webServerUrlStr = launcher.getServerDetails().getWebServerUrl();
- URI webServerUri = new URI(webServerUrlStr);
-
- assertEquals(launcher.getApplications(), ImmutableList.of());
- assertTrue(webServerUri.getPort() >= 10000 && webServerUri.getPort() < 10100, "port="+webServerUri.getPort()+"; uri="+webServerUri);
- HttpTestUtils.assertUrlReachable(webServerUrlStr);
- }
-
- // Integration because takes a few seconds to start web-console
- @Test(groups="Integration")
- public void testWebServerTempDirRespectsDataDirConfig() throws Exception {
- String dataDirName = ".brooklyn-foo"+Strings.makeRandomId(4);
- String dataDir = "~/"+dataDirName;
-
- launcher = newLauncherForTests(true)
- .brooklynProperties(BrooklynServerConfig.MGMT_BASE_DIR, dataDir)
- .start();
-
- ManagementContext managementContext = launcher.getServerDetails().getManagementContext();
- String expectedTempDir = Os.mergePaths(Os.home(), dataDirName, "planes", managementContext.getManagementPlaneId(), managementContext.getManagementNodeId(), "jetty");
-
- File webappTempDir = launcher.getServerDetails().getWebServer().getWebappTempDir();
- assertEquals(webappTempDir.getAbsolutePath(), expectedTempDir);
- }
-
- @Test
- public void testCanDisableWebServerStartup() throws Exception {
- launcher = newLauncherForTests(true)
- .webconsole(false)
- .start();
-
- assertNull(launcher.getServerDetails().getWebServer());
- assertNull(launcher.getServerDetails().getWebServerUrl());
- Assert.assertTrue( ((ManagementContextInternal)launcher.getServerDetails().getManagementContext()).errors().isEmpty() );
- }
-
- @Test
- public void testStartsAppInstance() throws Exception {
- launcher = newLauncherForTests(true)
- .webconsole(false)
- .application(new TestApplicationImpl())
- .start();
-
- assertOnlyApp(launcher, TestApplication.class);
- }
-
- @Test
- public void testStartsAppFromSpec() throws Exception {
- launcher = newLauncherForTests(true)
- .webconsole(false)
- .application(EntitySpec.create(TestApplication.class))
- .start();
-
- assertOnlyApp(launcher, TestApplication.class);
- }
-
- @Test
- public void testStartsAppFromBuilder() throws Exception {
- launcher = newLauncherForTests(true)
- .webconsole(false)
- .application(new ApplicationBuilder(EntitySpec.create(TestApplication.class)) {
- @Override protected void doBuild() {
- }})
- .start();
-
- assertOnlyApp(launcher, TestApplication.class);
- }
-
- @Test
- public void testStartsAppFromYAML() throws Exception {
- String yaml = "name: example-app\n" +
- "services:\n" +
- "- serviceType: brooklyn.test.entity.TestEntity\n" +
- " name: test-app";
- launcher = newLauncherForTests(true)
- .webconsole(false)
- .application(yaml)
- .start();
-
- assertEquals(launcher.getApplications().size(), 1, "apps="+launcher.getApplications());
- Application app = Iterables.getOnlyElement(launcher.getApplications());
- assertEquals(app.getChildren().size(), 1, "children=" + app.getChildren());
- assertTrue(Iterables.getOnlyElement(app.getChildren()) instanceof TestEntity);
- }
-
- @Test // may take 2s initializing location if running this test case alone, but noise if running suite
- public void testStartsAppInSuppliedLocations() throws Exception {
- launcher = newLauncherForTests(true)
- .webconsole(false)
- .location("localhost")
- .application(new ApplicationBuilder(EntitySpec.create(TestApplication.class)) {
- @Override protected void doBuild() {
- }})
- .start();
-
- Application app = Iterables.find(launcher.getApplications(), Predicates.instanceOf(TestApplication.class));
- assertOnlyLocation(app, LocalhostMachineProvisioningLocation.class);
- }
-
- @Test
- public void testUsesSuppliedManagementContext() throws Exception {
- LocalManagementContext myManagementContext = LocalManagementContextForTests.newInstance();
- launcher = newLauncherForTests(false)
- .webconsole(false)
- .managementContext(myManagementContext)
- .start();
-
- assertSame(launcher.getServerDetails().getManagementContext(), myManagementContext);
- }
-
- @Test
- public void testUsesSuppliedBrooklynProperties() throws Exception {
- BrooklynProperties props = LocalManagementContextForTests.builder(true).buildProperties();
- props.put("mykey", "myval");
- launcher = newLauncherForTests(false)
- .webconsole(false)
- .brooklynProperties(props)
- .start();
-
- assertEquals(launcher.getServerDetails().getManagementContext().getConfig().getFirst("mykey"), "myval");
- }
-
- @Test
- public void testUsesSupplementaryBrooklynProperties() throws Exception {
- launcher = newLauncherForTests(true)
- .webconsole(false)
- .brooklynProperties("mykey", "myval")
- .start();
-
- assertEquals(launcher.getServerDetails().getManagementContext().getConfig().getFirst("mykey"), "myval");
- }
-
- @Test
- public void testReloadBrooklynPropertiesRestoresProgrammaticProperties() throws Exception {
- launcher = newLauncherForTests(true)
- .webconsole(false)
- .brooklynProperties("mykey", "myval")
- .start();
- LocalManagementContext managementContext = (LocalManagementContext)launcher.getServerDetails().getManagementContext();
- assertEquals(managementContext.getConfig().getFirst("mykey"), "myval");
- managementContext.getBrooklynProperties().put("mykey", "newval");
- assertEquals(managementContext.getConfig().getFirst("mykey"), "newval");
- managementContext.reloadBrooklynProperties();
- assertEquals(managementContext.getConfig().getFirst("mykey"), "myval");
- }
-
- @Test
- public void testReloadBrooklynPropertiesFromFile() throws Exception {
- File globalPropertiesFile = File.createTempFile("local-brooklyn-properties-test", ".properties");
- FileUtil.setFilePermissionsTo600(globalPropertiesFile);
- try {
- String property = "mykey=myval";
- Files.append(getMinimalLauncherPropertiesString()+property, globalPropertiesFile, Charsets.UTF_8);
- launcher = newLauncherForTests(false)
- .webconsole(false)
- .globalBrooklynPropertiesFile(globalPropertiesFile.getAbsolutePath())
- .start();
- LocalManagementContext managementContext = (LocalManagementContext)launcher.getServerDetails().getManagementContext();
- assertEquals(managementContext.getConfig().getFirst("mykey"), "myval");
- property = "mykey=newval";
- Files.write(getMinimalLauncherPropertiesString()+property, globalPropertiesFile, Charsets.UTF_8);
- managementContext.reloadBrooklynProperties();
- assertEquals(managementContext.getConfig().getFirst("mykey"), "newval");
- } finally {
- globalPropertiesFile.delete();
- }
- }
-
- @Test(groups="Integration")
- public void testChecksGlobalBrooklynPropertiesPermissionsX00() throws Exception {
- File propsFile = File.createTempFile("testChecksGlobalBrooklynPropertiesPermissionsX00", ".properties");
- propsFile.setReadable(true, false);
- try {
- launcher = newLauncherForTests(false)
- .webconsole(false)
- .globalBrooklynPropertiesFile(propsFile.getAbsolutePath())
- .start();
-
- Assert.fail("Should have thrown");
- } catch (FatalRuntimeException e) {
- if (!e.toString().contains("Invalid permissions for file")) throw e;
- } finally {
- propsFile.delete();
- }
- }
-
- @Test(groups="Integration")
- public void testChecksLocalBrooklynPropertiesPermissionsX00() throws Exception {
- File propsFile = File.createTempFile("testChecksLocalBrooklynPropertiesPermissionsX00", ".properties");
- propsFile.setReadable(true, false);
- try {
- launcher = newLauncherForTests(false)
- .webconsole(false)
- .localBrooklynPropertiesFile(propsFile.getAbsolutePath())
- .start();
-
- Assert.fail("Should have thrown");
- } catch (FatalRuntimeException e) {
- if (!e.toString().contains("Invalid permissions for file")) throw e;
- } finally {
- propsFile.delete();
- }
- }
-
- @Test(groups="Integration")
- public void testStartsWithBrooklynPropertiesPermissionsX00() throws Exception {
- File globalPropsFile = File.createTempFile("testChecksLocalBrooklynPropertiesPermissionsX00_global", ".properties");
- Files.write(getMinimalLauncherPropertiesString()+"key_in_global=1", globalPropsFile, Charset.defaultCharset());
- File localPropsFile = File.createTempFile("testChecksLocalBrooklynPropertiesPermissionsX00_local", ".properties");
- Files.write("key_in_local=2", localPropsFile, Charset.defaultCharset());
- FileUtil.setFilePermissionsTo600(globalPropsFile);
- FileUtil.setFilePermissionsTo600(localPropsFile);
- try {
- launcher = newLauncherForTests(false)
- .webconsole(false)
- .localBrooklynPropertiesFile(localPropsFile.getAbsolutePath())
- .globalBrooklynPropertiesFile(globalPropsFile.getAbsolutePath())
- .start();
- assertEquals(launcher.getServerDetails().getManagementContext().getConfig().getFirst("key_in_global"), "1");
- assertEquals(launcher.getServerDetails().getManagementContext().getConfig().getFirst("key_in_local"), "2");
- } finally {
- globalPropsFile.delete();
- localPropsFile.delete();
- }
- }
-
- @Test // takes a bit of time because starts webapp, but also tests rest api so useful
- public void testErrorsCaughtByApiAndRestApiWorks() throws Exception {
- launcher = newLauncherForTests(true)
- .catalogInitialization(new CatalogInitialization(null, false, null, false).addPopulationCallback(new Function<CatalogInitialization, Void>() {
- @Override
- public Void apply(CatalogInitialization input) {
- throw new RuntimeException("deliberate-exception-for-testing");
- }
- }))
- .start();
- // such an error should be thrown, then caught in this calling thread
- ManagementContext mgmt = launcher.getServerDetails().getManagementContext();
- Assert.assertFalse( ((ManagementContextInternal)mgmt).errors().isEmpty() );
- Assert.assertTrue( ((ManagementContextInternal)mgmt).errors().get(0).toString().contains("deliberate"), ""+((ManagementContextInternal)mgmt).errors() );
- HttpTestUtils.assertContentMatches(
- Urls.mergePaths(launcher.getServerDetails().getWebServerUrl(), "v1/server/up"),
- "true");
- HttpTestUtils.assertContentMatches(
- Urls.mergePaths(launcher.getServerDetails().getWebServerUrl(), "v1/server/healthy"),
- "false");
- // TODO test errors api?
- }
-
- private BrooklynLauncher newLauncherForTests(boolean minimal) {
- Preconditions.checkArgument(launcher==null, "can only be used if no launcher yet");
- BrooklynLauncher launcher = BrooklynLauncher.newInstance();
- if (minimal)
- launcher.brooklynProperties(LocalManagementContextForTests.builder(true).buildProperties());
- return launcher;
- }
-
- private String getMinimalLauncherPropertiesString() throws IOException {
- BrooklynProperties p1 = LocalManagementContextForTests.builder(true).buildProperties();
- Properties p = new Properties();
- p.putAll(Maps.transformValues(p1.asMapWithStringKeys(), StringFunctions.toStringFunction()));
- Writer w = new StringWriter();
- p.store(w, "test");
- w.close();
- return w.toString()+"\n";
- }
-
- private void assertOnlyApp(BrooklynLauncher launcher, Class<? extends Application> expectedType) {
- assertEquals(launcher.getApplications().size(), 1, "apps="+launcher.getApplications());
- assertNotNull(Iterables.find(launcher.getApplications(), Predicates.instanceOf(TestApplication.class), null), "apps="+launcher.getApplications());
- }
-
- private void assertOnlyLocation(Application app, Class<? extends Location> expectedType) {
- assertEquals(app.getLocations().size(), 1, "locs="+app.getLocations());
- assertNotNull(Iterables.find(app.getLocations(), Predicates.instanceOf(LocalhostMachineProvisioningLocation.class), null), "locs="+app.getLocations());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/brooklyn/launcher/BrooklynWebServerTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/BrooklynWebServerTest.java b/usage/launcher/src/test/java/brooklyn/launcher/BrooklynWebServerTest.java
deleted file mode 100644
index b40a023..0000000
--- a/usage/launcher/src/test/java/brooklyn/launcher/BrooklynWebServerTest.java
+++ /dev/null
@@ -1,209 +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 brooklyn.launcher;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.security.KeyStore;
-import java.security.SecureRandom;
-import java.util.List;
-import java.util.Map;
-
-import javax.net.ssl.SSLHandshakeException;
-import javax.net.ssl.SSLPeerUnverifiedException;
-
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import brooklyn.config.BrooklynProperties;
-import brooklyn.entity.basic.Entities;
-import brooklyn.management.internal.LocalManagementContext;
-import brooklyn.rest.BrooklynWebConfig;
-import brooklyn.test.entity.LocalManagementContextForTests;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.exceptions.Exceptions;
-import brooklyn.util.http.HttpTool;
-import brooklyn.util.http.HttpToolResponse;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-
-public class BrooklynWebServerTest {
-
- public static final Logger log = LoggerFactory.getLogger(BrooklynWebServer.class);
-
- private BrooklynProperties brooklynProperties;
- private BrooklynWebServer webServer;
- private List<LocalManagementContext> managementContexts = Lists.newCopyOnWriteArrayList();
-
- @BeforeMethod(alwaysRun=true)
- public void setUp(){
- brooklynProperties = BrooklynProperties.Factory.newEmpty();
- }
-
- @AfterMethod(alwaysRun=true)
- public void tearDown() throws Exception {
- for (LocalManagementContext managementContext : managementContexts) {
- Entities.destroyAll(managementContext);
- }
- managementContexts.clear();
- if (webServer != null) webServer.stop();
- }
-
- private LocalManagementContext newManagementContext(BrooklynProperties brooklynProperties) {
- LocalManagementContext result = new LocalManagementContextForTests(brooklynProperties);
- managementContexts.add(result);
- return result;
- }
-
- @Test
- public void verifyHttp() throws Exception {
- webServer = new BrooklynWebServer(newManagementContext(brooklynProperties));
- try {
- webServer.start();
-
- HttpToolResponse response = HttpTool.execAndConsume(new DefaultHttpClient(), new HttpGet(webServer.getRootUrl()));
- assertEquals(response.getResponseCode(), 200);
- } finally {
- webServer.stop();
- }
- }
-
- @DataProvider(name="keystorePaths")
- public Object[][] getKeystorePaths() {
- return new Object[][] {
- {getFile("server.ks")},
- {new File(getFile("server.ks")).toURI().toString()},
- {"classpath://server.ks"}};
- }
-
- @Test(dataProvider="keystorePaths")
- public void verifyHttps(String keystoreUrl) throws Exception {
- Map<String,?> flags = ImmutableMap.<String,Object>builder()
- .put("httpsEnabled", true)
- .put("keystoreUrl", keystoreUrl)
- .put("keystorePassword", "password")
- .build();
- webServer = new BrooklynWebServer(flags, newManagementContext(brooklynProperties));
- webServer.start();
-
- try {
- KeyStore keyStore = load("client.ks", "password");
- KeyStore trustStore = load("client.ts", "password");
- SSLSocketFactory socketFactory = new SSLSocketFactory(SSLSocketFactory.TLS, keyStore, "password", trustStore, (SecureRandom)null, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
-
- HttpToolResponse response = HttpTool.execAndConsume(
- HttpTool.httpClientBuilder()
- .port(webServer.getActualPort())
- .https(true)
- .socketFactory(socketFactory)
- .build(),
- new HttpGet(webServer.getRootUrl()));
- assertEquals(response.getResponseCode(), 200);
- } finally {
- webServer.stop();
- }
- }
-
- @Test
- public void verifyHttpsFromConfig() throws Exception {
- brooklynProperties.put(BrooklynWebConfig.HTTPS_REQUIRED, true);
- brooklynProperties.put(BrooklynWebConfig.KEYSTORE_URL, getFile("server.ks"));
- brooklynProperties.put(BrooklynWebConfig.KEYSTORE_PASSWORD, "password");
- verifyHttpsFromConfig(brooklynProperties);
- }
-
- @Test
- public void verifyHttpsCiphers() throws Exception {
- brooklynProperties.put(BrooklynWebConfig.HTTPS_REQUIRED, true);
- brooklynProperties.put(BrooklynWebConfig.TRANSPORT_PROTOCOLS, "XXX");
- brooklynProperties.put(BrooklynWebConfig.TRANSPORT_CIPHERS, "XXX");
- try {
- verifyHttpsFromConfig(brooklynProperties);
- fail("Expected to fail due to unsupported ciphers during connection negotiation");
- } catch (Exception e) {
- assertTrue(Exceptions.getFirstThrowableOfType(e, SSLPeerUnverifiedException.class) != null ||
- Exceptions.getFirstThrowableOfType(e, SSLHandshakeException.class) != null,
- "Expected to fail due to inability to negotiate");
- }
- }
-
- private void verifyHttpsFromConfig(BrooklynProperties brooklynProperties) throws Exception {
- webServer = new BrooklynWebServer(MutableMap.of(), newManagementContext(brooklynProperties));
- webServer.start();
-
- try {
- KeyStore keyStore = load("client.ks", "password");
- KeyStore trustStore = load("client.ts", "password");
- SSLSocketFactory socketFactory = new SSLSocketFactory(SSLSocketFactory.TLS, keyStore, "password", trustStore, (SecureRandom)null, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
-
- HttpToolResponse response = HttpTool.execAndConsume(
- HttpTool.httpClientBuilder()
- .port(webServer.getActualPort())
- .https(true)
- .socketFactory(socketFactory)
- .build(),
- new HttpGet(webServer.getRootUrl()));
- assertEquals(response.getResponseCode(), 200);
- } finally {
- webServer.stop();
- }
- }
-
- private KeyStore load(String name, String password) throws Exception {
- KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
- FileInputStream instream = new FileInputStream(new File(getFile(name)));
- keystore.load(instream, password.toCharArray());
- return keystore;
- }
-
- @Test
- public void testGetFileFromUrl() throws Exception {
- // On Windows will treat as relative paths
- String url = "file:///tmp/special%40file%20with%20spaces";
- String file = "/tmp/special@file with spaces";
- assertEquals(getFile(new URL(url)), new File(file).getAbsolutePath());
- }
-
- private String getFile(String classpathResource) {
- // this works because both IDE and Maven run tests with classes/resources on the file system
- return getFile(getClass().getResource("/" + classpathResource));
- }
-
- private String getFile(URL url) {
- try {
- return new File(url.toURI()).getAbsolutePath();
- } catch (URISyntaxException e) {
- throw Exceptions.propagate(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/brooklyn/launcher/SimpleYamlLauncherForTests.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/SimpleYamlLauncherForTests.java b/usage/launcher/src/test/java/brooklyn/launcher/SimpleYamlLauncherForTests.java
deleted file mode 100644
index 9ab8131..0000000
--- a/usage/launcher/src/test/java/brooklyn/launcher/SimpleYamlLauncherForTests.java
+++ /dev/null
@@ -1,31 +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 brooklyn.launcher;
-
-import brooklyn.launcher.camp.SimpleYamlLauncher;
-import brooklyn.management.ManagementContext;
-import brooklyn.test.entity.LocalManagementContextForTests;
-
-public class SimpleYamlLauncherForTests extends SimpleYamlLauncher {
-
- protected ManagementContext newManagementContext() {
- return new LocalManagementContextForTests();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/brooklyn/launcher/WebAppRunnerTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/WebAppRunnerTest.java b/usage/launcher/src/test/java/brooklyn/launcher/WebAppRunnerTest.java
deleted file mode 100644
index c89b399..0000000
--- a/usage/launcher/src/test/java/brooklyn/launcher/WebAppRunnerTest.java
+++ /dev/null
@@ -1,168 +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 brooklyn.launcher;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.fail;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.test.TestResourceUnavailableException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.config.BrooklynProperties;
-import brooklyn.entity.basic.Entities;
-import brooklyn.management.internal.LocalManagementContext;
-import brooklyn.management.internal.ManagementContextInternal;
-import brooklyn.test.HttpTestUtils;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.net.Networking;
-
-import com.google.common.collect.Lists;
-
-
-/**
- * These tests require the brooklyn.war to work. (Should be placed by maven build.)
- */
-public class WebAppRunnerTest {
-
- public static final Logger log = LoggerFactory.getLogger(WebAppRunnerTest.class);
-
- List<LocalManagementContext> managementContexts = Lists.newCopyOnWriteArrayList();
-
- @AfterMethod(alwaysRun=true)
- public void tearDown() throws Exception {
- for (LocalManagementContext managementContext : managementContexts) {
- Entities.destroyAll(managementContext);
- }
- managementContexts.clear();
- }
-
- LocalManagementContext newManagementContext(BrooklynProperties brooklynProperties) {
- LocalManagementContext result = new LocalManagementContext(brooklynProperties);
- managementContexts.add(result);
- return result;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- BrooklynWebServer createWebServer(Map properties) {
- Map bigProps = MutableMap.copyOf(properties);
- Map attributes = MutableMap.copyOf( (Map) bigProps.get("attributes") );
- bigProps.put("attributes", attributes);
-
- BrooklynProperties brooklynProperties = BrooklynProperties.Factory.newEmpty();
- brooklynProperties.putAll(bigProps);
- brooklynProperties.put("brooklyn.webconsole.security.provider","brooklyn.rest.security.provider.AnyoneSecurityProvider");
- brooklynProperties.put("brooklyn.webconsole.security.https.required","false");
- return new BrooklynWebServer(bigProps, newManagementContext(brooklynProperties));
- }
-
- @Test
- public void testStartWar1() throws Exception {
- if (!Networking.isPortAvailable(8090))
- fail("Another process is using port 8090 which is required for this test.");
- BrooklynWebServer server = createWebServer(MutableMap.of("port", 8090));
- assertNotNull(server);
-
- try {
- server.start();
- assertBrooklynEventuallyAt("http://localhost:8090/");
- } finally {
- server.stop();
- }
- }
-
- public static void assertBrooklynEventuallyAt(String url) {
- HttpTestUtils.assertContentEventuallyContainsText(url, "Brooklyn Web Console");
- }
-
- @Test
- public void testStartSecondaryWar() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
-
- if (!Networking.isPortAvailable(8090))
- fail("Another process is using port 8090 which is required for this test.");
- BrooklynWebServer server = createWebServer(
- MutableMap.of("port", 8090, "war", "brooklyn.war", "wars", MutableMap.of("hello", "hello-world.war")) );
- assertNotNull(server);
-
- try {
- server.start();
-
- assertBrooklynEventuallyAt("http://localhost:8090/");
- HttpTestUtils.assertContentEventuallyContainsText("http://localhost:8090/hello",
- "This is the home page for a sample application");
-
- } finally {
- server.stop();
- }
- }
-
- @Test
- public void testStartSecondaryWarAfter() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
-
- if (!Networking.isPortAvailable(8090))
- fail("Another process is using port 8090 which is required for this test.");
- BrooklynWebServer server = createWebServer(MutableMap.of("port", 8090, "war", "brooklyn.war"));
- assertNotNull(server);
-
- try {
- server.start();
- server.deploy("/hello", "hello-world.war");
-
- assertBrooklynEventuallyAt("http://localhost:8090/");
- HttpTestUtils.assertContentEventuallyContainsText("http://localhost:8090/hello",
- "This is the home page for a sample application");
-
- } finally {
- server.stop();
- }
- }
-
- @Test
- public void testStartWithLauncher() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
-
- BrooklynLauncher launcher = BrooklynLauncher.newInstance()
- .brooklynProperties(BrooklynProperties.Factory.newEmpty())
- .brooklynProperties("brooklyn.webconsole.security.provider","brooklyn.rest.security.provider.AnyoneSecurityProvider")
- .webapp("/hello", "hello-world.war")
- .start();
- BrooklynServerDetails details = launcher.getServerDetails();
-
- try {
- details.getWebServer().deploy("/hello2", "hello-world.war");
-
- assertBrooklynEventuallyAt(details.getWebServerUrl());
- HttpTestUtils.assertContentEventuallyContainsText(details.getWebServerUrl()+"hello", "This is the home page for a sample application");
- HttpTestUtils.assertContentEventuallyContainsText(details.getWebServerUrl()+"hello2", "This is the home page for a sample application");
- HttpTestUtils.assertHttpStatusCodeEventuallyEquals(details.getWebServerUrl()+"hello0", 404);
-
- } finally {
- details.getWebServer().stop();
- ((ManagementContextInternal)details.getManagementContext()).terminate();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/brooklyn/launcher/YamlLauncher.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/YamlLauncher.java b/usage/launcher/src/test/java/brooklyn/launcher/YamlLauncher.java
deleted file mode 100644
index 1bd8ab8..0000000
--- a/usage/launcher/src/test/java/brooklyn/launcher/YamlLauncher.java
+++ /dev/null
@@ -1,35 +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 brooklyn.launcher;
-
-import brooklyn.launcher.camp.SimpleYamlLauncher;
-
-public class YamlLauncher {
-
- public static void main(String[] args) {
- SimpleYamlLauncher l = new SimpleYamlLauncher();
- l.setShutdownAppsOnExit(true);
-
- l.launchAppYaml("java-web-app-and-db-with-function.yaml");
-// l.launchAppYaml("java-web-app-and-memsql.yaml");
-// l.launchAppYaml("memsql.yaml");
-// l.launchAppYaml("classpath://mongo-blueprint.yaml");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java b/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
deleted file mode 100644
index 63a8bfb..0000000
--- a/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
+++ /dev/null
@@ -1,202 +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 brooklyn.launcher.blueprints;
-
-import static org.testng.Assert.assertNotEquals;
-
-import java.io.File;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Collection;
-
-import org.apache.brooklyn.camp.brooklyn.BrooklynCampPlatformLauncherAbstract;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-
-import brooklyn.entity.Application;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.Attributes;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.Lifecycle;
-import brooklyn.entity.basic.SoftwareProcess;
-import brooklyn.entity.rebind.RebindOptions;
-import brooklyn.entity.rebind.RebindTestUtils;
-import brooklyn.entity.rebind.persister.FileBasedObjectStore;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.launcher.SimpleYamlLauncherForTests;
-import brooklyn.launcher.camp.BrooklynCampPlatformLauncher;
-import brooklyn.management.ManagementContext;
-import brooklyn.management.internal.LocalManagementContext;
-import brooklyn.test.Asserts;
-import brooklyn.test.EntityTestUtils;
-import brooklyn.util.ResourceUtils;
-import brooklyn.util.os.Os;
-
-public abstract class AbstractBlueprintTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractBlueprintTest.class);
-
- protected File mementoDir;
- protected ClassLoader classLoader = AbstractBlueprintTest.class.getClassLoader();
-
- protected ManagementContext mgmt;
- protected SimpleYamlLauncherForTests launcher;
- protected BrooklynLauncher viewer;
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- mementoDir = Os.newTempDir(getClass());
- mgmt = createOrigManagementContext();
- LOG.info("Test "+getClass()+" persisting to "+mementoDir);
-
- launcher = new SimpleYamlLauncherForTests() {
- @Override
- protected BrooklynCampPlatformLauncherAbstract newPlatformLauncher() {
- return new BrooklynCampPlatformLauncher() {
- protected ManagementContext newManagementContext() {
- return AbstractBlueprintTest.this.mgmt;
- }
- };
- }
- };
- viewer = BrooklynLauncher.newInstance()
- .managementContext(mgmt)
- .start();
- }
-
- @AfterMethod(alwaysRun=true)
- public void tearDown() throws Exception {
- try {
- if (mgmt != null) {
- for (Application app: mgmt.getApplications()) {
- LOG.debug("destroying app "+app+" (managed? "+Entities.isManaged(app)+"; mgmt is "+mgmt+")");
- try {
- Entities.destroy(app);
- LOG.debug("destroyed app "+app+"; mgmt now "+mgmt);
- } catch (Exception e) {
- LOG.error("problems destroying app "+app, e);
- }
- }
- }
- if (launcher != null) launcher.destroyAll();
- if (viewer != null) viewer.terminate();
- if (mgmt != null) Entities.destroyAll(mgmt);
- if (mementoDir != null) FileBasedObjectStore.deleteCompletely(mementoDir);
- } catch (Throwable t) {
- LOG.error("Caught exception in tearDown method", t);
- } finally {
- mgmt = null;
- launcher = null;
- }
- }
-
- protected void runTest(String yamlFile) throws Exception {
- final Application app = launcher.launchAppYaml(yamlFile);
-
- assertNoFires(app);
-
- Application newApp = rebind();
- assertNoFires(newApp);
- }
-
- protected void runTest(Reader yaml) throws Exception {
- final Application app = launcher.launchAppYaml(yaml);
-
- assertNoFires(app);
-
- Application newApp = rebind();
- assertNoFires(newApp);
- }
-
- protected void assertNoFires(final Entity app) {
- EntityTestUtils.assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
-
- Asserts.succeedsEventually(new Runnable() {
- public void run() {
- for (Entity entity : Entities.descendants(app)) {
- assertNotEquals(entity.getAttribute(Attributes.SERVICE_STATE_ACTUAL), Lifecycle.ON_FIRE);
- assertNotEquals(entity.getAttribute(Attributes.SERVICE_UP), false);
-
- if (entity instanceof SoftwareProcess) {
- EntityTestUtils.assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
- EntityTestUtils.assertAttributeEquals(entity, Attributes.SERVICE_UP, Boolean.TRUE);
- }
- }
- }});
- }
-
- protected Reader loadYaml(String url, String location) {
- String yaml =
- "location: "+location+"\n"+
- new ResourceUtils(this).getResourceAsString(url);
- return new StringReader(yaml);
- }
-
-
- //////////////////////////////////////////////////////////////////
- // FOR REBIND //
- // See brooklyn.entity.rebind.RebindTestFixture in core's tests //
- //////////////////////////////////////////////////////////////////
-
- /** rebinds, and sets newApp */
- protected Application rebind() throws Exception {
- return rebind(RebindOptions.create());
- }
-
- protected Application rebind(RebindOptions options) throws Exception {
- ManagementContext origMgmt = mgmt;
- ManagementContext newMgmt = createNewManagementContext();
- Collection<Application> origApps = origMgmt.getApplications();
-
- options = RebindOptions.create(options);
- if (options.classLoader == null) options.classLoader(classLoader);
- if (options.mementoDir == null) options.mementoDir(mementoDir);
- if (options.origManagementContext == null) options.origManagementContext(origMgmt);
- if (options.newManagementContext == null) options.newManagementContext(newMgmt);
-
- for (Application origApp : origApps) {
- RebindTestUtils.waitForPersisted(origApp);
- }
-
- mgmt = options.newManagementContext;
- Application newApp = RebindTestUtils.rebind(options);
- return newApp;
- }
-
- /** @return A started management context */
- protected LocalManagementContext createOrigManagementContext() {
- return RebindTestUtils.managementContextBuilder(mementoDir, classLoader)
- .persistPeriodMillis(1)
- .forLive(true)
- .emptyCatalog(true)
- .buildStarted();
- }
-
- /** @return An unstarted management context */
- protected LocalManagementContext createNewManagementContext() {
- return RebindTestUtils.managementContextBuilder(mementoDir, classLoader)
- .persistPeriodMillis(1)
- .forLive(true)
- .emptyCatalog(true)
- .buildUnstarted();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/brooklyn/launcher/blueprints/CouchbaseBlueprintTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/blueprints/CouchbaseBlueprintTest.java b/usage/launcher/src/test/java/brooklyn/launcher/blueprints/CouchbaseBlueprintTest.java
deleted file mode 100644
index 3450489..0000000
--- a/usage/launcher/src/test/java/brooklyn/launcher/blueprints/CouchbaseBlueprintTest.java
+++ /dev/null
@@ -1,69 +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 brooklyn.launcher.blueprints;
-
-import org.testng.annotations.Test;
-
-public class CouchbaseBlueprintTest extends AbstractBlueprintTest {
-
- @Test(groups={"Live"})
- public void testCouchbaseNode() throws Exception {
- runTest("couchbase-node.yaml");
- }
-
- @Test(groups={"Live"})
- public void testCouchbaseCluster() throws Exception {
- runTest("couchbase-cluster.yaml");
- }
-
- @Test(groups={"Live"})
- public void testCouchbaseClusterSingleNode() throws Exception {
- runTest("couchbase-cluster-singleNode.yaml");
- }
-
- @Test(groups={"Live"})
- public void testCouchbaseWithPillowfight() throws Exception {
- runTest("couchbase-w-pillowfight.yaml");
- }
-
- /**
- * FIXME Failed with "Unable to match required VM template constraints" - caused by NPE:
- * Caused by: java.lang.NullPointerException: id
- * at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229)
- * at org.jclouds.softlayer.domain.OperatingSystem.<init>(OperatingSystem.java:106)
- * at org.jclouds.softlayer.domain.OperatingSystem$Builder.build(OperatingSystem.java:87)
- * at org.jclouds.softlayer.domain.ContainerVirtualGuestConfiguration$4.apply(ContainerVirtualGuestConfiguration.java:209)
- * at org.jclouds.softlayer.domain.ContainerVirtualGuestConfiguration$4.apply(ContainerVirtualGuestConfiguration.java:206)
- * This blueprint uses {minRam: 16384, minCores: 4}.
- * Suspect this is already fixed by Andrea Turli in latest jclouds.
- */
- @Test(groups={"Live", "WIP"})
- public void testCouchbaseWithLoadgen() throws Exception {
- runTest("couchbase-w-loadgen.yaml");
- }
-
- /**
- * FIXME Failed with "Unable to match required VM template constraints" - caused by NPE
- * (see error described at {@link #testCouchbaseWithLoadgen()}.
- */
- @Test(groups={"Live", "WIP"})
- public void testCouchbaseReplicationWithPillowfight() throws Exception {
- runTest("couchbase-replication-w-pillowfight.yaml");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/brooklyn/launcher/blueprints/MongoDbBlueprintTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/blueprints/MongoDbBlueprintTest.java b/usage/launcher/src/test/java/brooklyn/launcher/blueprints/MongoDbBlueprintTest.java
deleted file mode 100644
index 2f77552..0000000
--- a/usage/launcher/src/test/java/brooklyn/launcher/blueprints/MongoDbBlueprintTest.java
+++ /dev/null
@@ -1,51 +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 brooklyn.launcher.blueprints;
-
-import org.testng.annotations.Test;
-
-public class MongoDbBlueprintTest extends AbstractBlueprintTest {
-
- // TODO Some tests are failing! Needs investigated.
-
- @Test(groups={"Integration", "WIP"})
- public void testMongoSharded() throws Exception {
- runTest("mongo-sharded.yaml");
- }
-
- @Test(groups={"Integration"})
- public void testMongoReplicaSet() throws Exception {
- runTest("mongo-blueprint.yaml");
- }
-
- @Test(groups={"Integration"})
- public void testMongoClientAndSingleServer() throws Exception {
- runTest("mongo-client-single-server.yaml");
- }
-
- @Test(groups={"Integration", "WIP"})
- public void testMongoScripts() throws Exception {
- runTest("mongo-scripts.yaml");
- }
-
- @Test(groups="Integration")
- public void testMongoSingleServer() throws Exception {
- runTest("mongo-single-server-blueprint.yaml");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/org/apache/brooklyn/entity/basic/VanillaSoftwareYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/org/apache/brooklyn/entity/basic/VanillaSoftwareYamlTest.java b/usage/launcher/src/test/java/org/apache/brooklyn/entity/basic/VanillaSoftwareYamlTest.java
new file mode 100644
index 0000000..1181dff
--- /dev/null
+++ b/usage/launcher/src/test/java/org/apache/brooklyn/entity/basic/VanillaSoftwareYamlTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.basic;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.Application;
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.SoftwareProcess;
+import brooklyn.entity.trait.Startable;
+import org.apache.brooklyn.launcher.SimpleYamlLauncherForTests;
+import org.apache.brooklyn.launcher.camp.SimpleYamlLauncher;
+import brooklyn.test.Asserts;
+import brooklyn.util.ResourceUtils;
+import brooklyn.util.os.Os;
+import brooklyn.util.text.Strings;
+
+import com.google.common.collect.Iterables;
+
+public class VanillaSoftwareYamlTest {
+
+ private static final Logger log = LoggerFactory.getLogger(VanillaSoftwareYamlTest.class);
+
+ @Test(groups="Integration")
+ public void testVanillaSoftwareYaml() {
+ SimpleYamlLauncher l = new SimpleYamlLauncherForTests();
+ try {
+ Application app = l.launchAppYaml("vanilla-software-blueprint.yaml");
+ log.info("started "+app);
+
+ String runDir = Iterables.getOnlyElement(app.getChildren()).getAttribute(SoftwareProcess.RUN_DIR);
+ final String filePath = Os.mergePaths(runDir, "DATE");
+
+ String fileContents = new ResourceUtils(this).getResourceAsString(filePath);
+ Long d1 = Long.parseLong( Strings.getFirstWordAfter(fileContents, "utc") );
+ Assert.assertTrue( Math.abs(d1*1000-System.currentTimeMillis())<15000, "Time UTC does not match system; "+d1+" v "+System.currentTimeMillis() );
+
+ Asserts.succeedsEventually(new Runnable() {
+ public void run() {
+ String fileContents = new ResourceUtils(this).getResourceAsString(filePath);
+ Assert.assertTrue(fileContents.contains("checkRunning"));
+ }
+ });
+
+ app.invoke(Startable.STOP, null).getUnchecked();
+ Asserts.succeedsEventually(new Runnable() {
+ public void run() {
+ String fileContents = new ResourceUtils(this).getResourceAsString(filePath);
+ Assert.assertTrue(fileContents.contains("stop"));
+ }
+ });
+
+ } finally {
+ l.destroyAll();
+ }
+ log.info("DONE");
+ }
+
+ /** yaml variant of VanillaSoftwareProcessAndChildrenIntegrationTest */
+ @Test(groups="Integration")
+ public void testVanillaSoftwareYamlWithChildStartedAfter() {
+ SimpleYamlLauncher l = new SimpleYamlLauncherForTests();
+ try {
+ Application app = l.launchAppYaml("vanilla-software-with-child-blueprint.yaml");
+ log.info("started "+app);
+
+ Entity p1 = Iterables.getOnlyElement( app.getChildren() );
+ Long d1 = Long.parseLong( Strings.getFirstWordAfter(new ResourceUtils(this).getResourceAsString(Os.mergePaths(p1.getAttribute(SoftwareProcess.RUN_DIR), "DATE")), "utc") );
+
+ Entity p2 = Iterables.getOnlyElement( p1.getChildren() );
+ Long d2 = Long.parseLong( Strings.getFirstWordAfter(new ResourceUtils(this).getResourceAsString(Os.mergePaths(p2.getAttribute(SoftwareProcess.RUN_DIR), "DATE")), "utc") );
+ Assert.assertTrue( d2-d1 > 2 && d2-d1 < 10, "p2 should have started 3s after parent, but it did not ("+(d2-d1)+"s difference" );
+ } finally {
+ l.destroyAll();
+ }
+ log.info("DONE");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynEntityMirrorIntegrationTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynEntityMirrorIntegrationTest.java b/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynEntityMirrorIntegrationTest.java
new file mode 100644
index 0000000..f42c574
--- /dev/null
+++ b/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynEntityMirrorIntegrationTest.java
@@ -0,0 +1,180 @@
+/*
+ * 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.brooklynnode;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.ApplicationBuilder;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.EntityInternal;
+import brooklyn.entity.brooklynnode.BrooklynEntityMirror;
+import brooklyn.entity.proxying.EntitySpec;
+import org.apache.brooklyn.launcher.BrooklynWebServer;
+import brooklyn.management.ManagementContext;
+import brooklyn.management.ha.HighAvailabilityMode;
+import brooklyn.rest.filter.BrooklynPropertiesSecurityFilter;
+import brooklyn.test.Asserts;
+import brooklyn.test.EntityTestUtils;
+import brooklyn.test.HttpTestUtils;
+import brooklyn.test.entity.LocalManagementContextForTests;
+import brooklyn.test.entity.TestApplication;
+import brooklyn.util.exceptions.Exceptions;
+import brooklyn.util.time.Duration;
+
+/**
+ * Test for EntityMirror, launching an in-memory server and ensuring we can mirror.
+ * Here so that we can access the REST server.
+ * <p>
+ * May require <code>-Dbrooklyn.localhost.address=127.0.0.1</code> so that the console which binds to localhost is addressible.
+ * (That and the time it takes to run are the only reasons this is Integration.)
+ */
+@Test
+public class BrooklynEntityMirrorIntegrationTest {
+
+ private static final Logger log = LoggerFactory.getLogger(BrooklynEntityMirrorIntegrationTest.class);
+
+ private BrooklynWebServer server;
+ private TestApplication serverApp;
+ private ManagementContext serverMgmt;
+
+ private TestApplication localApp;
+ private ManagementContext localMgmt;
+
+ @BeforeMethod(alwaysRun=true)
+ public void setUp() throws Exception {
+ localApp = TestApplication.Factory.newManagedInstanceForTests();
+ localMgmt = localApp.getManagementContext();
+ }
+
+ @AfterMethod(alwaysRun=true)
+ public void tearDown() throws Exception {
+ if (serverMgmt!=null) Entities.destroyAll(serverMgmt);
+ if (server!=null) server.stop();
+ if (localMgmt!=null) Entities.destroyAll(localMgmt);
+
+ serverMgmt = null;
+ }
+
+
+ protected void setUpServer() {
+ setUpServer(new LocalManagementContextForTests(), false);
+ }
+ protected void setUpServer(ManagementContext mgmt, boolean useSecurityFilter) {
+ try {
+ if (serverMgmt!=null) throw new IllegalStateException("server already set up");
+
+ serverMgmt = mgmt;
+ server = new BrooklynWebServer(mgmt);
+ if (useSecurityFilter) server.setSecurityFilter(BrooklynPropertiesSecurityFilter.class);
+ server.start();
+
+ serverMgmt.getHighAvailabilityManager().disabled();
+ serverApp = ApplicationBuilder.newManagedApp(TestApplication.class, serverMgmt);
+
+ ((LocalManagementContextForTests)serverMgmt).noteStartupComplete();
+ } catch (Exception e) {
+ throw Exceptions.propagate(e);
+ }
+ }
+
+ protected String getBaseUri() {
+ return server.getRootUrl();
+ }
+
+ @Test(groups="Integration")
+ public void testServiceMirroring() throws Exception {
+ setUpServer();
+
+ String catalogItemId = "test-catalog-item:1.0";
+ String catalogItemIdGA = "test-catalog-item:1.0-GA";
+ serverApp.setAttribute(TestApplication.MY_ATTRIBUTE, "austria");
+ serverApp.setCatalogItemId(catalogItemId);
+
+ String serviceId = serverApp.getId();
+ Entity mirror = localApp.addChild(EntitySpec.create(BrooklynEntityMirror.class)
+ .configure(BrooklynEntityMirror.POLL_PERIOD, Duration.millis(100))
+ .configure(BrooklynEntityMirror.MIRRORED_ENTITY_ID, serviceId)
+ .configure(BrooklynEntityMirror.MIRRORED_ENTITY_URL,
+ getBaseUri()+"/v1/applications/"+serviceId+"/entities/"+serviceId)
+ );
+
+ EntityTestUtils.assertAttributeEqualsEventually(mirror, TestApplication.MY_ATTRIBUTE, "austria");
+ EntityTestUtils.assertAttributeEqualsEventually(mirror, BrooklynEntityMirror.MIRROR_CATALOG_ITEM_ID, catalogItemId);
+ assertTrue(mirror.getAttribute(BrooklynEntityMirror.MIRROR_SUMMARY) != null, "entity summary is null");
+ log.info("Sensors mirrored are: "+((EntityInternal)mirror).getAllAttributes());
+
+ serverApp.setAttribute(TestApplication.MY_ATTRIBUTE, "bermuda");
+ serverApp.setCatalogItemId(catalogItemIdGA);
+ EntityTestUtils.assertAttributeEqualsEventually(mirror, TestApplication.MY_ATTRIBUTE, "bermuda");
+ EntityTestUtils.assertAttributeEqualsEventually(mirror, BrooklynEntityMirror.MIRROR_CATALOG_ITEM_ID, catalogItemIdGA);
+
+ serverApp.stop();
+ assertUnmanagedEventually(mirror);
+ }
+
+ @Test(groups="Integration")
+ public void testServiceMirroringHttps() throws Exception {
+ LocalManagementContextForTests mgmtHttps = new LocalManagementContextForTests();
+ mgmtHttps.getBrooklynProperties().put("brooklyn.webconsole.security.https.required", true);
+ mgmtHttps.getBrooklynProperties().put("brooklyn.webconsole.security.users", "admin");
+ mgmtHttps.getBrooklynProperties().put("brooklyn.webconsole.security.user.admin.password", "P5ssW0rd");
+
+ setUpServer(mgmtHttps, true);
+ Assert.assertTrue(getBaseUri().startsWith("https:"), "URL is not https: "+getBaseUri());
+ // check auth is required
+ HttpTestUtils.assertHttpStatusCodeEquals(getBaseUri(), 401);
+
+ serverApp.setAttribute(TestApplication.MY_ATTRIBUTE, "austria");
+
+ String serviceId = serverApp.getId();
+ Entity mirror = localApp.addChild(EntitySpec.create(BrooklynEntityMirror.class)
+ .configure(BrooklynEntityMirror.POLL_PERIOD, Duration.millis(100))
+ .configure(BrooklynEntityMirror.MANAGEMENT_USER, "admin")
+ .configure(BrooklynEntityMirror.MANAGEMENT_PASSWORD, "P5ssW0rd")
+ .configure(BrooklynEntityMirror.MIRRORED_ENTITY_ID, serviceId)
+ .configure(BrooklynEntityMirror.MIRRORED_ENTITY_URL,
+ getBaseUri()+"/v1/applications/"+serviceId+"/entities/"+serviceId)
+ );
+
+ EntityTestUtils.assertAttributeEqualsEventually(mirror, TestApplication.MY_ATTRIBUTE, "austria");
+ log.info("Sensors mirrored are: "+((EntityInternal)mirror).getAllAttributes());
+
+ serverApp.setAttribute(TestApplication.MY_ATTRIBUTE, "bermuda");
+ EntityTestUtils.assertAttributeEqualsEventually(mirror, TestApplication.MY_ATTRIBUTE, "bermuda");
+
+ serverApp.stop();
+ assertUnmanagedEventually(mirror);
+ }
+
+ private static void assertUnmanagedEventually(final Entity entity) {
+ Asserts.succeedsEventually(new Runnable() {
+ @Override public void run() {
+ assertFalse(Entities.isManaged(entity));
+ }});
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeRestTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeRestTest.java b/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeRestTest.java
new file mode 100644
index 0000000..4a630de
--- /dev/null
+++ b/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeRestTest.java
@@ -0,0 +1,149 @@
+/*
+ * 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.brooklynnode;
+
+import java.net.URI;
+import java.util.concurrent.Callable;
+
+import org.apache.http.client.HttpClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.Application;
+import brooklyn.entity.basic.ApplicationBuilder;
+import brooklyn.entity.basic.Attributes;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.EntityInternal;
+import brooklyn.entity.brooklynnode.BrooklynEntityMirror;
+import brooklyn.entity.brooklynnode.BrooklynNode;
+import brooklyn.entity.brooklynnode.SameBrooklynNodeImpl;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.event.basic.BasicConfigKey;
+import org.apache.brooklyn.launcher.SimpleYamlLauncherForTests;
+import org.apache.brooklyn.launcher.camp.SimpleYamlLauncher;
+import brooklyn.location.Location;
+import brooklyn.management.Task;
+import brooklyn.test.EntityTestUtils;
+import brooklyn.test.HttpTestUtils;
+import brooklyn.test.entity.TestApplication;
+import brooklyn.test.entity.TestEntity;
+import brooklyn.util.collections.Jsonya;
+import brooklyn.util.collections.MutableMap;
+import brooklyn.util.collections.MutableSet;
+import brooklyn.util.config.ConfigBag;
+import brooklyn.util.http.HttpTool;
+import brooklyn.util.http.HttpToolResponse;
+import brooklyn.util.net.Urls;
+import brooklyn.util.repeat.Repeater;
+import brooklyn.util.time.Duration;
+
+import com.google.common.collect.Iterables;
+
+/** REST-accessible extension of {@link BrooklynNodeTest} */
+public class BrooklynNodeRestTest {
+
+ private static final Logger log = LoggerFactory.getLogger(BrooklynNodeRestTest.class);
+
+ // takes a while when run on its own, because initializing war and making some requests;
+ // but there are no waits (beyond 10ms), the delay is all classloading;
+ // and this tests a lot of things, REST API, Brooklyn Node, yaml deployment,
+ // so feels worth it to have as a unit test
+ // FIXME[BROOKLYN-43]: Test fails if security is configured in brooklyn.properties.
+ @Test(groups = "WIP")
+ public void testBrooklynNodeRestDeployAndMirror() {
+ final SimpleYamlLauncher l = new SimpleYamlLauncherForTests();
+ try {
+ TestApplication app = ApplicationBuilder.newManagedApp(TestApplication.class, l.getManagementContext());
+
+ BrooklynNode bn = app.createAndManageChild(EntitySpec.create(BrooklynNode.class, SameBrooklynNodeImpl.class));
+ bn.start(MutableSet.<Location>of());
+
+ URI uri = bn.getAttribute(BrooklynNode.WEB_CONSOLE_URI);
+ Assert.assertNotNull(uri);
+ EntityTestUtils.assertAttributeEqualsEventually(bn, Attributes.SERVICE_UP, true);
+ log.info("Created BrooklynNode: "+bn);
+
+ // deploy
+ Task<?> t = bn.invoke(BrooklynNode.DEPLOY_BLUEPRINT, ConfigBag.newInstance()
+ .configure(BrooklynNode.DeployBlueprintEffector.BLUEPRINT_TYPE, TestApplication.class.getName())
+ .configure(BrooklynNode.DeployBlueprintEffector.BLUEPRINT_CONFIG, MutableMap.<String,Object>of("x", 1, "y", "Y"))
+ .getAllConfig());
+ log.info("Deployment result: "+t.getUnchecked());
+
+ MutableSet<Application> apps = MutableSet.copyOf( l.getManagementContext().getApplications() );
+ Assert.assertEquals(apps.size(), 2);
+ apps.remove(app);
+
+ Application newApp = Iterables.getOnlyElement(apps);
+ Entities.dumpInfo(newApp);
+
+ Assert.assertEquals(newApp.getConfig(new BasicConfigKey<Integer>(Integer.class, "x")), (Integer)1);
+
+ // check mirror
+ String newAppId = newApp.getId();
+ BrooklynEntityMirror mirror = app.createAndManageChild(EntitySpec.create(BrooklynEntityMirror.class)
+ .configure(BrooklynEntityMirror.MIRRORED_ENTITY_URL,
+ Urls.mergePaths(uri.toString(), "/v1/applications/"+newAppId+"/entities/"+newAppId))
+ .configure(BrooklynEntityMirror.MIRRORED_ENTITY_ID, newAppId)
+ .configure(BrooklynEntityMirror.POLL_PERIOD, Duration.millis(10)));
+
+ Entities.dumpInfo(mirror);
+
+ EntityTestUtils.assertAttributeEqualsEventually(mirror, Attributes.SERVICE_UP, true);
+
+ ((EntityInternal)newApp).setAttribute(TestEntity.NAME, "foo");
+ EntityTestUtils.assertAttributeEqualsEventually(mirror, TestEntity.NAME, "foo");
+ log.info("Mirror successfully validated");
+
+ // also try deploying by invoking deploy through json
+ // (catch issues when effector params are map)
+ HttpClient client = HttpTool.httpClientBuilder().build();
+ HttpToolResponse result = HttpTool.httpPost(client, URI.create(Urls.mergePaths(uri.toString(), "/v1/applications/"+app.getId()+"/entities/"+bn.getId()
+ +"/effectors/deployBlueprint")),
+ MutableMap.of(com.google.common.net.HttpHeaders.CONTENT_TYPE, "application/json"),
+ Jsonya.newInstance()
+ .put("blueprintType", TestApplication.class.getName())
+ .put("blueprintConfig", MutableMap.of(TestEntity.CONF_NAME.getName(), "foo"))
+ .toString().getBytes());
+ log.info("Deploy effector invoked, result: "+result);
+ HttpTestUtils.assertHealthyStatusCode( result.getResponseCode() );
+
+ Repeater.create().every(Duration.millis(10)).until(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ return l.getManagementContext().getApplications().size() == 3;
+ }
+ }).limitTimeTo(Duration.TEN_SECONDS).runRequiringTrue();
+
+ apps = MutableSet.copyOf( l.getManagementContext().getApplications() );
+ apps.removeAll( MutableSet.of(app, newApp) );
+ Application newApp2 = Iterables.getOnlyElement(apps);
+ Entities.dumpInfo(newApp2);
+
+ EntityTestUtils.assertAttributeEqualsEventually(newApp2, Attributes.SERVICE_UP, true);
+ Assert.assertEquals(newApp2.getConfig(TestEntity.CONF_NAME), "foo");
+
+ } finally {
+ l.destroyAll();
+ }
+ log.info("DONE");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6f58ef3e/usage/launcher/src/test/java/org/apache/brooklyn/entity/database/mssql/MssqlBlueprintLiveTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/org/apache/brooklyn/entity/database/mssql/MssqlBlueprintLiveTest.java b/usage/launcher/src/test/java/org/apache/brooklyn/entity/database/mssql/MssqlBlueprintLiveTest.java
new file mode 100644
index 0000000..9103792
--- /dev/null
+++ b/usage/launcher/src/test/java/org/apache/brooklyn/entity/database/mssql/MssqlBlueprintLiveTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.database.mssql;
+
+import java.io.StringReader;
+import java.util.Map;
+
+import org.testng.annotations.Test;
+
+import org.apache.brooklyn.launcher.blueprints.AbstractBlueprintTest;
+import brooklyn.util.ResourceUtils;
+import brooklyn.util.text.TemplateProcessor;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Assumes that brooklyn.properties contains something like the following (but with real values!):
+ *
+ * {@code
+ * test.mssql.download.url = http://myserver.com/sql2012.iso
+ * test.mssql.download.user = myname
+ * test.mssql.download.password = mypassword
+ * test.mssql.sa.password = mypassword
+ * test.mssql.instance.name = MYNAME
+ * }
+ */
+public class MssqlBlueprintLiveTest extends AbstractBlueprintTest {
+
+ // TODO Needs further testing
+
+ @Test(groups={"Live"})
+ public void testMssql() throws Exception {
+ Map<String, String> substitutions = ImmutableMap.of(
+ "mssql.download.url", mgmt.getConfig().getFirst("test.mssql.download.url"),
+ "mssql.download.user", mgmt.getConfig().getFirst("test.mssql.download.user"),
+ "mssql.download.password", mgmt.getConfig().getFirst("test.mssql.download.password"),
+ "mssql.sa.password", mgmt.getConfig().getFirst("test.mssql.sa.password"),
+ "mssql.instance.name", mgmt.getConfig().getFirst("test.mssql.instance.name"));
+
+ String rawYaml = new ResourceUtils(this).getResourceAsString("mssql-test.yaml");
+ String yaml = TemplateProcessor.processTemplateContents(rawYaml, substitutions);
+ runTest(new StringReader(yaml));
+ }
+}