1 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 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 |