brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [03/11] incubator-brooklyn git commit: ResourceUtils.getResources
Date Mon, 15 Jun 2015 07:46:03 GMT
ResourceUtils.getResources


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

Branch: refs/heads/master
Commit: 8ff666e4a597058c85dbbb08d871c38e6de3fb6d
Parents: b515f38
Author: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Authored: Tue May 26 22:09:25 2015 +0100
Committer: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Committed: Tue Jun 2 17:52:53 2015 +0100

----------------------------------------------------------------------
 core/src/main/java/brooklyn/util/ResourceUtils.java     | 7 +++++++
 core/src/test/java/brooklyn/util/ResourceUtilsTest.java | 9 +++++++++
 2 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8ff666e4/core/src/main/java/brooklyn/util/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/ResourceUtils.java b/core/src/main/java/brooklyn/util/ResourceUtils.java
index b1005bf..0195b9c 100644
--- a/core/src/main/java/brooklyn/util/ResourceUtils.java
+++ b/core/src/main/java/brooklyn/util/ResourceUtils.java
@@ -197,6 +197,13 @@ public class ResourceUtils {
     private BrooklynClassLoadingContext getLoader() {
         return (loader!=null ? loader : getClassLoadingContextInternal(null, contextObject!=null
? contextObject : this));
     }
+
+    /**
+     * @return all resources in Brooklyn's {@link BrooklynClassLoadingContext} with the given
name.
+     */
+    public Iterable<URL> getResources(String name) {
+        return getLoader().getResources(name);
+    }
     
     /**
      * Takes a string which is treated as a URL (with some extended "schemes" also expected),

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8ff666e4/core/src/test/java/brooklyn/util/ResourceUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/util/ResourceUtilsTest.java b/core/src/test/java/brooklyn/util/ResourceUtilsTest.java
index a588513..de54ebb 100644
--- a/core/src/test/java/brooklyn/util/ResourceUtilsTest.java
+++ b/core/src/test/java/brooklyn/util/ResourceUtilsTest.java
@@ -19,6 +19,7 @@
 package brooklyn.util;
 
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertTrue;
 
@@ -26,6 +27,7 @@ import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
+import java.net.URL;
 import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Properties;
@@ -43,6 +45,7 @@ import brooklyn.util.text.Identifiers;
 
 import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
 import com.google.common.io.Files;
 
 public class ResourceUtilsTest {
@@ -177,4 +180,10 @@ public class ResourceUtilsTest {
         assertEquals(utils.getResourceAsString(Urls.asDataUrlBase64(longString)), longString);
     }
 
+    @Test
+    public void testGetResources() {
+        Iterable<URL> manifests = ResourceUtils.create().getResources("META-INF/MANIFEST.MF");
+        assertFalse(Iterables.isEmpty(manifests));
+    }
+
 }


Mime
View raw message