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());
}
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());
}
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);
}
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());
}
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());
}
Aggregations