I have explained how Eclipse builds up the classpath to run a test case. Let
me try again.
1) The generated .classpath for each project contains entries for all maven
dependencies with different scopes (compile/runtime/test/provide/system).
The .classpath cannot tell the maven scope of an dependency.
2) Taking an example: there are two projects A and B. A depends on B. A has
a test resource META-INF/sca-contribution.xml (say R1) and B also has a test
resource META-INF/sca-contribution.xml (R2). R1 is visible on A's .classpath
while R2 is visible on B's .classpath.
3) When we run a test case from A inside Eclipse, Eclipse creates a JUnit
Run Profile with a classpath that combines entries from both A and B's
.classpath. As a result, the test case will see both R1 and R2.
The root cause of this behavior is that Eclipse doesn't distinguish between
scopes of maven dependencies. In maven, test dependencies are not
transitive. When we run a test case from A, B's test resources or classes
are not visible to A.
Thanks,
Raymond
--------------------------------------------------
From: "ant elder" <[email protected]>
Sent: Tuesday, November 24, 2009 9:45 AM
To: <[email protected]>
Subject: Re: svn commit: r719807 -
/tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
Ok if its not the .classpath what else could be causing it? The
problem was when running in Eclipse the test classes from the
deployment and node-impl modules were being included in the classpath
for the calculator sample.
...ant
On Tue, Nov 24, 2009 at 5:24 PM, Raymond Feng <[email protected]> wrote:
I don't think it is a .classpath issue. When you launch a test case or
main
class within Eclipse, it aggregates all the class path entries from the
depending projects. Eclipse doesn't have the concept of "test" dependency
but maven does.
Thanks,
Raymond
--------------------------------------------------
From: "ant elder" <[email protected]>
Sent: Tuesday, November 24, 2009 3:49 AM
To: <[email protected]>
Subject: Re: svn commit: r719807 -
/tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
I chatted with Luciano about this the other day and we debugged
through it and it turns out the problem was caused by some module test
classes being added to the samples classpath. It looked like that
could have been caused by a bug in the mvn -Peclipse .classpath
generation though i've not been able to recreate it. Does anyone else
see any of the module test classes in the samples referenced libraries
in Eclipse?
...ant
On Sat, Nov 22, 2008 at 5:11 AM, <[email protected]> wrote:
Author: lresende
Date: Fri Nov 21 21:11:38 2008
New Revision: 719807
URL: http://svn.apache.org/viewvc?rev=719807&view=rev
Log:
Using contribution helper to properly discover the contribution
location
Modified:
tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
Modified:
tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java?rev=719807&r1=719806&r2=719807&view=diff
==============================================================================
---
tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
(original)
+++
tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
Fri Nov 21 21:11:38 2008
@@ -18,9 +18,11 @@
*/
package calculator;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.AfterClass;
@@ -40,7 +42,9 @@
@BeforeClass
public static void setUpBeforeClass() throws Exception {
- node = NodeFactory.newInstance().createNode();
+ NodeFactory factory = NodeFactory.newInstance();
+ String contribution =
ContributionLocationHelper.getContributionLocation(CalculatorClient.class);
+ node = factory.createNode("Calculator.composite", new
Contribution("calculator", contribution));
node.start();
calculatorService =
((Client)node).getService(CalculatorService.class,
"CalculatorServiceComponent");