4
* Copyright Ericsson AB 2004-2010. All Rights Reserved.
6
* The contents of this file are subject to the Erlang Public License,
7
* Version 1.1, (the "License"); you may not use this file except in
8
* compliance with the License. You should have received a copy of the
9
* Erlang Public License along with this software. If not, it can be
10
* retrieved online at http://www.erlang.org/.
12
* Software distributed under the License is distributed on an "AS IS"
13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
* the License for the specific language governing rights and limitations
20
import com.ericsson.otp.erlang.*;
25
Implements test case jinterface_SUITE:node_ping/1
27
Creates three OtpNode objects. One with default cookie, one with
28
specified same cookie as the node running the test case and one
29
with a faulty cookie. From each OtpNode object the test_server
32
Also the default cookie node pings itself, and the node with the
33
specified cookie pings the node with default cookie.
36
public static void main(String argv[]) {
38
String cookie = argv[0];
39
String erlNode = argv[1];
42
OtpNode node1 = new OtpNode("javanode1");
43
ping(node1,erlNode,"Default cookie:",true,1);
44
ping(node1,node1.node(),"Self:",true,2);
45
ping(node1,"javanode1","Self:",true,3);
47
OtpNode node2 = new OtpNode("javanode2",cookie);
48
ping(node2,erlNode,"Specified cookie:",true,4);
49
ping(node2,"javanode1","Javanode (no host):",true,5);
50
ping(node2,node1.node(),"Javanode:",true,6);
52
OtpNode node3 = new OtpNode("javanode3","faultycookie");
53
ping(node3,erlNode,"Faulty cookie:",false,7);
55
// Test OtpNode.cookie() and OtpNode.setCookie(cookie) as well
56
if (!node3.cookie().equals("faultycookie"))
57
fail("Testing OtpNode.cookie()",8);
58
String old = node3.setCookie(cookie);
59
if (!old.equals("faultycookie"))
60
fail("Checking return of OtpNode.setCookie(cookie)",9);
61
ping(node3,erlNode,"setCookie:",true,10);
68
private static void ping(OtpNode node, String remote, String descr,
69
boolean expected, int reason) {
70
if ( node.ping(remote,2000) == expected ) {
71
System.out.println(descr + " ping(" + remote + ") -> " + expected);
74
fail("ERROR: " + descr + " ping(" + remote +") -> " + !expected,
79
private static void fail(String str, int reason) {
80
System.out.println(str);