tests/libjava-mauve/src/gnu/testlet/javax/management/remote/NotificationResultTest.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Copyright (C) 2008 Andrew John Hughes <gnu_andrew@member.fsf.org>
       
     2 
       
     3 // This file is part of Mauve.
       
     4 
       
     5 // Mauve is free software; you can redistribute it and/or modify
       
     6 // it under the terms of the GNU General Public License as published by
       
     7 // the Free Software Foundation; either version 2, or (at your option)
       
     8 // any later version.
       
     9 
       
    10 // Mauve is distributed in the hope that it will be useful,
       
    11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13 // GNU General Public License for more details.
       
    14 
       
    15 // You should have received a copy of the GNU General Public License
       
    16 // along with Mauve; see the file COPYING.  If not, write to
       
    17 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    18 // Boston, MA 02111-1307, USA.
       
    19 
       
    20 // Tags: JDK1.5
       
    21 
       
    22 package gnu.testlet.javax.management.remote;
       
    23 
       
    24 import gnu.testlet.Testlet;
       
    25 import gnu.testlet.TestHarness;
       
    26 
       
    27 import javax.management.remote.NotificationResult;
       
    28 import javax.management.remote.TargetedNotification;
       
    29 
       
    30 public class NotificationResultTest
       
    31   implements Testlet
       
    32 {
       
    33   public void test(TestHarness h)
       
    34   {
       
    35     NotificationResult nr;
       
    36     TargetedNotification[] array = new TargetedNotification[]{};
       
    37     h.checkPoint("Constructor tests");
       
    38     try
       
    39       {
       
    40 	nr = new NotificationResult(-1, 0, array);
       
    41 	h.fail("Failed to catch negative earliest sequence number");
       
    42       }
       
    43     catch (Exception e)
       
    44       {
       
    45 	if (e instanceof IllegalArgumentException)
       
    46 	  h.check(true, "Caught negative earliest sequence number.");
       
    47 	else
       
    48 	  {
       
    49 	    h.debug(e);
       
    50 	    h.fail("Unknown exception");
       
    51 	  }
       
    52       }
       
    53     try
       
    54       {
       
    55 	nr = new NotificationResult(0, -1, array);
       
    56 	h.fail("Failed to catch negative next sequence number");
       
    57       }
       
    58     catch (Exception e)
       
    59       {
       
    60 	if (e instanceof IllegalArgumentException)
       
    61 	  h.check(true, "Caught negative next sequence number.");
       
    62 	else
       
    63 	  {
       
    64 	    h.debug(e);
       
    65 	    h.fail("Unknown exception");
       
    66 	  }
       
    67       }
       
    68     try
       
    69       {
       
    70 	nr = new NotificationResult(0, 1, null);
       
    71 	h.fail("Failed to catch null result array");
       
    72       }
       
    73     catch (Exception e)
       
    74       {
       
    75 	if (e instanceof IllegalArgumentException)
       
    76 	  h.check(true, "Caught null result array.");
       
    77 	else
       
    78 	  {
       
    79 	    h.debug(e);
       
    80 	    h.fail("Unknown exception");
       
    81 	  }
       
    82       }
       
    83     try
       
    84       {
       
    85 	nr = new NotificationResult(0, 1, array);
       
    86 	h.check(true, "NotificationResult successfully created.");
       
    87 	h.check(nr.getEarliestSequenceNumber() == 0,
       
    88 		"Retrieved earliest sequence number.");
       
    89 	h.check(nr.getNextSequenceNumber() == 1,
       
    90 		"Retrieved next sequence number.");
       
    91  	h.check(nr.getTargetedNotifications() == array,
       
    92 		"Retrieved array.");
       
    93       }
       
    94     catch (Exception e)
       
    95       {
       
    96 	if (e instanceof IllegalArgumentException)
       
    97 	  h.fail("Wrongly threw IllegalArgumentException.");
       
    98 	else
       
    99 	  {
       
   100 	    h.debug(e);
       
   101 	    h.fail("Unknown exception");
       
   102 	  }
       
   103       }
       
   104     
       
   105   }
       
   106 }
       
   107