@Test
  public void assertNoComputeraDoesNotThrowNPEWhenResolvingNodeName() {
    when(launcher.getComputer()).thenReturn(null);

    BuildVariableResolver resolver = new BuildVariableResolver(project, launcher);
    assertNull("Variable resolution was incorrect", resolver.resolve("NODE_NAME"));
    verifyZeroInteractions(project);
  }
  @Test
  public void assertNodeNameIsResolved() {
    Computer computer = mock(Computer.class);
    when(launcher.getComputer()).thenReturn(computer);
    when(computer.getName()).thenReturn("AKIRA");

    BuildVariableResolver resolver = new BuildVariableResolver(project, launcher);
    assertEquals("Variable resolution was incorrect", "AKIRA", resolver.resolve("NODE_NAME"));
    verifyZeroInteractions(project);
  }
  @Test
  public void assertComputerUserNameIsResolved() throws Exception {
    Map<Object, Object> map = new HashMap<Object, Object>();
    map.put("user.name", "Other_user");

    Computer computer = mock(Computer.class);
    when(launcher.getComputer()).thenReturn(computer);
    when(computer.getSystemProperties()).thenReturn(map);

    BuildVariableResolver resolver = new BuildVariableResolver(project, launcher);
    assertEquals("Variable resolution was incorrect", "Other_user", resolver.resolve("USER_NAME"));
    verifyZeroInteractions(project);
  }
  @Test
  public void assertComputerEnvVarIsResolved() throws Exception {
    Map<String, String> map = new HashMap<String, String>();
    map.put("ENV_VAR", "This is an env var");

    Computer computer = mock(Computer.class);
    when(launcher.getComputer()).thenReturn(computer);
    when(computer.getEnvVars()).thenReturn(map);

    BuildVariableResolver resolver = new BuildVariableResolver(project, launcher);
    assertEquals(
        "Variable resolution was incorrect", "This is an env var", resolver.resolve("ENV_VAR"));
    verifyZeroInteractions(project);
  }
示例#5
0
 @Override
 public Computer getComputer() {
     return inner.getComputer();
 }