Search in sources :

Example 1 with MockMessageLogger

use of org.apache.ivy.util.MockMessageLogger in project ant-ivy by apache.

the class IBiblioResolverTest method testErrorReport.

@Test
public void testErrorReport() throws Exception {
    IBiblioResolver resolver = new IBiblioResolver();
    resolver.setRoot("http://unknown.host.comx/");
    resolver.setName("test");
    resolver.setM2compatible(true);
    resolver.setSettings(settings);
    assertEquals("test", resolver.getName());
    MockMessageLogger mockMessageImpl = new MockMessageLogger();
    IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockMessageImpl);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "commons-fileupload", "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNull(rmr);
    mockMessageImpl.assertLogContains("tried http://unknown.host.comx/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.pom");
    mockMessageImpl.assertLogContains("tried http://unknown.host.comx/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar");
}
Also used : ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) MockMessageLogger(org.apache.ivy.util.MockMessageLogger) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 2 with MockMessageLogger

use of org.apache.ivy.util.MockMessageLogger in project ant-ivy by apache.

the class BintrayResolverTest method testErrorReport.

@Test
public void testErrorReport() throws Exception {
    BintrayResolver resolver = new BintrayResolver();
    resolver.setSubject("unknown");
    resolver.setRepo("unknown");
    resolver.setName("test");
    resolver.setM2compatible(true);
    resolver.setSettings(settings);
    assertEquals("test", resolver.getName());
    MockMessageLogger mockMessageImpl = new MockMessageLogger();
    IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockMessageImpl);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "commons-fileupload", "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNull(rmr);
    mockMessageImpl.assertLogContains("trying https://dl.bintray.com/unknown/unknown/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar");
    mockMessageImpl.assertLogContains("tried https://dl.bintray.com/unknown/unknown/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar");
}
Also used : ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) MockMessageLogger(org.apache.ivy.util.MockMessageLogger) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 3 with MockMessageLogger

use of org.apache.ivy.util.MockMessageLogger in project ant-ivy by apache.

the class ChainResolverTest method testDownloadWithDual.

@Test
public void testDownloadWithDual() {
    ChainResolver chain = new ChainResolver();
    chain.setName("chain");
    chain.setSettings(settings);
    chain.setDual(true);
    // first resolver has only an artifact pattern which don't lead to anything: it won't find
    // the module
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("1");
    resolver.setSettings(settings);
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/nowhere/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    chain.add(resolver);
    resolver = new FileSystemResolver();
    resolver.setName("2");
    resolver.setSettings(settings);
    resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/ivys/ivy-[revision].xml");
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    chain.add(resolver);
    settings.addResolver(chain);
    MockMessageLogger mockLogger = new MockMessageLogger();
    IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockLogger);
    DownloadReport report = chain.download(new Artifact[] { new DefaultArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"), new Date(), "mod1.1", "jar", "jar") }, new DownloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    assertEquals(DownloadStatus.SUCCESSFUL, report.getArtifactsReports()[0].getDownloadStatus());
    mockLogger.assertLogDoesntContain("[FAILED     ] org1#mod1.1;1.0!mod1.1.jar");
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) DownloadOptions(org.apache.ivy.core.resolve.DownloadOptions) MockMessageLogger(org.apache.ivy.util.MockMessageLogger) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Date(java.util.Date) Test(org.junit.Test)

Example 4 with MockMessageLogger

use of org.apache.ivy.util.MockMessageLogger in project ant-ivy by apache.

the class RetrieveTest method testRetrieveSameFileConflict.

@Test
public void testRetrieveSameFileConflict() throws Exception {
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.1.xml").toURI().toURL(), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    String pattern = "build/test/retrieve/[module]/[artifact]-[revision].[ext]";
    MockMessageLogger mockLogger = new MockMessageLogger();
    Message.setDefaultLogger(mockLogger);
    ivy.retrieve(md.getModuleRevisionId(), getRetrieveOptions().setDestArtifactPattern(pattern));
    assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.2", "mod1.2", "jar", "jar", "default")).exists());
    mockLogger.assertLogDoesntContain("conflict on");
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ResolveReport(org.apache.ivy.core.report.ResolveReport) MockMessageLogger(org.apache.ivy.util.MockMessageLogger) File(java.io.File) Test(org.junit.Test)

Example 5 with MockMessageLogger

use of org.apache.ivy.util.MockMessageLogger in project ant-ivy by apache.

the class WarnCircularDependencyStrategyTest method setUp.

@Before
public void setUp() {
    // setup a new IvyContext for each test
    IvyContext.pushNewContext();
    strategy = WarnCircularDependencyStrategy.getInstance();
    mockMessageLogger = new MockMessageLogger();
    loggerEngine = setupMockLogger(mockMessageLogger);
}
Also used : MockMessageLogger(org.apache.ivy.util.MockMessageLogger) Before(org.junit.Before)

Aggregations

MockMessageLogger (org.apache.ivy.util.MockMessageLogger)10 Test (org.junit.Test)8 File (java.io.File)4 ResolveReport (org.apache.ivy.core.report.ResolveReport)4 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)2 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)2 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)2 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)2 Before (org.junit.Before)2 Date (java.util.Date)1 JarFile (java.util.jar.JarFile)1 Ivy (org.apache.ivy.Ivy)1 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)1 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)1 DownloadReport (org.apache.ivy.core.report.DownloadReport)1 DownloadOptions (org.apache.ivy.core.resolve.DownloadOptions)1