All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.softicar.platform.common.core.thread.sleeper.TestSleeper Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
package com.softicar.platform.common.core.thread.sleeper;

import com.softicar.platform.common.core.clock.TestClock;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;

/**
 * Implementation of {@link ISleeper} for unit tests.
 * 

* This implementation simply forwards the given {@link TestClock}. *

* The {@link #sleep(long)} implementation in this class will not cause * any execution pause. * * @author Oliver Richers */ public class TestSleeper implements ISleeper { private final TestClock clock; private final List callParameters; public TestSleeper(TestClock clock) { this.clock = clock; this.callParameters = new ArrayList<>(); } @Override public void sleep(long millis) { clock.addMillis(millis); callParameters.add(millis); } public void assertOneCall(long expectedMillis) { Assert.assertEquals("sleep calls", 1, callParameters.size()); Assert.assertEquals("sleep call milliseconds", expectedMillis, callParameters.get(0).longValue()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy