You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2015/08/11 22:42:53 UTC
[15/18] incubator-brooklyn git commit: Creates ApplicationsYamlTest
Creates ApplicationsYamlTest
Moves tests about app-wrapping from EntitiesYamlTest to
ApplicationsYamlTest.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/a5fbce79
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/a5fbce79
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/a5fbce79
Branch: refs/heads/master
Commit: a5fbce79024b5645feaa7e21fce06a55f35c6b89
Parents: 4549e28
Author: Aled Sage <al...@gmail.com>
Authored: Tue Aug 4 23:23:58 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Aug 11 20:04:32 2015 +0100
----------------------------------------------------------------------
.../camp/brooklyn/ApplicationsYamlTest.java | 115 +++++++++++++++++++
.../camp/brooklyn/EntitiesYamlTest.java | 38 ------
2 files changed, 115 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a5fbce79/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ApplicationsYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ApplicationsYamlTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ApplicationsYamlTest.java
new file mode 100644
index 0000000..3f860d6
--- /dev/null
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ApplicationsYamlTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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 io.brooklyn.camp.brooklyn;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.BasicApplication;
+import brooklyn.entity.basic.BasicEntity;
+import brooklyn.management.internal.EntityManagementUtils;
+
+import com.google.common.collect.Iterables;
+
+@Test
+public class ApplicationsYamlTest extends AbstractYamlTest {
+ private static final Logger log = LoggerFactory.getLogger(ApplicationsYamlTest.class);
+
+ @Test
+ public void testWrapsEntity() throws Exception {
+ Entity app = createAndStartApplication(
+ "services:",
+ "- type: " + BasicEntity.class.getName());
+ assertTrue(app.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
+ assertTrue(app instanceof BasicApplication);
+ assertTrue(Iterables.getOnlyElement(app.getChildren()) instanceof BasicEntity);
+ }
+
+ @Test
+ public void testDoesNotWrapApp() throws Exception {
+ Entity app = createAndStartApplication(
+ "services:",
+ "- type: " + BasicApplication.class.getName());
+ assertNull(app.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
+ assertTrue(app instanceof BasicApplication);
+ assertTrue(app.getChildren().isEmpty());
+ }
+
+ @Test
+ public void testWrapsAppIfForced() throws Exception {
+ Entity app = createAndStartApplication(
+ "wrappedApp: true",
+ "services:",
+ "- type: " + BasicApplication.class.getName());
+ assertTrue(app.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
+ assertTrue(app instanceof BasicApplication);
+ assertTrue(Iterables.getOnlyElement(app.getChildren()) instanceof BasicApplication);
+ assertTrue(Iterables.getOnlyElement(app.getChildren()).getChildren().isEmpty());
+ }
+
+ @Test
+ public void testDoesNotWrapAppIfUnforced() throws Exception {
+ Entity app = createAndStartApplication(
+ "wrappedApp: false",
+ "services:",
+ "- type: " + BasicApplication.class.getName());
+ assertNull(app.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
+ assertTrue(app instanceof BasicApplication);
+ assertTrue(app.getChildren().isEmpty());
+ }
+
+ @Test
+ public void testWrapsEntityIfDifferentTopLevelName() throws Exception {
+ Entity app = createAndStartApplication(
+ "name: topLevel",
+ "services:",
+ "- type: " + BasicApplication.class.getName(),
+ " name: bottomLevel");
+ assertTrue(app.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
+ assertTrue(app instanceof BasicApplication);
+ assertEquals(app.getDisplayName(), "topLevel");
+ assertTrue(Iterables.getOnlyElement(app.getChildren()) instanceof BasicApplication);
+ assertTrue(Iterables.getOnlyElement(app.getChildren()).getChildren().isEmpty());
+ assertEquals(Iterables.getOnlyElement(app.getChildren()).getDisplayName(), "bottomLevel");
+ }
+
+ @Test
+ public void testDoesNotWrapsEntityIfNoNameOnService() throws Exception {
+ Entity app = createAndStartApplication(
+ "name: topLevel",
+ "services:",
+ "- type: " + BasicApplication.class.getName());
+ assertNull(app.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
+ assertTrue(app instanceof BasicApplication);
+ assertTrue(app.getChildren().isEmpty());
+ assertEquals(app.getDisplayName(), "topLevel");
+ }
+
+ @Override
+ protected Logger getLogger() {
+ return log;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a5fbce79/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EntitiesYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EntitiesYamlTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EntitiesYamlTest.java
index e873ffa..e35b217 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EntitiesYamlTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/EntitiesYamlTest.java
@@ -20,7 +20,6 @@ package org.apache.brooklyn.camp.brooklyn;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.io.StringReader;
@@ -44,7 +43,6 @@ import brooklyn.entity.Application;
import brooklyn.entity.Effector;
import brooklyn.entity.Entity;
import brooklyn.entity.basic.Attributes;
-import brooklyn.entity.basic.BasicApplication;
import brooklyn.entity.basic.BasicEntity;
import brooklyn.entity.basic.ConfigKeys;
import brooklyn.entity.basic.Entities;
@@ -60,7 +58,6 @@ import brooklyn.event.AttributeSensor;
import brooklyn.event.basic.Sensors;
import brooklyn.location.Location;
import brooklyn.management.Task;
-import brooklyn.management.internal.EntityManagementUtils;
import brooklyn.management.internal.EntityManagerInternal;
import brooklyn.test.entity.TestEntity;
import brooklyn.test.entity.TestEntityImpl;
@@ -877,43 +874,8 @@ public class EntitiesYamlTest extends AbstractYamlTest {
}
}
- @Test
- public void testWrapperAppMarkerExists() throws Exception {
- Entity entity = createAndStartApplication(
- "services:",
- "- type: " + BasicEntity.class.getName());
- assertTrue(entity.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
- }
-
- @Test
- public void testWrapperAppMarkerDoesntExist() throws Exception {
- Entity entity = createAndStartApplication(
- "services:",
- "- type: " + BasicApplication.class.getName());
- assertNull(entity.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
- }
-
- @Test
- public void testWrapperAppMarkerForced() throws Exception {
- Entity entity = createAndStartApplication(
- "wrappedApp: true",
- "services:",
- "- type: " + BasicApplication.class.getName());
- assertTrue(entity.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
- }
-
- @Test
- public void testWrapperAppMarkerUnforced() throws Exception {
- Entity entity = createAndStartApplication(
- "wrappedApp: false",
- "services:",
- "- type: " + BasicApplication.class.getName());
- assertNull(entity.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
- }
-
@Override
protected Logger getLogger() {
return log;
}
-
}