Remove the dependency on Java 5 from the Junit4OSGi framework.
Tests can now be run on Foundation (tested on J9)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@650602 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/examples/junit4osgi/felix-command/pom.xml b/ipojo/examples/junit4osgi/felix-command/pom.xml
index 220d497..98133b6 100644
--- a/ipojo/examples/junit4osgi/felix-command/pom.xml
+++ b/ipojo/examples/junit4osgi/felix-command/pom.xml
@@ -48,8 +48,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.4</source>
+ <target>1.4</target>
</configuration>
</plugin>
<plugin>
diff --git a/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java b/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java
index a217a9e..1a16e44 100644
--- a/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java
+++ b/ipojo/examples/junit4osgi/felix-command/src/main/java/org/apache/felix/ipojo/junit4osgi/command/JunitCommand.java
@@ -40,8 +40,8 @@
private OSGiJunitRunner runner;
- private List<String> getNamesFromTests(List<Test> list) {
- List<String> names = new ArrayList<String>(list.size());
+ private List getNamesFromTests(List list) {
+ List names = new ArrayList(list.size());
for (int i = 0; i < list.size(); i++) {
if (list.get(i) instanceof TestCase) {
names.add(((TestCase) list.get(i)).getName());
@@ -59,7 +59,7 @@
public void execute(String line, PrintStream out, PrintStream err) {
line = line.substring(getName().length()).trim();
- List<TestResult> tr = null;
+ List tr = null;
if (line.equals("all")) {
if (runner.getTests() == null) {
err.println("No tests to execute");
@@ -71,12 +71,12 @@
} else {
try {
Long bundleId = new Long(line);
- if (runner.getTests(bundleId) == null) {
+ if (runner.getTests(bundleId.longValue()) == null) {
err.println("No tests to execute");
return;
} else {
- out.println("Executing " + getNamesFromTests(runner.getTests(bundleId)));
- tr = runner.run(bundleId);
+ out.println("Executing " + getNamesFromTests(runner.getTests(bundleId.longValue())));
+ tr = runner.run(bundleId.longValue());
}
} catch (NumberFormatException e) {
err.println("Unable to parse id " + line);
@@ -84,9 +84,9 @@
}
}
- ListIterator<TestResult> it = tr.listIterator();
+ ListIterator it = tr.listIterator();
while (it.hasNext()) {
- TestResult result = it.next();
+ TestResult result = (TestResult) it.next();
if (result.failureCount() != 0) {
TestFailure fail = (TestFailure) result.failures().nextElement();
out.println(fail.trace());
diff --git a/ipojo/examples/junit4osgi/junit4osgi/pom.xml b/ipojo/examples/junit4osgi/junit4osgi/pom.xml
index ae4ea6f..929816f 100644
--- a/ipojo/examples/junit4osgi/junit4osgi/pom.xml
+++ b/ipojo/examples/junit4osgi/junit4osgi/pom.xml
@@ -46,8 +46,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.4</source>
+ <target>1.4</target>
</configuration>
</plugin>
<plugin>
@@ -70,6 +70,7 @@
<Export-Package>
org.apache.felix.ipojo.junit4osgi, junit.*
</Export-Package>
+ <Import-Package>!javax.swing*, *</Import-Package>
<Test-Suite>
org.apache.felix.ipojo.junit4osgi.test.TestTestCase,
org.apache.felix.ipojo.junit4osgi.test.TestOSGiTestCase,
diff --git a/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiJunitRunner.java b/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiJunitRunner.java
index 57a67d6..7998a55 100644
--- a/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiJunitRunner.java
+++ b/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiJunitRunner.java
@@ -40,27 +40,27 @@
* Run the tests.
* @return the list of TestResult.
*/
- List<TestResult> run();
+ List/*<TestResult>*/ run();
/**
* Run the tests from the given bundle.
* @param bundleId : bundle containing the tests.
- * @return the list of the results.
+ * @return the list of the test results.
*/
- List<TestResult> run(long bundleId);
+ List/*<TestResult>*/ run(long bundleId);
/**
* Get the list of available test suites.
- * @return the list of test suites.
+ * @return the list of Test objects.
*/
- List<Test> getTests();
+ List/*<Test>*/ getTests();
/**
* Get the tests from the given bundle.
* @param bundleId : bundle id.
- * @return the list of test suites contained in the given bundle.
+ * @return the list of Test contained in the given bundle.
*/
- List<Test> getTests(long bundleId);
+ List/*<Test>*/ getTests(long bundleId);
/**
* Run the given test.
diff --git a/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java b/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java
index e10ad04..d4550c7 100644
--- a/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java
+++ b/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/OSGiTestCase.java
@@ -39,7 +39,7 @@
*/
static public void assertEquals(String message, double expected, double actual) {
if (Double.compare(expected, actual) != 0) {
- fail(formatEqualsMessage(message, expected, actual));
+ fail(formatEqualsMessage(message, new Double(expected), new Double(actual)));
}
}
@@ -103,7 +103,7 @@
for (int i = 0; i < array.length; i++) {
bytes[i] = new Byte(array[i]);
}
- fail(formatContainsMessage(message, bytes, txt));
+ fail(formatContainsMessage(message, bytes, new Integer(txt)));
}
static public void assertContains(String message, short[] array, int txt) {
@@ -116,7 +116,7 @@
for (int i = 0; i < array.length; i++) {
bytes[i] = new Short(array[i]);
}
- fail(formatContainsMessage(message, bytes, txt));
+ fail(formatContainsMessage(message, bytes, new Integer(txt)));
}
static public void assertContains(String message, int[] array, int txt) {
@@ -129,7 +129,7 @@
for (int i = 0; i < array.length; i++) {
bytes[i] = new Integer(array[i]);
}
- fail(formatContainsMessage(message, bytes, txt));
+ fail(formatContainsMessage(message, bytes, new Integer(txt)));
}
static public void assertContains(String message, long[] array, long txt) {
@@ -142,7 +142,7 @@
for (int i = 0; i < array.length; i++) {
bytes[i] = new Long(array[i]);
}
- fail(formatContainsMessage(message, bytes, txt));
+ fail(formatContainsMessage(message, bytes, new Long(txt)));
}
static public void assertContains(String message, float[] array, float txt) {
@@ -155,7 +155,7 @@
for (int i = 0; i < array.length; i++) {
bytes[i] = new Float(array[i]);
}
- fail(formatContainsMessage(message, bytes, txt));
+ fail(formatContainsMessage(message, bytes, new Float(txt)));
}
static public void assertContains(String message, double[] array, double txt) {
@@ -168,7 +168,7 @@
for (int i = 0; i < array.length; i++) {
bytes[i] = new Double(array[i]);
}
- fail(formatContainsMessage(message, bytes, txt));
+ fail(formatContainsMessage(message, bytes, new Double(txt)));
}
static public void assertContains(String message, char[] array, char txt) {
@@ -181,7 +181,7 @@
for (int i = 0; i < array.length; i++) {
bytes[i] = new Character(array[i]);
}
- fail(formatContainsMessage(message, bytes, txt));
+ fail(formatContainsMessage(message, bytes, new Character(txt)));
}
}
diff --git a/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java b/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java
index 34f0382..020718a 100644
--- a/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java
+++ b/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java
@@ -37,6 +37,7 @@
import org.apache.felix.ipojo.junit4osgi.OSGiJunitRunner;
import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.apache.felix.ipojo.parser.ParseUtils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -48,17 +49,17 @@
public static final String SUITE_METHODNAME = "suite";
- private Map<Bundle, List<Class>> m_suites = new HashMap<Bundle, List<Class>>();
+ private Map/*<Bundle, List<Class>>*/ m_suites = new HashMap/*<Bundle, List<Class>>*/();
private ResultPrinter m_printer = new ResultPrinter(System.out);
void onBundleArrival(Bundle bundle, String header) {
- String[] tss = header.split(",");
+ String[] tss = ParseUtils.split(header, ",");
for (int i = 0; i < tss.length; i++) {
try {
if (tss[i].length() != 0) {
System.out.println("Loading " + tss[i]);
- Class<? extends Test> clazz = bundle.loadClass(tss[i].trim());
+ Class/*<? extends Test>*/ clazz = bundle.loadClass(tss[i].trim());
addTestSuite(bundle, clazz);
}
} catch (ClassNotFoundException e) {
@@ -67,10 +68,10 @@
}
}
- private synchronized void addTestSuite(Bundle bundle, Class<? extends Test> test) {
- List<Class> list = m_suites.get(bundle);
+ private synchronized void addTestSuite(Bundle bundle, Class/*<? extends Test>*/ test) {
+ List/*<Class>*/ list = (List) m_suites.get(bundle);
if (list == null) {
- list = new ArrayList<Class>();
+ list = new ArrayList/*<Class>*/();
list.add(test);
m_suites.put(bundle, list);
} else {
@@ -90,15 +91,15 @@
m_printer = new ResultPrinter(pw);
}
- public synchronized List<TestResult> run() {
- List<TestResult> results = new ArrayList<TestResult>(m_suites.size());
- Iterator<Entry<Bundle, List<Class>>> it = m_suites.entrySet().iterator();
+ public synchronized List/*<TestResult>*/ run() {
+ List/*<TestResult>*/ results = new ArrayList/*<TestResult>*/(m_suites.size());
+ Iterator/*<Entry<Bundle, List<Class>>>*/ it = m_suites.entrySet().iterator();
while (it.hasNext()) {
- Entry<Bundle, List<Class>> entry = it.next();
- Bundle bundle = entry.getKey();
- List<Class> list = m_suites.get(bundle);
+ Entry/*<Bundle, List<Class>>*/ entry = (Entry) it.next();
+ Bundle bundle = (Bundle) entry.getKey();
+ List/*<Class>*/ list = (List) m_suites.get(bundle);
for (int i = 0; i < list.size(); i++) {
- Test test = createTestFromClass(list.get(i), bundle);
+ Test test = createTestFromClass((Class)list.get(i), bundle);
TestResult tr = doRun(test);
results.add(tr);
}
@@ -120,7 +121,7 @@
return result;
}
- private Test createTestFromClass(Class<?> clazz, Bundle bundle) {
+ private Test createTestFromClass(Class/*<?>*/ clazz, Bundle bundle) {
Method suiteMethod = null;
boolean bc = false;
try {
@@ -166,15 +167,15 @@
return test;
}
- public synchronized List<Test> getTests() {
- List<Test> results = new ArrayList<Test>();
- Iterator<Entry<Bundle, List<Class>>> it = m_suites.entrySet().iterator();
+ public synchronized List/*<Test>*/ getTests() {
+ List/*<Test>*/ results = new ArrayList/*<Test>*/();
+ Iterator/*<Entry<Bundle, List<Class>>>*/ it = m_suites.entrySet().iterator();
while (it.hasNext()) {
- Entry<Bundle, List<Class>> entry = it.next();
- Bundle bundle = entry.getKey();
- List<Class> list = m_suites.get(bundle);
+ Entry/*<Bundle, List<Class>>*/ entry = (Entry) it.next();
+ Bundle bundle = (Bundle) entry.getKey();
+ List/*<Class>*/ list = (List) m_suites.get(bundle);
for (int i = 0; i < list.size(); i++) {
- Test test = createTestFromClass(list.get(i), bundle);
+ Test test = createTestFromClass((Class) list.get(i), bundle);
results.add(test);
}
}
@@ -185,16 +186,16 @@
return doRun(test);
}
- public synchronized List<Test> getTests(long bundleId) {
- Iterator<Entry<Bundle, List<Class>>> it = m_suites.entrySet().iterator();
+ public synchronized List/*<Test>*/ getTests(long bundleId) {
+ Iterator/*<Entry<Bundle, List<Class>>>*/ it = m_suites.entrySet().iterator();
while (it.hasNext()) {
- Entry<Bundle, List<Class>> entry = it.next();
- Bundle bundle = entry.getKey();
+ Entry/*<Bundle, List<Class>>*/ entry = (Entry) it.next();
+ Bundle bundle = (Bundle) entry.getKey();
if (bundle.getBundleId() == bundleId) {
- List<Test> results = new ArrayList<Test>();
- List<Class> list = m_suites.get(bundle);
+ List/*<Test>*/ results = new ArrayList/*<Test>*/();
+ List/*<Class>*/ list = (List) m_suites.get(bundle);
for (int i = 0; i < list.size(); i++) {
- Test test = createTestFromClass(list.get(i), bundle);
+ Test test = createTestFromClass((Class) list.get(i), bundle);
results.add(test);
}
return results;
@@ -203,16 +204,16 @@
return null;
}
- public synchronized List<TestResult> run(long bundleId) {
- Iterator<Entry<Bundle, List<Class>>> it = m_suites.entrySet().iterator();
+ public synchronized List/*<TestResult>*/ run(long bundleId) {
+ Iterator/*<Entry<Bundle, List<Class>>>*/ it = m_suites.entrySet().iterator();
while (it.hasNext()) {
- Entry<Bundle, List<Class>> entry = it.next();
- Bundle bundle = entry.getKey();
+ Entry/*<Bundle, List<Class>>*/ entry = (Entry) it.next();
+ Bundle bundle = (Bundle) entry.getKey();
if (bundle.getBundleId() == bundleId) {
- List<TestResult> results = new ArrayList<TestResult>();
- List<Class> list = m_suites.get(bundle);
+ List/*<TestResult>*/ results = new ArrayList/*<TestResult>*/();
+ List/*<Class>*/ list = (List) m_suites.get(bundle);
for (int i = 0; i < list.size(); i++) {
- Test test = createTestFromClass(list.get(i), bundle);
+ Test test = createTestFromClass((Class) list.get(i), bundle);
TestResult tr = doRun(test);
results.add(tr);
}
diff --git a/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/ResultPrinter.java b/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/ResultPrinter.java
index 4eb4e96..2acb056 100644
--- a/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/ResultPrinter.java
+++ b/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/ResultPrinter.java
@@ -75,7 +75,7 @@
printDefects(result.failures(), result.failureCount(), "failure");
}
- protected void printDefects(Enumeration<TestFailure> booBoos, int count, String type) {
+ protected void printDefects(Enumeration/*<TestFailure>*/ booBoos, int count, String type) {
if (count == 0)
return;
if (count == 1)
@@ -83,7 +83,7 @@
else
getWriter().println("There were " + count + " " + type + "s:");
for (int i = 1; booBoos.hasMoreElements(); i++) {
- printDefect(booBoos.nextElement(), i);
+ printDefect((TestFailure) booBoos.nextElement(), i);
}
}
diff --git a/ipojo/examples/junit4osgi/pom.xml b/ipojo/examples/junit4osgi/pom.xml
index dfb8be8..caa5026 100644
--- a/ipojo/examples/junit4osgi/pom.xml
+++ b/ipojo/examples/junit4osgi/pom.xml
@@ -23,6 +23,11 @@
<version>0.7.6-SNAPSHOT</version>
<name>Apache Felix iPOJO Junit4OSGi</name>
<packaging>pom</packaging>
+
+ <modules>
+ <module>junit4osgi</module>
+ <module>felix-command</module>
+ </modules>
<profiles>
<profile>
@@ -31,8 +36,6 @@
<jdk>1.5</jdk>
</activation>
<modules>
- <module>junit4osgi</module>
- <module>felix-command</module>
<module>swing-runner</module>
<module>immediate-launcher</module>
</modules>
@@ -43,8 +46,6 @@
<jdk>1.6</jdk>
</activation>
<modules>
- <module>junit4osgi</module>
- <module>felix-command</module>
<module>swing-runner</module>
<module>immediate-launcher</module>
</modules>