You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/02/20 09:09:36 UTC
svn commit: r509450 - in
/incubator/tuscany/branches/sca-java-integration/sca:
kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java
test/src/main/java/org/apache/tuscany/test/SCATestCaseRunner.java
Author: rfeng
Date: Tue Feb 20 00:09:35 2007
New Revision: 509450
URL: http://svn.apache.org/viewvc?view=rev&rev=509450
Log:
[sca-integration-branch] Format the code
Modified:
incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java
incubator/tuscany/branches/sca-java-integration/sca/test/src/main/java/org/apache/tuscany/test/SCATestCaseRunner.java
Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java?view=diff&rev=509450&r1=509449&r2=509450
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultSCAContainer.java Tue Feb 20 00:09:35 2007
@@ -80,10 +80,11 @@
urls = cl.getResources(SCAContainer.EXTENSION_SCDL);
extensions.addAll(Collections.list(urls));
if (exts != null) {
- for (URL ext : exts) {
- if (!extensions.contains(ext))
- extensions.add(ext);
- }
+ for (URL ext : exts) {
+ if (!extensions.contains(ext)) {
+ extensions.add(ext);
+ }
+ }
}
int i = 0;
for (URL ext : extensions) {
Modified: incubator/tuscany/branches/sca-java-integration/sca/test/src/main/java/org/apache/tuscany/test/SCATestCaseRunner.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/test/src/main/java/org/apache/tuscany/test/SCATestCaseRunner.java?view=diff&rev=509450&r1=509449&r2=509450
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/test/src/main/java/org/apache/tuscany/test/SCATestCaseRunner.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/test/src/main/java/org/apache/tuscany/test/SCATestCaseRunner.java Tue Feb 20 00:09:35 2007
@@ -27,120 +27,121 @@
import junit.framework.TestSuite;
/**
- * A helper class that can be used to run an SCA JUnit test case.
- * The test case will run in an isolated class loader.
+ * A helper class that can be used to run an SCA JUnit test case. The test case
+ * will run in an isolated class loader.
*
* @version $Rev$ $Date$
*/
public class SCATestCaseRunner {
- private ClassLoader classLoader;
- private Class testSuiteClass;
- private Object testSuite;
- private Class testResultClass;
- private Class testCaseClass;
- private Object testCase;
-
- /**
- * Constructs a new TestCase runner.
- * @param testClass
- */
- public SCATestCaseRunner(Class testClass) {
+ private ClassLoader classLoader;
+ private Class testSuiteClass;
+ private Object testSuite;
+ private Class testResultClass;
+ private Class testCaseClass;
+ private Object testCase;
+
+ /**
+ * Constructs a new TestCase runner.
+ *
+ * @param testClass
+ */
+ public SCATestCaseRunner(Class testClass) {
+ try {
+ classLoader = (URLClassLoader)testClass.getClassLoader();
+ if (classLoader instanceof URLClassLoader) {
+ URL[] urls = ((URLClassLoader)classLoader).getURLs();
+ classLoader = new URLClassLoader(urls, classLoader.getParent());
+ } else {
+ classLoader = new URLClassLoader(new URL[0], classLoader);
+ }
+
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(classLoader);
+
+ testCaseClass = Class.forName(testClass.getName(), true, classLoader);
+ testCase = testCaseClass.newInstance();
+
+ testSuiteClass = Class.forName(TestSuite.class.getName(), true, classLoader);
+ Constructor testSuiteConstructor = testSuiteClass.getConstructor(Class.class);
+ testSuite = testSuiteConstructor.newInstance(testCaseClass);
+
+ testResultClass = Class.forName(TestResult.class.getName(), true, classLoader);
+
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Run the test case
+ */
+ public void run() {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ Object testResult = testResultClass.newInstance();
+ Method runMethod = testSuiteClass.getMethod("run", testResultClass);
+ runMethod.invoke(testSuite, testResult);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+
+ /**
+ * Invoke the setUp method
+ */
+ public void setUp() {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ Method setUpMethod = testCaseClass.getDeclaredMethod("setUp");
+ setUpMethod.setAccessible(true);
+ setUpMethod.invoke(testCase);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+
+ /**
+ * Invoke the tearDown method
+ */
+ public void tearDown() {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ Method tearDownMethod = testCaseClass.getDeclaredMethod("tearDown");
+ tearDownMethod.setAccessible(true);
+ tearDownMethod.invoke(testCase);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+
+ /**
+ * Invoke the specified test method.
+ */
+ public void run(String methodName) {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
- classLoader = (URLClassLoader)testClass.getClassLoader();
- if (classLoader instanceof URLClassLoader) {
- URL[] urls = ((URLClassLoader)classLoader).getURLs();
- classLoader = new URLClassLoader(urls, classLoader.getParent());
- } else {
- classLoader = new URLClassLoader(new URL[0], classLoader);
- }
-
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(classLoader);
-
- testCaseClass = Class.forName(testClass.getName(), true, classLoader);
- testCase = testCaseClass.newInstance();
-
- testSuiteClass = Class.forName(TestSuite.class.getName(), true, classLoader);
- Constructor testSuiteConstructor = testSuiteClass.getConstructor(Class.class);
- testSuite = testSuiteConstructor.newInstance(testCaseClass);
-
- testResultClass = Class.forName(TestResult.class.getName(), true, classLoader);
-
- } finally {
- Thread.currentThread().setContextClassLoader(tccl);
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Run the test case
- */
- public void run() {
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(classLoader);
- Object testResult = testResultClass.newInstance();
- Method runMethod = testSuiteClass.getMethod("run", testResultClass);
- runMethod.invoke(testSuite, testResult);
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- Thread.currentThread().setContextClassLoader(tccl);
- }
- }
-
- /**
- * Invoke the setUp method
- */
- public void setUp() {
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(classLoader);
- Method setUpMethod = testCaseClass.getDeclaredMethod("setUp");
- setUpMethod.setAccessible(true);
- setUpMethod.invoke(testCase);
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- Thread.currentThread().setContextClassLoader(tccl);
- }
- }
-
- /**
- * Invoke the tearDown method
- */
- public void tearDown() {
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(classLoader);
- Method tearDownMethod = testCaseClass.getDeclaredMethod("tearDown");
- tearDownMethod.setAccessible(true);
- tearDownMethod.invoke(testCase);
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- Thread.currentThread().setContextClassLoader(tccl);
- }
- }
-
- /**
- * Invoke the specified test method.
- */
- public void run(String methodName) {
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(classLoader);
- Method testMethod = testCaseClass.getMethod(methodName);
- testMethod.invoke(testCase);
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- Thread.currentThread().setContextClassLoader(tccl);
- }
- }
+ Thread.currentThread().setContextClassLoader(classLoader);
+ Method testMethod = testCaseClass.getMethod(methodName);
+ testMethod.invoke(testCase);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org