You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by gr...@apache.org on 2018/11/08 11:28:10 UTC

[1/8] brooklyn-server git commit: [rt-felix] embedded framework test survives teardown

Repository: brooklyn-server
Updated Branches:
  refs/heads/master da7550d0f -> 61ac3cc4a


[rt-felix] embedded framework test survives teardown

When deleting files during teardown, if a temporary file can't be deleted
then the test should not fail for that reason. Log that the file could not
be delete and carry on.


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

Branch: refs/heads/master
Commit: 9f89562caf16b58154c31366d89f54b8bebced21
Parents: da7550d
Author: Paul Campbell <pc...@kemitix.net>
Authored: Mon Nov 5 10:50:46 2018 +0000
Committer: Paul Campbell <pc...@kemitix.net>
Committed: Tue Nov 6 15:15:44 2018 +0000

----------------------------------------------------------------------
 .../apache/brooklyn/rt/felix/EmbeddedFelixFrameworkTest.java   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9f89562c/utils/rt-felix/src/test/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFrameworkTest.java
----------------------------------------------------------------------
diff --git a/utils/rt-felix/src/test/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFrameworkTest.java b/utils/rt-felix/src/test/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFrameworkTest.java
index 11dfe27..cde02b1 100644
--- a/utils/rt-felix/src/test/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFrameworkTest.java
+++ b/utils/rt-felix/src/test/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFrameworkTest.java
@@ -66,7 +66,11 @@ public class EmbeddedFelixFrameworkTest {
         EmbeddedFelixFramework.stopFramework(framework);
         framework = null;
         if (storageTempDir != null) {
-            FileUtils.deleteDirectory(storageTempDir);
+            try {
+                FileUtils.deleteDirectory(storageTempDir);
+            } catch (IOException e) {
+                log.warn(e.getMessage());
+            }
             storageTempDir = null;
         }
     }


[3/8] brooklyn-server git commit: [core] Disable BashCommandsIntegrationTest test on Windows

Posted by gr...@apache.org.
[core] Disable BashCommandsIntegrationTest test on Windows


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

Branch: refs/heads/master
Commit: 2ba7ce671973fdf49ad099f3c744b2f38807860c
Parents: c5a851d
Author: Paul Campbell <pc...@kemitix.net>
Authored: Tue Nov 6 10:23:50 2018 +0000
Committer: Paul Campbell <pc...@kemitix.net>
Committed: Tue Nov 6 15:15:58 2018 +0000

----------------------------------------------------------------------
 .../core/ssh/BashCommandsIntegrationTest.java   | 21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2ba7ce67/core/src/test/java/org/apache/brooklyn/util/core/ssh/BashCommandsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/util/core/ssh/BashCommandsIntegrationTest.java b/core/src/test/java/org/apache/brooklyn/util/core/ssh/BashCommandsIntegrationTest.java
index 3f99ee3..311bce7 100644
--- a/core/src/test/java/org/apache/brooklyn/util/core/ssh/BashCommandsIntegrationTest.java
+++ b/core/src/test/java/org/apache/brooklyn/util/core/ssh/BashCommandsIntegrationTest.java
@@ -35,6 +35,7 @@ import java.util.List;
 
 import org.apache.brooklyn.core.test.BrooklynMgmtUnitTestSupport;
 import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.test.DisableOnWindows;
 import org.apache.brooklyn.util.core.ResourceUtils;
 import org.apache.brooklyn.util.core.task.BasicExecutionContext;
 import org.apache.brooklyn.util.core.task.ssh.SshTasks;
