<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/test/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.3"/>
+ <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="output" path="bin"/>
</classpath>
--- /dev/null
+#Sun Sep 14 07:26:48 CEST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.3
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
+org.eclipse.jdt.core.compiler.source=1.3
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<jardesc>
+ <jar path="/home/mbaudier/dev/src/slc/sandbox/argeo.slc.jemmytest/local/autouiserver.jar"/>
+ <options buildIfNeeded="true" compress="true" descriptionLocation="/argeo.slc.jemmytest/autouiserver.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
+ <storedRefactorings deprecationInfo="true" structuralOnly="false"/>
+ <selectedProjects/>
+ <manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
+ <sealing sealJar="false">
+ <packagesToSeal/>
+ <packagesToUnSeal/>
+ </sealing>
+ </manifest>
+ <selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
+ <javaElement handleIdentifier="=argeo.slc.jemmytest/src\/main\/java"/>
+ </selectedElements>
+</jardesc>
<project xmlns="http://maven.apache.org/POM/4.0.0"
- 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>
- <version>0.1.1-SNAPSHOT</version>
- <description />
- <build>
- <filters></filters>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.3</source>
- <target>1.3</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>package</phase>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <profiles></profiles>
- <dependencies>
- <dependency>
- <groupId>org.netbeans</groupId>
- <artifactId>jemmy</artifactId>
- <version>2.2.7.5</version>
- </dependency>
- <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>
- </dependency>
- </dependencies>
- <dependencyManagement>
- <dependencies></dependencies>
- </dependencyManagement>
+ 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>
+ <version>0.1.1-SNAPSHOT</version>
+ <description />
+ <build>
+ <filters></filters>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.3</source>
+ <target>1.3</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <profiles></profiles>
+ <dependencies>
+ <dependency>
+ <groupId>org.netbeans</groupId>
+ <artifactId>jemmy</artifactId>
+ <version>2.2.7.5</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ </dependency>
+ <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>
+ </dependency>
+ </dependencies>
+ <dependencyManagement>
+ <dependencies></dependencies>
+ </dependencyManagement>
</project>
\ No newline at end of file
--- /dev/null
+grant codeBase "file:/home/mbaudier/dev/src/slc/sandbox/argeo.slc.jemmytest/bin/" {
+ permission java.security.AllPermission;
+};
+
+grant codeBase "file:/home/mbaudier/dev/src/slc/sandbox/argeo.slc.jemmytest/local/autouiserver.jar" {
+ permission java.security.AllPermission;
+};
+
+grant codeBase "file:/home/mbaudier/.m2/repository/org/netbeans/jemmy/2.2.7.5/jemmy-2.2.7.5.jar" {
+ permission java.security.AllPermission;
+};
--- /dev/null
+grant {
+ // Allow everything for now
+ permission java.security.AllPermission;
+};
+++ /dev/null
-package org.argeo.slc.autoui.swingtest;
-
-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;
-
-public class SwingTestJemmy {
- private final static Log log = LogFactory.getLog(SwingTestJemmy.class);
-
- public static void main(String[] args) {
- try {
- ClassReference classReference = new ClassReference(
- SwingTestUi.class.getName());
- classReference.startApplication();
- JFrameOperator jFrameOperator = new JFrameOperator(
- "HelloWorldSwing");
- JButtonOperator jButtonOperator = new JButtonOperator(
- jFrameOperator, "Button");
- jButtonOperator.push();
- String textAfterPush = jButtonOperator.getText();
- log.info("textAfterPush=" + textAfterPush);
-
- jFrameOperator.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
package org.argeo.slc.autoui.swingtest;
+import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
public class SwingTestUi {
- private static void createAndShowGUI() {
+ private static void createAndShowGUI(boolean exitOnClose) {
// Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ 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() {
-
- @Override
public void actionPerformed(ActionEvent e) {
- button.setText("Pressed!!");
-
- }});
+ label.setText("Pressed!!");
+ }
+ });
// Display the window.
frame.pack();
}
public static void main(String[] args) {
- // Schedule a job for the event-dispatching thread:
- // creating and showing this application's GUI.
+ 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();
+ createAndShowGUI(exitOnClose);
}
});
}
--- /dev/null
+package org.argeo.slc.autoui.swingtest.rmi;
+
+public interface AutoUiContext {
+ public Object getLocalRef(String key);
+
+ public void setLocalRef(String key, Object ref);
+}
--- /dev/null
+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;
+}
--- /dev/null
+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();
+ }
+
+ }
+}
--- /dev/null
+package org.argeo.slc.autoui.swingtest.rmi;
+
+import java.io.Serializable;
+
+public interface AutoUiTask extends Serializable {
+ public Object execute(AutoUiContext context) throws Exception;
+}
--- /dev/null
+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();
+ }
+ }
+}
--- /dev/null
+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();
+ }
+
+}