You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2008/03/07 22:12:48 UTC
svn commit: r634826 -
/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java
Author: dblevins
Date: Fri Mar 7 13:12:48 2008
New Revision: 634826
URL: http://svn.apache.org/viewvc?rev=634826&view=rev
Log:
Fix redeploy test so it doesn't have a hardcoded version number
Modified:
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java?rev=634826&r1=634825&r2=634826&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java Fri Mar 7 13:12:48 2008
@@ -23,6 +23,8 @@
import org.apache.openejb.test.stateful.AnnotatedFieldInjectionStatefulBean;
import org.apache.openejb.test.stateful.EncStatefulHome;
import org.apache.openejb.test.stateful.EncStatefulObject;
+import org.apache.openejb.test.stateless.BasicStatelessBean;
+import org.apache.openejb.loader.JarLocation;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -42,7 +44,8 @@
public class RedeployTest extends TestCase {
public void test() throws Exception {
// create reference to openejb itests
- File file = getFile("org/apache/openejb/openejb-itests-beans/3.0.0-SNAPSHOT/openejb-itests-beans-3.0.0-SNAPSHOT.jar");
+ File file = JarLocation.jarLocation(BasicStatelessBean.class);
+
if (file == null) return;
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
@@ -102,41 +105,4 @@
// this also should happen
}
}
- /**
- * This method tries to find a file in the default maven repository i.e. user.home/.m2/repository. If it cannot find the repository in this location
- * then it tries to find user.home/settings.xml and obtains the value of the <localRepository> element from the settings.xml file. Once the local
- * repository is obtained from the settings.xml file, it tries to search for the file in this repository and returns it. If it cannot find the
- * specified file here also, then it returns null
- * @param fileName -- the name of the file to be searched
- * @return -- java.io.File
- */
- private static File getFile(String fileName) {
- String userHome = System.getProperty("user.home");
- File file = new File(userHome + "/.m2/repository/" + fileName);
- if (!file.canRead()) {
- File f = new File(userHome + "/.m2/settings.xml");
- if (f.canRead()) {
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- try {
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document document = builder.parse(f);
- NodeList localRepository = document
- .getElementsByTagName("localRepository");
- Node node = localRepository.item(0);
- file = new File(node.getFirstChild().getNodeValue() + "/"
- + fileName);
- if (file.canRead())
- return file;
- else
- return null;
- } catch (Exception e) {
- return null;
- }
- }
- } else {
- return file;
- }
- return null;
- }
}