You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2008/03/03 16:51:03 UTC
svn commit: r633142 - in /felix/sandbox/clement/ipojo/examples/junit4osgi:
./ junit4osgi/
junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/
swing-runner/
swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/
Author: clement
Date: Mon Mar 3 07:51:01 2008
New Revision: 633142
URL: http://svn.apache.org/viewvc?rev=633142&view=rev
Log:
Fix a synchronization issue in the JunitExtender.
Improve the Junit Swing Runner Gui
Removed:
felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/NewJFrame.form
Modified:
felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/metadata.xml
felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/pom.xml
felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java
felix/sandbox/clement/ipojo/examples/junit4osgi/pom.xml
felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/metadata.xml
felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/pom.xml
felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/ResultTableModel.java
felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.form
felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.java
felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/TestListModel.java
Modified: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/metadata.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/metadata.xml?rev=633142&r1=633141&r2=633142&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/metadata.xml (original)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/metadata.xml Mon Mar 3 07:51:01 2008
@@ -3,6 +3,7 @@
<Component className="org.apache.felix.ipojo.junit4osgi.impl.JunitExtender">
<extender:extender extension="Test-Suite" onArrival="onBundleArrival" onDeparture="onBundleDeparture"/>
<callback transition="invalidate" method="stopping"/>
+ <callback transition="validate" method="starting"/>
<provides/>
</Component>
<instance component="org.apache.felix.ipojo.junit4osgi.impl.JunitExtender"/>
Modified: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/pom.xml?rev=633142&r1=633141&r2=633142&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/pom.xml (original)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/pom.xml Mon Mar 3 07:51:01 2008
@@ -1,71 +1,85 @@
<project>
- <parent>
- <groupId>ipojo.examples</groupId>
- <artifactId>Junit4Osgi</artifactId>
- <version>0.7.6-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>Junit4Osgi</name>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${pom.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- <version>${pom.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.2.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>iPOJO OSGi Junit Runner</Bundle-Name>
- <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
- <Private-Package>org.apache.felix.ipojo.junit4osgi.impl, org.apache.felix.ipojo.junit4osgi.test</Private-Package>
- <Export-Package>org.apache.felix.ipojo.junit4osgi, junit.*</Export-Package>
- <Test-Suite>org.apache.felix.ipojo.junit4osgi.test.TestTestCase, org.apache.felix.ipojo.junit4osgi.test.TestOSGiTestCase, org.apache.felix.ipojo.junit4osgi.test.TestTestSuite, org.apache.felix.ipojo.junit4osgi.test.TestOSGiTestSuite</Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${pom.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <parent>
+ <groupId>ipojo.examples</groupId>
+ <artifactId>Junit4Osgi</artifactId>
+ <version>0.7.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>bundle</packaging>
+ <name>Junit4Osgi</name>
+ <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.metadata</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.2.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>
+ iPOJO OSGi Junit Runner
+ </Bundle-Name>
+ <Bundle-SymbolicName>
+ ${pom.artifactId}
+ </Bundle-SymbolicName>
+ <Private-Package>
+ org.apache.felix.ipojo.junit4osgi.impl,
+ org.apache.felix.ipojo.junit4osgi.test
+ </Private-Package>
+ <Export-Package>
+ org.apache.felix.ipojo.junit4osgi, junit.*
+ </Export-Package>
+ <Test-Suite>
+ org.apache.felix.ipojo.junit4osgi.test.TestTestCase,
+ org.apache.felix.ipojo.junit4osgi.test.TestOSGiTestCase,
+ org.apache.felix.ipojo.junit4osgi.test.TestTestSuite,
+ org.apache.felix.ipojo.junit4osgi.test.TestOSGiTestSuite
+ </Test-Suite>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-ipojo-plugin</artifactId>
+ <version>${pom.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>ipojo-bundle</goal>
+ </goals>
+ <configuration>
+ <ignoreAnnotations>true</ignoreAnnotations>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java?rev=633142&r1=633141&r2=633142&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java (original)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/junit4osgi/src/main/java/org/apache/felix/ipojo/junit4osgi/impl/JunitExtender.java Mon Mar 3 07:51:01 2008
@@ -166,7 +166,7 @@
return test;
}
- public List<Test> getTests() {
+ public synchronized List<Test> getTests() {
List<Test> results = new ArrayList<Test>();
Iterator<Entry<Bundle, List<Class>>> it = m_suites.entrySet().iterator();
while (it.hasNext()) {
@@ -225,6 +225,10 @@
public void stopping() {
System.out.println("Cleaning test suites ...");
m_suites = null;
+ }
+
+ public void starting() {
+ System.out.println("Junit Extender starting ...");
}
private BundleContext getBundleContext(Bundle bundle) {
Modified: felix/sandbox/clement/ipojo/examples/junit4osgi/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/pom.xml?rev=633142&r1=633141&r2=633142&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/pom.xml (original)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/pom.xml Mon Mar 3 07:51:01 2008
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<project>
<parent>
<groupId>ipojo.examples</groupId>
@@ -34,4 +35,4 @@
</modules>
</profile>
</profiles>
-</project>
\ No newline at end of file
+</project>
Modified: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/metadata.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/metadata.xml?rev=633142&r1=633141&r2=633142&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/metadata.xml (original)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/metadata.xml Mon Mar 3 07:51:01 2008
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
-<iPOJO>
- <component classname="org.apache.felix.ipojo.junit4osgi.command.SwingRunner">
- <requires field="m_runner"/>
- <callback method="stop" transition="invalidate"/>
- <callback method="start" transition="validate"/>
- </component>
- <instance component="org.apache.felix.ipojo.junit4osgi.command.SwingRunner"/>
+<iPOJO>
+ <component
+ classname="org.apache.felix.ipojo.junit4osgi.command.SwingRunner">
+ <requires field="m_runner" />
+ <callback method="stop" transition="invalidate" />
+ <callback method="start" transition="validate" />
+ </component>
+ <instance
+ component="org.apache.felix.ipojo.junit4osgi.command.SwingRunner" />
</iPOJO>
Modified: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/pom.xml?rev=633142&r1=633141&r2=633142&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/pom.xml (original)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/pom.xml Mon Mar 3 07:51:01 2008
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<project>
<parent>
<groupId>ipojo.examples</groupId>
@@ -8,9 +9,7 @@
<modelVersion>4.0.0</modelVersion>
<packaging>bundle</packaging>
<name>Junit4Osgi-Swing-GUI</name>
- <artifactId>
- org.apache.felix.ipojo.junit4osgi.swing-gui
- </artifactId>
+ <artifactId>org.apache.felix.ipojo.junit4osgi.swing-gui</artifactId>
<dependencies>
<dependency>
<groupId>${pom.groupId}</groupId>
@@ -45,15 +44,9 @@
<extensions>true</extensions>
<configuration>
<instructions>
- <Bundle-Name>
- iPOJO OSGi Junit Runner - Swing Gui
- </Bundle-Name>
- <Bundle-SymbolicName>
- ${pom.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.junit4osgi.command
- </Private-Package>
+ <Bundle-Name>iPOJO OSGi Junit Runner - Swing Gui</Bundle-Name>
+ <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+ <Private-Package>org.apache.felix.ipojo.junit4osgi.command</Private-Package>
</instructions>
</configuration>
</plugin>
@@ -74,4 +67,11 @@
</plugin>
</plugins>
</build>
+ <repositories>
+ <repository>
+ <id>unknown-jars-temp-repo</id>
+ <name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
+ <url>file:${project.basedir}/lib</url>
+ </repository>
+ </repositories>
</project>
Modified: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/ResultTableModel.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/ResultTableModel.java?rev=633142&r1=633141&r2=633142&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/ResultTableModel.java (original)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/ResultTableModel.java Mon Mar 3 07:51:01 2008
@@ -18,9 +18,13 @@
*/
package org.apache.felix.ipojo.junit4osgi.command;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
+
import javax.swing.table.AbstractTableModel;
+
import junit.framework.AssertionFailedError;
import junit.framework.Test;
@@ -29,9 +33,16 @@
* Store the results of executed tests.
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
-public class ResultTableModel extends AbstractTableModel{
-
+public class ResultTableModel extends AbstractTableModel {
+
+ public static final String SUCESS = "success";
+
+ public static final String FAILURE = "failure";
+
+ public static final String ERROR = "error";
+
private static final long serialVersionUID = 1L;
+
private List<TestRecord> results = new ArrayList<TestRecord>();
public int getRowCount() {
@@ -41,93 +52,128 @@
public int getColumnCount() {
return 2;
}
-
+
public void addTest(Test t, AssertionFailedError e) {
TestRecord rec = new TestRecord(t, e);
results.add(rec);
fireTableDataChanged();
}
-
+
public void addTest(Test t, Throwable e) {
TestRecord rec = new TestRecord(t, e);
results.add(rec);
fireTableDataChanged();
}
-
+
public void addTest(Test t) {
- TestRecord rec = new TestRecord(t);
- results.add(rec);
- fireTableDataChanged();
+ if (!contains(t)) {
+ TestRecord rec = new TestRecord(t);
+ results.add(rec);
+ fireTableDataChanged();
+ }
+ }
+
+ public int getTestCount() {
+ return results.size();
+ }
+
+ public int getSucess() {
+ int count = 0;
+ for (TestRecord test : results) {
+ if (test.m_wasSucessFull) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ public int getErrors() {
+ int count = 0;
+ for (TestRecord test : results) {
+ if (test.m_error != null) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ public int getFailures() {
+ int count = 0;
+ for (TestRecord test : results) {
+ if (test.m_failure != null) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ private boolean contains(Test t) {
+ for (TestRecord test : results) {
+ if (test.m_test.equals(t)) { return true; }
+ }
+ return false;
}
-
+
public void clear() {
results.clear();
fireTableDataChanged();
}
public Object getValueAt(int rowIndex, int columnIndex) {
- if (columnIndex == 0) {
- return results.get(rowIndex).m_test;
- }
+ if (columnIndex == 0) { return results.get(rowIndex).m_test; }
if (columnIndex == 1) {
TestRecord tr = results.get(rowIndex);
- if (tr.m_wasSucessFull) { return "sucess"; }
- if (tr.m_failure != null) { return "failure"; }
- if (tr.m_error != null) { return "error"; }
+ if (tr.m_wasSucessFull) { return SUCESS; }
+ if (tr.m_failure != null) { return FAILURE; }
+ if (tr.m_error != null) { return ERROR; }
}
return null;
}
-
-
-
+
public String getColumnName(int column) {
- if (column == 0) {
- return "Test";
- }
-
- if (column == 1) {
- return "Status";
- }
-
+ if (column == 0) { return "Test"; }
+
+ if (column == 1) { return "Status"; }
+
return null;
}
-
-
+
public String getMessage(int row, int column) {
- if (row == -1) {
- return null;
- }
+ if (row == -1) { return null; }
TestRecord rec = results.get(row);
- if (rec.m_wasSucessFull) {
- return "The test " + rec.m_test + " was executed sucessfully.";
- }
- if (rec.m_failure != null) {
- return "The test " + rec.m_test + " has failed : \n" + rec.m_failure.getMessage();
- }
+ if (rec.m_wasSucessFull) { return "The test " + rec.m_test + " was executed sucessfully."; }
+ if (rec.m_failure != null) { return "The test " + rec.m_test + " has failed : \n" + rec.m_failure.getMessage(); }
if (rec.m_error != null) {
- return "The test " + rec.m_test + " has thrown an error : \n" + rec.m_error.getMessage();
+ String message = "The test " + rec.m_test + " has thrown an error : \n" + rec.m_error.getMessage();
+ StringWriter sw = new StringWriter();
+ rec.m_error.printStackTrace(new PrintWriter(sw));
+ message += "\n" + sw.toString();
+ return message;
}
return "";
}
-
+
private class TestRecord {
private boolean m_wasSucessFull;
+
private Test m_test;
+
private AssertionFailedError m_failure;
+
private Throwable m_error;
-
+
public TestRecord(Test t, AssertionFailedError e) {
m_test = t;
m_wasSucessFull = false;
m_failure = e;
}
-
+
public TestRecord(Test t, Throwable e) {
m_test = t;
m_wasSucessFull = false;
m_error = e;
}
-
+
public TestRecord(Test t) {
m_test = t;
m_wasSucessFull = true;
Modified: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.form
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.form?rev=633142&r1=633141&r2=633142&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.form (original)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.form Mon Mar 3 07:51:01 2008
@@ -14,26 +14,13 @@
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="onDialogClosed"/>
</Events>
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
- <Component class="javax.swing.JButton" name="m_ok">
- <Properties>
- <Property name="text" type="java.lang.String" value="Ok"/>
- <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
- <Dimension value="[120, 23]"/>
- </Property>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_okActionPerformed"/>
- </Events>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="1" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
- </Component>
<Container class="javax.swing.JScrollPane" name="m_message">
<Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="null"/>
+ </Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[300, 202]"/>
</Property>
@@ -45,8 +32,8 @@
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
@@ -63,7 +50,7 @@
<Property name="rows" type="int" value="5"/>
<Property name="wrapStyleWord" type="boolean" value="true"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
- <Dimension value="[250, 200]"/>
+ <Dimension value="[300, 250]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[250, 200]"/>
@@ -72,6 +59,22 @@
</Component>
</SubComponents>
</Container>
+ <Component class="javax.swing.JButton" name="m_ok">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Ok"/>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[120, 23]"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_okActionPerformed"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="South"/>
+ </Constraint>
+ </Constraints>
+ </Component>
</SubComponents>
</Container>
</NonVisualComponents>
@@ -110,7 +113,7 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="0.0" weightY="0.0"/>
+ <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="2" fill="1" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
@@ -243,6 +246,27 @@
</Component>
</SubComponents>
</Container>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="m_statusBar">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JProgressBar" name="m_progress">
+ <Properties>
+ <Property name="indeterminate" type="boolean" value="true"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="m_executedResults">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="aaaaaaaaaaaaaaa"/>
+ </Properties>
+ </Component>
</SubComponents>
</Container>
</SubComponents>
Modified: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.java?rev=633142&r1=633141&r2=633142&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.java (original)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/SwingRunner.java Mon Mar 3 07:51:01 2008
@@ -25,6 +25,7 @@
import javax.swing.JScrollBar;
+import javax.swing.table.TableColumn;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestResult;
@@ -58,62 +59,20 @@
private boolean m_running = false;
// Variables declaration - do not modify//GEN-BEGIN:variables
-
- /**
- * Select all button.
- */
private javax.swing.JButton m_allButton;
-
- /**
- * Execute button.
- */
private javax.swing.JButton m_executeButton;
-
- /**
- * Message scroll pane.
- */
+ private javax.swing.JLabel m_executedResults;
private javax.swing.JScrollPane m_message;
-
- /**
- * Message Text Area.
- */
private javax.swing.JTextArea m_messageArea;
-
- /**
- * Ok button (test dialog).
- */
private javax.swing.JButton m_ok;
-
- /**
- * Main panel.
- */
private javax.swing.JPanel m_panel;
-
- /**
- * Result dialog.
- */
+ private javax.swing.JProgressBar m_progress;
private javax.swing.JDialog m_resultDialog;
-
- /**
- * Result scroll pane.
- */
private javax.swing.JScrollPane m_resultScroll;
-
- /**
- * Result table.
- */
private javax.swing.JTable m_resultTable;
-
- /**
- * Available Suite List.
- */
+ private javax.swing.JPanel m_statusBar;
private javax.swing.JList m_suiteList;
-
- /**
- * Test Suite scroll pane.
- */
private javax.swing.JScrollPane m_suiteScroll;
-
// End of variables declaration//GEN-END:variables
/**
@@ -133,6 +92,21 @@
m_resultDialog.setVisible(false);
refreshSuites();
m_context.addBundleListener(this);
+ m_executedResults.setText(" \t No executed tests");
+ m_progress.setIndeterminate(false);
+ m_progress.setMaximum(100);
+ m_progress.setValue(100);
+
+ TableColumn column = null;
+ for (int i = 0; i < m_resultTable.getColumnCount(); i++) {
+ column = m_resultTable.getColumnModel().getColumn(i);
+ if (i == 0) {
+ column.setPreferredWidth(350); //first column is bigger
+ } else {
+ column.setPreferredWidth(50);
+ column.setCellRenderer(new ResultCellRenderer());
+ }
+}
}
/**
@@ -165,9 +139,9 @@
java.awt.GridBagConstraints gridBagConstraints;
m_resultDialog = new javax.swing.JDialog();
- m_ok = new javax.swing.JButton();
m_message = new javax.swing.JScrollPane();
m_messageArea = new javax.swing.JTextArea();
+ m_ok = new javax.swing.JButton();
m_panel = new javax.swing.JPanel();
m_suiteScroll = new javax.swing.JScrollPane();
m_suiteList = new javax.swing.JList();
@@ -175,6 +149,9 @@
m_executeButton = new javax.swing.JButton();
m_resultScroll = new javax.swing.JScrollPane();
m_resultTable = new javax.swing.JTable();
+ m_statusBar = new javax.swing.JPanel();
+ m_progress = new javax.swing.JProgressBar();
+ m_executedResults = new javax.swing.JLabel();
m_resultDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
m_resultDialog.setMinimumSize(new java.awt.Dimension(320, 250));
@@ -182,26 +159,12 @@
public void windowClosed(java.awt.event.WindowEvent evt) {
onDialogClosed(evt);
}
-
public void windowClosing(java.awt.event.WindowEvent evt) {
onDialogClosed(evt);
}
});
- m_resultDialog.getContentPane().setLayout(new java.awt.GridBagLayout());
-
- m_ok.setText("Ok");
- m_ok.setPreferredSize(new java.awt.Dimension(120, 23));
- m_ok.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- okActionPerformed(evt);
- }
- });
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.insets = new java.awt.Insets(1, 3, 3, 3);
- m_resultDialog.getContentPane().add(m_ok, gridBagConstraints);
+ m_message.setBorder(null);
m_message.setMinimumSize(new java.awt.Dimension(300, 202));
m_message.setPreferredSize(new java.awt.Dimension(300, 202));
@@ -211,15 +174,20 @@
m_messageArea.setLineWrap(true);
m_messageArea.setRows(5);
m_messageArea.setWrapStyleWord(true);
- m_messageArea.setMinimumSize(new java.awt.Dimension(250, 200));
+ m_messageArea.setMinimumSize(new java.awt.Dimension(300, 250));
m_messageArea.setPreferredSize(new java.awt.Dimension(250, 200));
m_message.setViewportView(m_messageArea);
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 0;
- gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
- m_resultDialog.getContentPane().add(m_message, gridBagConstraints);
+ m_resultDialog.getContentPane().add(m_message, java.awt.BorderLayout.CENTER);
+
+ m_ok.setText("Ok");
+ m_ok.setPreferredSize(new java.awt.Dimension(120, 23));
+ m_ok.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ okActionPerformed(evt);
+ }
+ });
+ m_resultDialog.getContentPane().add(m_ok, java.awt.BorderLayout.SOUTH);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Junit Runner");
@@ -284,7 +252,6 @@
m_resultScroll.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
m_resultScroll.setMinimumSize(new java.awt.Dimension(452, 402));
- //m_resultTable.setAutoCreateRowSorter(true);
m_resultTable.setFont(new java.awt.Font("Tahoma", 0, 10));
m_resultTable.setModel(new ResultTableModel());
m_resultTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
@@ -309,10 +276,25 @@
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
getContentPane().add(m_panel, gridBagConstraints);
+ m_statusBar.setLayout(new javax.swing.BoxLayout(m_statusBar, javax.swing.BoxLayout.LINE_AXIS));
+
+ m_progress.setIndeterminate(true);
+ m_statusBar.add(m_progress);
+
+ m_executedResults.setText("aaaaaaaaaaaaaaa");
+ m_statusBar.add(m_executedResults);
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ getContentPane().add(m_statusBar, gridBagConstraints);
+
pack();
}// </editor-fold>//GEN-END:initComponents
@@ -331,26 +313,26 @@
}
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
executeTest(list);
- } //GEN-LAST:event_m_executeButtonActionPerformed
+ }//GEN-LAST:event_m_executeButtonActionPerformed
/**
* All button action.
* @param evt : event.
*/
- private void allButtonActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_m_allButtonActionPerformed
+ private void allButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_allButtonActionPerformed
int max = m_suiteList.getModel().getSize();
int[] indices = new int[max];
for (int i = 0; i < max; i++) {
indices[i] = i;
}
m_suiteList.setSelectedIndices(indices);
- } //GEN-LAST:event_m_allButtonActionPerformed
+ }//GEN-LAST:event_m_allButtonActionPerformed
/**
* Listener on table click.
* @param evt : event.
*/
- private void resultTableMouseClicked(java.awt.event.MouseEvent evt) { //GEN-FIRST:event_m_resultTableMouseClicked
+ private void resultTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_m_resultTableMouseClicked
Point p = evt.getPoint();
int row = m_resultTable.rowAtPoint(p);
int col = m_resultTable.columnAtPoint(p);
@@ -362,25 +344,25 @@
m_messageArea.setText(message);
m_resultDialog.setVisible(true);
}
- } //GEN-LAST:event_m_resultTableMouseClicked
+ }//GEN-LAST:event_m_resultTableMouseClicked
/**
* Ok button action.
* @param evt : event.
*/
- private void okActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_m_okActionPerformed
+ private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_okActionPerformed
m_resultDialog.setVisible(false);
setEnabled(true);
- } //GEN-LAST:event_m_okActionPerformed
+ }//GEN-LAST:event_m_okActionPerformed
/**
* Listener when the test report is closed.
* @param evt : event.
*/
- private void onDialogClosed(java.awt.event.WindowEvent evt) { //GEN-FIRST:event_onDialogClosed
+ private void onDialogClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_onDialogClosed
m_resultDialog.setVisible(false);
setEnabled(true);
- } //GEN-LAST:event_onDialogClosed
+ }//GEN-LAST:event_onDialogClosed
/**
* Execute method.
@@ -392,6 +374,7 @@
ResultTableModel model = (ResultTableModel) m_resultTable.getModel();
m_running = true;
m_executeButton.setText("Running...");
+ m_progress.setIndeterminate(true);
model.clear();
for (int i = 0; i < list.size(); i++) {
TestResult tr = new TestResult();
@@ -399,17 +382,28 @@
list.get(i).run(tr);
}
m_running = false;
+ m_progress.setIndeterminate(false);
+ m_progress.setMaximum(100);
+ m_progress.setValue(100);
m_executeButton.setText("Execute");
+ computeExecutedTest();
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
+
};
new Thread(thread).start();
}
+
+ private void computeExecutedTest() {
+ ResultTableModel results = (ResultTableModel) m_resultTable.getModel();
+ String m = " \t ";
+ m+= results.getTestCount() + " tests executed / ";
+ m+= results.getSucess() + " sucess / ";
+ m+= results.getFailures() + " failures / ";
+ m+= results.getErrors() + " errors ";
+ m_executedResults.setText(m);
+ }
- /**
- * @author clement
- *
- */
private class MyTestListener implements junit.framework.TestListener {
/**
* Table model.
Modified: felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/TestListModel.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/TestListModel.java?rev=633142&r1=633141&r2=633142&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/TestListModel.java (original)
+++ felix/sandbox/clement/ipojo/examples/junit4osgi/swing-runner/src/main/java/org/apache/felix/ipojo/junit4osgi/command/TestListModel.java Mon Mar 3 07:51:01 2008
@@ -34,7 +34,11 @@
private List<TestRecord> list = new ArrayList<TestRecord>();
public Object getElementAt(int index) {
- return list.get(index).name;
+ if (index >= list.size()) {
+ return null;
+ } else {
+ return list.get(index).name;
+ }
}
public Test getTestElementAt(int index) {
@@ -42,21 +46,29 @@
}
public void addTest(Test test) {
- TestRecord tr = new TestRecord();
- tr.test = test;
- tr.name = test.toString();
- list.add(tr);
+ synchronized(this) {
+ TestRecord tr = new TestRecord();
+ tr.test = test;
+ tr.name = test.toString();
+ list.add(tr);
+ }
fireContentsChanged(this, list.size() - 1, list.size() - 1);
}
public void removeTest(Test test) {
- for (TestRecord t : list) {
- if (t.test.equals(test)) {
- int index = list.indexOf(t);
- list.remove(t);
- fireContentsChanged(this, index, index);
- return;
+ int index = 1;
+ synchronized(this) {
+ for (TestRecord t : list) {
+ if (t.test.equals(test)) {
+ index = list.indexOf(t);
+ list.remove(t);
+ return;
+ }
}
+ }
+
+ if (index != -1) {
+ fireContentsChanged(this, index, index);
}
}