You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2012/03/07 11:42:22 UTC

[2/24] git commit: WICKET-4439

WICKET-4439

Count all packages but the explicitly blacklisted ones.
Add more debug info if there is a clash


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/6498d3ca
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/6498d3ca
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/6498d3ca

Branch: refs/heads/sandbox/wicket4439
Commit: 6498d3ca720e81ad0fb5748f16189758c6eb5478
Parents: 980b760
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Mar 7 12:26:19 2012 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Wed Mar 7 12:28:49 2012 +0200

----------------------------------------------------------------------
 .../wicket/osgi/OsgiClashingPackagesTest.java      |   39 +++++++++++++--
 1 files changed, 35 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/6498d3ca/testing/common-tests/src/test/java/org/apache/wicket/osgi/OsgiClashingPackagesTest.java
----------------------------------------------------------------------
diff --git a/testing/common-tests/src/test/java/org/apache/wicket/osgi/OsgiClashingPackagesTest.java b/testing/common-tests/src/test/java/org/apache/wicket/osgi/OsgiClashingPackagesTest.java
index 5e9cefe..90e5e35 100644
--- a/testing/common-tests/src/test/java/org/apache/wicket/osgi/OsgiClashingPackagesTest.java
+++ b/testing/common-tests/src/test/java/org/apache/wicket/osgi/OsgiClashingPackagesTest.java
@@ -1,6 +1,7 @@
 package org.apache.wicket.osgi;
 
 import java.io.IOException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -63,10 +64,24 @@ public class OsgiClashingPackagesTest extends Assert
 
 	private void fail(Entry<String, List<Project>> entry) {
 		StringBuilder builder = new StringBuilder();
-		builder.append("Package '").append(entry.getKey()).append("' has classes in two or more modules: ");
+		String packageName = entry.getKey();
+		builder.append("Package '").append(packageName).append("' has files in two or more modules: ");
 		for (Project conflict : entry.getValue()) {
 			builder.append(conflict.getName()).append(", ");
 		}
+		try
+		{
+			builder.append("\nResources:\n");
+			Enumeration<URL> resources = getClass().getClassLoader().getResources(packageName);
+			while (resources.hasMoreElements())
+			{
+				URL resource = resources.nextElement();
+				builder.append("\n\t").append(resource.toExternalForm());
+			}
+		} catch (IOException e)
+		{
+			e.printStackTrace();
+		}
 		fail(builder.toString());
 	}
 
@@ -107,10 +122,10 @@ public class OsgiClashingPackagesTest extends Assert
 			while (entries.hasMoreElements())
 			{
 				JarEntry jarEntry = entries.nextElement();
-				String className = jarEntry.getName();
-				if (className.endsWith(".class"))
+				String entryName = jarEntry.getName();
+				if (shouldCollect(entryName))
 				{
-					String packageName = Strings.beforeLast(className, '/');
+					String packageName = Strings.beforeLast(entryName, '/');
 					packagesWithContent.add(packageName);
 				}
 			}
@@ -127,6 +142,22 @@ public class OsgiClashingPackagesTest extends Assert
 					"name='" + name + '\'' +
 					'}';
 		}
+
+		private boolean shouldCollect(final String entryName)
+		{
+			if (
+				// all modules have META-INF {MANIFEST.MF, Maven stuff, ..}
+				entryName.startsWith("META-INF/") ||
+
+				// ignore Wicket's IInitializer conf files
+				(entryName.startsWith("wicket") && entryName.endsWith(".properties"))
+			)
+			{
+				return false;
+			}
+
+			return true;
+		}
 	}
 
 }