1 19 package org.enhydra.zeus.util; 20 21 import junit.framework.Test; 22 import junit.framework.TestCase; 23 import junit.framework.TestSuite; 24 25 33 public class ArgumentsTest extends TestCase { 34 35 42 public ArgumentsTest(String name) { 43 super(name); 44 } 45 46 55 public static Test suite(){ 56 return new TestSuite(ArgumentsTest.class); 57 } 58 59 65 public void testNoParameterConstructor() { 66 Arguments arguments = new Arguments(); 67 assertTrue(arguments != null); 68 } 69 70 76 public void testStringArrayConstructor() { 77 String [] args = 78 new String [] {"-file=/usr/src/dtd/song.dtd","-quiet=true"}; 79 80 Arguments arguments = new Arguments(args); 81 82 String expected = "/usr/src/dtd/song.dtd"; 83 assertEquals(arguments.getValue("file"), expected); 84 85 expected = "true"; 86 assertEquals(arguments.getValue("quiet"), expected); 87 } 88 89 94 public void testSetValue() { 95 Arguments arguments = new Arguments(); 96 97 String expected = "value1"; 98 arguments.setValue("argument1", expected); 99 assertEquals(arguments.getValue("argument1"), expected); 100 101 expected = "value2"; 102 arguments.setValue("argument2", expected); 103 assertEquals(arguments.getValue("argument2"), expected); 104 } 105 106 111 public void testGetValue() { 112 Arguments arguments = new Arguments(); 113 114 String expected = "testValue"; 115 arguments.setValue("testArgument", expected); 116 assertEquals(arguments.getValue("testArgument"), expected); 117 } 118 119 124 public void testHasValue() { 125 Arguments arguments = new Arguments(); 126 127 arguments.setValue("testArgument", "testValue"); 128 129 assertTrue(arguments.hasValue("testArgument")); 130 assertTrue(!arguments.hasValue("missingArgument")); 131 } 132 133 138 public void testSetValues() { 139 String [] args = 140 new String [] {"-file=/usr/src/dtd/song.dtd","-quiet=true"}; 141 142 Arguments arguments = new Arguments(); 143 arguments.setValues(args); 144 145 String expected = "/usr/src/dtd/song.dtd"; 146 assertEquals(arguments.getValue("file"), expected); 147 148 expected = "true"; 149 assertEquals(arguments.getValue("quiet"), expected); 150 } 151 } 152 153 | Popular Tags |