Skip to content

Commit 4f11c69

Browse files
committed
Draft test Add a flux command for waiting a specific time #495
1 parent 18b6ae0 commit 4f11c69

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2016 Christoph Böhme
3+
*
4+
* Licensed under the Apache License, Version 2.0 the "License";
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.metafacture.flowcontrol;
18+
19+
import static org.mockito.ArgumentMatchers.anyString;
20+
import static org.mockito.Mockito.doThrow;
21+
22+
import org.junit.Before;
23+
import org.junit.Test;
24+
import org.metafacture.framework.MetafactureException;
25+
import org.metafacture.framework.ObjectReceiver;
26+
import org.mockito.Mock;
27+
import org.mockito.MockitoAnnotations;
28+
import java.time.Duration;
29+
import java.time.Instant;
30+
31+
/**
32+
* Tests for class {@link ObjectSleeper}.
33+
*
34+
* @author Tobias Bülte
35+
*
36+
*/
37+
public final class ObjectExceptionSleeperTest {
38+
39+
@Mock
40+
private ObjectReceiver<String> sleepTimer;
41+
42+
@Before
43+
public void setup() {
44+
MockitoAnnotations.initMocks(this);
45+
}
46+
47+
@After
48+
public void cleanup() {
49+
bulk.closeStream();
50+
}
51+
52+
53+
@Test
54+
public void shouldTestIfClockedTimeExceedsDuration() {
55+
long sleepTime = 10;
56+
57+
objectSleeper = new ObjectSleeper();
58+
objectSleeper.setSleepTime(sleepTime);
59+
Instant start = Instant.now();
60+
sleepTimer.objectSleeper();
61+
Instant end = Instant.now();
62+
63+
Duration timeElapsed = Duration.between(start, end);
64+
65+
if (timeElampse > sleepTime) {
66+
exception.expect(MetafactureException.class);
67+
exception.expectMessage("Process did not sleep enough.");
68+
}
69+
70+
}
71+
72+
73+
}

0 commit comments

Comments
 (0)