~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/jinterface/test/jinterface_SUITE_data/NodePing.java

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * %CopyrightBegin%
 
3
 *
 
4
 * Copyright Ericsson AB 2004-2010. All Rights Reserved.
 
5
 *
 
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/.
 
11
 *
 
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
 
15
 * under the License.
 
16
 *
 
17
 * %CopyrightEnd%
 
18
 */
 
19
 
 
20
import com.ericsson.otp.erlang.*;
 
21
 
 
22
class NodePing {
 
23
 
 
24
    /*
 
25
      Implements test case jinterface_SUITE:node_ping/1
 
26
 
 
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
 
30
      node is pinged.
 
31
 
 
32
      Also the default cookie node pings itself, and the node with the
 
33
      specified cookie pings the node with default cookie.
 
34
    */
 
35
 
 
36
    public static void main(String argv[]) {
 
37
 
 
38
        String cookie = argv[0];
 
39
        String erlNode = argv[1];
 
40
 
 
41
        try {
 
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);
 
46
 
 
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);
 
51
 
 
52
            OtpNode node3 = new OtpNode("javanode3","faultycookie");
 
53
            ping(node3,erlNode,"Faulty cookie:",false,7);
 
54
 
 
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);
 
62
        }
 
63
        catch (Exception e) {
 
64
            fail("" + e, 11);
 
65
        }
 
66
    }
 
67
 
 
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);
 
72
        }
 
73
        else {
 
74
            fail("ERROR: " + descr + " ping(" + remote +") -> " + !expected,
 
75
                 reason);
 
76
        }
 
77
    }
 
78
 
 
79
    private static void fail(String str, int reason) {
 
80
        System.out.println(str);
 
81
        System.exit(reason);
 
82
    }
 
83
}