use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class RepositoryPathMaskMetadataTest method run.
/**
* Case where user requests maven-metadata.xml which is allowed by path mask
* - Should include versions from the member that has a path mask
*/
@Test
public void run() throws Exception {
final String path_metadata = "org/bar/bar-project/maven-metadata.xml";
final String remote1 = "remote1";
final String hosted1 = "hosted1";
server.expect(server.formatUrl(remote1, path_metadata), 200, meta1);
RemoteRepository remoteRepo1 = new RemoteRepository(remote1, server.formatUrl(remote1));
Set<String> pathMaskPatterns = new HashSet<>();
// regex patterns
pathMaskPatterns.add("r|org/bar.*|");
remoteRepo1.setPathMaskPatterns(pathMaskPatterns);
remoteRepo1 = client.stores().create(remoteRepo1, "adding remote 1", RemoteRepository.class);
HostedRepository hostedRepo1 = new HostedRepository(hosted1);
pathMaskPatterns = new HashSet<>();
pathMaskPatterns.add("org/bar.*");
hostedRepo1.setPathMaskPatterns(pathMaskPatterns);
hostedRepo1 = client.stores().create(hostedRepo1, "adding hosted 1", HostedRepository.class);
client.content().store(hosted, hosted1, path_metadata, new ByteArrayInputStream(meta2.getBytes()));
Group g = new Group("group1", remoteRepo1.getKey(), hostedRepo1.getKey());
g = client.stores().create(g, "adding group1", Group.class);
System.out.printf("\n\nGroup constituents are:\n %s\n\n", StringUtils.join(g.getConstituents(), "\n "));
InputStream stream = null;
String str = null;
// get metadata from hosted1
stream = client.content().get(hosted, hostedRepo1.getName(), path_metadata);
assertThat(stream, notNullValue());
str = IOUtils.toString(stream);
System.out.println("hosted1.metadata >>>> " + str);
stream.close();
// get metadata from remote1
stream = client.content().get(remote, remoteRepo1.getName(), path_metadata);
assertThat(stream, notNullValue());
str = IOUtils.toString(stream);
System.out.println("remote1.metadata >>>> " + str);
stream.close();
// get metadata from group1
stream = client.content().get(group, g.getName(), path_metadata);
assertThat(stream, notNullValue());
// return aggregated versions from all repositories with valid mask
str = IOUtils.toString(stream);
System.out.println("group1.metadata >>>> " + str);
assertThat(str.trim(), equalTo(aggregatedMeta));
stream.close();
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class StoreListingDTOTest method deserializeStoreListingDTO.
@Test
public void deserializeStoreListingDTO() throws Exception {
/* @formatter:off */
final String json = "{\n" + " \"items\" : [ {\n" + " \"type\": \"hosted\",\n" + " \"key\" : \"maven:hosted:eSPeEZPG\",\n" + " \"snapshotTimeoutSeconds\" : 0,\n" + " \"name\" : \"eSPeEZPG\",\n" + " \"doctype\" : \"hosted\",\n" + " \"allow_snapshots\" : false,\n" + " \"allow_releases\" : true\n" + " }, {\n" + " \"type\": \"hosted\",\n" + " \"key\" : \"maven:hosted:qI3Cq2OZ\",\n" + " \"snapshotTimeoutSeconds\" : 0,\n" + " \"name\" : \"qI3Cq2OZ\",\n" + " \"doctype\" : \"hosted\",\n" + " \"allow_snapshots\" : false,\n" + " \"allow_releases\" : true\n" + " }, {\n" + " \"type\": \"hosted\",\n" + " \"key\" : \"maven:hosted:local-deployments\",\n" + " \"snapshotTimeoutSeconds\" : 86400,\n" + " \"name\" : \"local-deployments\",\n" + " \"doctype\" : \"hosted\",\n" + " \"allow_snapshots\" : true,\n" + " \"allow_releases\" : true\n" + " }, {\n" + " \"type\": \"hosted\",\n" + " \"key\" : \"maven:hosted:AFhJnQLW\",\n" + " \"snapshotTimeoutSeconds\" : 0,\n" + " \"name\" : \"AFhJnQLW\",\n" + " \"doctype\" : \"hosted\",\n" + " \"allow_snapshots\" : false,\n" + " \"allow_releases\" : true\n" + " } ]\n" + "}";
/* @formatter:on */
final StoreListingDTO<HostedRepository> value = new IndyObjectMapper(true).readValue(json, new TypeReference<StoreListingDTO<HostedRepository>>() {
});
final List<HostedRepository> items = value.getItems();
assertThat(items.size(), equalTo(4));
int i = 0;
assertThat(items.get(i++).getName(), equalTo("eSPeEZPG"));
assertThat(items.get(i++).getName(), equalTo("qI3Cq2OZ"));
assertThat(items.get(i++).getName(), equalTo("local-deployments"));
assertThat(items.get(i++).getName(), equalTo("AFhJnQLW"));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class HostedRepositoryTest method copyFidelity.
@Test
public void copyFidelity() {
HostedRepository src = new HostedRepository(GenericPackageTypeDescriptor.GENERIC_PKG_KEY, "test");
src.setMetadata("key", "value");
src.setAllowReleases(false);
src.setAllowSnapshots(false);
src.setDescription("some description");
src.setDisableTimeout(500);
src.setDisabled(true);
src.setPathMaskPatterns(Collections.singleton("some/path"));
src.setTransientMetadata("transient", "someval");
src.setSnapshotTimeoutSeconds(600);
src.setStorage("/path/to/storage");
src.setPathStyle(PathStyle.hashed);
HostedRepository target = src.copyOf();
Stream.of(HostedRepository.class.getMethods()).filter(m -> m.getName().startsWith("get") && m.isAccessible() && m.getParameterCount() == 0).forEach(m -> {
try {
assertThat(m.getName() + " didn't get copied correctly!", m.invoke(target), equalTo(m.invoke(src)));
} catch (IllegalAccessException e) {
e.printStackTrace();
fail("Failed to invoke: " + m.getName());
} catch (InvocationTargetException e) {
e.printStackTrace();
}
});
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class AddAndDeleteHostedRepoTest method addMinimalHostedRepositoryAndDeleteIt.
@Test
public void addMinimalHostedRepositoryAndDeleteIt() throws Exception {
final HostedRepository repo = new HostedRepository(newName());
final HostedRepository result = client.stores().create(repo, name.getMethodName(), HostedRepository.class);
assertThat(result.getName(), equalTo(repo.getName()));
assertThat(result.equals(repo), equalTo(true));
client.stores().delete(StoreType.hosted, repo.getName(), name.getMethodName());
assertThat(client.stores().exists(StoreType.hosted, repo.getName()), equalTo(false));
}
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