use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class DefaultArtifactTest method testArtifactType.
@Test
public void testArtifactType() {
DefaultArtifactType type = new DefaultArtifactType("typeId", "typeExt", "typeCls", "typeLang", true, true);
Artifact a = new DefaultArtifact("gid", "aid", null, null, null, null, type);
assertEquals("typeExt", a.getExtension());
assertEquals("typeCls", a.getClassifier());
assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
assertEquals("true", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
assertEquals("true", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
a = new DefaultArtifact("gid", "aid", "cls", "ext", "ver", null, type);
assertEquals("ext", a.getExtension());
assertEquals("cls", a.getClassifier());
assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
assertEquals("true", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
assertEquals("true", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
Map<String, String> props = new HashMap<String, String>();
props.put("someNonStandardProperty", "someNonStandardProperty");
a = new DefaultArtifact("gid", "aid", "cls", "ext", "ver", props, type);
assertEquals("ext", a.getExtension());
assertEquals("cls", a.getClassifier());
assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
assertEquals("true", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
assertEquals("true", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
assertEquals("someNonStandardProperty", a.getProperties().get("someNonStandardProperty"));
props = new HashMap<String, String>();
props.put("someNonStandardProperty", "someNonStandardProperty");
props.put(ArtifactProperties.CONSTITUTES_BUILD_PATH, "rubbish");
props.put(ArtifactProperties.INCLUDES_DEPENDENCIES, "rubbish");
a = new DefaultArtifact("gid", "aid", "cls", "ext", "ver", props, type);
assertEquals("ext", a.getExtension());
assertEquals("cls", a.getClassifier());
assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
assertEquals("rubbish", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
assertEquals("rubbish", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
assertEquals("someNonStandardProperty", a.getProperties().get("someNonStandardProperty"));
}
use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class DefaultArtifactTest method testImmutability.
@Test
public void testImmutability() {
Artifact a = new DefaultArtifact("gid:aid:ext:cls:ver");
assertNotSame(a, a.setFile(new File("file")));
assertNotSame(a, a.setVersion("otherVersion"));
assertNotSame(a, a.setProperties(Collections.singletonMap("key", "value")));
}
use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class SubArtifactTest method testImmutability.
@Test
public void testImmutability() {
Artifact a = new SubArtifact(newMainArtifact("gid:aid:ver"), "", "pom");
assertNotSame(a, a.setFile(new File("file")));
assertNotSame(a, a.setVersion("otherVersion"));
assertNotSame(a, a.setProperties(Collections.singletonMap("key", "value")));
}
use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class SubArtifactTest method testEmptyClassifier.
@Test
public void testEmptyClassifier() {
Artifact main = newMainArtifact("gid:aid:ext:cls:ver");
Artifact sub = new SubArtifact(main, "", "pom");
assertEquals("", sub.getClassifier());
sub = new SubArtifact(main, null, "pom");
assertEquals("", sub.getClassifier());
}
use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.
the class DefaultUpdateCheckManager method touchArtifact.
public void touchArtifact(RepositorySystemSession session, UpdateCheck<Artifact, ArtifactTransferException> check) {
Artifact artifact = check.getItem();
File artifactFile = check.getFile();
File touchFile = getTouchFile(artifact, artifactFile);
String updateKey = getUpdateKey(artifactFile, check.getRepository());
String dataKey = getDataKey(artifact, artifactFile, check.getAuthoritativeRepository());
String transferKey = getTransferKey(artifact, artifactFile, check.getRepository());
setUpdated(session.getData(), updateKey);
Properties props = write(touchFile, dataKey, transferKey, check.getException());
if (artifactFile.exists() && !hasErrors(props)) {
touchFile.delete();
}
}
Aggregations