1 20 package org.enhydra.barracuda.plankton.data; 21 22 import java.io.*; 23 import java.util.*; 24 import java.security.*; 25 import javax.servlet.*; 26 import javax.servlet.http.*; 27 28 import org.w3c.dom.*; 29 import junit.framework.*; 30 31 import org.enhydra.barracuda.plankton.*; 32 import org.enhydra.barracuda.plankton.data.*; 33 import org.enhydra.barracuda.core.util.dom.*; 34 import org.apache.log4j.*; 35 import org.enhydra.barracuda.core.view.*; 36 import org.enhydra.barracuda.examples.xmlc.*; 37 import org.enhydra.barracuda.testbed.*; 38 39 40 43 public class TestParam extends DefaultTestCase { 44 private static String testClass = TestParam.class.getName(); 46 private static Logger logger = Logger.getLogger("test."+testClass); 47 48 50 54 public TestParam(String name) { 55 super(name); 56 } 57 58 65 public static void main(String args[]) { 66 TestUtil.parseParams(args); 68 69 if (TestUtil.BATCH_MODE) junit.textui.TestRunner.main(new String [] {testClass}); 71 else junit.swingui.TestRunner.main(new String [] {testClass}); 72 } 73 74 75 81 84 public void testParam() { 85 if (logger.isInfoEnabled()) logger.info("testing param"); 86 87 Param p = null; 89 Param p2 = null; 90 String key1 = "foo1"; 91 String key1a = "foo1"; 92 String key2 = "foo2"; 93 String value1 = "blah1"; 94 String value1a = "blah1"; 95 String value2 = "blah2"; 96 97 p = new Param(); 99 assertTrue("param obj check 1a.1 failed - p.key!=null", p.key==null); 100 assertTrue("param obj check 1a.2 failed - p.getKey()!=null", p.getKey()==null); 101 assertTrue("param obj check 1b.1 failed - p.value!=null", p.value==null); 102 assertTrue("param obj check 1b.2 failed - p.getvalue()!=null", p.getValue()==null); 103 p = new Param(key1, value1); 104 assertTrue("param obj check 2a.1 failed - p.key!=key", p.key==key1); 105 assertTrue("param obj check 2a.2 failed - p.getKey()!=key", p.getKey()==key1); 106 assertTrue("param obj check 2b.1 failed - p.value!=value", p.value==value1); 107 assertTrue("param obj check 2b.2 failed - p.getvalue()!=value", p.getValue()==value1); 108 109 p2 = new Param(key2, value2); 111 assertTrue("param obj check 3a.1 failed - equality check failed", !(p.equals(p2))); 112 assertTrue("param obj check 3a.2 failed - equality check failed", !(p2.equals(p))); 113 p2.setKey(key1); 114 assertTrue("param obj check 3a.3 failed - equality check failed", !(p.equals(p2))); 115 assertTrue("param obj check 3a.4 failed - equality check failed", !(p2.equals(p))); 116 p2.setKey(key2); 117 p2.setValue(value1); 118 assertTrue("param obj check 3a.5 failed - equality check failed", !(p.equals(p2))); 119 assertTrue("param obj check 3a.6 failed - equality check failed", !(p2.equals(p))); 120 p2.setKey(key1); 121 assertTrue("param obj check 3a.7 failed - equality check failed", (p.equals(p2))); 122 assertTrue("param obj check 3a.8 failed - equality check failed", (p2.equals(p))); 123 p2.setKey(key1a); 124 p2.setValue(value1a); 125 assertTrue("param obj check 3a.9 failed - equality check failed", (p.equals(p2))); 126 assertTrue("param obj check 3a.10 failed - equality check failed", (p2.equals(p))); 127 } 128 } 129 | Popular Tags |