1 23 24 30 31 package com.sun.enterprise.config.backup; 32 33 import com.sun.enterprise.config.backup.*; 34 import com.sun.enterprise.util.io.FileUtils; 35 import java.io.*; 36 import junit.framework.*; 37 38 42 public class BackupRequestTest extends TestCase 43 { 44 45 public BackupRequestTest(java.lang.String testName) 46 { 47 super(testName); 48 } 49 50 public static Test suite() 51 { 52 TestSuite suite = new TestSuite(BackupRequestTest.class); 53 return suite; 54 } 55 56 57 public void testBadCtor() 58 { 59 System.out.println("testVerifyInfo"); 60 try 61 { 62 BackupRequest req = new BackupRequest(null, null); 63 BackupManager mgr = new BackupManager(req); 64 } 65 catch(NullPointerException e) 66 { 67 System.out.println(e); 68 return; 69 } 70 catch(BackupException be) 71 { 72 System.out.println(be); 73 return; 74 } 75 fail("Should have got an Exception!"); 76 } 77 78 public void testBadDomainsDir() 79 { 80 System.out.println("testBadDomainsDir"); 81 try 82 { 83 BackupRequest req = new BackupRequest("w:/foo", "goo"); 84 BackupManager mgr = new BackupManager(req); 85 } 86 catch(BackupException be) 87 { 88 System.out.println(be); 89 return; 90 } 91 fail("Should have got an Exception!"); 92 } 93 94 public void testGoodDomainsDir() 95 { 96 System.out.println("testGoodDomainsDir"); 97 File f = new File("c:/temp/goo"); 98 f.mkdirs(); 99 try 100 { 101 BackupRequest req = new BackupRequest("c:/temp", "goo"); 102 BackupManager mgr = new BackupManager(req); 103 } 104 catch(BackupException be) 105 { 106 System.out.println(be); 107 fail("Should not have got an Exception!"); 108 } 109 finally 110 { 111 FileUtils.whack(f); 112 } 113 } 114 public void testBadDomainName() 115 { 116 System.out.println("testBadDomainName"); 117 try 118 { 119 BackupRequest req = new BackupRequest("c:/temp", ""); 120 BackupManager mgr = new BackupManager(req); 121 } 122 catch(BackupException be) 123 { 124 System.out.println(be); 125 return; 126 } 127 fail("Should have got an Exception!"); 128 } 129 public void testGoodDomainNameButNotExisting() 130 { 131 System.out.println("testGoodDomainName"); 132 try 133 { 134 File f = new File("c:/temp/goo"); 135 FileUtils.whack(f); 136 BackupRequest req = new BackupRequest("c:/temp", "goo"); 137 BackupManager mgr = new BackupManager(req); 138 } 139 catch(BackupException be) 140 { 141 System.out.println(be); 142 return; 143 } 144 145 fail("Should have got an Exception!"); 146 } 147 public void testGoodDomainName() 148 { 149 System.out.println("testGoodDomainName"); 150 File f = new File("c:/temp/goo"); 151 f.mkdirs(); 152 try 153 { 154 BackupRequest req = new BackupRequest("c:/temp", "goo"); 155 BackupManager mgr = new BackupManager(req); 156 } 157 catch(BackupException be) 158 { 159 System.out.println(be); 160 fail("Should not have got an Exception!"); 161 } 162 finally 163 { 164 FileUtils.whack(f); 165 } 166 } 167 168 public void testBadBackupFile() 169 { 170 System.out.println("testBadBackupFile"); 171 File f = new File("c:/temp/goo"); 172 try 173 { 174 f.mkdirs(); 175 BackupRequest req = new BackupRequest("c:/temp", "goo", "c:/temp/q.zip"); 176 BackupManager mgr = new BackupManager(req); 177 } 178 catch(BackupException be) 179 { 180 System.out.println(be); 181 return; 182 } 183 finally 184 { 185 FileUtils.whack(f); 186 } 187 fail("Should have got an Exception!"); 188 } 189 190 public static void main(java.lang.String [] args) 191 { 192 junit.textui.TestRunner.run(suite()); 193 } 194 } 195 | Popular Tags |