use of org.codehaus.plexus.logging.AbstractLogger in project tycho by eclipse.
the class IncludeValidationHelperTest method testWarning.
@Test
public void testWarning() throws Exception {
final List<String> warnings = new ArrayList<>();
Logger log = new AbstractLogger(Logger.LEVEL_DEBUG, null) {
@Override
public void warn(String message, Throwable throwable) {
warnings.add(message);
}
@Override
public void info(String message, Throwable throwable) {
Assert.fail();
}
@Override
public Logger getChildLogger(String name) {
return null;
}
@Override
public void fatalError(String message, Throwable throwable) {
Assert.fail();
}
@Override
public void error(String message, Throwable throwable) {
Assert.fail();
}
@Override
public void debug(String message, Throwable throwable) {
Assert.fail();
}
};
IncludeValidationHelper subject = new IncludeValidationHelper(log);
BuildPropertiesImpl buildProperties = createBuildProperties("src.includes", "foo3, bar3*,**/*.me");
MavenProject project = createMockProject();
subject.checkSourceIncludesExist(project, buildProperties, false);
Assert.assertEquals(1, warnings.size());
Assert.assertEquals(new File(project.getBasedir(), "build.properties").getAbsolutePath() + ": src.includes value(s) [foo3, bar3*] do not match any files.", warnings.get(0));
}
use of org.codehaus.plexus.logging.AbstractLogger in project build-info by JFrogDev.
the class BuildInfoRecorderLifecycleParticipantTest method testParticipantImplementation.
public void testParticipantImplementation() throws Exception {
BuildInfoRecorder buildInfoRecorder = new BuildInfoRecorder();
BuildInfoRecorderLifecycleParticipant participant = new BuildInfoRecorderLifecycleParticipant();
Class<BuildInfoRecorderLifecycleParticipant> participantClass = BuildInfoRecorderLifecycleParticipant.class;
Field recorderField = participantClass.getDeclaredField("recorder");
recorderField.set(participant, buildInfoRecorder);
Field loggerField = participantClass.getDeclaredField("logger");
loggerField.setAccessible(true);
loggerField.set(participant, new AbstractLogger(1, "dummy") {
public void debug(String message, Throwable throwable) {
Assert.assertTrue(message.contains("value is true"));
}
public void info(String message, Throwable throwable) {
assert false;
}
public void warn(String message, Throwable throwable) {
assert false;
}
public void error(String message, Throwable throwable) {
assert false;
}
public void fatalError(String message, Throwable throwable) {
assert false;
}
public Logger getChildLogger(String name) {
assert false;
return null;
}
});
PlexusContainer plexusContainerMock = EasyMock.createMock(PlexusContainer.class);
RepositorySystemSession repositorySystemSession = EasyMock.createMock(RepositorySystemSession.class);
MavenExecutionRequest requestMock = EasyMock.createMock(MavenExecutionRequest.class);
Properties mockSessionProperties = new Properties();
mockSessionProperties.setProperty(BuildInfoConfigProperties.ACTIVATE_RECORDER, "true");
EasyMock.expect(requestMock.getSystemProperties()).andReturn(mockSessionProperties).once();
EasyMock.expect(requestMock.getUserProperties()).andReturn(mockSessionProperties).once();
AbstractExecutionListener existingListener = new AbstractExecutionListener();
EasyMock.expect(requestMock.getExecutionListener()).andReturn(existingListener).times(1);
EasyMock.expect(requestMock.getUserSettingsFile()).andReturn(null).once();
EasyMock.expect(requestMock.setExecutionListener(buildInfoRecorder)).andReturn(null).once();
EasyMock.replay(requestMock);
MavenExecutionResult resultMock = EasyMock.createMock(MavenExecutionResult.class);
MavenSession session = new MavenSession(plexusContainerMock, repositorySystemSession, requestMock, resultMock);
// value is true
participant.afterProjectsRead(session);
}
Aggregations