use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class AutoCreateRepoWithTrackingIdTest method run.
@Test
public void run() throws Exception {
final String testRepo = "test";
final PomRef pom = loadPom("simple.pom", Collections.<String, String>emptyMap());
final String url = server.formatUrl(testRepo, pom.path);
server.expect(url, 200, pom.pom);
final HttpGet get = new HttpGet(url);
CloseableHttpClient client = proxiedHttp(USER, PASS);
CloseableHttpResponse response = null;
InputStream stream = null;
try {
response = client.execute(get, proxyContext(USER, PASS));
stream = response.getEntity().getContent();
final String resultingPom = IOUtils.toString(stream);
assertThat(resultingPom, notNullValue());
assertThat(resultingPom, equalTo(pom.pom));
} finally {
IOUtils.closeQuietly(stream);
HttpResources.cleanupResources(get, response, client);
}
// Remote
String remote = creator.formatId(HOST, 0, 0, TRACKING_ID, StoreType.remote);
final RemoteRepository remoteRepo = this.client.stores().load(new StoreKey(GENERIC_PKG_KEY, StoreType.remote, remote), RemoteRepository.class);
assertThat(remoteRepo, notNullValue());
assertThat(remoteRepo.getUrl(), equalTo(server.getBaseUri()));
assertThat(remoteRepo.isPassthrough(), equalTo(false));
String pomUrl = this.client.content().contentUrl(remoteRepo.getKey(), testRepo, pom.path) + "?cache-only=true";
HttpHead head = new HttpHead(pomUrl);
client = HttpClients.createDefault();
try {
response = client.execute(head);
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
} finally {
HttpResources.cleanupResources(head, response, client);
}
// Hosted
String hosted = creator.formatId(HOST, 0, 0, TRACKING_ID, StoreType.hosted);
final HostedRepository hostedRepo = this.client.stores().load(new StoreKey(GENERIC_PKG_KEY, StoreType.hosted, hosted), HostedRepository.class);
assertThat(hostedRepo, notNullValue());
// Group
final Group group = this.client.stores().load(new StoreKey(GENERIC_PKG_KEY, StoreType.group, creator.formatId(HOST, 0, 0, TRACKING_ID, StoreType.group)), Group.class);
assertThat(group, notNullValue());
List<StoreKey> constituents = group.getConstituents();
assertThat(constituents.contains(remoteRepo.getKey()), equalTo(true));
assertThat(constituents.contains(hostedRepo.getKey()), equalTo(true));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class HostedByArcWithoutIgnoreRootUploadTest method testUploadZipAndCreate.
@Test
public void testUploadZipAndCreate() throws Exception {
IndyHostedByArchiveClientModule module = client.module(IndyHostedByArchiveClientModule.class);
final String hostedRepoName = "hosted-zip-no-ignore";
HostedRepository repo = module.createRepo(getZipFile(), hostedRepoName);
assertThat(repo, notNullValue());
assertThat(repo.getName(), equalTo(hostedRepoName));
boolean exists = client.content().exists(repo.getKey(), "org/foo/bar/1.0/foo-bar-1.0.pom");
assertTrue(exists);
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class AbstractProxyRepositoryCreator method createHosted.
protected HostedRepository createHosted(String trackingID, String name, UrlInfo info, Logger logger) {
HostedRepository hosted = new HostedRepository(GENERIC_PKG_KEY, name);
setPropsAndMetadata(hosted, trackingID, info);
return hosted;
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class ListStoresByTypeTest method listByType.
@Test
public void listByType() throws Exception {
final Set<ArtifactStore> hosteds = new HashSet<>();
for (int i = 0; i < 3; i++) {
final HostedRepository repo = new HostedRepository(newName());
assertThat(client.stores().create(repo, name.getMethodName(), HostedRepository.class), notNullValue());
hosteds.add(repo);
}
final Set<ArtifactStore> remotes = new HashSet<>();
for (int i = 0; i < 3; i++) {
final RemoteRepository repo = new RemoteRepository(newName(), newUrl());
assertThat(client.stores().create(repo, name.getMethodName(), RemoteRepository.class), notNullValue());
remotes.add(repo);
}
final Set<ArtifactStore> groups = new HashSet<>();
for (int i = 0; i < 3; i++) {
final Group repo = new Group(newName());
assertThat(client.stores().create(repo, name.getMethodName(), Group.class), notNullValue());
groups.add(repo);
}
// Now, start listing by type and verify that ONLY those of the given type are present
checkListing(client.stores().listHostedRepositories(), hosteds, Arrays.asList(remotes, groups));
checkListing(client.stores().listRemoteRepositories(), remotes, Arrays.asList(groups, hosteds));
checkListing(client.stores().listGroups(), groups, Arrays.asList(hosteds, remotes));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class GroupAdjustmentToMemberDeletionTest method groupAdjustsToConstituentDeletion.
@Test
@Category(EventDependent.class)
public void groupAdjustsToConstituentDeletion() throws Exception {
final HostedRepository repo = new HostedRepository(newName());
final Group group = new Group(newName());
group.addConstituent(repo);
assertThat(client.stores().create(repo, name.getMethodName(), HostedRepository.class), notNullValue());
assertThat(client.stores().create(group, name.getMethodName(), Group.class), notNullValue());
client.stores().delete(repo.getKey().getType(), repo.getName(), name.getMethodName());
waitForEventPropagation();
final Group result = client.stores().load(group.getKey().getType(), group.getName(), Group.class);
assertThat(result.getConstituents() == null || result.getConstituents().isEmpty(), equalTo(true));
}
Aggregations