KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > backup > BackupRequestTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * BackupRequestTest.java
26  * JUnit based test
27  *
28  * Created on March 18, 2004, 1:23 PM
29  */

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 /**
39  *
40  * @author Byron Nevins
41  */

42 public class BackupRequestTest extends TestCase
43 {
44     
45     public BackupRequestTest(java.lang.String JavaDoc 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     /** Test of verifyInfo method, of class com.sun.enterprise.config.backup.BackupRequest. */
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 JavaDoc 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 JavaDoc[] args)
191     {
192         junit.textui.TestRunner.run(suite());
193     }
194 }
195
Popular Tags