Author: rmannibucau Date: Sat Aug 23 17:08:59 2014 New Revision: 1620053 URL: http://svn.apache.org/r1620053 Log: supporting raw file path in provisioning util and fixing few tests relying on environment
Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/config/AutoConfigPersistenceUnitsTest.java tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/config/ServiceClasspathTest.java tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=1620053&r1=1620052&r2=1620053&view=diff ============================================================================== --- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java (original) +++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Sat Aug 23 17:08:59 2014 @@ -1258,7 +1258,7 @@ public class ConfigurationFactory implem for (int i = 0; i < strings.length; i++) { final String string = strings[i]; - final String pathname = PropertyPlaceHolderHelper.simpleValue(ProvisioningUtil.realLocation(string)); + final String pathname = ProvisioningUtil.realLocation(PropertyPlaceHolderHelper.simpleValue(string)); final File file = base.getFile(pathname, false); classpath[i] = file.toURI(); } Modified: tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/config/AutoConfigPersistenceUnitsTest.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/config/AutoConfigPersistenceUnitsTest.java?rev=1620053&r1=1620052&r2=1620053&view=diff ============================================================================== --- tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/config/AutoConfigPersistenceUnitsTest.java (original) +++ tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/config/AutoConfigPersistenceUnitsTest.java Sat Aug 23 17:08:59 2014 @@ -37,6 +37,7 @@ import org.apache.openejb.monitoring.Loc import org.apache.openejb.util.Join; import javax.naming.NamingException; +import java.io.File; import java.io.IOException; import java.sql.Connection; import java.sql.DriverPropertyInfo; @@ -238,7 +239,9 @@ public class AutoConfigPersistenceUnitsT public void testFromUnitNameJtaWithClasspath() throws Exception { final Resource resource = new Resource("orange-unit", "DataSource"); - resource.setClasspath("foo/bar.jar"); + final File file = new File("target/" + getClass().getName()); + file.mkdirs(); + resource.setClasspath(file.getPath()); final ResourceInfo supplied = addDataSource(OrangeDriver.class, "jdbc:orange:some:stuff", true, resource); assertSame(supplied, resources.get(0)); Modified: tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/config/ServiceClasspathTest.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/config/ServiceClasspathTest.java?rev=1620053&r1=1620052&r2=1620053&view=diff ============================================================================== --- tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/config/ServiceClasspathTest.java (original) +++ tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/config/ServiceClasspathTest.java Sat Aug 23 17:08:59 2014 @@ -25,6 +25,7 @@ import org.apache.openejb.config.sys.Res import org.apache.openejb.core.ivm.naming.InitContextFactory; import org.apache.openejb.loader.Files; import org.apache.openejb.loader.IO; +import org.apache.openejb.loader.ProvisioningUtil; import org.apache.openejb.loader.SystemInstance; import org.apache.openejb.util.Join; import org.apache.openejb.util.PropertyPlaceHolderHelper; @@ -69,7 +70,6 @@ public class ServiceClasspathTest extend PropertyPlaceHolderHelper.reset(); } - @Test public void test() throws Exception { @@ -90,6 +90,8 @@ public class ServiceClasspathTest extend resource.getProperties().put("blue", "00"); resource.setClasspath(jar.getAbsolutePath()); + createEnvrt(); + final ConfigurationFactory config = new ConfigurationFactory(); final Assembler assembler = new Assembler(); assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class)); @@ -108,6 +110,10 @@ public class ServiceClasspathTest extend assertEquals("Orange.00", color.getBlue()); } + private void createEnvrt() { + new File(SystemInstance.get().getBase().getDirectory(), ProvisioningUtil.cache()).mkdirs(); + } + @Test public void testXml() throws Exception { @@ -134,6 +140,8 @@ public class ServiceClasspathTest extend final ConfigurationFactory config = new ConfigurationFactory(); final Assembler assembler = new Assembler(); + createEnvrt(); + assembler.buildContainerSystem(config.getOpenEjbConfiguration(xml)); final InitialContext initialContext = new InitialContext(); @@ -165,6 +173,7 @@ public class ServiceClasspathTest extend " </Resource>\n" + "</openejb>"); out.close(); + new File(jar.getParentFile(), "temp").mkdirs(); System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName()); @@ -173,6 +182,7 @@ public class ServiceClasspathTest extend properties.setProperty("openejb.home", jar.getParentFile().getAbsolutePath()); SystemInstance.init(properties); PropertyPlaceHolderHelper.reset(); + createEnvrt(); final ConfigurationFactory config = new ConfigurationFactory(); final Assembler assembler = new Assembler(); @@ -220,6 +230,7 @@ public class ServiceClasspathTest extend final ConfigurationFactory config = new ConfigurationFactory(); final Assembler assembler = new Assembler(); + createEnvrt(); assembler.buildContainerSystem(config.getOpenEjbConfiguration(json)); final InitialContext initialContext = new InitialContext(); Modified: tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java?rev=1620053&r1=1620052&r2=1620053&view=diff ============================================================================== --- tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java (original) +++ tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java Sat Aug 23 17:08:59 2014 @@ -152,7 +152,12 @@ public final class ProvisioningUtil { } else { // try url try { final File file = cacheFile(lastPart(rawLocation)); - final URL url = new URL(rawLocation); + final File local = new File(rawLocation); + if (local.isDirectory()) { + return local.getAbsolutePath(); + } + + final URL url = local.isFile() ? local.toURI().toURL() : new URL(rawLocation); InputStream is = null; try { is = new BufferedInputStream(url.openStream());