use of org.jmock.Expectations in project gradle by gradle.
the class LineBufferingOutputStreamTest method logsPartialLineOnFlush.
@Test
public void logsPartialLineOnFlush() throws IOException {
LineBufferingOutputStream outputStream = new LineBufferingOutputStream(action, 8);
context.checking(new Expectations() {
{
one(action).text("line 1");
}
});
outputStream.write("line 1".getBytes());
outputStream.flush();
}
use of org.jmock.Expectations in project gradle by gradle.
the class DefaultProjectDescriptorTest method setName.
@Test
public void setName() {
final String newName = "newName";
final ProjectDescriptorRegistry projectDescriptorRegistryMock = context.mock(ProjectDescriptorRegistry.class);
projectDescriptor.setProjectDescriptorRegistry(projectDescriptorRegistryMock);
context.checking(new Expectations() {
{
one(projectDescriptorRegistryMock).changeDescriptorPath(Path.path(TEST_NAME), Path.path(Project.PATH_SEPARATOR + newName));
}
});
projectDescriptor.setName(newName);
assertEquals(newName, projectDescriptor.getName());
}
use of org.jmock.Expectations in project gradle by gradle.
the class BuildResultLoggerTest method logsBuildFailedAndTotalTime.
@Test
public void logsBuildFailedAndTotalTime() {
context.checking(new Expectations() {
{
one(buildTimeClock).getElapsed();
will(returnValue("10s"));
one(textOutputFactory).create(BuildResultLogger.class, LogLevel.LIFECYCLE);
will(returnValue(textOutput));
}
});
listener.buildFinished(new BuildResult("Action", null, new RuntimeException()));
assertEquals("\n{failure}ACTION FAILED{normal}\n\nTotal time: 10s\n", textOutput.getValue());
}
use of org.jmock.Expectations in project gradle by gradle.
the class BuildResultLoggerTest method logsBuildSuccessAndTotalTime.
@Test
public void logsBuildSuccessAndTotalTime() {
context.checking(new Expectations() {
{
one(buildTimeClock).getElapsed();
will(returnValue("10s"));
one(textOutputFactory).create(BuildResultLogger.class, LogLevel.LIFECYCLE);
will(returnValue(textOutput));
}
});
listener.buildFinished(new BuildResult("Action", null, null));
assertEquals("\n{success}ACTION SUCCESSFUL{normal}\n\nTotal time: 10s\n", textOutput.getValue());
}
use of org.jmock.Expectations in project gradle by gradle.
the class LineBufferingOutputStreamTest method logsEmptyLines.
@Test
public void logsEmptyLines() throws IOException {
System.setProperty("line.separator", "-");
LineBufferingOutputStream outputStream = new LineBufferingOutputStream(action, 8);
context.checking(new Expectations() {
{
one(action).text("-");
one(action).text("-");
}
});
outputStream.write("--".getBytes());
}
Aggregations