use of org.apache.ivy.util.MockMessageLogger in project ant-ivy by apache.
the class ResolveTest method testExtraAttributes3.
/**
* Test case for IVY-745.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-745">IVY-745</a>
*/
@Test
public void testExtraAttributes3() throws Exception {
MockMessageLogger mockLogger = new MockMessageLogger();
Ivy ivy = new Ivy();
ivy.getLoggerEngine().setDefaultLogger(mockLogger);
ivy.configure(new File("test/repositories/extra-attributes/ivysettings.xml"));
ivy.getSettings().setDefaultCache(cache);
ivy.getSettings().validate();
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att3.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }).setValidate(false));
assertTrue(report.hasError());
// should report error about missing extra attribute in dependency module descriptor
mockLogger.assertLogContains("expected='task2' found='null'");
}
use of org.apache.ivy.util.MockMessageLogger in project ant-ivy by apache.
the class RetrieveTest method testRetrieveDifferentArtifactsOfSameModuleToSameFile.
@Test(expected = RuntimeException.class)
public void testRetrieveDifferentArtifactsOfSameModuleToSameFile() throws Exception {
ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.2/ivys/ivy-0.5.xml").toURI().toURL(), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
String pattern = "build/test/retrieve/[module]/[module].[ext]";
MockMessageLogger mockLogger = new MockMessageLogger();
Message.setDefaultLogger(mockLogger);
try {
ivy.retrieve(md.getModuleRevisionId(), getRetrieveOptions().setDestArtifactPattern(pattern));
} finally {
mockLogger.assertLogDoesntContain("multiple artifacts");
}
}
use of org.apache.ivy.util.MockMessageLogger in project ant-ivy by apache.
the class IgnoreCircularDependencyStrategyTest method setUp.
@Before
public void setUp() {
strategy = IgnoreCircularDependencyStrategy.getInstance();
mockMessageImpl = new MockMessageLogger();
messageLoggerEngine = setupMockLogger(mockMessageImpl);
}
use of org.apache.ivy.util.MockMessageLogger in project ant-ivy by apache.
the class IvyTest method testMultipleInstances.
@Test
public void testMultipleInstances() throws Exception {
// this test checks that IvyContext is properly set and unset when using multiple instances
// of Ivy. We also check logging, because it heavily relies on IvyContext.
// we start by loading one ivy instance and using it to resolve some dependencies
MockMessageLogger mockLogger = new MockMessageLogger();
Ivy ivy = Ivy.newInstance();
ivy.getLoggerEngine().setDefaultLogger(mockLogger);
ivy.configure(new File("test/repositories/ivysettings.xml"));
assertNotSame("IvyContext should be cleared and return a default Ivy instance", IvyContext.getContext().getIvy(), ivy);
ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(ivy, new String[] { "*" }));
assertNotNull(report);
assertFalse(report.hasError());
mockLogger.assertLogContains("mod1.1");
assertNotSame("IvyContext should be cleared and return a default Ivy instance", IvyContext.getContext().getIvy(), ivy);
// then we load another instance, and use it for another resolution
MockMessageLogger mockLogger2 = new MockMessageLogger();
Ivy ivy2 = new Ivy();
ivy2.getLoggerEngine().setDefaultLogger(mockLogger2);
ivy2.configure(new File("test/repositories/norev/ivysettings.xml").toURI().toURL());
report = ivy2.resolve(new File("test/repositories/norev/ivy.xml"), getResolveOptions(ivy2, new String[] { "*" }));
assertNotNull(report);
assertFalse(report.hasError());
mockLogger2.assertLogContains("norev/ivysettings.xml");
assertNotSame("IvyContext should be cleared and return a default Ivy instance", IvyContext.getContext().getIvy(), ivy2);
// finally we reuse the first instance to make another resolution
report = ivy.resolve(new File("test/repositories/1/org6/mod6.1/ivys/ivy-0.3.xml"), getResolveOptions(ivy, new String[] { "extension" }));
assertNotNull(report);
assertFalse(report.hasError());
mockLogger.assertLogContains("mod6.1");
assertNotSame("IvyContext should be cleared and return a default Ivy instance", IvyContext.getContext().getIvy(), ivy);
}
use of org.apache.ivy.util.MockMessageLogger in project ant-ivy by apache.
the class LogTriggerTest method testMessage.
@Test
public void testMessage() {
trigger.setMessage("msg: ${organisation} ${module} ${revision}");
MockMessageLogger mockLogger = new MockMessageLogger();
Message.setDefaultLogger(mockLogger);
trigger.progress(ev);
mockLogger.assertLogInfoContains("msg: o A 1");
}
Aggregations