/** Test password with & and ! characters */ @Test public void testPasswordStrange() throws Exception { final String username = "******"; final String password = "******"; final String remoteName = "myRemote"; // specify remote and username CommandInvoker commandInvoker = getInvoker().argument("username", username).option("--remote", remoteName); // set strange password ! commandInvoker.setSystemIn(password + System.lineSeparator()); // Mock remote CommandSession commandSession = commandInvoker.getCommandSession(); Mockito.reset(commandSession); MultiRemoteCodenvy remoteCodenvy = mock(MultiRemoteCodenvy.class); doReturn(remoteCodenvy).when(commandSession).get(MultiRemoteCodenvy.class.getName()); doReturn(true).when(remoteCodenvy).hasAvailableRemotes(); // Check we have the same password in input doAnswer( new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); Assert.assertEquals(args[0], remoteName); Assert.assertEquals(args[1], username); Assert.assertEquals(args[2], password); return null; } }) .when(remoteCodenvy) .login(anyString(), anyString(), anyString()); // invoke command commandInvoker.invoke(); }