1 package org.apache.turbine.om.security; 2 3 18 19 import junit.framework.Test; 20 import junit.framework.TestSuite; 21 22 import org.apache.cactus.ServletTestCase; 23 import org.apache.turbine.Turbine; 24 import java.util.*; 25 26 35 public class TurbineUserTest extends ServletTestCase 36 { 37 38 Turbine turbine = null; 39 40 44 public TurbineUserTest(String name) 45 { 46 super(name); 47 } 48 49 53 54 protected void setUp() throws Exception 55 { 56 super.setUp(); 57 58 config.setInitParameter("properties", "/WEB-INF/conf/TurbineComplete.properties"); 59 turbine = new Turbine(); 60 turbine.init(config); 61 } 62 63 68 protected void tearDown() throws Exception 69 { 70 turbine.destroy(); 71 super.tearDown(); 72 } 73 74 79 public static Test suite() 80 { 81 return new TestSuite(TurbineUserTest.class); 82 } 83 84 88 public void testCreatingTurbineUser() throws Exception 89 { 90 TurbineUser user = null; 91 92 user = new TurbineUser(); 93 94 assertNotNull(user); 95 } 96 97 public void testSavingAndStoringTemporaryValues() throws Exception 98 { 99 TurbineUser user = new TurbineUser(); 100 user.setTemp("test", "value"); 101 assertEquals("value", user.getTemp("test")); 102 103 assertNull(user.getTemp("nonexistentvalue")); 104 assertEquals("defaultvalue", user.getTemp("nonexistentvalues", "defaultvalue")); 105 Hashtable htTemp = new Hashtable(); 106 htTemp.put("test1", "value1"); 107 htTemp.put("test2", new Integer (5)); 108 109 user.setTempStorage(htTemp); 110 assertEquals("value1", user.getTemp("test1")); 111 Integer retVal = (Integer ) user.getTemp("test2"); 112 assertTrue(retVal.intValue() == 5); 113 assertNull(user.getTemp("test")); 114 } 115 116 public void testSavingAndStoringPermValues() throws Exception 117 { 118 TurbineUser user = new TurbineUser(); 119 user.setPerm("test", "value"); 120 assertEquals("value", user.getPerm("test")); 121 122 assertNull(user.getPerm("nonexistentvalue")); 123 assertEquals("defaultvalue", user.getPerm("nonexistentvalues", "defaultvalue")); 124 125 Hashtable htPerm = new Hashtable(); 126 htPerm.put("test1", "value1"); 127 htPerm.put("test2", new Integer (5)); 128 129 user.setPermStorage(htPerm); 130 assertEquals("value1", user.getPerm("test1")); 131 Integer retVal = (Integer ) user.getPerm("test2"); 132 assertTrue(retVal.intValue() == 5); 133 assertNull(user.getPerm("test")); 134 } 135 } 136 | Popular Tags |