@Test
public void testNewWithVarArgs() throws Exception {
final String firstString = "hello";
final String secondString = "world";
ExpectNewDemo tested = new ExpectNewDemo();
VarArgsConstructorDemo varArgsConstructorDemoMock = mock(VarArgsConstructorDemo.class);
whenNew(VarArgsConstructorDemo.class).withArguments(firstString, secondString).thenReturn(
varArgsConstructorDemoMock);
when(varArgsConstructorDemoMock.getAllMessages()).thenReturn(new String[] { firstString, secondString });
String[] varArgs = tested.newVarArgs(firstString, secondString);
assertEquals(2, varArgs.length);
assertEquals(firstString, varArgs[0]);
assertEquals(secondString, varArgs[1]);
verifyNew(VarArgsConstructorDemo.class).withArguments(firstString, secondString);