You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by li...@apache.org on 2012/04/11 20:02:33 UTC

git commit: Fixing up the SW archives a bit to use the actual jar on the CP

Updated Branches:
  refs/heads/master 2820780c5 -> e39cf97e7


Fixing up the SW archives a bit to use the actual jar on the CP


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

Branch: refs/heads/master
Commit: e39cf97e789b9afd134f529945f8336850537620
Parents: 2820780
Author: Jason Porter <li...@apache.org>
Authored: Wed Apr 11 12:02:01 2012 -0600
Committer: Jason Porter <li...@apache.org>
Committed: Wed Apr 11 12:02:01 2012 -0600

----------------------------------------------------------------------
 .../api/temptestutil/ShrinkWrapArchiveUtil.java    |   25 +++++++++++++-
 .../test/util/ShrinkWrapArchiveUtil.java           |   25 +++++++++++++-
 2 files changed, 46 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e39cf97e/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/temptestutil/ShrinkWrapArchiveUtil.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/temptestutil/ShrinkWrapArchiveUtil.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/temptestutil/ShrinkWrapArchiveUtil.java
index fcab80b..a0f115e 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/temptestutil/ShrinkWrapArchiveUtil.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/temptestutil/ShrinkWrapArchiveUtil.java
@@ -25,6 +25,7 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -97,8 +98,28 @@ public class ShrinkWrapArchiveUtil
         String jarUrlPath = isJarUrl(urlString);
         if (jarUrlPath != null)
         {
-            return addJarArchive((new URL(ensureCorrectUrlFormat(jarUrlPath))).openStream(),
-                    includeIfPackageExists, excludeIfPackageExists);
+            final JavaArchive foundJar = ShrinkWrap.createFromZipFile(JavaArchive.class, new File(URI.create(jarUrlPath)));
+
+            if (excludeIfPackageExists != null)
+            {
+                for (String excludePackage : excludeIfPackageExists)
+                {
+                    if (foundJar.contains(excludePackage.replaceAll("\\.", "\\/"))) {
+                        return null;
+                    }
+                }
+            }
+            if (includeIfPackageExists != null)
+            {
+                for (String includePackage : includeIfPackageExists)
+                {
+                    if (foundJar.contains(includePackage.replaceAll("\\.", "\\/")))
+                    {
+                        return foundJar;
+                    }
+                }
+            }
+            return null; // couldn't find any jar
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e39cf97e/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java
index 96b3677..a9424f6 100644
--- a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java
@@ -24,6 +24,7 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -95,8 +96,28 @@ public class ShrinkWrapArchiveUtil
         String jarUrlPath = isJarUrl(urlString);
         if (jarUrlPath != null)
         {
-            return addJarArchive((new URL(ensureCorrectUrlFormat(jarUrlPath))).openStream(),
-                    includeIfPackageExists, excludeIfPackageExists);
+            final JavaArchive foundJar = ShrinkWrap.createFromZipFile(JavaArchive.class, new File(URI.create(jarUrlPath)));
+
+            if (excludeIfPackageExists != null)
+            {
+                for (String excludePackage : excludeIfPackageExists)
+                {
+                    if (foundJar.contains(excludePackage.replaceAll("\\.", "\\/"))) {
+                        return null;
+                    }
+                }
+            }
+            if (includeIfPackageExists != null)
+            {
+                for (String includePackage : includeIfPackageExists)
+                {
+                    if (foundJar.contains(includePackage.replaceAll("\\.", "\\/")))
+                    {
+                        return foundJar;
+                    }
+                }
+            }
+            return null; // couldn't find any jar
         }
         else
         {