1 23 24 package com.sun.enterprise.cli.framework; 25 26 import junit.framework.*; 27 32 33 public class ValidOptionTest extends TestCase { 34 public static void assertFalse(boolean t) { 35 assertTrue(!t); 36 } 37 38 public void testName() { 39 assertNull(vo.getName()); 40 vo.setName("foo"); 41 assertEquals("foo", vo.getName()); 42 } 43 public void testShortNames(){ 44 assertTrue(vo.getShortNames().isEmpty()); 45 assertFalse(vo.hasShortName()); 46 vo.setShortName("foo"); 47 assertEquals(1, vo.getShortNames().size()); 48 assertTrue(vo.getShortNames().contains("foo")); 49 assertTrue(vo.hasShortName()); 50 } 51 52 public void testType(){ 53 assertNull(vo.getType()); 54 vo.setType("t1"); 55 assertEquals("t1", vo.getType()); 56 } 57 58 public void testRequired(){ 59 assertEquals(0, vo.isValueRequired()); 60 vo.setRequired(12345); 61 assertEquals(12345, vo.isValueRequired()); 62 } 63 64 public void testDefault(){ 65 assertFalse(vo.hasDefaultValue()); 66 vo.setDefaultValue("def"); 67 assertEquals("def", vo.getDefaultValue()); 68 assertTrue(vo.hasDefaultValue()); 69 } 70 71 public void testToString(){ 72 assertEquals("null null null", vo.toString()); 73 vo.setShortName("foo"); 74 assertEquals("null null foo, null", vo.toString()); 75 } 76 77 public ValidOptionTest(String name){ 78 super(name); 79 } 80 81 ValidOption vo; 82 83 protected void setUp() { 84 vo = new ValidOption(); 85 } 86 87 protected void tearDown() { 88 } 89 90 private void nyi(){ 91 fail("Not Yet Implemented"); 92 } 93 94 public static void main(String args[]){ 95 if (args.length == 0){ 96 junit.textui.TestRunner.run(ValidOptionTest.class); 97 } else { 98 junit.textui.TestRunner.run(makeSuite(args)); 99 } 100 } 101 private static TestSuite makeSuite(String args[]){ 102 final TestSuite ts = new TestSuite(); 103 for (int i = 0; i < args.length; i++){ 104 ts.addTest(new ValidOptionTest(args[i])); 105 } 106 return ts; 107 } 108 } 109 | Popular Tags |