use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ArchivaRepositoryScanningTaskExecutorPhase2Test method testExecutorScanOnlyNewArtifactsMidScan.
@Test
public void testExecutorScanOnlyNewArtifactsMidScan() throws Exception {
RepositoryTask repoTask = new RepositoryTask();
repoTask.setRepositoryId(TEST_REPO_ID);
repoTask.setScanAll(false);
createAndSaveTestStats();
Path newArtifactGroup = repoDir.resolve("org/apache/archiva");
assertFalse("newArtifactGroup should not exist.", Files.exists(newArtifactGroup));
FileUtils.copyDirectoryStructure(Paths.get("target/test-classes/test-repo/org/apache/archiva").toFile(), newArtifactGroup.toFile());
// update last modified date, placing in middle of last scan
Files.setLastModifiedTime(newArtifactGroup.resolve("archiva-index-methods-jar-test/1.0/pom.xml"), FileTime.fromMillis(Calendar.getInstance().getTimeInMillis() - 50000));
Files.setLastModifiedTime(newArtifactGroup.resolve("archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar"), FileTime.fromMillis(Calendar.getInstance().getTimeInMillis() - 50000));
assertTrue(Files.exists(newArtifactGroup));
// scan using the really long previous duration
taskExecutor.executeTask(repoTask);
// check no artifacts processed
Collection<ArtifactReference> unprocessedResultList = testConsumer.getConsumed();
assertNotNull(unprocessedResultList);
assertEquals("Incorrect number of unprocessed artifacts detected. One new artifact should have been found.", 1, unprocessedResultList.size());
// check correctness of new stats
RepositoryStatistics newStats = repositoryStatisticsManager.getLastStatistics(metadataRepository, TEST_REPO_ID);
assertEquals(2, newStats.getNewFileCount());
assertEquals(33, newStats.getTotalFileCount());
// FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation
// assertEquals( 8, newStats.getTotalArtifactCount() );
// assertEquals( 3, newStats.getTotalGroupCount() );
// assertEquals( 5, newStats.getTotalProjectCount() );
// assertEquals( 19301, newStats.getTotalArtifactFileSize() );
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ArchivaRepositoryScanningTaskExecutorPhase2Test method testExecutorForceScanAll.
@Test
public void testExecutorForceScanAll() throws Exception {
RepositoryTask repoTask = new RepositoryTask();
repoTask.setRepositoryId(TEST_REPO_ID);
repoTask.setScanAll(true);
Date date = Calendar.getInstance().getTime();
//
repositoryStatisticsManager.addStatisticsAfterScan(//
metadataRepository, //
TEST_REPO_ID, //
new Date(date.getTime() - 1234567), date, 8, //
8);
taskExecutor.executeTask(repoTask);
Collection<ArtifactReference> unprocessedResultList = testConsumer.getConsumed();
assertNotNull(unprocessedResultList);
assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size());
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class DefaultPathParserTest method assertLayout.
/**
* Perform a path to artifact reference lookup, and verify the results.
*/
private void assertLayout(String path, String groupId, String artifactId, String version, String classifier, String type) throws LayoutException {
// Path to Artifact Reference.
ArtifactReference testReference = parser.toArtifactReference(path);
assertArtifactReference(testReference, groupId, artifactId, version, classifier, type);
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class AbstractDefaultRepositoryContentTestCase method assertLayout.
/**
* Perform a roundtrip through the layout routines to determine success.
*/
private void assertLayout(String path, String groupId, String artifactId, String version, String classifier, String type) throws LayoutException {
ArtifactReference expectedArtifact = createArtifact(groupId, artifactId, version, classifier, type);
// --- Artifact Tests.
// Artifact to Path
assertEquals("Artifact <" + expectedArtifact + "> to path:", path, toPath(expectedArtifact));
// --- Artifact Reference Tests
// Path to Artifact Reference.
ArtifactReference testReference = toArtifactReference(path);
assertArtifactReference(testReference, groupId, artifactId, version, classifier, type);
// And back again, using test Reference from previous step.
assertEquals("Artifact <" + expectedArtifact + "> to path:", path, toPath(testReference));
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testToPathOnNullArtifactReference.
@Test
@Override
public void testToPathOnNullArtifactReference() {
try {
ArtifactReference reference = null;
repoContent.toPath(reference);
fail("Should have failed due to null artifact reference.");
} catch (IllegalArgumentException e) {
/* expected path */
}
}
Aggregations