Search in sources :

Example 6 with DefaultArtifact

use of org.apache.ivy.core.module.descriptor.DefaultArtifact in project ant-ivy by apache.

the class FileSystemResolverTest method testPublishTransaction.

@Test
public void testPublishTransaction() throws Exception {
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact].[ext]");
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision");
    Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml");
    Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext");
    File src = new File("test/repositories/ivysettings.xml");
    resolver.beginPublishTransaction(mrid, false);
    // files should not be available until the transaction is committed
    resolver.publish(ivyArtifact, src, false);
    assertFalse(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists());
    resolver.publish(artifact, src, false);
    assertFalse(new File("test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext").exists());
    resolver.commitPublishTransaction();
    assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists());
    assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext").exists());
}
Also used : ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) File(java.io.File) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Date(java.util.Date) Test(org.junit.Test)

Example 7 with DefaultArtifact

use of org.apache.ivy.core.module.descriptor.DefaultArtifact in project ant-ivy by apache.

the class FileSystemResolverTest method testPublishTransactionWithBranch.

@Test
public void testPublishTransactionWithBranch() throws Exception {
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[branch]/[revision]/[artifact].[ext]");
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[branch]/[revision]/[artifact]-[revision].[ext]");
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "mybranch", "myrevision");
    Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml");
    Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext");
    File src = new File("test/repositories/ivysettings.xml");
    resolver.beginPublishTransaction(mrid, false);
    // files should not be available until the transaction is committed
    resolver.publish(ivyArtifact, src, false);
    assertFalse(new File("test/repositories/1/myorg/mymodule/mybranch/myrevision/ivy.xml").exists());
    resolver.publish(artifact, src, false);
    assertFalse(new File("test/repositories/1/myorg/mymodule/mybranch/myrevision/myartifact-myrevision.myext").exists());
    resolver.commitPublishTransaction();
    assertTrue(new File("test/repositories/1/myorg/mymodule/mybranch/myrevision/ivy.xml").exists());
    assertTrue(new File("test/repositories/1/myorg/mymodule/mybranch/myrevision/myartifact-myrevision.myext").exists());
}
Also used : ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) File(java.io.File) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Date(java.util.Date) Test(org.junit.Test)

Example 8 with DefaultArtifact

use of org.apache.ivy.core.module.descriptor.DefaultArtifact in project ant-ivy by apache.

the class FileSystemResolverTest method testUnsupportedTransaction2.

/**
 * Publishing with transaction=true and an unsupported combination of patterns must fail.
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testUnsupportedTransaction2() throws Exception {
    expExc.expect(IllegalStateException.class);
    expExc.expectMessage("transactional");
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    resolver.setTransactional("true");
    // the two patterns are inconsistent and thus not supported for transactions
    resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]-[module]/[revision]/[artifact]-[revision].[ext]");
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision");
    Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml");
    Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext");
    File src = new File("test/repositories/ivysettings.xml");
    resolver.beginPublishTransaction(mrid, false);
    resolver.publish(ivyArtifact, src, false);
    resolver.publish(artifact, src, false);
}
Also used : ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) File(java.io.File) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Date(java.util.Date) Test(org.junit.Test)

Example 9 with DefaultArtifact

use of org.apache.ivy.core.module.descriptor.DefaultArtifact in project ant-ivy by apache.

the class FileSystemResolverTest method testPublish.

@Test
public void testPublish() throws Exception {
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    assertEquals("test", resolver.getName());
    resolver.addIvyPattern(settings.getBaseDir() + FS + "test" + FS + "repositories" + FS + "1" + FS + "[organisation]" + FS + "[module]" + FS + "[revision]" + FS + "[artifact].[ext]");
    resolver.addArtifactPattern(settings.getBaseDir() + FS + "test/repositories/1/" + "[organisation]/[module]/[type]s/[artifact]-[revision].[ext]");
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision");
    Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml");
    Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext");
    File src = new File("test/repositories/ivysettings.xml");
    resolver.beginPublishTransaction(mrid, false);
    resolver.publish(ivyArtifact, src, false);
    resolver.publish(artifact, src, false);
    resolver.commitPublishTransaction();
    assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists());
    assertTrue(new File("test/repositories/1/myorg/mymodule/mytypes/myartifact-myrevision.myext").exists());
}
Also used : ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) File(java.io.File) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Date(java.util.Date) Test(org.junit.Test)

Example 10 with DefaultArtifact

use of org.apache.ivy.core.module.descriptor.DefaultArtifact in project ant-ivy by apache.

the class FileSystemResolverTest method testDisableTransaction.

@Test
public void testDisableTransaction() throws Exception {
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    resolver.setTransactional("false");
    resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact].[ext]");
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision");
    Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml");
    Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext");
    File src = new File("test/repositories/ivysettings.xml");
    resolver.beginPublishTransaction(mrid, false);
    // with transactions disabled the file should be available as soon as they are published
    resolver.publish(ivyArtifact, src, false);
    assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists());
    resolver.publish(artifact, src, false);
    assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext").exists());
    resolver.commitPublishTransaction();
    assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists());
    assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext").exists());
}
Also used : ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) File(java.io.File) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)38 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)33 Test (org.junit.Test)27 Artifact (org.apache.ivy.core.module.descriptor.Artifact)25 Date (java.util.Date)24 File (java.io.File)21 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)13 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)12 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)10 DownloadReport (org.apache.ivy.core.report.DownloadReport)10 GregorianCalendar (java.util.GregorianCalendar)5 IOException (java.io.IOException)3 Locale (java.util.Locale)3 DefaultRepositoryCacheManager (org.apache.ivy.core.cache.DefaultRepositoryCacheManager)3 ModuleId (org.apache.ivy.core.module.id.ModuleId)3 PackagerResolver (org.apache.ivy.plugins.resolver.packager.PackagerResolver)3 ResolvedResource (org.apache.ivy.plugins.resolver.util.ResolvedResource)3 MalformedURLException (java.net.MalformedURLException)2 ParseException (java.text.ParseException)2 HashMap (java.util.HashMap)2