Skip to content

Commit

Permalink
[JENKINS-43624] more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrille Le Clerc committed May 7, 2017
1 parent b3e05bb commit f7ae91b
Showing 1 changed file with 20 additions and 0 deletions.
@@ -1,5 +1,6 @@
package org.jenkinsci.plugins.pipeline.maven.util;

import hudson.FilePath;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Before;
Expand All @@ -8,6 +9,7 @@
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.Arrays;
Expand Down Expand Up @@ -129,4 +131,22 @@ public void concatenate_two_strings(){
String actual = XmlUtils.join(elements, ",");
Assert.assertThat(actual, CoreMatchers.is("a,b,c"));
}

@Test
public void test_getPathInWorkspace_linux(){
String workspace = "/path/to/spring-petclinic";
String absolutePath = "/path/to/spring-petclinic/pom.xml";
String actual = XmlUtils.getPathInWorkspace(absolutePath, new FilePath(new File(workspace)));
String expected = "pom.xml";
Assert.assertThat(actual, CoreMatchers.is(expected));
}

@Test
public void test_getPathInWorkspace_windows(){
String workspace = "C:\\path\\to\\spring-petclinic";
String absolutePath = "C:\\path\\to\\spring-petclinic\\pom.xml";
String actual = XmlUtils.getPathInWorkspace(absolutePath, new FilePath(new File(workspace)));
String expected = "pom.xml";
Assert.assertThat(actual, CoreMatchers.is(expected));
}
}

0 comments on commit f7ae91b

Please sign in to comment.