@@ -133,6 +134,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
     
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs a bash shell available on localhost")
     public void testRemoveRequireTtyFromSudoersFile() throws Exception {
         String cmds = BashCommands.dontRequireTtyForSudo();
 
@@ -154,6 +156,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
     
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs a whoami command available on localhost")
     public void testSudo() throws Exception {
         ByteArrayOutputStream outStream = new ByteArrayOutputStream();
         ByteArrayOutputStream errStream = new ByteArrayOutputStream();
@@ -177,6 +180,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
     
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs a bash shell available on localhost")
     public void testDownloadFirstSuccessfulFile() throws Exception {
         List<String> cmds = BashCommands.commandsToDownloadUrlsAs(
                 ImmutableList.of(sourceNonExistantFileUrl, sourceFileUrl1, sourceFileUrl2), 
@@ -188,6 +192,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
     
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs an ssh server listening on port 22 on localhost")
     public void testDownloadToStdout() throws Exception {
         ProcessTaskWrapper<String> t = SshTasks.newSshExecTaskFactory(loc, 
                 "cd "+destFile.getParentFile().getAbsolutePath(),
@@ -199,6 +204,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs an ssh server listening on port 22 on localhost")
     public void testAlternativesWhereFirstSucceeds() throws Exception {
         ProcessTaskWrapper<Integer> t = SshTasks.newSshExecTaskFactory(loc)
                 .add(BashCommands.alternatives(Arrays.asList("echo first", "exit 88")))
@@ -213,6 +219,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs an ssh server listening on port 22 on localhost")
     public void testAlternatives() throws Exception {
         ProcessTaskWrapper<Integer> t = SshTasks.newSshExecTaskFactory(loc)
                 .add(BashCommands.alternatives(Arrays.asList("asdfj_no_such_command_1", "exit 88")))
@@ -224,6 +231,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs an ssh server listening on port 22 on localhost")
     public void testRequireTestHandlesFailure() throws Exception {
         ProcessTaskWrapper<?> t = SshTasks.newSshExecTaskFactory(loc)
             .add(BashCommands.requireTest("-f "+sourceNonExistantFile.getPath(),
@@ -236,6 +244,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs an ssh server listening on port 22 on localhost")
     public void testRequireTestHandlesSuccess() throws Exception {
         ProcessTaskWrapper<?> t = SshTasks.newSshExecTaskFactory(loc)
             .add(BashCommands.requireTest("-f "+sourceFile1.getPath(),
@@ -247,6 +256,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs an ssh server listening on port 22 on localhost")
     public void testRequireFileHandlesFailure() throws Exception {
         ProcessTaskWrapper<?> t = SshTasks.newSshExecTaskFactory(loc)
             .add(BashCommands.requireFile(sourceNonExistantFile.getPath())).newTask();
@@ -260,6 +270,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs an ssh server listening on port 22 on localhost")
     public void testRequireFileHandlesSuccess() throws Exception {
         ProcessTaskWrapper<?> t = SshTasks.newSshExecTaskFactory(loc)
             .add(BashCommands.requireFile(sourceFile1.getPath())).newTask();
@@ -270,6 +281,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs an ssh server listening on port 22 on localhost")
     public void testRequireFailureExitsImmediately() throws Exception {
         ProcessTaskWrapper<?> t = SshTasks.newSshExecTaskFactory(loc)
             .add(BashCommands.requireTest("-f "+sourceNonExistantFile.getPath(),
@@ -284,6 +296,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs a bash shell available on localhost")
     public void testPipeMultiline() throws Exception {
         String output = execRequiringZeroAndReturningStdout(loc,
                 BashCommands.pipeTextTo("hello world\n"+"and goodbye\n", "wc")).get();
@@ -292,6 +305,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs a bash shell available on localhost")
     public void testWaitForFileContentsWhenAbortingOnFail() throws Exception {
         String fileContent = "mycontents";
         String cmd = BashCommands.waitForFileContents(destFile.getAbsolutePath(), fileContent, Duration.ONE_SECOND, true);
@@ -305,6 +319,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs a bash shell available on localhost")
     public void testWaitForFileContentsWhenNotAbortingOnFail() throws Exception {
         String fileContent = "mycontents";
         String cmd = BashCommands.waitForFileContents(destFile.getAbsolutePath(), fileContent, Duration.ONE_SECOND, false);
@@ -318,6 +333,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
     
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs a bash shell available on localhost")
     public void testWaitForFileContentsWhenContentsAppearAfterStart() throws Exception {
         String fileContent = "mycontents";
 
@@ -335,6 +351,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
     
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs a bash shell available on localhost")
     public void testWaitForFileExistsWhenAbortingOnFail() throws Exception {
         String cmd = BashCommands.waitForFileExists(destFile.getAbsolutePath(), Duration.ONE_SECOND, true);
 
@@ -347,6 +364,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration")
+    @DisableOnWindows(reason = "Needs a bash shell available on localhost")
     public void testWaitForFileExistsWhenNotAbortingOnFail() throws Exception {
         String cmd = BashCommands.waitForFileExists(destFile.getAbsolutePath(), Duration.ONE_SECOND, false);
 
@@ -359,6 +377,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
     
     @Test(groups="Integration", dependsOnMethods="testSudo")
+    @DisableOnWindows(reason = "Needs a bash shell available on localhost")
     public void testWaitForPortFreeWhenAbortingOnTimeout() throws Exception {
         ServerSocket serverSocket = openServerSocket();
         try {
@@ -378,6 +397,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
 
     @Test(groups="Integration", dependsOnMethods="testSudo")
+    @DisableOnWindows(reason = "Needs a bash shell available on localhost")
     public void testWaitForPortFreeWhenNotAbortingOnTimeout() throws Exception {
         ServerSocket serverSocket = openServerSocket();
         try {
@@ -397,6 +417,7 @@ public class BashCommandsIntegrationTest extends BrooklynMgmtUnitTestSupport {
     }
     
     @Test(groups="Integration", dependsOnMethods="testSudo")
+    @DisableOnWindows(reason = "Needs a bash shell available on localhost")
     public void testWaitForPortFreeWhenFreedAfterStart() throws Exception {
         ServerSocket serverSocket = openServerSocket();
         try {


[2/8] brooklyn-server git commit: [core] embedded framework test survives teardown

Posted by gr...@apache.org.
[core] embedded framework test survives teardown

When deleting files during teardown, if a temporary file can't be deleted
then the test should not fail for that reason. Log that the file could not
be delete and carry on.


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

Branch: refs/heads/master
Commit: fbb6a6f2e678dcaac66a7ad15de701f856823965
Parents: 9f89562
Author: Paul Campbell <pc...@kemitix.net>
Authored: Mon Nov 5 14:05:18 2018 +0000
Committer: Paul Campbell <pc...@kemitix.net>
Committed: Tue Nov 6 15:15:53 2018 +0000

----------------------------------------------------------------------
 .../org/apache/brooklyn/util/core/osgi/OsgiTestBase.java  | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/fbb6a6f2/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java b/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
index 4bc1e58..31b8065 100644
--- a/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
+++ b/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
@@ -28,6 +28,8 @@ import org.apache.commons.io.FileUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.launch.Framework;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 
@@ -37,6 +39,8 @@ import org.testng.annotations.BeforeMethod;
  */
 public class OsgiTestBase {
 
+    private static final Logger log = LoggerFactory.getLogger(OsgiTestBase.class);
+
     public static final String BROOKLYN_OSGI_TEST_A_0_1_0_PATH = OsgiTestResources.BROOKLYN_OSGI_TEST_A_0_1_0_PATH;
     public static final String BROOKLYN_OSGI_TEST_A_0_1_0_URL = "classpath:"+BROOKLYN_OSGI_TEST_A_0_1_0_PATH;
 
@@ -75,7 +79,11 @@ public class OsgiTestBase {
         Osgis.ungetFramework(framework);
         framework = null;
         if (storageTempDir != null) {
-            FileUtils.deleteDirectory(storageTempDir);
+            try {
+                FileUtils.deleteDirectory(storageTempDir);
+            } catch (IOException e) {
+                log.warn(e.getMessage());
+            }
             storageTempDir = null;
         }
     }


[8/8] brooklyn-server git commit: This closes #1013

Posted by gr...@apache.org.
This closes #1013

* origin/pr/1013:
  [core] Remove unused Logger in OsgiTestBase
  [core] Disable BashCommandsIntegrationTest test on Windows
  [test-support] Add @DisableOnWindows annotation for TestNG tests
  [core] Fix syntax for maven-compiler plugin
  [utils] Extract FileUtil.deleteDirectory() from duplicated code
  [core] embedded framework test survives teardown
  [rt-felix] embedded framework test survives teardown


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

Branch: refs/heads/master
Commit: 61ac3cc4af04e68841794ab1eaa40d763d3f69a5
Parents: da7550d 6dddc5d
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Thu Nov 8 11:27:41 2018 +0000
Committer: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Committed: Thu Nov 8 11:27:41 2018 +0000

----------------------------------------------------------------------
 core/pom.xml                                    |  4 +-
 .../brooklyn/util/core/osgi/OsgiTestBase.java   | 19 +++----
 .../core/ssh/BashCommandsIntegrationTest.java   | 21 ++++++++
 parent/pom.xml                                  |  1 +
 .../apache/brooklyn/test/DisableOnWindows.java  | 40 ++++++++++++++
 .../brooklyn/test/DisableOnWindowsListener.java | 57 ++++++++++++++++++++
 .../services/org.testng.ITestNGListener         |  1 +
 .../brooklyn/test/DisableOnWindowsTest.java     | 41 ++++++++++++++
 .../org/apache/brooklyn/util/io/FileUtil.java   | 17 ++++++
 .../rt/felix/EmbeddedFelixFrameworkTest.java    | 14 ++---
 10 files changed, 192 insertions(+), 23 deletions(-)
----------------------------------------------------------------------



[5/8] brooklyn-server git commit: [core] Fix syntax for maven-compiler plugin

Posted by gr...@apache.org.
[core] Fix syntax for maven-compiler plugin


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

Branch: refs/heads/master
Commit: 18f65e1ebffa6bfc55bc2f706098747296ec429c
Parents: c2af743
Author: Paul Campbell <pc...@kemitix.net>
Authored: Mon Nov 5 22:06:18 2018 +0000
Committer: Paul Campbell <pc...@kemitix.net>
Committed: Tue Nov 6 15:15:58 2018 +0000

----------------------------------------------------------------------
 core/pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/18f65e1e/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index e7e7236..28de44e 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -261,9 +261,9 @@
                         </goals>
                         <configuration>
                             <compilerId>groovy-eclipse-compiler</compilerId>
-                            <includes>
+                            <testIncludes>
                               <include>**/*.groovy</include>
-                            </includes>
+                            </testIncludes>
                             <fork>true</fork>
                             <verbose>false</verbose>
                             <source>${java.version}</source>


[6/8] brooklyn-server git commit: [test-support] Add @DisableOnWindows annotation for TestNG tests

Posted by gr...@apache.org.
[test-support] Add @DisableOnWindows annotation for TestNG tests


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

Branch: refs/heads/master
Commit: c5a851d626cf5069fe06c9dceac174f238892dbb
Parents: 18f65e1
Author: Paul Campbell <pc...@kemitix.net>
Authored: Tue Nov 6 10:15:26 2018 +0000
Committer: Paul Campbell <pc...@kemitix.net>
Committed: Tue Nov 6 15:15:58 2018 +0000

----------------------------------------------------------------------
 parent/pom.xml                                  |  1 +
 .../apache/brooklyn/test/DisableOnWindows.java  | 40 ++++++++++++++
 .../brooklyn/test/DisableOnWindowsListener.java | 57 ++++++++++++++++++++
 .../services/org.testng.ITestNGListener         |  1 +
 .../brooklyn/test/DisableOnWindowsTest.java     | 41 ++++++++++++++
 5 files changed, 140 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c5a851d6/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index d6feccf..971c76e 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1110,6 +1110,7 @@
                   <exclude>**/src/main/license/**</exclude>
                   <exclude>**/src/test/license/**</exclude>
                   <exclude>**/MANIFEST.MF</exclude>
+                  <exclude>**/META-INF/services/**</exclude>
                   <exclude>**/test-output/**</exclude>
                   <exclude>**/*.pem.pub</exclude>
                   <exclude>**/*.pem</exclude>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c5a851d6/test-support/src/main/java/org/apache/brooklyn/test/DisableOnWindows.java
----------------------------------------------------------------------
diff --git a/test-support/src/main/java/org/apache/brooklyn/test/DisableOnWindows.java b/test-support/src/main/java/org/apache/brooklyn/test/DisableOnWindows.java
new file mode 100644
index 0000000..9fa2998
--- /dev/null
+++ b/test-support/src/main/java/org/apache/brooklyn/test/DisableOnWindows.java
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+import java.lang.annotation.*;
+
+/**
+ * Used to indicate that a test should ne be executed on Windows.
+ *
+ * <p>You must add the following to the class where this annotation is being used:
+ * {@code @Listeners(DisableOnWindows)}</p>
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@Documented
+public @interface DisableOnWindows {
+
+    /**3
+     * Explain the reason for the test being disabled.
+     *
+     * <p>e.g. "Needs an ssh server listening on port 22 on localhost."</p>
+     */
+    String reason();
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c5a851d6/test-support/src/main/java/org/apache/brooklyn/test/DisableOnWindowsListener.java
----------------------------------------------------------------------
diff --git a/test-support/src/main/java/org/apache/brooklyn/test/DisableOnWindowsListener.java b/test-support/src/main/java/org/apache/brooklyn/test/DisableOnWindowsListener.java
new file mode 100644
index 0000000..743edde
--- /dev/null
+++ b/test-support/src/main/java/org/apache/brooklyn/test/DisableOnWindowsListener.java
@@ -0,0 +1,57 @@
+/*
+ * 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;
+
+import org.apache.brooklyn.util.os.Os;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.IAnnotationTransformer;
+import org.testng.annotations.ITestAnnotation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/**
+ * Scans all tests annotated with {@link DisableOnWindows} and, on Windows, sets {@code enabled=false} if the current
+ * environment is Windows..
+ */
+public class DisableOnWindowsListener implements IAnnotationTransformer {
+
+    private static final Logger LOG = LoggerFactory.getLogger(DisableOnWindowsListener.class);
+
+    @Override
+    public void transform(
+            final ITestAnnotation annotation,
+            final Class testClass,
+            final Constructor testConstructor,
+            final Method testMethod
+    ) {
+        if (testMethod != null ) {
+            final DisableOnWindows disableOnWindows = testMethod.getAnnotation(DisableOnWindows.class);
+            if (disableOnWindows != null && Os.isMicrosoftWindows()) {
+                annotation.setEnabled(false);
+                LOG.info(String.format("Disabled: %s.%s - %s",
+                        testMethod.getDeclaringClass().getName(),
+                        testMethod.getName(),
+                        disableOnWindows.reason()));
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c5a851d6/test-support/src/main/resources/META-INF/services/org.testng.ITestNGListener
----------------------------------------------------------------------
diff --git a/test-support/src/main/resources/META-INF/services/org.testng.ITestNGListener b/test-support/src/main/resources/META-INF/services/org.testng.ITestNGListener
new file mode 100644
index 0000000..584861a
--- /dev/null
+++ b/test-support/src/main/resources/META-INF/services/org.testng.ITestNGListener
@@ -0,0 +1 @@
+org.apache.brooklyn.test.DisableOnWindowsListener
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c5a851d6/test-support/src/test/java/org/apache/brooklyn/test/DisableOnWindowsTest.java
----------------------------------------------------------------------
diff --git a/test-support/src/test/java/org/apache/brooklyn/test/DisableOnWindowsTest.java b/test-support/src/test/java/org/apache/brooklyn/test/DisableOnWindowsTest.java
new file mode 100644
index 0000000..9929f66
--- /dev/null
+++ b/test-support/src/test/java/org/apache/brooklyn/test/DisableOnWindowsTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import org.apache.brooklyn.util.os.Os;
+import org.testng.annotations.Test;
+
+import static org.apache.brooklyn.test.Asserts.assertTrue;
+import static org.apache.brooklyn.test.Asserts.fail;
+
+public class DisableOnWindowsTest {
+
+    @Test
+    public void alwaysRun() {
+        assertTrue(true);
+    }
+
+    @Test
+    @DisableOnWindows(reason = "unit test")
+    public void isDisabledOnWindows() {
+        if (Os.isMicrosoftWindows()) {
+            fail("Test should have been disabled on windows");
+        }
+    }
+}


[7/8] brooklyn-server git commit: [core] Remove unused Logger in OsgiTestBase

Posted by gr...@apache.org.
[core] Remove unused Logger in OsgiTestBase


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

Branch: refs/heads/master
Commit: 6dddc5d102bcecfeb15f5076fe8e2675c7db76c6
Parents: 2ba7ce6
Author: Paul Campbell <pc...@kemitix.net>
Authored: Tue Nov 6 15:31:58 2018 +0000
Committer: Paul Campbell <pc...@kemitix.net>
Committed: Tue Nov 6 15:31:58 2018 +0000

----------------------------------------------------------------------
 .../test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6dddc5d1/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java b/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
index 4bcadbd..0569ffb 100644
--- a/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
+++ b/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
@@ -38,8 +38,6 @@ import org.testng.annotations.BeforeMethod;
  */
 public class OsgiTestBase {
 
-    private static final Logger log = LoggerFactory.getLogger(OsgiTestBase.class);
-
     public static final String BROOKLYN_OSGI_TEST_A_0_1_0_PATH = OsgiTestResources.BROOKLYN_OSGI_TEST_A_0_1_0_PATH;
     public static final String BROOKLYN_OSGI_TEST_A_0_1_0_URL = "classpath:"+BROOKLYN_OSGI_TEST_A_0_1_0_PATH;
 


[4/8] brooklyn-server git commit: [utils] Extract FileUtil.deleteDirectory() from duplicated code

Posted by gr...@apache.org.
[utils] Extract FileUtil.deleteDirectory() from duplicated code


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

Branch: refs/heads/master
Commit: c2af743b6c7daa392b1301946e9b5632b4a61fc1
Parents: fbb6a6f
Author: Paul Campbell <pc...@kemitix.net>
Authored: Mon Nov 5 22:03:15 2018 +0000
Committer: Paul Campbell <pc...@kemitix.net>
Committed: Tue Nov 6 15:15:58 2018 +0000

----------------------------------------------------------------------
 .../brooklyn/util/core/osgi/OsgiTestBase.java   | 21 ++++++--------------
 .../org/apache/brooklyn/util/io/FileUtil.java   | 17 ++++++++++++++++
 .../rt/felix/EmbeddedFelixFrameworkTest.java    | 18 ++++-------------
 3 files changed, 27 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c2af743b/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java b/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
index 31b8065..4bcadbd 100644
--- a/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
+++ b/core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgiTestBase.java
@@ -16,15 +16,14 @@
 package org.apache.brooklyn.util.core.osgi;
 
 import java.io.File;
-import java.io.IOException;
 
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
 import org.apache.brooklyn.test.support.TestResourceUnavailableException;
 import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.io.FileUtil;
 import org.apache.brooklyn.util.os.Os;
 import org.apache.brooklyn.util.osgi.OsgiTestResources;
-import org.apache.commons.io.FileUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.launch.Framework;
@@ -44,7 +43,7 @@ public class OsgiTestBase {
     public static final String BROOKLYN_OSGI_TEST_A_0_1_0_PATH = OsgiTestResources.BROOKLYN_OSGI_TEST_A_0_1_0_PATH;
     public static final String BROOKLYN_OSGI_TEST_A_0_1_0_URL = "classpath:"+BROOKLYN_OSGI_TEST_A_0_1_0_PATH;
 
-    protected Bundle install(String url) throws BundleException {
+    protected Bundle install(String url) {
         try {
             return Osgis.install(framework, url);
         } catch (Exception e) {
@@ -52,7 +51,7 @@ public class OsgiTestBase {
         }
     }
 
-    protected Bundle installFromClasspath(String resourceName) throws BundleException {
+    protected Bundle installFromClasspath(String resourceName) {
         TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), resourceName);
         try {
             return Osgis.install(framework, String.format("classpath:%s", resourceName));
@@ -71,21 +70,13 @@ public class OsgiTestBase {
     }
 
     @AfterMethod(alwaysRun = true)
-    public void tearDown() throws BundleException, IOException, InterruptedException {
+    public void tearDown() {
         tearDownOsgiFramework(framework, storageTempDir);
     }
 
-    public static void tearDownOsgiFramework(Framework framework, File storageTempDir) throws BundleException, InterruptedException, IOException {
+    public static void tearDownOsgiFramework(Framework framework, File storageTempDir) {
         Osgis.ungetFramework(framework);
-        framework = null;
-        if (storageTempDir != null) {
-            try {
-                FileUtils.deleteDirectory(storageTempDir);
-            } catch (IOException e) {
-                log.warn(e.getMessage());
-            }
-            storageTempDir = null;
-        }
+        FileUtil.deleteDirectory(storageTempDir);
     }
 
     public static void preinstallLibrariesLowLevelToPreventCatalogBomParsing(ManagementContext mgmt, String ...libraries) {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c2af743b/utils/common/src/main/java/org/apache/brooklyn/util/io/FileUtil.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/io/FileUtil.java b/utils/common/src/main/java/org/apache/brooklyn/util/io/FileUtil.java
index a4908f2..176ad82 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/io/FileUtil.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/io/FileUtil.java
@@ -184,4 +184,21 @@ public class FileUtil {
         }
         return file.createNewFile();
     }
+
+    /**
+     * Recursively delete a directory.
+     *
+     * <p>Any IOException that might be raised is logged and not thrown.</p>
+     *
+     * @param file The directory to be deleted
+     */
+    public static void deleteDirectory(final File file) {
+        if (file != null) {
+            try {
+                FileUtils.deleteDirectory(file);
+            } catch (IOException e) {
+                LOG.warn(e.getMessage());
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c2af743b/utils/rt-felix/src/test/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFrameworkTest.java
----------------------------------------------------------------------
diff --git a/utils/rt-felix/src/test/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFrameworkTest.java b/utils/rt-felix/src/test/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFrameworkTest.java
index cde02b1..0c837cd 100644
--- a/utils/rt-felix/src/test/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFrameworkTest.java
+++ b/utils/rt-felix/src/test/java/org/apache/brooklyn/rt/felix/EmbeddedFelixFrameworkTest.java
@@ -16,7 +16,6 @@
 package org.apache.brooklyn.rt.felix;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Enumeration;
@@ -25,11 +24,10 @@ import java.util.jar.JarInputStream;
 
 import org.apache.brooklyn.test.support.TestResourceUnavailableException;
 import org.apache.brooklyn.util.collections.MutableSet;
+import org.apache.brooklyn.util.io.FileUtil;
 import org.apache.brooklyn.util.os.Os;
 import org.apache.brooklyn.util.osgi.OsgiTestResources;
 import org.apache.brooklyn.util.stream.Streams;
-import org.apache.commons.io.FileUtils;
-import org.osgi.framework.BundleException;
 import org.osgi.framework.launch.Framework;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -58,21 +56,13 @@ public class EmbeddedFelixFrameworkTest {
     }
 
     @AfterMethod(alwaysRun = true)
-    public void tearDown() throws BundleException, IOException, InterruptedException {
+    public void tearDown() {
         tearDownOsgiFramework(framework, storageTempDir);
     }
 
-    public static void tearDownOsgiFramework(Framework framework, File storageTempDir) throws BundleException, InterruptedException, IOException {
+    private static void tearDownOsgiFramework(Framework framework, File storageTempDir) {
         EmbeddedFelixFramework.stopFramework(framework);
-        framework = null;
-        if (storageTempDir != null) {
-            try {
-                FileUtils.deleteDirectory(storageTempDir);
-            } catch (IOException e) {
-                log.warn(e.getMessage());
-            }
-            storageTempDir = null;
-        }
+        FileUtil.deleteDirectory(storageTempDir);
     }
 
     @Test