KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > labelincrementers > DefaultLabelIncrementerTest


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.labelincrementers;
38
39 import junit.framework.TestCase;
40
41 public class DefaultLabelIncrementerTest extends TestCase {
42
43     private DefaultLabelIncrementer incrementer;
44
45     public DefaultLabelIncrementerTest(String JavaDoc name) {
46         super(name);
47     }
48
49     public void setUp() {
50         incrementer = new DefaultLabelIncrementer();
51     }
52
53     public void testIsValidLabel() {
54         assertTrue(incrementer.isValidLabel("x.88"));
55         assertFalse(incrementer.isValidLabel("x.y"));
56         assertFalse(incrementer.isValidLabel("x88"));
57         
58         incrementer.setSeparator("#");
59         assertFalse(incrementer.isValidLabel("x.88"));
60         assertTrue(incrementer.isValidLabel("x#88"));
61         
62         incrementer = new DefaultLabelIncrementer();
63         assertTrue(incrementer.isValidLabel("x.88"));
64         assertFalse(incrementer.isValidLabel("x#88"));
65     }
66
67     public void testIncrementLabel() {
68         assertEquals("x.89", incrementer.incrementLabel("x.88", null));
69     }
70
71     public void testSetPreBuildIncrementer() {
72         assertFalse(incrementer.isPreBuildIncrementer());
73         incrementer.setPreBuildIncrementer(true);
74         assertTrue(incrementer.isPreBuildIncrementer());
75
76         incrementer = new DefaultLabelIncrementer();
77         assertFalse(incrementer.isPreBuildIncrementer());
78     }
79     
80     public void testGetDefaultLabel() {
81         assertEquals("build.1", incrementer.getDefaultLabel());
82         incrementer.setSeparator("#");
83         assertEquals("build#1", incrementer.getDefaultLabel());
84         assertTrue(incrementer.isValidLabel(incrementer.getDefaultLabel()));
85     }
86
87     public void testDefaultLabel() {
88         incrementer.setDefaultLabel("foo.69");
89         assertEquals("foo.69", incrementer.getDefaultLabel());
90     }
91
92     public void testDefaultLabelNonDefaultSeparator() {
93         incrementer.setDefaultLabel("R_604");
94         incrementer.setSeparator("_");
95         assertEquals("R_604", incrementer.getDefaultLabel());
96     }
97
98 }
99
Popular Tags