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

12 files changed:
org.argeo.slc.autoui/.classpath [new file with mode: 0644]
org.argeo.slc.autoui/.project [new file with mode: 0644]
org.argeo.slc.autoui/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.argeo.slc.autoui/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
org.argeo.slc.autoui/pom.xml [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiApplication.java [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/internal/AutoUiApplicationJemmy.java [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiContext.java [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServer.java [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServerImpl.java [new file with mode: 0644]
org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiTask.java [new file with mode: 0644]

diff --git a/org.argeo.slc.autoui/.classpath b/org.argeo.slc.autoui/.classpath
new file mode 100644 (file)
index 0000000..e39ef13
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src/main/java"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.3"/>
+       <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.argeo.slc.autoui/.project b/org.argeo.slc.autoui/.project
new file mode 100644 (file)
index 0000000..7e38595
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.autoui</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.maven.ide.eclipse.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.maven.ide.eclipse.maven2Nature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.argeo.slc.autoui/.settings/org.eclipse.jdt.core.prefs b/org.argeo.slc.autoui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..b2ea700
--- /dev/null
@@ -0,0 +1,12 @@
+#Thu Sep 18 18:22:15 CEST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+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
diff --git a/org.argeo.slc.autoui/.settings/org.maven.ide.eclipse.prefs b/org.argeo.slc.autoui/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..78b8c9f
--- /dev/null
@@ -0,0 +1,9 @@
+#Thu Sep 18 18:28:43 CEST 2008
+activeProfiles=
+eclipse.preferences.version=1
+filterResources=false
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+useMavenFolders=false
+version=1
diff --git a/org.argeo.slc.autoui/pom.xml b/org.argeo.slc.autoui/pom.xml
new file mode 100644 (file)
index 0000000..14d16f2
--- /dev/null
@@ -0,0 +1,90 @@
+<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>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>argeo-slc</artifactId>
+               <version>0.10.3-SNAPSHOT</version>
+               <relativePath>../org.argeo.slc</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.autoui</artifactId>
+       <name>SLC Auto UI</name>
+       <packaging>bundle</packaging>
+       <description />
+       <build>
+               <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>
+                                               <Bundle-Activator>
+                                                       org.argeo.slc.autoui.AutoUiActivator
+                                               </Bundle-Activator>
+                                               <Export-Package>
+                                                       org.argeo.slc.autoui.*
+                                               </Export-Package>
+                                               <Import-Package>
+                                                       org.argeo.slc.jemmytest.ui.*;resolution=optional
+                                               </Import-Package>
+                                               <!-- 
+                                                       <Export-Service>
+                                                       org.argeo.slc.autoui.AutoUiApplication
+                                                       </Export-Service> -->
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <configuration>
+                                       <source>1.3</source>
+                                       <target>1.1</target>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-source-plugin</artifactId>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <!-- 
+                       <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       </dependency>
+                       <dependency>
+                       <groupId>commons-logging</groupId>
+                       <artifactId>commons-logging</artifactId>
+                       </dependency>
+                       <dependency>
+                       <groupId>log4j</groupId>
+                       <artifactId>log4j</artifactId>
+                       </dependency>
+               -->
+               <dependency>
+                       <groupId>org.argeo.dep.jemmy</groupId>
+                       <artifactId>org.argeo.dep.jemmy.nb61</artifactId>
+               </dependency>
+
+               <!-- OSGi -->
+               <dependency>
+                       <groupId>org.apache.felix</groupId>
+                       <artifactId>org.osgi.core</artifactId>
+                       <version>1.0.0</version>
+               </dependency>
+               <!-- 
+                       <dependency>
+                       <groupId>org.apache.felix</groupId>
+                       <artifactId>org.apache.felix.main</artifactId>
+                       </dependency> -->
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiActivator.java
new file mode 100644 (file)
index 0000000..463a10b
--- /dev/null
@@ -0,0 +1,28 @@
+package org.argeo.slc.autoui;
+
+import java.util.Properties;
+
+import org.argeo.slc.autoui.internal.AutoUiApplicationJemmy;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class AutoUiActivator implements BundleActivator {
+
+       public void start(BundleContext context) throws Exception {
+               stdOut("AutoUi started");
+               Properties properties = new Properties();
+               AutoUiApplicationJemmy applicationJemmy = new AutoUiApplicationJemmy();
+               context.registerService(AutoUiApplication.class.getName(),
+                               applicationJemmy, properties);
+               context.registerService(Runnable.class.getName(), applicationJemmy,
+                               properties);
+       }
+
+       public void stop(BundleContext context) throws Exception {
+               stdOut("AutoUi stopped");
+       }
+
+       public static void stdOut(Object obj) {
+               System.out.println(obj);
+       }
+}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiApplication.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/AutoUiApplication.java
new file mode 100644 (file)
index 0000000..203843e
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.autoui;
+
+public interface AutoUiApplication extends Runnable{
+       public Object execute(Object object) throws Exception;
+}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/internal/AutoUiApplicationJemmy.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/internal/AutoUiApplicationJemmy.java
new file mode 100644 (file)
index 0000000..d220742
--- /dev/null
@@ -0,0 +1,47 @@
+package org.argeo.slc.autoui.internal;
+
+import org.argeo.slc.autoui.AutoUiActivator;
+import org.argeo.slc.autoui.AutoUiApplication;
+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 AutoUiApplicationJemmy implements AutoUiApplication {
+       public void run() {
+               try {
+                       execute(new Object());
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       throw new RuntimeException("Could not execute as Runnable", e);
+               }
+       }
+
+       public Object execute(Object object) throws Exception {
+
+               String className = "org.argeo.slc.jemmytest.ui.SwingTestUi";
+               // String[] args = {};
+               // SwingTestUi.main(args);
+               // Start application
+               ClassReference classReference = new ClassReference(className);
+               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();
+               AutoUiActivator.stdOut("textAfterPush=" + textAfterPush);
+
+               return null;
+       }
+
+}
diff --git a/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiContext.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiContext.java
new file mode 100644 (file)
index 0000000..868a0c9
--- /dev/null
@@ -0,0 +1,7 @@
+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/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServer.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServer.java
new file mode 100644 (file)
index 0000000..089e6f8
--- /dev/null
@@ -0,0 +1,8 @@
+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/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServerImpl.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiServerImpl.java
new file mode 100644 (file)
index 0000000..b32b237
--- /dev/null
@@ -0,0 +1,55 @@
+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/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiTask.java b/org.argeo.slc.autoui/src/main/java/org/argeo/slc/autoui/swingtest/rmi/AutoUiTask.java
new file mode 100644 (file)
index 0000000..86dcc1f
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.autoui.swingtest.rmi;
+
+import java.io.Serializable;
+
+public interface AutoUiTask extends Serializable {
+       public Object execute(AutoUiContext context) throws Exception;
+}