Search in sources :

Example 1 with TestingClock

use of com.thoughtworks.go.util.TestingClock in project gocd by gocd.

the class DownloadActionTest method setUp.

@Before
public void setUp() throws Exception {
    clock = new TestingClock();
    fetchHandler = mock(FetchHandler.class);
    publisher = new StubGoPublisher();
}
Also used : TestingClock(com.thoughtworks.go.util.TestingClock) Before(org.junit.Before)

Example 2 with TestingClock

use of com.thoughtworks.go.util.TestingClock in project gocd by gocd.

the class ServerHealthStateTest method setUp.

@Before
public void setUp() {
    testingClock = new TestingClock();
    ServerHealthState.clock = testingClock;
}
Also used : TestingClock(com.thoughtworks.go.util.TestingClock) Before(org.junit.Before)

Example 3 with TestingClock

use of com.thoughtworks.go.util.TestingClock in project gocd by gocd.

the class StreamPumperTest method shouldNotHaveExpiredTimeoutWhenCompleted.

@Test
public void shouldNotHaveExpiredTimeoutWhenCompleted() throws Exception {
    PipedOutputStream output = new PipedOutputStream();
    InputStream inputStream = new PipedInputStream(output);
    TestingClock clock = new TestingClock();
    StreamPumper pumper = new StreamPumper(inputStream, new TestConsumer(), "", null, clock);
    new Thread(pumper).start();
    output.write("line1\n".getBytes());
    output.flush();
    output.close();
    pumper.readToEnd();
    clock.addSeconds(2);
    assertThat(pumper.didTimeout(1L, TimeUnit.SECONDS), is(false));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) TestingClock(com.thoughtworks.go.util.TestingClock) Test(org.junit.Test)

Example 4 with TestingClock

use of com.thoughtworks.go.util.TestingClock in project gocd by gocd.

the class FetchArtifactBuilderTest method setUp.

@Before
public void setUp() throws Exception {
    File folder = TestFileUtil.createTempFolder("log");
    File consolelog = new File(folder, "console.log");
    folder.mkdirs();
    consolelog.createNewFile();
    zip = new ZipUtil().zip(folder, TestFileUtil.createUniqueTempFile(folder.getName()), Deflater.NO_COMPRESSION);
    toClean.add(folder);
    toClean.add(zip);
    dest = new File("dest");
    dest.mkdirs();
    toClean.add(dest);
    clock = new TestingClock();
    publisher = new StubGoPublisher();
    checksumFileHandler = mock(ChecksumFileHandler.class);
    urlService = mock(URLService.class);
    downloadAction = mock(DownloadAction.class);
}
Also used : ZipUtil(com.thoughtworks.go.util.ZipUtil) URLService(com.thoughtworks.go.util.URLService) File(java.io.File) TestingClock(com.thoughtworks.go.util.TestingClock) Before(org.junit.Before)

Example 5 with TestingClock

use of com.thoughtworks.go.util.TestingClock in project gocd by gocd.

the class BuildVariablesTest method setup.

@Before
public void setup() {
    AgentIdentifier agentIdentifier = new AgentIdentifier("duloc", "127.0.0.1", "uuid");
    AgentRuntimeInfo runtimeInfo = new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, "/home/lord-farquaad/builds", "cookie", false);
    bvs = new BuildVariables(runtimeInfo, new TestingClock(new Date(0)));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) TestingClock(com.thoughtworks.go.util.TestingClock) Date(java.util.Date) Before(org.junit.Before)

Aggregations

TestingClock (com.thoughtworks.go.util.TestingClock)9 Before (org.junit.Before)5 Test (org.junit.Test)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 PipedInputStream (java.io.PipedInputStream)2 PipedOutputStream (java.io.PipedOutputStream)2 JobInstance (com.thoughtworks.go.domain.JobInstance)1 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)1 JobDurationStrategy (com.thoughtworks.go.server.domain.JobDurationStrategy)1 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)1 TransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TransactionSynchronizationManager)1 URLService (com.thoughtworks.go.util.URLService)1 ZipUtil (com.thoughtworks.go.util.ZipUtil)1 File (java.io.File)1 Date (java.util.Date)1