Yes, that client was just because from within an Maven execution the
classpath would give me the -client.jar first, but I needed the jar
without client.
Stefan
Alexander Klimetschek wrote:
Thanks Stefan, nice hack ;-) I didn't know that you can get the Jar file
via the class resource URL, but it makes sense.
FYI, I made a useful method out of this (I removed the special
-client.jar replacement):
/**
* Returns the path to the JAR file that a certain class is located in.
This only works
* if the classloader loaded this class from a JAR file.
*/
public static final String getJarFileForClass(Class clazz) {
// eg. /org/apache/derby/drda/NetworkServerControl.class
String classResource = "/" + clazz.getCanonicalName().replace(".",
"/") + ".class";
// eg.
jar:file:/Users/alex/.m2/repository/org/apache/derby/derbynet/10.2.1.6/derbynet-10.2.1.6.jar!/org/apache/derby/drda/NetworkServerControl.class
String fullResourceURL = clazz.getResource(classResource).toString();
// eg.
/Users/alex/.m2/repository/org/apache/derby/derbynet/10.2.1.6/derbynet-10.2.1.6.jar
return fullResourceURL.replaceFirst("jar:file:([^!]+).*", "$1");
}
Regards,
Alex
Am 26.02.2008 um 12:11 schrieb VUB Stefan Seidel:
I am looking for a solution to that too. My workaround was until now
to pick specific classes whose JAR files I needed and do
_class.getResource("/" + _class.getCanonicalName().replace(".", "/") +
".class").toString().replaceAll("-client.jar!",
".jar!").replaceFirst("jar:file:([^!]+).*", "$1")
and append this to java.class.path. Kindofa hack though ...
Stefan
Alexander Klimetschek wrote:
I forgot to mention that the unit test runs perfect in Eclipse,
because the project created by "mvn eclipse:eclipse" includes all
test dependencies as well and the Eclipse jUnit runner puts all of
them in the class path for the test. Would be cool to have the
Eclipse project and mvn test behave the same without two different
configurations.
Alex
Am 25.02.2008 um 20:58 schrieb Alexander Klimetschek:
Hi all,
I have a test case which starts another JVM (a derby database server
in network mode). The classpath for the new JVM needs jar files
which are defined as test dependencies (derby is available in the
form of maven artifacts, and I want to test it against the same
derby version against which the actual code is written). The problem
is that due to the surefire boot mechanism, it's not sufficient to
read the classpath of the JVM in which test is running via
System.getProperty("java.class.path").
How can I get access to the classpath of surefire?
Or is there another way to retrieve the path of the jar files
defined in the pom from my junit test class?
Regards,
Alex
--
Alexander Klimetschek
[EMAIL PROTECTED]
--
Alexander Klimetschek
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
best regards,
Stefan Seidel
software developer
________________________
VUB Printmedia GmbH
Chopinstraße 4
D-04103 Leipzig
Germany
tel. +49 (341) 9 60 50 07
fax. +49 (341) 9 60 50 92
mail. [EMAIL PROTECTED]
web. www.vub.de
HRB Köln 24015
UStID DE 122 649 251
GF Dr. Achim Preuss Neudorf,
Dr. Christian Preuss Neudorf
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Alexander Klimetschek
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]