HHH-4666 - Implement the clarified rules for resource discovery (esp for <mapping-file> and co)
Refactored packaged tests while investigating this issue. Made sure packages get created in a subdirectory of target git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18918 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
b763122d4c
commit
6dce44c363
|
@ -4,7 +4,7 @@
|
|||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
|
||||
version="2.0">
|
||||
<persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL">
|
||||
<jar-file>${basedir}/target/externaljar.jar</jar-file>
|
||||
<jar-file>${basedir}/target/packages/externaljar.jar</jar-file>
|
||||
<class>org.hibernate.ejb.test.Cat</class>
|
||||
<class>org.hibernate.ejb.test.Kitten</class>
|
||||
<class>org.hibernate.ejb.test.Distributor</class>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// $Id:$
|
||||
// $Id$
|
||||
/*
|
||||
* JBoss, Home of Professional Open Source
|
||||
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
|
||||
|
@ -22,6 +22,7 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -89,6 +90,8 @@ public abstract class PackagingTestCase extends TestCase {
|
|||
catch ( MalformedURLException e ) {
|
||||
fail( "Unable to build custom class loader" );
|
||||
}
|
||||
targetDir = new File( targetDir, "packages" );
|
||||
targetDir.mkdirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -105,9 +108,9 @@ public abstract class PackagingTestCase extends TestCase {
|
|||
Thread.currentThread().setContextClassLoader( originalClassLoader );
|
||||
}
|
||||
|
||||
protected void addPackageToClasspath(File... testPackages) throws MalformedURLException {
|
||||
protected void addPackageToClasspath(File... files) throws MalformedURLException {
|
||||
List<URL> urlList = new ArrayList<URL>();
|
||||
for ( File file : testPackages ) {
|
||||
for ( File file : files ) {
|
||||
urlList.add( file.toURL() );
|
||||
}
|
||||
URLClassLoader classLoader = new URLClassLoader(
|
||||
|
@ -116,6 +119,15 @@ public abstract class PackagingTestCase extends TestCase {
|
|||
Thread.currentThread().setContextClassLoader( classLoader );
|
||||
}
|
||||
|
||||
protected void addPackageToClasspath(URL... urls) throws MalformedURLException {
|
||||
List<URL> urlList = new ArrayList<URL>();
|
||||
urlList.addAll( Arrays.asList( urls ) );
|
||||
URLClassLoader classLoader = new URLClassLoader(
|
||||
urlList.toArray( new URL[urlList.size()] ), originalClassLoader
|
||||
);
|
||||
Thread.currentThread().setContextClassLoader( classLoader );
|
||||
}
|
||||
|
||||
protected File buildDefaultPar() {
|
||||
String fileName = "defaultpar.par";
|
||||
JavaArchive archive = Archives.create( fileName, JavaArchive.class );
|
||||
|
|
Loading…
Reference in New Issue