Behaviours.get(remoteRepoRoot)
)
.start();
// create the proxy
final MavenProxyRepository proxyRepository = repositories()
.create(MavenProxyRepository.class, repositoryIdForTest("someorgProxy1"))
.asProxyOf(server.getUrl().toExternalForm())
.doNotDownloadRemoteIndexes()
.save();
routingTest().waitForAllRoutingUpdateJobToStop();
// waitForWLPublishingOutcomes( proxyRepository.id() );
client().getSubsystem(Scheduler.class).waitForAllTasksToStop();
// nuke the repo cache
nukeProxyCaches(proxyRepository.id());
try {
// clear recorder
recorder.clear();
// remote repo lives without prefix file
{
// check that newly added proxy is not publishing prefix file
assertThat(routing().getStatus(proxyRepository.id()).getPublishedStatus(),
equalTo(Outcome.FAILED));
// and because no WL, we can fetch whatever we want (com and org)
// all these will go remotely
fetchAndAssert(downloadsDir, proxyRepository.id(), COM_SOMEORG_ARTIFACT_10_POM, true);
fetchAndAssert(downloadsDir, proxyRepository.id(), COM_SOMEORG_ARTIFACT_10_JAR, true);
fetchAndAssert(downloadsDir, proxyRepository.id(), ORG_SOMEORG_ARTIFACT_10_POM, true);
fetchAndAssert(downloadsDir, proxyRepository.id(), ORG_SOMEORG_ARTIFACT_10_JAR, true);
fetchAndAssert(downloadsDir, proxyRepository.id(), FLUKE_ARTIFACT_POM, false);
fetchAndAssert(downloadsDir, proxyRepository.id(), FLUKE_ARTIFACT_JAR, false);
// note: sha1 is asked for existing files only
// GET /hu/fluke/artifact/1.0/artifact-1.0.jar,
// GET /hu/fluke/artifact/1.0/artifact-1.0.pom,
// GET /org/someorg/artifact/1.0/artifact-1.0.jar.sha1,
// GET /org/someorg/artifact/1.0/artifact-1.0.jar,
// GET /org/someorg/artifact/1.0/artifact-1.0.pom.sha1,
// GET /org/someorg/artifact/1.0/artifact-1.0.pom,
// GET /com/someorg/artifact/1.0/artifact-1.0.jar.sha1,
// GET /com/someorg/artifact/1.0/artifact-1.0.jar,
// GET /com/someorg/artifact/1.0/artifact-1.0.pom.sha1,
// GET /com/someorg/artifact/1.0/artifact-1.0.pom,
final List<String> requests = recorder.getPathsForVerb("GET");
assertThat(requests.size(), is(10));
assertThat(
requests,
containsInAnyOrder(COM_SOMEORG_ARTIFACT_10_POM, COM_SOMEORG_ARTIFACT_10_POM + ".sha1",
COM_SOMEORG_ARTIFACT_10_JAR, COM_SOMEORG_ARTIFACT_10_JAR + ".sha1",
ORG_SOMEORG_ARTIFACT_10_POM, ORG_SOMEORG_ARTIFACT_10_POM + ".sha1",
ORG_SOMEORG_ARTIFACT_10_JAR, ORG_SOMEORG_ARTIFACT_10_JAR + ".sha1", FLUKE_ARTIFACT_POM,
FLUKE_ARTIFACT_JAR));
}
// nuke the repo cache
nukeProxyCaches(proxyRepository.id());
// now set the prefixes file that contains /org/someorg prefix only, and repeat
prefixesFile.setContent(Files.toString(testData().resolveFile("someorg-prefixes.txt"),
Charset.forName("UTF-8")));
// update the WL of proxy repo to have new prefixes file picked up
routing().updatePrefixFile(proxyRepository.id());
// wait for update to finish since it's async op, client above returned immediately
// but update happens in a separate thread. Still this should be quick operation as prefix file is used
Status proxyStatus = routing().getStatus(proxyRepository.id());
// sit and wait for remote discovery (or the timeout Junit @Rule will kill us)
while (proxyStatus.getPublishedStatus() != Outcome.SUCCEEDED) {
Thread.sleep(10000);
proxyStatus = routing().getStatus(proxyRepository.id());
}
// nuke the repo cache
nukeProxyCaches(proxyRepository.id());
// clear recorder
recorder.clear();
// repeat the test with slightly different expectations
{
// check that newly added proxy is publishing prefix file
assertThat(routing().getStatus(proxyRepository.id()).getPublishedStatus(),
equalTo(Outcome.SUCCEEDED));
// and because we have WL, we cant fetch whatever we want (com and org)
// only WL-enlisted of these will go remotely
fetchAndAssert(downloadsDir, proxyRepository.id(), COM_SOMEORG_ARTIFACT_10_POM, false);
fetchAndAssert(downloadsDir, proxyRepository.id(), COM_SOMEORG_ARTIFACT_10_JAR, false);
fetchAndAssert(downloadsDir, proxyRepository.id(), ORG_SOMEORG_ARTIFACT_10_POM, true);
fetchAndAssert(downloadsDir, proxyRepository.id(), ORG_SOMEORG_ARTIFACT_10_JAR, true);
fetchAndAssert(downloadsDir, proxyRepository.id(), FLUKE_ARTIFACT_POM, false);
fetchAndAssert(downloadsDir, proxyRepository.id(), FLUKE_ARTIFACT_JAR, false);
// GET /org/someorg/artifact/1.0/artifact-1.0.jar.sha1,
// GET /org/someorg/artifact/1.0/artifact-1.0.jar,
// GET /org/someorg/artifact/1.0/artifact-1.0.pom.sha1,
// GET /org/someorg/artifact/1.0/artifact-1.0.pom,