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 TestObjectRepositoryAssembler extends DefaultTestCase { 44 private static String testClass = TestObjectRepositoryAssembler.class.getName(); 46 private static Logger logger = Logger.getLogger("test."+testClass); 47 48 50 54 public TestObjectRepositoryAssembler(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 testAssembler() { 85 if (logger.isInfoEnabled()) logger.info("testing assembler"); 86 87 103 new ObjectRepositoryAssembler().assemble("../WEB-INF/object-repository.xml"); 105 106 assertTrue("Failed to set TEST_CLASS", ObjectRepositoryAssembler.TEST_CLASS.equals(Param.class)); 108 assertTrue("Failed to set TEST_STRING", ObjectRepositoryAssembler.TEST_STRING.equals("foo")); 109 assertTrue("Failed to set TEST_INT", ObjectRepositoryAssembler.TEST_INT==99); 110 assertTrue("Failed to set TEST_SHORT", ObjectRepositoryAssembler.TEST_SHORT==((short) 99)); 111 assertTrue("Failed to set TEST_LONG", ObjectRepositoryAssembler.TEST_LONG==((long) 99)); 112 assertTrue("Failed to set TEST_DOUBLE", ObjectRepositoryAssembler.TEST_DOUBLE==((double) 99)); 113 assertTrue("Failed to set TEST_FLOAT", ObjectRepositoryAssembler.TEST_FLOAT==((float) 99)); 114 assertTrue("Failed to set TEST_BOOLEAN", ObjectRepositoryAssembler.TEST_BOOLEAN==true); 115 assertEquals("Failed to set TEST_INT2", ObjectRepositoryAssembler.TEST_INT2, new Integer (99)); 116 assertEquals("Failed to set TEST_SHORT2", ObjectRepositoryAssembler.TEST_SHORT2, new Short ((short) 99)); 117 assertEquals("Failed to set TEST_LONG2", ObjectRepositoryAssembler.TEST_LONG2, new Long (99)); 118 assertEquals("Failed to set TEST_DOUBLE2", ObjectRepositoryAssembler.TEST_DOUBLE2, new Double (99)); 119 assertEquals("Failed to set TEST_FLOAT2", ObjectRepositoryAssembler.TEST_FLOAT2, new Float (99)); 120 assertEquals("Failed to set TEST_BOOLEAN2", ObjectRepositoryAssembler.TEST_BOOLEAN2, Boolean.TRUE); 121 assertTrue("Failed to set TEST_STRING2", ObjectRepositoryAssembler.TEST_STRING2.equals("foo")); 122 assertTrue("Failed to set TEST_STRING3", ObjectRepositoryAssembler.TEST_STRING3.equals("jujubean")); 123 124 ObjectRepository or = ObjectRepository.getGlobalRepository(); 125 assertEquals("Failed to set TEST_KEY1", or.getState("TEST_KEY1").toString(), "my very elderly mother just sent us nine pizzas"); 126 assertEquals("Failed to set TEST_KEY2", or.getState("TEST_KEY2").toString(), "sometimes you feel like a nut, sometimes you don't"); 127 assertEquals("Failed to set TEST_KEY3", or.getState("TEST_KEY3"), or.getState("TEST_KEY2").toString()); 128 assertEquals("Failed to set TEST_KEY4", or.getState("TEST_KEY4"), ObjectRepositoryAssembler.class); 129 assertTrue("Failed to set TEST_KEY5", or.getState("TEST_KEY5")!=null); 130 131 134 135 } 136 } 137 | Popular Tags |