Skip to content

Commit 701dbe9

Browse files
author
Wenjun Che
committed
ADAP-44: create junit tests
1 parent 0857f7d commit 701dbe9

12 files changed

+361
-31
lines changed

release/PubSubExample.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Example for Pub/Sub with OpenFin API</title>
5+
<script type="text/javascript" language="javascript">
6+
function init() {
7+
fin.desktop.main(function () {
8+
document.getElementById("status").innerHTML = "Connected to OpenFin Runtime";
9+
10+
var listener = function(payload, sourceUuid) {
11+
document.getElementById("status").innerHTML = "Received message " + JSON.stringify(payload);
12+
fin.desktop.InterApplicationBus.publish('unit-test', { response: payload.text + " received" });
13+
fin.desktop.InterApplicationBus.unsubscribe('*', 'unit-test', listener);
14+
};
15+
fin.desktop.InterApplicationBus.subscribe('*', 'unit-test', listener);
16+
17+
fin.desktop.InterApplicationBus.subscribe('*', 'private-channel', function(payload, sourceUuid) {
18+
document.getElementById("status").innerHTML = "Received message " + JSON.stringify(payload);
19+
// call send to target one particular App with uuid
20+
fin.desktop.InterApplicationBus.send(sourceUuid, 'private-channel', { response: payload.text + " received" });
21+
});
22+
23+
// init is done. broadcast check-in message
24+
fin.desktop.InterApplicationBus.publish('check-in', {name: 'Pub/Sub example app'});
25+
});
26+
}
27+
</script>
28+
</head>
29+
<body onload='init();' >
30+
<div>Example OpenFin app to test publish and susbcribe API calls</div>
31+
<div id="status"></div>
32+
33+
</body>
34+
</html>

release/SimpleOpenFinApp.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Simple OpenFin app</title>
5+
<script type="text/javascript" language="javascript">
6+
function init() {
7+
fin.desktop.main(function () {
8+
console.log("Connected to OpenFin Runtime");
9+
document.getElementById("status").innerHTML = "Connected to OpenFin Runtime"
10+
});
11+
}
12+
</script>
13+
</head>
14+
<body onload='init();' >
15+
<div>Simple OpenFin app</div>
16+
<div id="status"></div>
17+
</body>
18+
</html>
82 Bytes
Binary file not shown.
7.62 KB
Binary file not shown.
1.56 KB
Binary file not shown.

src/test/java/com/openfin/desktop/AllTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
*/
1111

1212
@RunWith(Suite.class)
13-
@Suite.SuiteClasses({ ApplicationTest.class, OpenFinRuntimeTest.class, WindowTest.class, SystemTest.class})
13+
@Suite.SuiteClasses({ ApplicationTest.class, OpenFinRuntimeTest.class, WindowTest.class, SystemTest.class, InterApplicationBusTest.class})
1414
public class AllTests {
1515
}

src/test/java/com/openfin/desktop/ApplicationTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ public static void teardown() throws Exception {
3939
@Test
4040
public void runAndClose() throws Exception {
4141
logger.debug("runAndClose");
42-
ApplicationOptions options = TestUtils.getAppOptions();
42+
ApplicationOptions options = TestUtils.getAppOptions(null);
4343
Application application = TestUtils.runApplication(options, desktopConnection);
4444

45-
// duplciate UUID is not allowed
46-
ApplicationOptions options2 = TestUtils.getAppOptions(options.getUUID());
45+
// duplicate UUID is not allowed
46+
ApplicationOptions options2 = TestUtils.getAppOptions(options.getUUID(), null);
4747
CountDownLatch dupLatch = new CountDownLatch(1);
4848
Application application2 = new Application(options2, desktopConnection, new AckListener() {
4949
@Override
@@ -65,7 +65,7 @@ public void onError(Ack ack) {
6565
@Test
6666
public void runAndTerminate() throws Exception {
6767
logger.debug("runAndTerminate");
68-
ApplicationOptions options = TestUtils.getAppOptions();
68+
ApplicationOptions options = TestUtils.getAppOptions(null);
6969
Application application = TestUtils.createApplication(options, desktopConnection);
7070

7171
CountDownLatch stoppedLatch = new CountDownLatch(1);
@@ -87,7 +87,7 @@ public void eventReceived(ActionEvent actionEvent) {
8787
@Test
8888
public void getApplicationManifest() throws Exception {
8989
logger.debug("getApplicationManifest");
90-
ApplicationOptions options = TestUtils.getAppOptions();
90+
ApplicationOptions options = TestUtils.getAppOptions(null);
9191
Application application = TestUtils.runApplication(options, desktopConnection);
9292
CountDownLatch latch = new CountDownLatch(1);
9393
application.getManifest(new AckListener() {
@@ -110,7 +110,7 @@ public void onError(Ack ack) {
110110
@Ignore("restart does not fire started event. need to take a look later")
111111
@Test
112112
public void restartApplication() throws Exception {
113-
ApplicationOptions options = TestUtils.getAppOptions();
113+
ApplicationOptions options = TestUtils.getAppOptions(null);
114114
Application application = TestUtils.runApplication(options, desktopConnection);
115115
CountDownLatch latch = new CountDownLatch(1);
116116
TestUtils.addEventListener(application, "started", actionEvent -> {
@@ -125,7 +125,7 @@ public void restartApplication() throws Exception {
125125

126126
@Test
127127
public void runReqestedEventListeners() throws Exception {
128-
ApplicationOptions options = TestUtils.getAppOptions();
128+
ApplicationOptions options = TestUtils.getAppOptions(null);
129129
Application application = TestUtils.createApplication(options, desktopConnection);
130130
CountDownLatch latch = new CountDownLatch(1);
131131
TestUtils.addEventListener(application, "run-requested", actionEvent -> {
@@ -144,7 +144,7 @@ public void runReqestedEventListeners() throws Exception {
144144

145145
@Test
146146
public void createChildWindow() throws Exception {
147-
Application application = TestUtils.runApplication(TestUtils.getAppOptions(), desktopConnection);
147+
Application application = TestUtils.runApplication(TestUtils.getAppOptions(null), desktopConnection);
148148
WindowOptions childOptions = TestUtils.getWindowOptions("child1", TestUtils.openfin_app_url); // use same URL as main app
149149
Window childWindow = TestUtils.createChildWindow(application, childOptions, desktopConnection);
150150
TestUtils.closeApplication(application);

0 commit comments

Comments
 (0)