@@ -142,20 +142,66 @@ public void setupXvfbInstallations() throws IOException {
setupXvfbInstallations (system .jenkins , tempDir );
}
@ Test
public void shouldCreateCommandLineArguments () throws IOException {
final Xvfb xvfb = new Xvfb ();
xvfb .setInstallationName ("cmd" );
xvfb .setDisplayName (42 );
final XvfbInstallation installation = new XvfbInstallation ("cmd" , "/usr/local/cmd-xvfb" , null );
final File tempDirRoot = tempDir .getRoot ();
final ArgumentListBuilder arguments = xvfb .createCommandArguments (installation , new FilePath (tempDirRoot ), 42 );
assertThat (arguments .toList (), contains ("/usr/local/cmd-xvfb/Xvfb" , ":42" , "-screen" , "0" , Xvfb .DEFAULT_SCREEN , "-fbdir" , tempDirRoot .getAbsolutePath ()));
}
@ Test
@ Issue ("JENKINS-32039" )
public void shouldCreateCommandLineArgumentsWithoutScreenIfEmpty () throws IOException {
final Xvfb xvfb = new Xvfb ();
xvfb .setInstallationName ("cmd" );
xvfb .setDisplayName (42 );
xvfb .setScreen ("" );
final XvfbInstallation installation = new XvfbInstallation ("cmd" , "/usr/local/cmd-xvfb" , null );
final File tempDirRoot = tempDir .getRoot ();
final ArgumentListBuilder arguments = xvfb .createCommandArguments (installation , new FilePath (tempDirRoot ), 42 );
assertThat (arguments .toList (), contains ("/usr/local/cmd-xvfb/Xvfb" , ":42" , "-fbdir" , tempDirRoot .getAbsolutePath ()));
}
@ Test
@ Issue ("JENKINS-32039" )
public void shouldCreateCommandLineArgumentsWithoutScreenIfNotGiven () throws IOException {
final Xvfb xvfb = new Xvfb ();
xvfb .setInstallationName ("cmd" );
xvfb .setDisplayName (42 );
xvfb .setScreen (null );
final XvfbInstallation installation = new XvfbInstallation ("cmd" , "/usr/local/cmd-xvfb" , null );
final File tempDirRoot = tempDir .getRoot ();
final ArgumentListBuilder arguments = xvfb .createCommandArguments (installation , new FilePath (tempDirRoot ), 42 );
assertThat (arguments .toList (), contains ("/usr/local/cmd-xvfb/Xvfb" , ":42" , "-fbdir" , tempDirRoot .getAbsolutePath ()));
}
@ SuppressWarnings ("unchecked" )
@ Test
public void shouldAbortIfInstallationIsNotFound () throws Exception {
public void shouldFailIfInstallationIsNotFound () throws Exception {
final Xvfb xvfb = new Xvfb ();
xvfb .setInstallationName ("nonexistant" );
final FreeStyleProject project = createFreeStyleJob (system , "shouldAbortIfInstallationIsNotFound " );
final FreeStyleProject project = createFreeStyleJob (system , "shouldFailIfInstallationIsNotFound " );
setupXvfbOn (project , xvfb );
final QueueTaskFuture <FreeStyleBuild > buildResult = project .scheduleBuild2 (0 );
final FreeStyleBuild build = buildResult .get ();
system .assertBuildStatus (Result .ABORTED , build );
system .assertBuildStatus (Result .FAILURE , build );
final List <String > logLines = build .getLog (10 );
@@ -164,17 +210,17 @@ public void shouldAbortIfInstallationIsNotFound() throws Exception {
@ SuppressWarnings ("unchecked" )
@ Test
public void shouldAbortIfNoInstallationIsDefined () throws Exception {
public void shouldFailIfNoInstallationIsDefined () throws Exception {
final Xvfb xvfb = new Xvfb ();
final FreeStyleProject project = createFreeStyleJob (system , "shouldAbortIfNoInstallationIsDefined " );
final FreeStyleProject project = createFreeStyleJob (system , "shouldFailIfNoInstallationIsDefined " );
setupXvfbOn (project , xvfb );
final QueueTaskFuture <FreeStyleBuild > buildResult = project .scheduleBuild2 (0 );
final FreeStyleBuild build = buildResult .get ();
system .assertBuildStatus (Result .ABORTED , build );
system .assertBuildStatus (Result .FAILURE , build );
final List <String > logLines = build .getLog (10 );
@@ -184,12 +230,12 @@ public void shouldAbortIfNoInstallationIsDefined() throws Exception {
@ SuppressWarnings ("unchecked" )
@ Test
@ Issue ("JENKINS-18094" )
public void shouldAbortIfXvfbFailsToStart () throws Exception {
public void shouldFailIfXvfbFailsToStart () throws Exception {
final Xvfb xvfb = new Xvfb ();
xvfb .setInstallationName ("failing" );
xvfb .setTimeout (10 );
final FreeStyleProject project = createFreeStyleJob (system , "shouldAbortIfXvfbFailsToStart " );
final FreeStyleProject project = createFreeStyleJob (system , "shouldFailIfXvfbFailsToStart " );
setupXvfbOn (project , xvfb );
final QueueTaskFuture <FreeStyleBuild > buildResult = project .scheduleBuild2 (0 );
@@ -205,52 +251,6 @@ public void shouldAbortIfXvfbFailsToStart() throws Exception {
}
@ Test
public void shouldCreateCommandLineArguments () throws IOException {
final Xvfb xvfb = new Xvfb ();
xvfb .setInstallationName ("cmd" );
xvfb .setDisplayName (42 );
final XvfbInstallation installation = new XvfbInstallation ("cmd" , "/usr/local/cmd-xvfb" , null );
final File tempDirRoot = tempDir .getRoot ();
final ArgumentListBuilder arguments = xvfb .createCommandArguments (installation , new FilePath (tempDirRoot ), 42 );
assertThat (arguments .toList (), contains ("/usr/local/cmd-xvfb/Xvfb" , ":42" , "-screen" , "0" , Xvfb .DEFAULT_SCREEN , "-fbdir" , tempDirRoot .getAbsolutePath ()));
}
@ Test
@ Issue ("JENKINS-32039" )
public void shouldCreateCommandLineArgumentsWithoutScreenIfNotGiven () throws IOException {
final Xvfb xvfb = new Xvfb ();
xvfb .setInstallationName ("cmd" );
xvfb .setDisplayName (42 );
xvfb .setScreen (null );
final XvfbInstallation installation = new XvfbInstallation ("cmd" , "/usr/local/cmd-xvfb" , null );
final File tempDirRoot = tempDir .getRoot ();
final ArgumentListBuilder arguments = xvfb .createCommandArguments (installation , new FilePath (tempDirRoot ), 42 );
assertThat (arguments .toList (), contains ("/usr/local/cmd-xvfb/Xvfb" , ":42" , "-fbdir" , tempDirRoot .getAbsolutePath ()));
}
@ Test
@ Issue ("JENKINS-32039" )
public void shouldCreateCommandLineArgumentsWithoutScreenIfEmpty () throws IOException {
final Xvfb xvfb = new Xvfb ();
xvfb .setInstallationName ("cmd" );
xvfb .setDisplayName (42 );
xvfb .setScreen ("" );
final XvfbInstallation installation = new XvfbInstallation ("cmd" , "/usr/local/cmd-xvfb" , null );
final File tempDirRoot = tempDir .getRoot ();
final ArgumentListBuilder arguments = xvfb .createCommandArguments (installation , new FilePath (tempDirRoot ), 42 );
assertThat (arguments .toList (), contains ("/usr/local/cmd-xvfb/Xvfb" , ":42" , "-fbdir" , tempDirRoot .getAbsolutePath ()));
}
@ Test
public void shouldHonourSpecifiedDisplayNameOffset () throws Exception {
final Xvfb xvfb = new Xvfb ();