use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class AbstractContentManagementTest method before.
@Before
public void before() throws Exception {
if (!createStandardTestStructures()) {
return;
}
final String changelog = "Create test structures";
final HostedRepository hosted = this.client.stores().create(new HostedRepository(STORE), changelog, HostedRepository.class);
client.stores().delete(remote, CENTRAL, "removing to setup test instance");
final RemoteRepository central = client.stores().create(new RemoteRepository(CENTRAL, server.formatUrl("central")), changelog, RemoteRepository.class);
Group g;
if (client.stores().exists(group, PUBLIC)) {
System.out.println("Loading pre-existing public group.");
g = client.stores().load(group, PUBLIC, Group.class);
} else {
System.out.println("Creating new group 'public'");
g = client.stores().create(new Group(PUBLIC), changelog, Group.class);
}
g.setConstituents(Arrays.asList(hosted.getKey(), central.getKey()));
client.stores().update(g, changelog);
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class DeleteHostedRepoWithContentTest method run.
@Test
public void run() throws Exception {
final HostedRepository repo = new HostedRepository(MAVEN_PKG_KEY, "build_perftest-20200229T021845");
final StoreKey key = repo.getKey();
final HostedRepository result = client.stores().create(repo, name.getMethodName(), HostedRepository.class);
assertThat(result.getName(), equalTo(repo.getName()));
assertThat(result.equals(repo), equalTo(true));
// Store files
client.content().store(repo.getKey(), path_1, new ByteArrayInputStream(content.getBytes()));
client.content().store(repo.getKey(), path_2, new ByteArrayInputStream(content.getBytes()));
ConcreteResource r1 = new ConcreteResource(LocationUtils.toLocation(repo), path_1);
ConcreteResource r2 = new ConcreteResource(LocationUtils.toLocation(repo), path_2);
// Verify files exist
assertTrue(cacheProvider.exists(r1));
assertTrue(cacheProvider.exists(r2));
// Delete repo with deleteContent flag
client.stores().delete(key, "Delete", true);
assertThat(client.stores().exists(key), equalTo(false));
// Verify files were deleted
assertFalse(cacheProvider.exists(r1));
assertFalse(cacheProvider.exists(r2));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class DownloadFromSecondRemoteAfterFirstHostedRepoTest method setupTest.
@Before
public void setupTest() throws Exception {
String change = "test setup";
hosted = client.stores().create(new HostedRepository(HOSTED), change, HostedRepository.class);
remote = client.stores().create(new RemoteRepository(REMOTE, server.formatUrl(REMOTE)), change, RemoteRepository.class);
group = client.stores().create(new Group(GROUP, hosted.getKey(), remote.getKey()), change, Group.class);
client.content().store(hosted.getKey(), JAR_PATH, new ByteArrayInputStream("This is the jar".getBytes()));
server.expect(server.formatUrl(REMOTE, PATH), 200, CONTENT);
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class DeleteGroupWithContentTest method run.
@Test
@Category(EventDependent.class)
public void run() throws Exception {
// Create hosted repo
final HostedRepository repo = new HostedRepository(MAVEN_PKG_KEY, "test_1");
assertThat(client.stores().create(repo, name.getMethodName(), HostedRepository.class), notNullValue());
// Store pom file in hosted repo
client.content().store(repo.getKey(), pomPath, new ByteArrayInputStream(pomContent.getBytes()));
// Generate metadata file in hosted repo
try (InputStream in = client.content().get(repo.getKey(), metadataPath)) {
IOUtils.toString(in);
}
// Verify the hosted meta file exists
ConcreteResource r_meta_hosted = new ConcreteResource(LocationUtils.toLocation(repo), metadataPath);
assertTrue(cacheProvider.exists(r_meta_hosted));
// Create group with hosted member
final Group group = new Group(MAVEN_PKG_KEY, "test_1", repo.getKey());
assertThat(client.stores().create(group, name.getMethodName(), Group.class), notNullValue());
// Generate group metadata file
try (InputStream in = client.content().get(group.getKey(), metadataPath)) {
IOUtils.toString(in);
}
// Verify the group meta file exists
ConcreteResource r_meta = new ConcreteResource(LocationUtils.toLocation(group), metadataPath);
assertTrue(cacheProvider.exists(r_meta));
// Delete group
client.stores().delete(group.getKey(), "Delete", true);
assertThat(client.stores().exists(group.getKey()), equalTo(false));
// Verify the group meta file gone
assertFalse(cacheProvider.exists(r_meta));
// Verify hosted files not change (delete group not affect the files in hosted repo)
ConcreteResource r1 = new ConcreteResource(LocationUtils.toLocation(repo), pomPath);
assertTrue(cacheProvider.exists(r1));
assertTrue(cacheProvider.exists(r_meta_hosted));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class GroupMetadataMergeWhenSeqNewHostedAddedInMultiHostedGroupTest method createHostedAndStorePath.
private HostedRepository createHostedAndStorePath(final String repoName, final String path, final String content) throws Exception {
HostedRepository hosted = new HostedRepository(repoName);
hosted = client.stores().create(hosted, "adding " + repoName, HostedRepository.class);
if (StringUtils.isNotBlank(content)) {
client.content().store(hosted.getKey(), path, new ByteArrayInputStream(content.getBytes()));
}
return hosted;
}
Aggregations