KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > bootstrappers > CurrentBuildStatusFTPBootstrapperTest


1 /********************************************************************************
2  * CruiseControl, a Continuous Integration Toolkit
3  * Copyright (c) 2001, ThoughtWorks, Inc.
4  * 651 W Washington Ave. Suite 600
5  * Chicago, IL 60661 USA
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * + Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * + Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  *
20  * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
21  * names of its contributors may be used to endorse or promote
22  * products derived from this software without specific prior
23  * written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
29  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  ********************************************************************************/

37 package net.sourceforge.cruisecontrol.bootstrappers;
38
39 import java.text.SimpleDateFormat JavaDoc;
40 import java.util.ArrayList JavaDoc;
41 import java.util.Date JavaDoc;
42 import java.util.Iterator JavaDoc;
43 import java.util.List JavaDoc;
44 import java.io.File JavaDoc;
45
46 import junit.framework.TestCase;
47 import net.sourceforge.cruisecontrol.CruiseControlException;
48
49 /**
50  * @deprecated Tests deprecated code
51  */

52 public class CurrentBuildStatusFTPBootstrapperTest extends TestCase {
53     private final List JavaDoc filesToClear = new ArrayList JavaDoc();
54
55     public CurrentBuildStatusFTPBootstrapperTest(String JavaDoc name) {
56         super(name);
57     }
58
59     public void tearDown() {
60         for (Iterator JavaDoc iterator = filesToClear.iterator(); iterator.hasNext();) {
61             File JavaDoc file = (File JavaDoc) iterator.next();
62             if (file.exists()) {
63                 file.delete();
64             }
65         }
66     }
67
68     public void testValidate1() {
69         CurrentBuildStatusFTPBootstrapper cbsfb =
70             new CurrentBuildStatusFTPBootstrapper();
71         try {
72             cbsfb.validate();
73             fail("did not fail for unset properties");
74         } catch (CruiseControlException cce) {
75             // test exception?
76
}
77     }
78
79     public void testValidate2() {
80         CurrentBuildStatusFTPBootstrapper cbsfb =
81             new CurrentBuildStatusFTPBootstrapper();
82         cbsfb.setTargetHost("x");
83         try {
84             cbsfb.validate();
85             fail("'file' should be a required attribute on CurrentBuildStatusFTPBootstrapper");
86         } catch (CruiseControlException cce) {
87             // test exception?
88
}
89     }
90
91     public void testValidate3() {
92         CurrentBuildStatusFTPBootstrapper cbsfb =
93             new CurrentBuildStatusFTPBootstrapper();
94         cbsfb.setFile("x");
95         try {
96             cbsfb.validate();
97             fail("'targetHost' should be a required attribute on CurrentBuildStatusFTPBootstrapper");
98         } catch (CruiseControlException cce) {
99             // test exception?
100
}
101     }
102     
103     public void testValidate4() throws Exception JavaDoc {
104         CurrentBuildStatusFTPBootstrapper cbsfb =
105             new CurrentBuildStatusFTPBootstrapper();
106         cbsfb.setTargetHost("x");
107         cbsfb.setFile("x");
108         cbsfb.setDestDir("x");
109         cbsfb.validate();
110     }
111
112     public void testMakeFile1() throws Exception JavaDoc {
113         CurrentBuildStatusFTPBootstrapper cbsfb =
114             new CurrentBuildStatusFTPBootstrapper();
115         cbsfb.setFile("_testCurrentBuildStatus1.txt");
116         filesToClear.add(new File JavaDoc("_testCurrentBuildStatus1.txt"));
117         
118         // This should be equivalent to the date used in bootstrap at seconds
119
// precision
120
SimpleDateFormat JavaDoc formatter = new SimpleDateFormat JavaDoc("MM/dd/yyyy HH:mm:ss");
121         String JavaDoc expected =
122             "Current Build Started At:\n"
123             + formatter.format(new Date JavaDoc());
124         String JavaDoc out = cbsfb.makeFile();
125         assertEquals(expected, out);
126     }
127 }
128
Popular Tags