Skip to content
Permalink
Browse files
separated test for JENKINS-27203.
added test for std form ${VAR]
  • Loading branch information
15knots committed Jun 17, 2015
1 parent 56083b1 commit fd0ab9acd957bfe4739c86744483598c3c73351f
Showing with 28 additions and 10 deletions.
  1. +28 −10 src/test/java/hudson/plugins/cmake/EnvVarReplacerTest.java
@@ -1,6 +1,7 @@
package hudson.plugins.cmake;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.HashMap;
@@ -11,22 +12,39 @@

@Test
public void checkReplacement() throws Exception {
String strWithEnvVars = "Is $HOME in $PATH? $NODE $NODE_ID";
String desired = "Is /home/jonnyro in /usr/bin/;/usr/local/bin/? abc123 987";
String strWithEnvVars = "Is $HOME in $PATH?";
String desired = "Is /home/jonnyro in /usr/bin/;/usr/local/bin/?";
HashMap<String,String> envVars = new HashMap<String,String>();

envVars.put("HOME","/home/jonnyro");
envVars.put("HOME","/home/jonnyro");
envVars.put("PATH","/usr/bin/;/usr/local/bin/");
envVars.put("NODE","abc123");
envVars.put("NODE_ID","987");

EnvVarReplacer e = new EnvVarReplacer();

String res = e.replace(strWithEnvVars, envVars);

assertTrue("'" + res + "'!='" + desired + "'", res.equals(desired) );
String res = EnvVarReplacer.replace(strWithEnvVars, envVars);

assertTrue("'" + res + "'!='" + desired + "'", res.equals(desired) );
}

@Test
// @Issue("JENKINS-27203")
public final void testExpandLengthDependent() {
String strWithEnvVars = "Is $HOME in? $NODE $NODE_ID";
String expected = "Is $HOME in? abc123 987";

HashMap<String,String> envVars = new HashMap<String,String>();
envVars.put("NODE","abc123");
envVars.put("NODE_ID","987");
String res = EnvVarReplacer.replace(strWithEnvVars, envVars);
assertEquals(expected,res);
}

@Test
public final void testBracketedFrorm() {
HashMap<String,String> envVars = new HashMap<String,String>();
envVars.put("NODE","abc123");
envVars.put("NODE_ID","987");
// test whether the usual syntax of jenkins is supported
String strWithEnvVars = "Is ${HOME} in? ${NODE} ${NODE_ID}";
String res = EnvVarReplacer.replace(strWithEnvVars, envVars);
assertEquals("Is ${HOME} in? abc123 987",res);
}
}

0 comments on commit fd0ab9a

Please sign in to comment.