You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by sb...@apache.org on 2012/07/24 03:32:29 UTC
[10/20] fix compiler errors, checkstyle violations
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/6acddac9/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 2b44343..edfd8eb 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
@@ -145,43 +145,54 @@ public class ShrinkWrapArchiveUtil
JavaArchive ret = null;
JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class);
- if (includeIfPackageExists == null) {
+ if (includeIfPackageExists == null)
+ {
// no include rule, thus add it immediately
ret = javaArchive;
}
JarInputStream jar = new JarInputStream(inputStream);
- try {
- for (ZipEntry jarEntry = jar.getNextEntry(); jarEntry != null; jarEntry = jar.getNextEntry()) {
+ try
+ {
+ for (ZipEntry jarEntry = jar.getNextEntry(); jarEntry != null; jarEntry = jar.getNextEntry())
+ {
String entryName = jarEntry.getName();
- if (jarEntry.isDirectory()) {
+ if (jarEntry.isDirectory())
+ {
// exclude rule
- if (excludeIfPackageExists(entryName, excludeIfPackageExists)) {
+ if (excludeIfPackageExists(entryName, excludeIfPackageExists))
+ {
return null;
}
- if (ret == null && includeIfPackageExists(entryName, includeIfPackageExists)) {
+ if (ret == null && includeIfPackageExists(entryName, includeIfPackageExists))
+ {
ret = javaArchive;
}
continue;
}
- if (entryName.endsWith(".class")) {
+ if (entryName.endsWith(".class"))
+ {
String className = pathToClassName(entryName.substring(0, entryName.length()-(".class".length())));
javaArchive.addClass(className);
}
- else {
+ else
+ {
javaArchive.addAsResource(entryName);
}
}
}
- finally {
- try {
+ finally
+ {
+ try
+ {
jar.close();
}
- catch (IOException ignored) {
+ catch (IOException ignored)
+ {
// all fine
}
}
@@ -192,40 +203,48 @@ public class ShrinkWrapArchiveUtil
private static JavaArchive addFileArchive(File archiveBasePath,
String[] includeIfPackageExists,
String[] excludeIfPackageExists)
- throws IOException {
- if (!archiveBasePath.exists()) {
+ throws IOException
+ {
+ if (!archiveBasePath.exists())
+ {
return null;
}
JavaArchive ret = null;
JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class);
- if (includeIfPackageExists == null) {
+ if (includeIfPackageExists == null)
+ {
// no include rule, thus add it immediately
ret = javaArchive;
}
int basePathLength = archiveBasePath.getAbsolutePath().length() + 1;
- for (File archiveEntry : collectArchiveEntries(archiveBasePath) ) {
+ for (File archiveEntry : collectArchiveEntries(archiveBasePath) )
+ {
String entryName = archiveEntry.getAbsolutePath().substring(basePathLength);
// exclude rule
- if (excludeIfPackageExists(entryName, excludeIfPackageExists)) {
+ if (excludeIfPackageExists(entryName, excludeIfPackageExists))
+ {
continue;
}
// include rule
- if (ret == null && includeIfPackageExists(entryName, includeIfPackageExists)) {
+ if (ret == null && includeIfPackageExists(entryName, includeIfPackageExists))
+ {
ret = javaArchive;
}
- if (entryName.endsWith(".class")) {
+ if (entryName.endsWith(".class"))
+ {
String className = pathToClassName(entryName.substring(0, entryName.length()-(".class".length())));
javaArchive.addClass(className);
}
- else {
+ else
+ {
javaArchive.addAsResource(entryName.replace('\\', '/'));
}
}
@@ -235,15 +254,19 @@ public class ShrinkWrapArchiveUtil
private static List<File> collectArchiveEntries(File archiveBasePath)
{
- if (archiveBasePath.isDirectory()) {
+ if (archiveBasePath.isDirectory())
+ {
List<File> archiveEntries = new ArrayList<File>();
File[] files = archiveBasePath.listFiles();
- for (File file : files) {
- if (file.isDirectory()) {
+ for (File file : files)
+ {
+ if (file.isDirectory())
+ {
archiveEntries.addAll(collectArchiveEntries(file));
}
- else {
+ else
+ {
archiveEntries.add(file);
}
}
@@ -255,12 +278,16 @@ public class ShrinkWrapArchiveUtil
}
- private static boolean excludeIfPackageExists(String jarEntryName, String[] excludeOnPackages) {
- if (excludeOnPackages != null) {
+ private static boolean excludeIfPackageExists(String jarEntryName, String[] excludeOnPackages)
+ {
+ if (excludeOnPackages != null)
+ {
String packageName = pathToClassName(jarEntryName);
- for (String excludeOnPackage : excludeOnPackages) {
- if (packageName.startsWith(excludeOnPackage)) {
+ for (String excludeOnPackage : excludeOnPackages)
+ {
+ if (packageName.startsWith(excludeOnPackage))
+ {
return true;
}
}
@@ -269,15 +296,19 @@ public class ShrinkWrapArchiveUtil
return false;
}
- private static boolean includeIfPackageExists(String jarEntryName, String[] includeOnPackages) {
- if (includeOnPackages == null ) {
+ private static boolean includeIfPackageExists(String jarEntryName, String[] includeOnPackages)
+ {
+ if (includeOnPackages == null )
+ {
return true;
}
String packageName = pathToClassName(jarEntryName);
- for (String includeOnPackage : includeOnPackages) {
- if (packageName.startsWith(includeOnPackage)) {
+ for (String includeOnPackage : includeOnPackages)
+ {
+ if (packageName.startsWith(includeOnPackage))
+ {
return true;
}
}
@@ -289,10 +320,12 @@ public class ShrinkWrapArchiveUtil
* check if the given url path is a Jar
* @param urlPath to check
*/
- private static String isJarUrl(String urlPath) {
+ private static String isJarUrl(String urlPath)
+ {
// common prefixes of the url are: jar: (tomcat), zip: (weblogic) and wsjar: (websphere)
final int jarColon = urlPath.indexOf(':');
- if (urlPath.endsWith("!/") && jarColon > 0) {
+ if (urlPath.endsWith("!/") && jarColon > 0)
+ {
urlPath = urlPath.substring(jarColon + 1, urlPath.length() - 2);
return urlPath;
}
@@ -300,15 +333,18 @@ public class ShrinkWrapArchiveUtil
return null;
}
- private static String ensureCorrectUrlFormat(String url) {
+ private static String ensureCorrectUrlFormat(String url)
+ {
//fix for wls
- if(!url.startsWith("file:/")) {
+ if(!url.startsWith("file:/"))
+ {
url = "file:/" + url;
}
return url;
}
- private static String pathToClassName(String pathName) {
+ private static String pathToClassName(String pathName)
+ {
return pathName.replace('/', '.').replace('\\', '.'); // replace unix and windows separators
}