Skip to content

Commit

Permalink
RW-602: Added project phantom execution unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-russell committed Feb 9, 2015
1 parent e064bc5 commit 3565c73
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions test/src/test/java/com/revo/deployr/client/RProjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.revo.deployr.client.about.RProjectDetails;
import com.revo.deployr.client.auth.basic.RBasicAuthentication;
import com.revo.deployr.client.factory.RClientFactory;
import com.revo.deployr.client.params.ProjectExecutionOptions;
import com.revo.deployr.client.params.ProjectDropOptions;
import org.junit.*;

Expand Down Expand Up @@ -417,6 +418,68 @@ public void testProjectTestSaveRProjectDetailsDropOptionsTrue() {
}
}

/**
* Test of phantom property of class ProjectExecutionOptions.
*/
@Test
public void testProjectPhantomExecution() {

// Test variables.
String code = "x<-1";
RProject rTempProject = null;
RProjectExecution codeResult = null;
List<RProjectExecution> projectHistoryList = null;

// Test error handling.
Exception exception = null;
String exceptionMsg = "";
Exception cleanupException = null;
String cleanupExceptionMsg = "";

// Test.
rTempProject = DeployrUtil.createTemporaryProject(rUser);
try {
ProjectExecutionOptions options =
new ProjectExecutionOptions();
options.phantom = true;
codeResult = rTempProject.executeCode(code, options);
} catch (Exception ex) {
exception = ex;
exceptionMsg = "rTempProject.executeCode failed: ";
}

if (exception == null) {
try {
projectHistoryList = rTempProject.getHistory();
} catch (Exception ex) {
exception = ex;
exceptionMsg = "rTempProject.getHistory failed: ";
}
}

// Test cleanup.
try {
if (rTempProject != null) {
rTempProject.close();
}
} catch (Exception ex) {
cleanupException = ex;
cleanupExceptionMsg = "rTempProject.close failed: ";
}

// Test asserts.
if (exception == null) {
assertEquals(projectHistoryList.size(), 0);
} else {
fail(exceptionMsg + exception.getMessage());
}

// Test cleanup errors.
if (cleanupException != null) {
fail(cleanupExceptionMsg + cleanupException.getMessage());
}
}

/**
* Test of saveAs method, of class RProject.
*/
Expand Down

0 comments on commit 3565c73

Please sign in to comment.