use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class ExpiringMemoryNotFoundCacheTest method expireUsingConfiguredValue.
@Test
public void expireUsingConfiguredValue() throws Exception {
final DefaultIndyConfiguration config = new DefaultIndyConfiguration();
config.setNotFoundCacheTimeoutSeconds(1);
final ExpiringMemoryNotFoundCache nfc = new ExpiringMemoryNotFoundCache(config);
final ConcreteResource res = new ConcreteResource(new SimpleLocation("test:uri"), "/path/to/expired/object");
nfc.addMissing(res);
assertThat(nfc.isMissing(res), equalTo(true));
Thread.sleep(TimeUnit.SECONDS.toMillis(2));
assertThat(nfc.isMissing(res), equalTo(false));
final Set<String> locMissing = nfc.getMissing(res.getLocation());
assertThat(locMissing == null || locMissing.isEmpty(), equalTo(true));
final Map<Location, Set<String>> allMissing = nfc.getAllMissing();
assertThat(allMissing == null || allMissing.isEmpty(), equalTo(true));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class DownloadManagerTest method downloadOnePOMFromSecondRepositoryAfterDummyRepoFails.
@Test
public void downloadOnePOMFromSecondRepositoryAfterDummyRepoFails() throws Exception {
final RemoteRepository repo = new RemoteRepository(MAVEN_PKG_KEY, "dummy", "http://www.nowhere.com/");
final String content = "This is a test";
final String path = "/org/apache/maven/maven-model/3.0.3/maven-model-3.0.3.pom";
final RemoteRepository repo2 = new RemoteRepository(MAVEN_PKG_KEY, "central", "http://repo.maven.apache.org/maven2");
fixture.getTransport().registerDownload(new ConcreteResource(new RepositoryLocation(repo2), path), new TestDownload(content.getBytes()));
data.storeArtifactStore(repo, summary, false, true, new EventMetadata());
data.storeArtifactStore(repo2, summary, false, true, new EventMetadata());
final List<ArtifactStore> repos = new ArrayList<ArtifactStore>();
repos.add(repo);
repos.add(repo2);
final Transfer stream = downloader.retrieveFirst(repos, path, new EventMetadata());
final String downloaded = IOUtils.toString(stream.openInputStream());
assertThat(downloaded, equalTo(content));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class DownloadManagerTest method downloadOnePOMFromSingleRepository.
@Test
public void downloadOnePOMFromSingleRepository() throws Exception {
final String content = "This is a test";
final String path = "/org/apache/maven/maven-model/3.0.3/maven-model-3.0.3.pom";
final RemoteRepository repo = new RemoteRepository(MAVEN_PKG_KEY, "central", "http://repo.maven.apache.org/maven2");
fixture.getTransport().registerDownload(new ConcreteResource(new RepositoryLocation(repo), path), new TestDownload(content.getBytes()));
data.storeArtifactStore(repo, summary, false, true, new EventMetadata());
final Transfer stream = downloader.retrieve(repo, path, new EventMetadata());
final String downloaded = IOUtils.toString(stream.openInputStream());
assertThat(downloaded, equalTo(content));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class NfcStoreContentAction method clearStoreContent.
/**
* When a path is removed from a store and affected groups, it might because of membership changes. e.g,
* Group A contains hosted B, and a NFC entry path/to/something exists. If a hosted C is added, we need to
* clear the NFC entry because the newly added repo may provide such artifact.
*/
@Override
public void clearStoreContent(String path, ArtifactStore store, Set<Group> affectedGroups, boolean clearOriginPath) {
logger.debug("Clearing NFC path: {}, store: {}, affected: {}", path, store.getKey(), affectedGroups);
nfc.clearMissing(new ConcreteResource(LocationUtils.toLocation(store), path));
affectedGroups.forEach(group -> nfc.clearMissing(new ConcreteResource(LocationUtils.toLocation(group), path)));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class ContentControllerTest method detectHtml_MultipleHtmlElementsOnALine.
@Test
public void detectHtml_MultipleHtmlElementsOnALine() throws Exception {
final ConcreteResource res = new ConcreteResource(new SimpleLocation("test:uri"), "file.html");
final Transfer tx = fixture.getCache().getTransfer(res);
PrintWriter writer = null;
try {
writer = new PrintWriter(new OutputStreamWriter(tx.openOutputStream(TransferOperation.GENERATE)));
writer.print("<html><body><h1>FOO</h1>");
writer.flush();
} finally {
IOUtils.closeQuietly(writer);
}
assertThat(content.isHtmlContent(tx), equalTo(true));
}
Aggregations