
org.mule.test.infrastructure.process.VerifyLogWithMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mule-tests-infrastructure Show documentation
Show all versions of mule-tests-infrastructure Show documentation
Tests infrastructure library for creating mule automated test cases.
/*
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.test.infrastructure.process;
import java.io.File;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.junit.internal.matchers.TypeSafeMatcher;
public class VerifyLogWithMatcher extends TypeSafeMatcher
{
private String app;
private Matcher fileMatcher;
@Factory
public static Matcher log(Matcher matcher)
{
return new VerifyLogWithMatcher(matcher);
}
@Factory
public static Matcher log(String appName, Matcher matcher)
{
return new VerifyLogWithMatcher(appName,matcher);
}
private VerifyLogWithMatcher(Matcher matcher)
{
fileMatcher = matcher;
}
private VerifyLogWithMatcher(String appName, Matcher matcher)
{
this.app = appName;
fileMatcher = matcher;
}
@Override
public boolean matchesSafely(MuleProcessController muleProcessController)
{
File logFile = (app == null) ? muleProcessController.getLog() : muleProcessController.getLog(app);
return fileMatcher.matches(logFile);
}
@Override
public void describeTo(Description description)
{
String message = (app == null) ? "mule log that has " : String.format("%s application log that have ",app);
description.appendText(message).appendDescriptionOf(fileMatcher);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy