use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class FileSystemResolverTest method testUnsupportedTransaction3.
/**
* Publishing with transaction=true and overwrite mode must fail.
*
* @throws Exception if something goes wrong
*/
@Test
public void testUnsupportedTransaction3() throws Exception {
expExc.expect(IllegalStateException.class);
expExc.expectMessage("transactional");
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
resolver.setTransactional("true");
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision");
Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext");
File src = new File("test/repositories/ivysettings.xml");
// overwrite transaction not supported
resolver.beginPublishTransaction(mrid, true);
resolver.publish(artifact, src, true);
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class FileSystemResolverTest method testFixedRevision.
@Test
public void testFixedRevision() throws Exception {
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
assertEquals("test", resolver.getName());
resolver.addIvyPattern(IVY_PATTERN);
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime();
assertEquals(pubdate, rmr.getPublicationDate());
// test to ask to download
DefaultArtifact artifact = new DefaultArtifact(mrid, pubdate, "mod1.1", "jar", "jar");
DownloadReport report = resolver.download(new Artifact[] { artifact }, getDownloadOptions());
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
// test to ask to download again, should use cache
report = resolver.download(new Artifact[] { artifact }, getDownloadOptions());
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class FileSystemResolverTest method testAbortTransaction.
@Test
public void testAbortTransaction() 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);
resolver.publish(ivyArtifact, src, false);
resolver.publish(artifact, src, false);
resolver.abortPublishTransaction();
assertFalse(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists());
assertFalse(new File("test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext").exists());
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class FileSystemResolverTest method testUnsupportedTransaction.
/**
* Publishing with transaction=true and an unsupported pattern must fail.
*
* @throws Exception if something goes wrong
*/
@Test
public void testUnsupportedTransaction() throws Exception {
expExc.expect(IllegalStateException.class);
expExc.expectMessage("transactional");
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
resolver.setTransactional("true");
resolver.addArtifactPattern(// this pattern is not supported for transaction publish
settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[artifact]-[revision].[ext]");
ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision");
Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext");
File src = new File("test/repositories/ivysettings.xml");
resolver.beginPublishTransaction(mrid, false);
resolver.publish(artifact, src, false);
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class IvyRepResolverTest method testIvyRepWithLocalURL.
@Test
public void testIvyRepWithLocalURL() throws Exception {
IvyRepResolver resolver = new IvyRepResolver();
String rootpath = new File("test/repositories/1").getAbsolutePath();
resolver.setName("testLocal");
resolver.setIvyroot("file:" + rootpath);
resolver.setIvypattern("[organisation]/[module]/ivys/ivy-[revision].xml");
resolver.setArtroot("file:" + rootpath);
resolver.setArtpattern("[organisation]/[module]/jars/[artifact]-[revision].[ext]");
resolver.setSettings(settings);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
DefaultArtifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "mod1.1", "jar", "jar");
DownloadReport report = resolver.download(new Artifact[] { artifact }, downloadOptions());
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
// test to ask to download again, should use cache
report = resolver.download(new Artifact[] { artifact }, downloadOptions());
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
Aggregations