<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
<artifactId>org.argeo.dep.jemmy.nb61</artifactId>
</dependency>
- <!-- OSGi -->
+ <!-- OSGi
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.0.0</version>
- </dependency>
- <!--
+ </dependency>-->
+
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
- </dependency> -->
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
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 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 {
--- /dev/null
+package org.argeo.slc.autoui;
+
+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.netbeans.jemmy.ClassReference;
+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/";
+ String uiPackage = "org.argeo.slc.testui";
+ 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,"*/
+ + "org.argeo.slc.autoui; version=0.10.3.SNAPSHOT,"
+ + uiPackage+","
+ + "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/sandbox/org.argeo.slc.sandbox.jemmytest/0.1.1-SNAPSHOT/org.argeo.slc.sandbox.jemmytest-0.1.1-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 AutoUiActivator());
+
+ 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);
+ }
+
+
+ // Start UI
+ String className = "org.argeo.slc.testui.SwingTestUi";
+ //String className = SwingTestUi.class.getName();
+ // String[] args = {};
+ // SwingTestUi.main(args);
+ // Start application
+ ClassReference classReference = new ClassReference(className);
+ String[] uiArgs = { "noExitOnClose" };
+ classReference.startApplication(uiArgs);
+
+
+
+ ServiceReference ref = context
+ .getServiceReference("org.argeo.slc.autoui.AutoUiApplication");
+// ServiceReference ref = context
+// .getServiceReference("java.lang.Runnable");
+ Object service = context.getService(ref);
+ AutoUiActivator.stdOut("service=" + service.getClass());
+ AutoUiApplication app = (AutoUiApplication) service;
+ app.execute(null);
+ // 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();
+ }
+
+}
+++ /dev/null
-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;
- }
-
-}
<Bundle-SymbolicName>
${pom.artifactId}
</Bundle-SymbolicName>
+ <Bundle-Activator>
+ org.argeo.slc.jemmytest.JemmyTestActivator
+ </Bundle-Activator>
<Import-Package>
- !org.apache.felix.*,*
+ !org.apache.felix.*,*,javax.swing.*
</Import-Package>
<Export-Package>
org.argeo.slc.jemmytest.*
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.main</artifactId>
+ </exclusion>
</exclusions>
</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>
--- /dev/null
+package org.argeo.slc.jemmytest;
+
+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.getMessage());
+ }
+ }
+
+ public Object execute(Object object) throws Exception {
+
+ // 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;
+ }
+
+}
package org.argeo.slc.jemmytest;
+import java.util.Properties;
+
+import org.argeo.slc.autoui.AutoUiApplication;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceEvent;
public void start(BundleContext context) throws Exception {
stdOut("JemmyTest started");
+ Properties properties = new Properties();
+ AutoUiApplicationJemmy applicationJemmy = new AutoUiApplicationJemmy();
+ context.registerService(AutoUiApplication.class.getName(),
+ applicationJemmy, properties);
+ context.registerService(Runnable.class.getName(), applicationJemmy,
+ properties);
// ServiceReference ref = context
// .getServiceReference("org.argeo.slc.autoui.AutoUiApplication");
+++ /dev/null
-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);
- }
- });
- }
-
-}
--- /dev/null
+<?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/j2sdk1.3.1"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>argeo.slc.testui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+#Sat Sep 20 12:22:38 GMT+02:00 2008
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.3
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.source=1.3
+eclipse.preferences.version=1
--- /dev/null
+package org.argeo.slc.testui;
+
+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);
+ }
+ });
+ }
+
+}