1 23 24 package com.sun.enterprise.admin.servermgmt.pe; 25 26 import junit.framework.*; 27 import java.util.HashMap ; 28 import java.util.Map ; 29 import com.sun.enterprise.admin.servermgmt.DomainConfig; 30 import java.util.Properties ; 31 import com.sun.enterprise.admin.servermgmt.InvalidConfigException; 32 37 38 public class PEDomainConfigValidatorTest extends TestCase { 39 public void testNumPorts(){ 40 assertEquals(7, dc2.getPorts().size()); 41 } 42 43 public void testDuplicatesInDomainConfig() { 44 try { 45 p.uniquePorts(dc2); 46 fail("Expectged an InvalidConfigException indicating that there were duplicate ports"); 47 } 48 catch (InvalidConfigException e){ 49 assertEquals("Duplicate ports were found: 1 -> {domain.adminPort, domain.instancePort, http.ssl.port, jms.port}, 2 -> {orb.listener.port, orb.ssl.port}", e.getMessage()); 50 } 51 } 52 53 public void testNoDuplicatesInDomainConfig() throws Exception { 54 p.uniquePorts(dc1); 55 } 56 57 public void testNoDuplicatePorts(){ 58 final Map ports = new HashMap (); 59 ports.put("a", "1"); 60 assertEquals("", p.getDuplicatePorts(ports)); 61 } 62 63 public void testGetDuplicatePorts() { 64 final Map ports = new HashMap (); 65 ports.put("a", "1"); 66 ports.put("b", "1"); 67 ports.put("c", "2"); 68 ports.put("d", "2"); 69 ports.put("e", "3"); 70 assertEquals("1 -> {a, b}, 2 -> {c, d}", p.getDuplicatePorts(ports)); 71 } 72 73 public PEDomainConfigValidatorTest(String name){ 74 super(name); 75 } 76 77 PEDomainConfigValidator p; 78 DomainConfig dc1, dc2; 79 80 protected void setUp() throws Exception { 81 p = new PEDomainConfigValidator(); 82 dc1 = new DomainConfig("domainName", 83 new Integer (1), 84 "domainRoot", 85 "adminUser", 86 "adminPassword", 87 "masterPassword", 88 new Integer (2), 89 "jmsUser", 90 "jmsPassword", 91 new Integer (3), 92 new Integer (4), 93 new Integer (5), 94 new Integer (6), 95 new Integer (7), 96 new Properties ()){ 97 protected String getFilePath(String p){ 98 return p; 99 } 100 }; 101 dc2 = new DomainConfig("domainName", 102 new Integer (1), 103 "domainRoot", 104 "adminUser", 105 "adminPassword", 106 new Integer (1), 107 "jmsUser", 108 "jmsPassword", 109 new Integer (1), 110 new Integer (2), 111 new Integer (1), 112 new Integer (2), 113 new Integer (3), 114 new Properties ()){ 115 protected String getFilePath(String p){ 116 return p; 117 } 118 }; 119 } 120 121 122 protected void tearDown() { 123 } 124 125 private void nyi(){ 126 fail("Not Yet Implemented"); 127 } 128 129 public static void main(String args[]){ 130 if (args.length == 0){ 131 junit.textui.TestRunner.run(PEDomainConfigValidatorTest.class); 132 } else { 133 junit.textui.TestRunner.run(makeSuite(args)); 134 } 135 } 136 private static TestSuite makeSuite(String args[]){ 137 final TestSuite ts = new TestSuite(); 138 for (int i = 0; i < args.length; i++){ 139 ts.addTest(new PEDomainConfigValidatorTest(args[i])); 140 } 141 return ts; 142 } 143 144 } 145 | Popular Tags |