[New] added RuntimeMock.assertServiceResult()

This commit is contained in:
Robert von Burg 2014-02-14 21:17:30 +01:00
parent bb3f3e7854
commit c37792fead
1 changed files with 16 additions and 0 deletions

View File

@ -15,6 +15,9 @@
*/
package li.strolch.testbase.runtime;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.File;
import java.text.MessageFormat;
@ -24,11 +27,14 @@ import li.strolch.agent.impl.StrolchRealm;
import li.strolch.runtime.configuration.RuntimeConfiguration;
import li.strolch.runtime.privilege.StrolchPrivilegeHandler;
import li.strolch.service.api.ServiceHandler;
import li.strolch.service.api.ServiceResult;
import li.strolch.service.api.ServiceResultState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.eitchnet.utils.helper.FileHelper;
import ch.eitchnet.utils.helper.StringHelper;
public final class RuntimeMock {
@ -139,4 +145,14 @@ public final class RuntimeMock {
logger.info("Failed to destroy container: " + e.getMessage()); //$NON-NLS-1$
}
}
public void assertServiceResult(ServiceResultState expectedState, Class<?> expectedResultType, ServiceResult result) {
assertEquals("Expected service result of type " + expectedResultType + " but was " + result.getClass(),
expectedResultType, result.getClass());
if (!expectedState.equals(result.getState())) {
fail("Expected service result state " + expectedState + " but was " + result.getState() + ": Reason: "
+ StringHelper.formatException(result.getThrowable()));
}
}
}