diff --git a/echosvg-test/src/test/java/io/sf/carte/echosvg/util/ClassFileUtilitiesTest.java b/echosvg-test/src/test/java/io/sf/carte/echosvg/util/ClassFileUtilitiesTest.java new file mode 100644 index 000000000..df5efb579 --- /dev/null +++ b/echosvg-test/src/test/java/io/sf/carte/echosvg/util/ClassFileUtilitiesTest.java @@ -0,0 +1,59 @@ +/* + + See the NOTICE file distributed with this work for additional + information regarding copyright ownership. + + 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 io.sf.carte.echosvg.util; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import io.sf.carte.echosvg.test.TestLocations; +import io.sf.carte.echosvg.util.ClassFileUtilities.ClassFile; +import io.sf.carte.echosvg.util.ClassFileUtilities.Jar; + +/** + * This test validates that the ClassFileUtilities work properly. + * + * @version $Id$ + */ +public class ClassFileUtilitiesTest { + + @Test + public void testCollectJars() throws Exception { + URL url = new URL(TestLocations.PROJECT_ROOT_URL); + collectJarsTest(url.getFile() + "test-resources/io/sf/carte/echosvg/bridge", 4, 6); + } + + private void collectJarsTest(String dir, int jarCount, int classCount) + throws SecurityException, IOException { + File f = new File(dir); + Map jars = new HashMap<>(); + Map classFiles = new HashMap<>(); + ClassFileUtilities.collectJars(f, jars, classFiles); + + assertEquals(jarCount, jars.size()); + assertEquals(classCount, classFiles.size()); + } + +} diff --git a/echosvg-util/src/main/java/io/sf/carte/echosvg/util/ClassFileUtilities.java b/echosvg-util/src/main/java/io/sf/carte/echosvg/util/ClassFileUtilities.java index 05e83a198..3249a9fda 100644 --- a/echosvg-util/src/main/java/io/sf/carte/echosvg/util/ClassFileUtilities.java +++ b/echosvg-util/src/main/java/io/sf/carte/echosvg/util/ClassFileUtilities.java @@ -215,7 +215,7 @@ public int compareTo(Triple o) { } } - private static void collectJars(File dir, Map jars, Map classFiles) + static void collectJars(File dir, Map jars, Map classFiles) throws IOException, SecurityException { File[] files = dir.listFiles(); if (files != null) {