Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-17096] Convert OS specific separators upfront in ConfigSpec
Raw config spec may have been defined with different OS separators, leading to issues when comparing them.
- Loading branch information
Showing
4 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/test/java/hudson/plugins/clearcase/ConfigSpecTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package hudson.plugins.clearcase; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.IOException; | ||
import java.util.Set; | ||
|
||
import hudson.util.IOUtils; | ||
|
||
import org.junit.Test; | ||
|
||
public class ConfigSpecTest { | ||
|
||
@Test | ||
public void testConfigSpecDifferentOS() { | ||
ConfigSpec cs1 = new ConfigSpec("element /MyVOB/... .../MyBranch/LATEST", true); | ||
ConfigSpec cs2 = new ConfigSpec("element \\MyVOB\\... ...\\MyBranch\\LATEST", true); | ||
assertEquals(cs1, cs2); | ||
} | ||
|
||
@Test | ||
public void testExtractLoadRulesUnix() throws IOException { | ||
String rawCs = IOUtils.toString(getClass().getResourceAsStream("ct-catcs-2-CRLF.log")); | ||
ConfigSpec cs = new ConfigSpec(rawCs, true); | ||
Set<String> loadRules = cs.getLoadRules(); | ||
assertEquals(1, loadRules.size()); | ||
assertEquals("/a/b", loadRules.iterator().next()); | ||
} | ||
|
||
@Test | ||
public void testLineEndings() throws IOException { | ||
String rawCs1 = IOUtils.toString(getClass().getResourceAsStream("ct-catcs-2-LF.log")); | ||
String rawCs2 = IOUtils.toString(getClass().getResourceAsStream("ct-catcs-2-CRLF.log")); | ||
ConfigSpec cs1 = new ConfigSpec(rawCs1, true); | ||
ConfigSpec cs2 = new ConfigSpec(rawCs2, true); | ||
assertEquals(cs1, cs2); | ||
} | ||
|
||
@Test | ||
public void testExtractLoadRulesWindows() throws IOException { | ||
String rawCs = IOUtils.toString(getClass().getResourceAsStream("ct-catcs-2-CRLF.log")); | ||
ConfigSpec cs = new ConfigSpec(rawCs, false); | ||
Set<String> loadRules = cs.getLoadRules(); | ||
assertEquals(1, loadRules.size()); | ||
assertEquals("\\a\\b", loadRules.iterator().next()); | ||
} | ||
|
||
@Test | ||
public void testStripLoadRulesWindows() throws IOException { | ||
String rawCs = IOUtils.toString(getClass().getResourceAsStream("ct-catcs-2-CRLF.log")); | ||
ConfigSpec cs = new ConfigSpec(rawCs, false); | ||
cs = cs.stripLoadRules(); | ||
assertTrue(cs.getLoadRules().isEmpty()); | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
src/test/resources/hudson/plugins/clearcase/ct-catcs-2-CRLF.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
element * CHECKEDOUT | ||
element * ...\rel2_bugfix\LATEST | ||
element * \main\LATEST -mkbranch rel2_bugfix | ||
|
||
load \a\b |
5 changes: 5 additions & 0 deletions
5
src/test/resources/hudson/plugins/clearcase/ct-catcs-2-LF.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
element * CHECKEDOUT | ||
element * .../rel2_bugfix/LATEST | ||
element * /main/LATEST -mkbranch rel2_bugfix | ||
|
||
load /a/b |