Author: veithen Date: Sun Aug 29 19:26:37 2010 New Revision: 990637 URL: http://svn.apache.org/viewvc?rev=990637&view=rev Log: Use a parent last class loader in the new dialect tests to make sure that we use the right parser. This also allows to execute the tests in Eclipse, where the classpath is different.
Added: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/ParentLastURLClassLoader.java (with props) Modified: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuite.java Modified: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuite.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuite.java?rev=990637&r1=990636&r2=990637&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuite.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuite.java Sun Aug 29 19:26:37 2010 @@ -22,7 +22,6 @@ import java.io.File; import java.io.FilenameFilter; import java.io.InputStream; import java.net.URL; -import java.net.URLClassLoader; import java.util.Properties; import junit.framework.Test; @@ -88,7 +87,8 @@ public class DialectTestSuite extends Te } } - ClassLoader parserClassLoader = new URLClassLoader(new URL[] { parserJar.toURL() }, DialectTestSuite.class.getClassLoader()); + ClassLoader parserClassLoader = new ParentLastURLClassLoader( + new URL[] { parserJar.toURL() }, DialectTestSuite.class.getClassLoader()); addTest(new DialectTest(parserClassLoader, parserJar.getName(), props)); } } Added: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/ParentLastURLClassLoader.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/ParentLastURLClassLoader.java?rev=990637&view=auto ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/ParentLastURLClassLoader.java (added) +++ webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/ParentLastURLClassLoader.java Sun Aug 29 19:26:37 2010 @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.axiom.util.stax.dialect; + +import java.net.URL; +import java.net.URLClassLoader; + +public class ParentLastURLClassLoader extends URLClassLoader { + public ParentLastURLClassLoader(URL[] urls, ClassLoader parent) { + super(urls, parent); + } + + public URL getResource(String name) { + URL url = findResource(name); + if (url == null) { + url = getParent().getResource(name); + } + return url; + } + + protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { + Class c = findLoadedClass(name); + if (c == null) { + try { + c = findClass(name); + } catch (ClassNotFoundException e) { + c = getParent().loadClass(name); + } + } + if (resolve) { + resolveClass(c); + } + return c; + } +} Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/ParentLastURLClassLoader.java ------------------------------------------------------------------------------ svn:eol-style = native