From 282188781fc2c342ad12bd4173aee139befa0da1 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 8 Aug 2006 11:35:44 +0000 Subject: [PATCH] inactive test case for Classloader repository sharing --- .../bcel/ClassLoaderRepositoryTests.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 weaver/testsrc/org/aspectj/weaver/bcel/ClassLoaderRepositoryTests.java diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/ClassLoaderRepositoryTests.java b/weaver/testsrc/org/aspectj/weaver/bcel/ClassLoaderRepositoryTests.java new file mode 100644 index 000000000..c60f43d57 --- /dev/null +++ b/weaver/testsrc/org/aspectj/weaver/bcel/ClassLoaderRepositoryTests.java @@ -0,0 +1,69 @@ +/* ******************************************************************* + * Copyright (c) 2006 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement initial implementation + * ******************************************************************/ + + +package org.aspectj.weaver.bcel; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Enumeration; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import junit.framework.TestCase; + +import org.aspectj.apache.bcel.util.ClassLoaderRepository; + +/** NOT YET INCLUDED IN A FULL TEST RUN - WORK IN PROGRESS CHECKING CLASSLOADERREPOSITORY OPTIMIZATIONS */ +public class ClassLoaderRepositoryTests extends TestCase { + + public void testRepositorySharing() throws Exception { + ClassLoaderRepository.useSharedCache=false; + File f = new File("../lib/aspectj/lib/aspectjtools.jar"); + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + ClassLoader cl1 = new URLClassLoader(new URL[]{f.toURL()},cl); + ClassLoader cl2 = new URLClassLoader(new URL[]{f.toURL()},cl); + ClassLoaderRepository rep1 = new ClassLoaderRepository(cl1); + ClassLoaderRepository rep2 = new ClassLoaderRepository(cl2); + try { + assertTrue("Couldnt find aspectjtools to test. Tried: "+f.getAbsolutePath(),f.exists()); + ZipFile zf = new ZipFile(f); + int i = 0; + Enumeration entries = zf.entries(); + while (entries.hasMoreElements()) { + ZipEntry zfe = (ZipEntry)entries.nextElement(); + String classfileName = zfe.getName(); + if (classfileName.endsWith(".class")) { + String clazzname = classfileName.substring(0,classfileName.length()-6).replace('/','.'); + + // twice by each + rep1.loadClass(clazzname); + rep1.loadClass(clazzname); + rep2.loadClass(clazzname); + rep2.loadClass(clazzname); + i++; + } + } + System.err.println("Successfully compared "+i+" entries!!"); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + System.err.println(rep1.reportAllStatistics()); + System.err.println(rep2.reportAllStatistics()); + } + + + +} -- 2.39.5