(non fonctionning) OSGi tests
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 19 Sep 2008 18:01:29 +0000 (18:01 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 19 Sep 2008 18:01:29 +0000 (18:01 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1602 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

15 files changed:
sandbox/argeo.slc.jemmytest/.classpath
sandbox/argeo.slc.jemmytest/build.properties [new file with mode: 0644]
sandbox/argeo.slc.jemmytest/pom.xml
sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/SwingTestUi.java [deleted file]
sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiContext.java [deleted file]
sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServer.java [deleted file]
sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServerImpl.java [deleted file]
sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiTask.java [deleted file]
sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/jemmytest/JemmyTestActivator.java [new file with mode: 0644]
sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/jemmytest/Main.java [new file with mode: 0644]
sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/jemmytest/ui/SwingTestUi.java [new file with mode: 0644]
sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/autoui/swingtest/JemmyRemoteTest.java [deleted file]
sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/autoui/swingtest/SwingTestJemmy.java [deleted file]
sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/jemmytest/JemmyRemoteTest.java [new file with mode: 0644]
sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/jemmytest/SwingTestJemmy.java [new file with mode: 0644]

index bddeaab3125ad6ef3effc4b0fae0d338fe10142a..cad23f08609300a45d912fee5ca1937d9221ae46 100644 (file)
@@ -3,7 +3,7 @@
        <classpathentry kind="src" path="src/main/java"/>
        <classpathentry kind="src" path="src/test/resources"/>
        <classpathentry kind="src" path="src/test/java"/>
-       <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/j2sdk1.3.1"/>
+       <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/sandbox/argeo.slc.jemmytest/build.properties b/sandbox/argeo.slc.jemmytest/build.properties
new file mode 100644 (file)
index 0000000..5289856
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/main/java/,\
+           src/test/resources/,\
+           src/test/java/
+bin.includes = META-INF/,\
+               .
index ff6769a0bd28d5c75876880b4e379f1390b72dd6..673bd0f8e31923d43f7ac5e7d67d029d28194203 100644 (file)
@@ -2,14 +2,37 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
-       <groupId>org.argeo.slc</groupId>
-       <artifactId>slc-jemmy</artifactId>
-       <name>SLC Jemmy</name>
+       <groupId>org.argeo.slc.sandbox</groupId>
+       <artifactId>org.argeo.slc.sandbox.jemmytest</artifactId>
+       <name>SLC Sandbox JemmyTest</name>
        <version>0.1.1-SNAPSHOT</version>
-       <description />
+       <packaging>bundle</packaging>
        <build>
-               <filters></filters>
                <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <version>1.4.3</version>
+                               <extensions>true</extensions>
+                               <configuration>
+                                       <manifestLocation>META-INF</manifestLocation>
+                                       <instructions>
+                                               <Bundle-SymbolicName>
+                                                       ${pom.artifactId}
+                                               </Bundle-SymbolicName>
+                                               <Import-Package>
+                                                       !org.apache.felix.*,*
+                                               </Import-Package>
+                                               <Export-Package>
+                                                       org.argeo.slc.jemmytest.*
+                                               </Export-Package>
+                                               <!-- 
+                                                       <Require-Bundle>
+                                                       org.argeo.slc.autoui
+                                                       </Require-Bundle> -->
+                                       </instructions>
+                               </configuration>
+                       </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-compiler-plugin</artifactId>
        <profiles></profiles>
        <dependencies>
                <dependency>
-                       <groupId>org.netbeans</groupId>
-                       <artifactId>jemmy</artifactId>
-                       <version>2.2.7.5</version>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.autoui</artifactId>
+                       <version>0.10.3-SNAPSHOT</version>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>org.apache.felix</groupId>
+                                       <artifactId>org.osgi.core</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+
+               <dependency>
+                       <groupId>org.argeo.dep.jemmy</groupId>
+                       <artifactId>org.argeo.dep.jemmy.nb61</artifactId>
+                       <version>0.2.0</version>
+                       <scope>test</scope>
                </dependency>
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                        <version>3.8.2</version>
+                       <scope>test</scope>
                </dependency>
+               <!-- OSGi -->
                <dependency>
-                       <groupId>commons-logging</groupId>
-                       <artifactId>commons-logging</artifactId>
-                       <version>1.1.1</version>
-               </dependency>
-               <dependency>
-                       <groupId>log4j</groupId>
-                       <artifactId>log4j</artifactId>
-                       <version>1.2.15</version>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>com.sun.jmx</groupId>
-                                       <artifactId>jmxri</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>com.sun.jdmk</groupId>
-                                       <artifactId>jmxtools</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>javax.mail</groupId>
-                                       <artifactId>mail</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>javax.jms</groupId>
-                                       <artifactId>jms</artifactId>
-                               </exclusion>
-                       </exclusions>
+                       <groupId>org.apache.felix</groupId>
+                       <artifactId>org.apache.felix.main</artifactId>
+                       <version>1.2.1</version>
                </dependency>
        </dependencies>
-       <dependencyManagement>
-               <dependencies></dependencies>
-       </dependencyManagement>
-
+       <repositories>
+               <repository>
+                       <id>argeo</id>
+                       <url>http://www.argeo.org/maven/argeo</url>
+               </repository>
+       </repositories>
 </project>
\ No newline at end of file
diff --git a/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/SwingTestUi.java b/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/SwingTestUi.java
deleted file mode 100644 (file)
index e29f2dd..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.argeo.slc.autoui.swingtest;
-
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-
-public class SwingTestUi {
-       private static void createAndShowGUI(boolean exitOnClose) {
-               // Create and set up the window.
-               JFrame frame = new JFrame("HelloWorldSwing");
-               if (exitOnClose)
-                       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
-               frame.getContentPane().setLayout(new GridLayout(2, 1));
-
-               // Add the ubiquitous "Hello World" label.
-               final JLabel label = new JLabel("Hello World");
-               frame.getContentPane().add(label);
-
-               final JButton button = new JButton("Button");
-               frame.getContentPane().add(button);
-               button.addActionListener(new ActionListener() {
-                       public void actionPerformed(ActionEvent e) {
-                               label.setText("Pressed!!");
-                       }
-               });
-
-               // Display the window.
-               frame.pack();
-               frame.setVisible(true);
-       }
-
-       public static void main(String[] args) {
-               boolean noExitOnClose = false;
-               for (int i = 0; i < args.length; i++) {
-                       if (args[i].equals("noExitOnClose")) {
-                               noExitOnClose = true;
-                       }
-               }
-
-               final boolean exitOnClose = !noExitOnClose;
-               javax.swing.SwingUtilities.invokeLater(new Runnable() {
-                       public void run() {
-                               createAndShowGUI(exitOnClose);
-                       }
-               });
-       }
-
-}
diff --git a/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiContext.java b/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiContext.java
deleted file mode 100644 (file)
index 868a0c9..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.autoui.swingtest.rmi;
-
-public interface AutoUiContext {
-       public Object getLocalRef(String key);
-
-       public void setLocalRef(String key, Object ref);
-}
diff --git a/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServer.java b/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServer.java
deleted file mode 100644 (file)
index 089e6f8..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.slc.autoui.swingtest.rmi;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-public interface AutoUiServer extends Remote {
-       public Object executeTask(AutoUiTask task) throws RemoteException;
-}
diff --git a/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServerImpl.java b/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServerImpl.java
deleted file mode 100644 (file)
index b32b237..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.argeo.slc.autoui.swingtest.rmi;
-
-import java.rmi.Naming;
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.rmi.server.UnicastRemoteObject;
-import java.util.Map;
-import java.util.TreeMap;
-
-public class AutoUiServerImpl extends UnicastRemoteObject implements
-               AutoUiServer, AutoUiContext {
-       private Map map = new TreeMap();
-
-       public AutoUiServerImpl() throws RemoteException {
-               super();
-       }
-
-       public Object executeTask(AutoUiTask task) throws RemoteException {
-               try {
-                       return task.execute(this);
-               } catch (Exception e) {
-                       throw new RemoteException("Coul not execute task.", e);
-               }
-       }
-
-       public Object getLocalRef(String key) {
-               return map.get(key);
-       }
-
-       public void setLocalRef(String key, Object ref) {
-               map.put(key, ref);
-       }
-
-       public static void main(String[] args) {
-               if (System.getSecurityManager() == null) {
-                       System.setSecurityManager(new SecurityManager());
-               }
-               try {
-                       String name = "AutoUiServer";
-                       AutoUiServer engine = new AutoUiServerImpl();
-                       // AutoUiServer stub = (AutoUiServer) UnicastRemoteObject
-                       // .exportObject(engine, 0);
-                       // Registry registry = LocateRegistry.getRegistry();
-                       // registry.rebind(name, stub);
-                       Naming.rebind(name, engine);
-                       System.out.println("AutoUiServer bound");
-
-               } catch (Exception e) {
-                       System.err.println("AutoUiServer exception:");
-                       e.printStackTrace();
-               }
-
-       }
-}
diff --git a/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiTask.java b/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiTask.java
deleted file mode 100644 (file)
index 86dcc1f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.autoui.swingtest.rmi;
-
-import java.io.Serializable;
-
-public interface AutoUiTask extends Serializable {
-       public Object execute(AutoUiContext context) throws Exception;
-}
diff --git a/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/jemmytest/JemmyTestActivator.java b/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/jemmytest/JemmyTestActivator.java
new file mode 100644 (file)
index 0000000..6047f83
--- /dev/null
@@ -0,0 +1,35 @@
+package org.argeo.slc.jemmytest;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+
+public class JemmyTestActivator implements BundleActivator, ServiceListener {
+
+       public void start(BundleContext context) throws Exception {
+               stdOut("JemmyTest started");
+
+//             ServiceReference ref = context
+//                             .getServiceReference("org.argeo.slc.autoui.AutoUiApplication");
+//             Object service = context.getService(ref);
+//             // JemmyTestActivator.stdOut("service=" + service.getClass());
+//             AutoUiApplication app = (AutoUiApplication) service;
+//             app.execute(null);
+
+       }
+
+       public void stop(BundleContext context) throws Exception {
+               stdOut("JemmyTest stopped");
+       }
+
+       public void serviceChanged(ServiceEvent serviceEvent) {
+               stdOut("serviceEvent=" + serviceEvent);
+
+       }
+
+       public static void stdOut(Object obj) {
+               System.out.println(obj);
+       }
+
+}
diff --git a/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/jemmytest/Main.java b/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/jemmytest/Main.java
new file mode 100644 (file)
index 0000000..45d02e7
--- /dev/null
@@ -0,0 +1,185 @@
+package org.argeo.slc.jemmytest;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.framework.Felix;
+import org.apache.felix.framework.cache.BundleCache;
+import org.apache.felix.framework.util.FelixConstants;
+import org.apache.felix.framework.util.StringMap;
+import org.apache.felix.main.AutoActivator;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+public class Main {
+
+       /**
+        * @param args
+        */
+       public static void main(String[] args) {
+               try {
+                       // Create a temporary bundle cache directory and
+                       // make sure to clean it up on exit.
+                       final File cachedir = File.createTempFile(
+                                       "felix.example.servicebased", null);
+                       cachedir.delete();
+                       Runtime.getRuntime().addShutdownHook(new Thread() {
+                               public void run() {
+                                       deleteFileOrDir(cachedir);
+                               }
+                       });
+
+                       String mavenBase = "file:/home/mbaudier/.m2/repository/";
+
+                       Map configMap = new StringMap(false);
+                       configMap
+                                       .put(
+                                                       Constants.FRAMEWORK_SYSTEMPACKAGES,
+                                                       "org.osgi.framework; version=1.4.0,"
+                                                                       + "org.osgi.service.packageadmin; version=1.2.0,"
+                                                                       + "org.osgi.service.startlevel; version=1.1.0,"
+                                                                       + "org.osgi.service.url; version=1.0.0,"
+                                                                       + "org.osgi.util.tracker; version=1.3.3,"
+                                                                       /*+ "org.apache.felix.example.servicebased.host.service; version=1.0.0,"*/
+                                                                       + "javax.swing");
+                       configMap
+                                       .put(
+                                                       AutoActivator.AUTO_START_PROP + ".1",
+                                                       mavenBase
+                                                                       + "org/apache/felix/org.apache.felix.shell/1.0.2/org.apache.felix.shell-1.0.2.jar "
+                                                                       + mavenBase
+                                                                       + "org/apache/felix/org.apache.felix.shell.tui/1.0.2/org.apache.felix.shell.tui-1.0.2.jar "
+                                                                       + mavenBase
+                                                                       + "org/argeo/dep/jemmy/org.argeo.dep.jemmy.nb61/0.2.0/org.argeo.dep.jemmy.nb61-0.2.0.jar "
+                                                                       + mavenBase
+                                                                       + "org/argeo/slc/org.argeo.slc.autoui/0.10.3-SNAPSHOT/org.argeo.slc.autoui-0.10.3-SNAPSHOT.jar");
+                       configMap.put(FelixConstants.LOG_LEVEL_PROP, "1");
+                       configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, cachedir
+                                       .getAbsolutePath());
+
+                       // Create list to hold custom framework activators.
+                       List list = new ArrayList();
+                       // Add activator to process auto-start/install properties.
+                       list.add(new AutoActivator(configMap));
+                       // Add our own activator.
+                       list.add(new JemmyTestActivator());
+
+                       BundleContext context = null;
+                       try {
+                               // Now create an instance of the framework.
+                               Felix felix = new Felix(configMap, list);
+                               felix.start();
+
+                               context = felix.getBundleContext();
+
+                               // Bundle jemmyTestBundle = context
+                               // .installBundle(mavenBase
+                               // +
+                               // "org/argeo/slc/sandbox/org.argeo.slc.sandbox.jemmytest/0.1.1-SNAPSHOT/org.argeo.slc.sandbox.jemmytest-0.1.1-SNAPSHOT.jar");
+                               // jemmyTestBundle.start();
+
+                       } catch (Exception ex) {
+                               System.err.println("Could not create framework: " + ex);
+                               ex.printStackTrace();
+                               System.exit(-1);
+                       }
+
+//                     ServiceReference ref = context
+//                     .getServiceReference("org.argeo.slc.autoui.AutoUiApplication");
+                       ServiceReference ref = context
+                       .getServiceReference("java.lang.Runnable");
+                       Object service = context.getService(ref);
+                       JemmyTestActivator.stdOut("service=" + service.getClass());
+                       Runnable app = (Runnable) service;
+                       app.run();
+                       // app.execute(null);
+
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       System.exit(-1);
+               }
+
+               // Felix felix;
+               // // JemmyTestActivator activator;
+               //
+               // // Create a case-insensitive configuration property map.
+               // Map configMap = new StringMap(false);
+               // // Configure the Felix instance to be embedded.
+               // configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");
+               // // Add core OSGi packages to be exported from the class path
+               // // via the system bundle.
+               // configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
+               // "org.osgi.framework; version=1.3.0,"
+               // + "org.osgi.service.packageadmin; version=1.2.0,"
+               // + "org.osgi.service.startlevel; version=1.0.0,"
+               // + "org.osgi.service.url; version=1.0.0");
+               // // Explicitly specify the directory to use for caching bundles.
+               // configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "target/cache");
+               //
+               // try {
+               // // Create host activator;
+               // // activator = new JemmyTestActivator();
+               // List list = new ArrayList();
+               // // list.add(activator);
+               // list.add(new Activator());
+               // list.add(new org.apache.felix.shell.impl.Activator());
+               // list.add(new org.apache.felix.bundlerepository.Activator());
+               //
+               // // Now create an instance of the framework with
+               // // our configuration properties and activator.
+               // felix = new Felix(configMap, list);
+               //
+               // // Now start Felix instance.
+               // felix.start();
+               //
+               // Bundle jemmyBundle = felix
+               // .getBundleContext()
+               // .installBundle(
+               // "file:/home/mbaudier/.m2/repository/org/argeo/dep/jemmy/org.argeo.dep.jemmy.nb61/0.2.0/org.argeo.dep.jemmy.nb61-0.2.0.jar");
+               // jemmyBundle.start();
+               // //
+               // // Bundle autoUiBundle = felix
+               // // .getBundleContext()
+               // // .installBundle(
+               // //
+               // "reference:file:/home/mbaudier/dev/src/slc/org.argeo.slc.autoui/");
+               // // autoUiBundle.start();
+               //
+               // Bundle[] bundles = felix.getBundleContext().getBundles();
+               // for (int i = 0; i < bundles.length; i++) {
+               // Bundle bundle = bundles[i];
+               // System.out.println("" + bundle.getBundleId() + "\t"
+               // + bundle.getSymbolicName() + "\t" + bundle.getState()
+               // + "\t" + bundle.getLocation());
+               // }
+               //
+               // // felix.stop();
+               // } catch (Exception ex) {
+               // System.err.println("Could not create framework: " + ex);
+               // ex.printStackTrace();
+               // }
+               //
+       }
+
+       /**
+        * Utility method used to delete the profile directory when run as a
+        * stand-alone application.
+        * 
+        * @param file
+        *            The file to recursively delete.
+        */
+       private static void deleteFileOrDir(File file) {
+               if (file.isDirectory()) {
+                       File[] childs = file.listFiles();
+                       for (int i = 0; i < childs.length; i++) {
+                               deleteFileOrDir(childs[i]);
+                       }
+               }
+               file.delete();
+       }
+
+}
diff --git a/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/jemmytest/ui/SwingTestUi.java b/sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/jemmytest/ui/SwingTestUi.java
new file mode 100644 (file)
index 0000000..91dfd12
--- /dev/null
@@ -0,0 +1,53 @@
+package org.argeo.slc.jemmytest.ui;
+
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+
+public class SwingTestUi {
+       private static void createAndShowGUI(boolean exitOnClose) {
+               // Create and set up the window.
+               JFrame frame = new JFrame("HelloWorldSwing");
+               if (exitOnClose)
+                       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+               frame.getContentPane().setLayout(new GridLayout(2, 1));
+
+               // Add the ubiquitous "Hello World" label.
+               final JLabel label = new JLabel("Hello World");
+               frame.getContentPane().add(label);
+
+               final JButton button = new JButton("Button");
+               frame.getContentPane().add(button);
+               button.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               label.setText("Pressed!!");
+                       }
+               });
+
+               // Display the window.
+               frame.pack();
+               frame.setVisible(true);
+       }
+
+       public static void main(String[] args) {
+               boolean noExitOnClose = false;
+               for (int i = 0; i < args.length; i++) {
+                       if (args[i].equals("noExitOnClose")) {
+                               noExitOnClose = true;
+                       }
+               }
+
+               final boolean exitOnClose = !noExitOnClose;
+               javax.swing.SwingUtilities.invokeLater(new Runnable() {
+                       public void run() {
+                               createAndShowGUI(exitOnClose);
+                       }
+               });
+       }
+
+}
diff --git a/sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/autoui/swingtest/JemmyRemoteTest.java b/sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/autoui/swingtest/JemmyRemoteTest.java
deleted file mode 100644 (file)
index 48bec9c..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.argeo.slc.autoui.swingtest;
-
-import java.io.Serializable;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-
-import org.argeo.slc.autoui.swingtest.rmi.AutoUiContext;
-import org.argeo.slc.autoui.swingtest.rmi.AutoUiServer;
-import org.argeo.slc.autoui.swingtest.rmi.AutoUiTask;
-import org.netbeans.jemmy.ClassReference;
-import org.netbeans.jemmy.operators.JButtonOperator;
-import org.netbeans.jemmy.operators.JFrameOperator;
-import org.netbeans.jemmy.operators.JLabelOperator;
-
-import junit.framework.TestCase;
-
-public class JemmyRemoteTest extends TestCase implements Serializable {
-       static final long serialVersionUID = 1l;
-
-       public void testRemote() throws Exception {
-                if (System.getSecurityManager() == null) {
-                       System.setSecurityManager(new SecurityManager());
-               }
-               String name = "AutoUiServer";
-               Registry registry = LocateRegistry.getRegistry("localhost");
-               AutoUiServer server = (AutoUiServer) registry.lookup(name);
-               AutoUiTask startFrame = new AutoUiTask() {
-                       static final long serialVersionUID = 1l;
-
-                       public Object execute(AutoUiContext context) throws Exception {
-                               // Start application
-                               ClassReference classReference = new ClassReference(
-                                               SwingTestUi.class.getName());
-                               String[] args = { "noExitOnClose" };
-                               classReference.startApplication(args);
-
-                               // Find components
-                               JFrameOperator jFrameOperator = new JFrameOperator(
-                                               "HelloWorldSwing");
-                               JButtonOperator jButtonOperator = new JButtonOperator(
-                                               jFrameOperator, "Button");
-                               JLabelOperator jLabelOperator = new JLabelOperator(
-                                               jFrameOperator, "Hello World");
-
-                               context.setLocalRef("label", jLabelOperator);
-                               context.setLocalRef("button", jButtonOperator);
-                               return null;
-                       }
-
-               };
-
-               AutoUiTask pushButton = new AutoUiTask() {
-                       static final long serialVersionUID = 1l;
-
-                       public Object execute(AutoUiContext context) throws Exception {
-                               JButtonOperator jButtonOperator = (JButtonOperator) context
-                                               .getLocalRef("button");
-                               JLabelOperator jLabelOperator = (JLabelOperator) context
-                                               .getLocalRef("label");
-
-                               // Execute actions
-                               jButtonOperator.push();
-
-                               // Performs checks
-                               String textAfterPush = jLabelOperator.getText();
-                               Boolean pressed = new Boolean(textAfterPush.equals("Pressed!!"));
-                               return pressed;
-                       }
-
-               };
-
-               server.executeTask(startFrame);
-               Boolean pressed = (Boolean) server.executeTask(pushButton);
-               assertTrue("Has been pressed", pressed.booleanValue());
-       }
-
-       public static void main(String[] args){
-               try {
-                       JemmyRemoteTest jemmyRemoteTest = new JemmyRemoteTest();
-                       jemmyRemoteTest.testRemote();
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
-       }
-}
diff --git a/sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/autoui/swingtest/SwingTestJemmy.java b/sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/autoui/swingtest/SwingTestJemmy.java
deleted file mode 100644 (file)
index 023968c..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.argeo.slc.autoui.swingtest;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.netbeans.jemmy.ClassReference;
-import org.netbeans.jemmy.operators.JButtonOperator;
-import org.netbeans.jemmy.operators.JFrameOperator;
-import org.netbeans.jemmy.operators.JLabelOperator;
-
-public class SwingTestJemmy extends TestCase {
-       private final static Log log = LogFactory.getLog(SwingTestJemmy.class);
-
-       public void testSimple() throws Exception {
-               // Start application
-               ClassReference classReference = new ClassReference(SwingTestUi.class
-                               .getName());
-               String[] args = { "noExitOnClose" };
-               classReference.startApplication(args);
-
-               // Find components
-               JFrameOperator jFrameOperator = new JFrameOperator("HelloWorldSwing");
-               JButtonOperator jButtonOperator = new JButtonOperator(jFrameOperator,
-                               "Button");
-               JLabelOperator jLabelOperator = new JLabelOperator(jFrameOperator,
-                               "Hello World");
-
-               // Execute actions
-               jButtonOperator.push();
-
-               // Performs checks
-               String textAfterPush = jLabelOperator.getText();
-               assertEquals("Pressed!!", textAfterPush);
-
-               // Clean up
-               jFrameOperator.close();
-       }
-
-}
diff --git a/sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/jemmytest/JemmyRemoteTest.java b/sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/jemmytest/JemmyRemoteTest.java
new file mode 100644 (file)
index 0000000..b7de73f
--- /dev/null
@@ -0,0 +1,86 @@
+package org.argeo.slc.jemmytest;
+
+import java.io.Serializable;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+import org.argeo.slc.autoui.swingtest.rmi.AutoUiContext;
+import org.argeo.slc.autoui.swingtest.rmi.AutoUiServer;
+import org.argeo.slc.autoui.swingtest.rmi.AutoUiTask;
+import org.argeo.slc.jemmytest.ui.SwingTestUi;
+import org.netbeans.jemmy.ClassReference;
+import org.netbeans.jemmy.operators.JButtonOperator;
+import org.netbeans.jemmy.operators.JFrameOperator;
+import org.netbeans.jemmy.operators.JLabelOperator;
+
+import junit.framework.TestCase;
+
+public class JemmyRemoteTest extends TestCase implements Serializable {
+       static final long serialVersionUID = 1l;
+
+       public void testRemote() throws Exception {
+                if (System.getSecurityManager() == null) {
+                       System.setSecurityManager(new SecurityManager());
+               }
+               String name = "AutoUiServer";
+               Registry registry = LocateRegistry.getRegistry("localhost");
+               AutoUiServer server = (AutoUiServer) registry.lookup(name);
+               AutoUiTask startFrame = new AutoUiTask() {
+                       static final long serialVersionUID = 1l;
+
+                       public Object execute(AutoUiContext context) throws Exception {
+                               // Start application
+                               ClassReference classReference = new ClassReference(
+                                               SwingTestUi.class.getName());
+                               String[] args = { "noExitOnClose" };
+                               classReference.startApplication(args);
+
+                               // Find components
+                               JFrameOperator jFrameOperator = new JFrameOperator(
+                                               "HelloWorldSwing");
+                               JButtonOperator jButtonOperator = new JButtonOperator(
+                                               jFrameOperator, "Button");
+                               JLabelOperator jLabelOperator = new JLabelOperator(
+                                               jFrameOperator, "Hello World");
+
+                               context.setLocalRef("label", jLabelOperator);
+                               context.setLocalRef("button", jButtonOperator);
+                               return null;
+                       }
+
+               };
+
+               AutoUiTask pushButton = new AutoUiTask() {
+                       static final long serialVersionUID = 1l;
+
+                       public Object execute(AutoUiContext context) throws Exception {
+                               JButtonOperator jButtonOperator = (JButtonOperator) context
+                                               .getLocalRef("button");
+                               JLabelOperator jLabelOperator = (JLabelOperator) context
+                                               .getLocalRef("label");
+
+                               // Execute actions
+                               jButtonOperator.push();
+
+                               // Performs checks
+                               String textAfterPush = jLabelOperator.getText();
+                               Boolean pressed = new Boolean(textAfterPush.equals("Pressed!!"));
+                               return pressed;
+                       }
+
+               };
+
+               server.executeTask(startFrame);
+               Boolean pressed = (Boolean) server.executeTask(pushButton);
+               assertTrue("Has been pressed", pressed.booleanValue());
+       }
+
+       public static void main(String[] args){
+               try {
+                       JemmyRemoteTest jemmyRemoteTest = new JemmyRemoteTest();
+                       jemmyRemoteTest.testRemote();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+}
diff --git a/sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/jemmytest/SwingTestJemmy.java b/sandbox/argeo.slc.jemmytest/src/test/java/org/argeo/slc/jemmytest/SwingTestJemmy.java
new file mode 100644 (file)
index 0000000..5de37ba
--- /dev/null
@@ -0,0 +1,39 @@
+package org.argeo.slc.jemmytest;
+
+import junit.framework.TestCase;
+
+import org.argeo.slc.jemmytest.ui.SwingTestUi;
+import org.netbeans.jemmy.ClassReference;
+import org.netbeans.jemmy.operators.JButtonOperator;
+import org.netbeans.jemmy.operators.JFrameOperator;
+import org.netbeans.jemmy.operators.JLabelOperator;
+
+public class SwingTestJemmy extends TestCase {
+//     private final static Log log = LogFactory.getLog(SwingTestJemmy.class);
+
+       public void testSimple() throws Exception {
+               // Start application
+               ClassReference classReference = new ClassReference(SwingTestUi.class
+                               .getName());
+               String[] args = { "noExitOnClose" };
+               classReference.startApplication(args);
+
+               // Find components
+               JFrameOperator jFrameOperator = new JFrameOperator("HelloWorldSwing");
+               JButtonOperator jButtonOperator = new JButtonOperator(jFrameOperator,
+                               "Button");
+               JLabelOperator jLabelOperator = new JLabelOperator(jFrameOperator,
+                               "Hello World");
+
+               // Execute actions
+               jButtonOperator.push();
+
+               // Performs checks
+               String textAfterPush = jLabelOperator.getText();
+               assertEquals("Pressed!!", textAfterPush);
+
+               // Clean up
+               jFrameOperator.close();
+       }
+
+}