diff --git a/release/junit.bat b/release/junit.bat index 9462cbb..b79d81f 100644 --- a/release/junit.bat +++ b/release/junit.bat @@ -6,4 +6,4 @@ set RuntimeVersion="stable" set RuntimeVersion="%1" ) -java -cp lib/hamcrest-core-1.3.jar;lib/hamcrest-library-1.1.jar;lib/jetty-client-9.4.18.v20190429.jar;lib/jetty-http-9.4.18.v20190429.jar;lib/jetty-io-9.4.18.v20190429.jar;lib/jetty-util-9.4.18.v20190429.jar;lib/jetty-xml-9.4.18.v20190429.jar;lib/jna-4.5.1.jar;lib/jna-platform-4.5.1.jar;lib/json-20160810.jar;lib/junit-4.11.jar;lib/log4j-1.2.17.jar;lib/mockito-core-1.9.5.jar;lib/objenesis-1.0.jar;lib/openfin-desktop-java-adapter-9.2.0.jar;lib/openfin-desktop-java-example-9.0.1-tests.jar;lib/slf4j-api-1.7.21.jar;lib/slf4j-jdk14-1.6.1.jar;lib/slf4j-log4j12-1.7.18.jar;lib/TableLayout-20050920.jar;lib/websocket-api-9.4.18.v20190429.jar;lib/websocket-client-9.4.18.v20190429.jar;lib/websocket-common-9.4.18.v20190429.jar -Djava.util.logging.config.file=logging.properties -Dcom.openfin.test.runtime.version=%RuntimeVersion% org.junit.runner.JUnitCore com.openfin.desktop.AllTests +java -cp lib/hamcrest-core-1.3.jar;lib/hamcrest-library-1.1.jar;lib/jetty-client-9.4.18.v20190429.jar;lib/jetty-http-9.4.18.v20190429.jar;lib/jetty-io-9.4.18.v20190429.jar;lib/jetty-util-9.4.18.v20190429.jar;lib/jetty-xml-9.4.18.v20190429.jar;lib/jna-4.5.1.jar;lib/jna-platform-4.5.1.jar;lib/json-20160810.jar;lib/junit-4.11.jar;lib/log4j-1.2.17.jar;lib/mockito-core-1.9.5.jar;lib/objenesis-1.0.jar;lib/openfin-desktop-java-adapter-9.2.0.jar;lib/openfin-desktop-java-example-9.2.1-tests.jar;lib/slf4j-api-1.7.21.jar;lib/slf4j-jdk14-1.6.1.jar;lib/slf4j-log4j12-1.7.18.jar;lib/TableLayout-20050920.jar;lib/websocket-api-9.4.18.v20190429.jar;lib/websocket-client-9.4.18.v20190429.jar;lib/websocket-common-9.4.18.v20190429.jar -Djava.util.logging.config.file=logging.properties -Dcom.openfin.test.runtime.version=%RuntimeVersion% org.junit.runner.JUnitCore com.openfin.desktop.AllTests diff --git a/release/lib/openfin-desktop-java-example-9.0.1-tests.jar b/release/lib/openfin-desktop-java-example-9.2.1-tests.jar similarity index 66% rename from release/lib/openfin-desktop-java-example-9.0.1-tests.jar rename to release/lib/openfin-desktop-java-example-9.2.1-tests.jar index b31d60c..2611d69 100644 Binary files a/release/lib/openfin-desktop-java-example-9.0.1-tests.jar and b/release/lib/openfin-desktop-java-example-9.2.1-tests.jar differ diff --git a/release/lib/openfin-desktop-java-example-9.2.2.jar b/release/lib/openfin-desktop-java-example-9.2.2.jar new file mode 100644 index 0000000..dea5aac Binary files /dev/null and b/release/lib/openfin-desktop-java-example-9.2.2.jar differ diff --git a/release/profile.bat b/release/profile.bat new file mode 100644 index 0000000..9e1cf11 --- /dev/null +++ b/release/profile.bat @@ -0,0 +1,2 @@ +java -Xmx100m -Xms100m -cp lib/hamcrest-core-1.3.jar;lib/hamcrest-library-1.1.jar;lib/jetty-client-9.4.18.v20190429.jar;lib/jetty-http-9.4.18.v20190429.jar;lib/jetty-io-9.4.18.v20190429.jar;lib/jetty-util-9.4.18.v20190429.jar;lib/jetty-xml-9.4.18.v20190429.jar;lib/jna-4.5.1.jar;lib/jna-platform-4.5.1.jar;lib/json-20160810.jar;lib/junit-4.11.jar;lib/mockito-core-1.9.5.jar;lib/objenesis-1.0.jar;lib/openfin-desktop-java-adapter-9.2.3-SNAPSHOT.jar;lib/openfin-desktop-java-example-9.0.1-tests.jar;lib/openfin-desktop-java-example-9.2.2.jar;lib/slf4j-api-1.7.21.jar;lib/slf4j-jdk14-1.6.1.jar;lib/slf4j-log4j12-1.7.18.jar;lib/TableLayout-20050920.jar;lib/websocket-api-9.4.18.v20190429.jar;lib/websocket-client-9.4.18.v20190429.jar;lib/websocket-common-9.4.18.v20190429.jar -Djava.util.logging.config.file=logging.properties -Dcom.openfin.temp=%LocalAppData%\OpenFin\temp -Dcom.openfin.demo.version=stable -Dcom.openfin.demo.licenseKey=123456 com.openfin.desktop.demo.MemoryProfile + diff --git a/src/main/java/com/openfin/desktop/demo/MemoryProfile.java b/src/main/java/com/openfin/desktop/demo/MemoryProfile.java new file mode 100644 index 0000000..0b22811 --- /dev/null +++ b/src/main/java/com/openfin/desktop/demo/MemoryProfile.java @@ -0,0 +1,96 @@ +package com.openfin.desktop.demo; + +import com.openfin.desktop.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + + +/** + * This class can be used to profile memory usage of Java Adapter for communicating with Runtime. The initial version + * just keeps calling getMachineId API. It can easily extended to test other APIs. + * + * VisualVM, available from https://visualvm.github.io/, can be used to monitor memory usgage while this code is running + */ + +public class MemoryProfile { + private final static Logger logger = LoggerFactory.getLogger(MemoryProfile.class.getName()); + + public static void main(String[] args) { + RuntimeConfiguration runtimeConfiguration = new RuntimeConfiguration(); + String connectionUuid = MemoryProfile.class.getName(); + String desktopVersion = java.lang.System.getProperty("com.openfin.demo.version"); + if (desktopVersion == null) { + desktopVersion = "stable"; + } + runtimeConfiguration.setRuntimeVersion(desktopVersion); + try { + final DesktopConnection desktopConnection = new DesktopConnection(connectionUuid); + DesktopStateListener listener = new DesktopStateListener() { + @Override + public void onReady() { + launchThread(desktopConnection); + } + @Override + public void onClose(String error) { + + } + @Override + public void onError(String reason) { + logger.error(String.format("onError %s", reason)); + } + + @Override + public void onMessage(String message) { + } + @Override + public void onOutgoingMessage(String message) { + } + }; + desktopConnection.connect(runtimeConfiguration, listener, 50); + } catch (Exception e) { + logger.error("", e); + } + } + + private static void launchThread(DesktopConnection desktopConnection) { + Thread t = new Thread() { + @Override + public void run() { + OpenFinRuntime openfinSystem = new OpenFinRuntime(desktopConnection); + AtomicInteger callCount = new AtomicInteger(); + AtomicBoolean shouldRun = new AtomicBoolean(true); + while (shouldRun.get()) { + try { + CountDownLatch latch = new CountDownLatch(1); + openfinSystem.getMachineId(new AckListener() { + @Override + public void onSuccess(Ack ack) { + if (ack.isSuccessful()) { + logger.info(String.format("API call count %d", callCount.incrementAndGet())); + latch.countDown(); + } else { + logger.error(String.format("API failed %s", ack.getReason())); + shouldRun.set(false); + } + } + @Override + public void onError(Ack ack) { + logger.error(String.format("API failed %s", ack.getReason())); + shouldRun.set(false); + } + }); + latch.await(1, TimeUnit.SECONDS); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + }; + t.start(); + } +} diff --git a/src/main/java/com/openfin/desktop/demo/NotificationServiceDemo.java b/src/main/java/com/openfin/desktop/demo/NotificationServiceDemo.java index 9d40d6f..30d5c3f 100644 --- a/src/main/java/com/openfin/desktop/demo/NotificationServiceDemo.java +++ b/src/main/java/com/openfin/desktop/demo/NotificationServiceDemo.java @@ -157,8 +157,8 @@ private JPanel createCreateNotificationPanel() { JTextField tfBody = new JTextField("Body"); JTextField tfCategory = new JTextField("Category"); JTextField tfIcon = new JTextField("https://openfin.co/favicon-32x32.png"); - JTextField tfIndicatorText = new JTextField(""); - JTextField tfExpiresInSecs = new JTextField("5"); + JTextField tfIndicatorText = new JTextField("Hello From Java"); + JTextField tfExpiresInSecs = new JTextField("60"); JComboBox cbSticky = new JComboBox<>(); cbSticky.addItem(NotificationOptions.STICKY_STICKY); @@ -168,6 +168,7 @@ private JPanel createCreateNotificationPanel() { cbIndicator.addItem(NotificationIndicator.TYPE_FAILURE); cbIndicator.addItem(NotificationIndicator.TYPE_WARNING); cbIndicator.addItem(NotificationIndicator.TYPE_SUCCESS); + cbIndicator.setSelectedIndex(2); JPanel pnlCenter = new JPanel(new GridBagLayout()); GridBagConstraints gbConst = new GridBagConstraints(); diff --git a/src/test/java/com/openfin/desktop/InteropTest.java b/src/test/java/com/openfin/desktop/InteropTest.java index 3ed0b7e..7b412c3 100644 --- a/src/test/java/com/openfin/desktop/InteropTest.java +++ b/src/test/java/com/openfin/desktop/InteropTest.java @@ -40,8 +40,7 @@ public static void setup() throws Exception { @AfterClass public static void teardown() throws Exception { - OpenFinRuntime runtime = new OpenFinRuntime(desktopConnection); - runtime.exit(); + TestUtils.teardownDesktopConnection(desktopConnection); } @Test @@ -154,6 +153,15 @@ public void clientFireIntent() throws Exception { CompletionStage fireIntentFuture = desktopConnection.getInterop().connect(BROKER_NANE).thenCompose(client->{ return client.fireIntent(intent); }); + desktopConnection.getInterop().connect(BROKER_NANE).thenCompose(client->{ + return client.registerIntentListener("JavaIntent", intentReceived->{ + String ticker = intentReceived.getContext().getId().optString("ticker", ""); + StringBuilder sb = new StringBuilder(context.getId().getString("ticker")); + }).thenCompose(v -> { + return client.fireIntent(intent); + }); + }); + fireIntentFuture.toCompletableFuture().get(10, TimeUnit.SECONDS); } diff --git a/src/test/java/com/openfin/desktop/OpenFinRuntimeTest.java b/src/test/java/com/openfin/desktop/OpenFinRuntimeTest.java index 7e2aade..a741f7a 100644 --- a/src/test/java/com/openfin/desktop/OpenFinRuntimeTest.java +++ b/src/test/java/com/openfin/desktop/OpenFinRuntimeTest.java @@ -12,6 +12,7 @@ import org.json.JSONObject; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -398,6 +399,8 @@ public void onError(Ack ack) { } } + // this test does not work anymore with Secure By Default in place + @Ignore @Test public void startAndTerminateExternalProcess() throws Exception { CountDownLatch startLatch = new CountDownLatch(1); diff --git a/src/test/java/com/openfin/desktop/SystemTest.java b/src/test/java/com/openfin/desktop/SystemTest.java index 19738f0..135e02d 100644 --- a/src/test/java/com/openfin/desktop/SystemTest.java +++ b/src/test/java/com/openfin/desktop/SystemTest.java @@ -393,6 +393,8 @@ public void onError(Ack ack) { } } + // this test does not work anymore with Secure By Default in place + @Ignore @Test public void startAndTerminateExternalProcess() throws Exception { CountDownLatch startLatch = new CountDownLatch(1);