1 23 24 29 package com.sun.enterprise.admin.jmx.remote.internal; 30 31 import junit.framework.*; 32 33 37 public class ShifterTest extends TestCase { 38 39 public void testRightLeftShiftFromEmpty() { 40 final Object [] s = new Object []{}; 41 final Shifter ss = new Shifter(s); 42 ss.shiftRight(new Object ()); 43 ss.shiftLeft(); 44 assertEquals(ss.state().length, 0); 45 } 46 public void testImpossibleLeftShift() { 47 try { 48 final String [] s = new String []{}; 49 final Shifter sh = new Shifter(s); 50 final Object r = sh.shiftLeft(); 51 fail("Should have thrown IllegalStateException, but didn't, hence test fails"); 52 } 53 catch(Exception e){} 54 } 55 public void testShiftLeftOne() { 56 final String one = "one"; 57 final String [] s = new String []{one}; 58 final Shifter sh = new Shifter(s); 59 final Object r = sh.shiftLeft(); 60 assertEquals(one, r); 61 } 62 public void testShiftRightFromTwo() { 63 final Object [] s = new Object []{new Object (), new Object ()}; 64 final Shifter sh = new Shifter(s); 65 final String add = "8"; 66 sh.shiftRight(add); 67 assertEquals(sh.state().length, 3); 68 } 69 public void testShiftRightOneFromEmpty() { 70 final String [] s = new String []{}; 71 final Shifter sh = new Shifter(s); 72 final String add = "8"; 73 sh.shiftRight(add); 74 assertEquals(sh.state().length, 1); 75 } 76 public void testShiftRightOne() { 77 final String [] s = new String []{"one"}; 78 final Shifter sh = new Shifter(s); 79 final String 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 []{"element1"}); 85 } 86 public ShifterTest(java.lang.String 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 args[]){ 105 junit.textui.TestRunner.run(suite()); 106 } 108 109 } 110 | Popular Tags |