KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > jmx > remote > internal > ShifterTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * $Id: ShifterTest.java,v 1.3 2005/12/25 04:26:45 tcfujii Exp $
26  * $Date: 2005/12/25 04:26:45 $
27  * $Revision: 1.3 $
28  */

29 package com.sun.enterprise.admin.jmx.remote.internal;
30
31 import junit.framework.*;
32
33 /**
34  * @author <a HREF="mailto:Kedar.Mhaswade@sun.com">Kedar Mhaswade</a>
35  * @since $Revision: 1.3 $
36  */

37 public class ShifterTest extends TestCase {
38
39     public void testRightLeftShiftFromEmpty() {
40         final Object JavaDoc[] s = new Object JavaDoc[]{};
41         final Shifter ss = new Shifter(s);
42         ss.shiftRight(new Object JavaDoc());
43         ss.shiftLeft();
44         assertEquals(ss.state().length, 0);
45     }
46     public void testImpossibleLeftShift() {
47         try {
48             final String JavaDoc[] s = new String JavaDoc[]{};
49             final Shifter sh = new Shifter(s);
50             final Object JavaDoc r = sh.shiftLeft();
51             fail("Should have thrown IllegalStateException, but didn't, hence test fails");
52         }
53         catch(Exception JavaDoc e){}
54     }
55     public void testShiftLeftOne() {
56         final String JavaDoc one = "one";
57         final String JavaDoc[] s = new String JavaDoc[]{one};
58         final Shifter sh = new Shifter(s);
59         final Object JavaDoc r = sh.shiftLeft();
60         assertEquals(one, r);
61     }
62     public void testShiftRightFromTwo() {
63         final Object JavaDoc[] s = new Object JavaDoc[]{new Object JavaDoc(), new Object JavaDoc()};
64         final Shifter sh = new Shifter(s);
65         final String JavaDoc add = "8";
66         sh.shiftRight(add);
67         assertEquals(sh.state().length, 3);
68     }
69     public void testShiftRightOneFromEmpty() {
70         final String JavaDoc[] s = new String JavaDoc[]{};
71         final Shifter sh = new Shifter(s);
72         final String JavaDoc add = "8";
73         sh.shiftRight(add);
74         assertEquals(sh.state().length, 1);
75     }
76     public void testShiftRightOne() {
77         final String JavaDoc[] s = new String JavaDoc[]{"one"};
78         final Shifter sh = new Shifter(s);
79         final String JavaDoc add = "8";
80         sh.shiftRight(add);
81         assertEquals(sh.state().length, 2);
82     }
83     public void testCreate() {
84         final Shifter s = new Shifter(new String JavaDoc[]{"element1"});
85     }
86     public ShifterTest(java.lang.String JavaDoc testName) {
87         super(testName);
88     }
89     protected void setUp() {
90     }
91     
92     protected void tearDown() {
93     }
94     
95     private void nyi() {
96         fail("Not yet implemented");
97     }
98     
99     public static Test suite(){
100         TestSuite suite = new TestSuite(ShifterTest.class);
101         return suite;
102     }
103     
104     public static void main(String JavaDoc args[]){
105         junit.textui.TestRunner.run(suite());
106         //junit.swingui.TestRunner.run(suite());
107
}
108     
109 }
110
Popular Tags