Property changes on: . ___________________________________________________________________ Modified: svn:ignore - target eclipse-target target-eclipse bin .settings .classpath .project + target eclipse-target target-eclipse bin .settings .classpath .project *.ipr shrinkwrap-parent.iml Index: impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/URLPackageScannerTestCase.java =================================================================== --- impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/URLPackageScannerTestCase.java (revision 0) +++ impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/URLPackageScannerTestCase.java (revision 0) @@ -0,0 +1,38 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * Licensed 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.jboss.shrinkwrap.impl.base; + +import org.junit.Test; + +/** + * URLPackageScannerTestCase for SHRINKWRAP-90. + * + * Asserts parameter validation for more user friendly errors on invalid + * parameters. + * + * @author Jason Porter + * @version $Revision$ + */ +public class URLPackageScannerTestCase +{ + @Test(expected = IllegalArgumentException.class) + public void shouldThrowExceptionNullPackage() + { + URLPackageScanner.newInstance((Package)null, true, + URLPackageScannerTestCase.class.getClassLoader()); + } +} Property changes on: impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/URLPackageScannerTestCase.java ___________________________________________________________________ Added: svn:mime-type + text/x-java-source Added: svn:keywords + Author Date Id Revision URL Added: svn:eol-style + native Index: impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java =================================================================== --- impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java (revision 3934) +++ impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java (working copy) @@ -744,7 +744,7 @@ for(Package pack : packages) { - URLPackageScanner scanner = new URLPackageScanner( + URLPackageScanner scanner = URLPackageScanner.newInstance( pack, recursive, SecurityActions.getThreadContextClassLoader()); Set> classes = scanner.getClasses(); for(Class clazz : classes) Index: impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/URLPackageScanner.java =================================================================== --- impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/URLPackageScanner.java (revision 3934) +++ impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/URLPackageScanner.java (working copy) @@ -56,18 +56,26 @@ private final Set> classes = new HashSet>(); - public URLPackageScanner(Package pkg, boolean addRecursively, ClassLoader classLoader) + /** + * Factory method to create an instance of URLPackageScanner. + * @param pkg Package that will be scanned + * @param addRecursively flag to add child packages + * @param classLoader class loader that will have classes added + * @return new instance of URLPackageScanner + */ + public static URLPackageScanner newInstance(Package pkg, boolean addRecursively, ClassLoader classLoader) { - this(pkg.getName(), addRecursively, classLoader); + Validate.notNull(pkg, "Pkg must be specified"); + Validate.notNull(pkg.getName(), "Pkg must have a name"); + Validate.notNull(addRecursively, "AddRecursively must be specified"); + Validate.notNull(classLoader, "ClassLoader must be specified"); + + return new URLPackageScanner(pkg, addRecursively, classLoader); } - public URLPackageScanner(String packageName, boolean addRecursively, ClassLoader classLoader) + private URLPackageScanner(Package pkg, boolean addRecursively, ClassLoader classLoader) { - Validate.notNull(packageName, "PackageName must be specified"); - Validate.notNull(addRecursively, "AddRecursively must be specified"); - Validate.notNull(classLoader, "ClassLoader must be specified"); - - this.packageName = packageName; + this.packageName = pkg.getName(); this.packageNamePath = packageName.replace(".", "/"); this.addRecursively = addRecursively; this.classLoader = classLoader; @@ -172,4 +180,4 @@ scanPackage(); return classes; } -} \ No newline at end of file +}