summaryrefslogtreecommitdiff
path: root/jessie-tests/testAlert.java
blob: ba063a713cb438b9d1b02849704ce9894fc5cb53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54


import gnu.javax.net.ssl.provider.Alert;
import java.nio.ByteBuffer;

class testAlert
{
  public static void main (String[] argv)
  {
    try
      {
        check ();
      }
    catch (Exception x)
      {
        System.out.println ("FAIL: caught exception " + x);
        x.printStackTrace ();
      }
  }

  static void check () throws Exception
  {
    Alert a1 = new Alert (ByteBuffer.allocate (2));
   
    a1.setLevel (Alert.Level.WARNING);
    System.out.println ("PASS: setLevel()");
    a1.setDescription (Alert.Description.UNEXPECTED_MESSAGE);
    System.out.println ("PASS: setDescription()");

    Alert a2 = new Alert (ByteBuffer.allocate (2));

    a2.setLevel (Alert.Level.WARNING);
    System.out.println ("PASS: setLevel()");
    a2.setDescription (Alert.Description.UNEXPECTED_MESSAGE);
    System.out.println ("PASS: setDescription()");

    if (a1.equals (a2))
      System.out.println ("PASS: equals()");
    else
      System.out.println ("FAIL: equals()");

    if (a1.level () == Alert.Level.WARNING)
      System.out.println ("PASS: level");
    else
      System.out.println ("FAIL: level");

    if (a1.description () == Alert.Description.UNEXPECTED_MESSAGE)
      System.out.println ("PASS: description");
    else
      System.out.println ("FAIL: description");

    System.err.println (a1);
  }
}