Skip to content

Commit

Permalink
tests: add a test for ClassFileUtilities
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosame committed May 10, 2024
1 parent 451d77f commit 460ae3c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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<String, Jar> jars = new HashMap<>();
Map<String, ClassFile> classFiles = new HashMap<>();
ClassFileUtilities.collectJars(f, jars, classFiles);

assertEquals(jarCount, jars.size());
assertEquals(classCount, classFiles.size());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public int compareTo(Triple o) {
}
}

private static void collectJars(File dir, Map<String, Jar> jars, Map<String, ClassFile> classFiles)
static void collectJars(File dir, Map<String, Jar> jars, Map<String, ClassFile> classFiles)
throws IOException, SecurityException {
File[] files = dir.listFiles();
if (files != null) {
Expand Down

0 comments on commit 460ae3c

Please sign in to comment.