use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class CalculateGroupTest method calculate.
@Test
public void calculate() throws Exception {
final String name = "test";
final AutoProxCalculation calculation = module.calculateRuleOutput(StoreType.group, name);
assertThat(calculation.getRuleName(), equalTo("0001-simple-rule"));
final List<ArtifactStore> supplemental = calculation.getSupplementalStores();
assertThat(supplemental.size(), equalTo(4));
final Group store = (Group) calculation.getStore();
assertThat(store.getName(), equalTo(name));
int idx = 0;
ArtifactStore supp = supplemental.get(idx);
assertThat(supp.getName(), equalTo(name));
assertThat(supp instanceof HostedRepository, equalTo(true));
final HostedRepository hosted = (HostedRepository) supp;
assertThat(hosted.isAllowReleases(), equalTo(true));
assertThat(hosted.isAllowSnapshots(), equalTo(true));
idx++;
supp = supplemental.get(idx);
assertThat(supp.getName(), equalTo(name));
assertThat(supp instanceof RemoteRepository, equalTo(true));
final RemoteRepository remote = (RemoteRepository) supp;
assertThat(remote.getUrl(), equalTo("http://localhost:1000/target/" + name));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class ReaonlyHostedDeleteFileTest method deleteFileNotAllowed.
@Test
public void deleteFileNotAllowed() throws Exception {
final String content = "This is a test: " + System.nanoTime();
InputStream stream = new ByteArrayInputStream(content.getBytes());
final String path = "/path/to/foo.class";
final String repoName = "test-hosted";
HostedRepository repo = new HostedRepository(repoName);
repo = client.stores().create(repo, name.getMethodName(), HostedRepository.class);
assertThat(client.content().exists(hosted, repoName, path), equalTo(false));
client.content().store(hosted, repoName, path, stream);
assertThat(client.content().exists(hosted, repoName, path), equalTo(true));
repo.setReadonly(true);
client.stores().update(repo, name.getMethodName());
try {
client.content().delete(hosted, repoName, path);
} catch (IndyClientException e) {
assertThat(e.getStatusCode(), equalTo(ApplicationStatus.METHOD_NOT_ALLOWED.code()));
}
assertThat(client.content().exists(hosted, repoName, path), equalTo(true));
repo.setReadonly(false);
client.stores().update(repo, name.getMethodName());
client.content().delete(hosted, repoName, path);
assertThat(client.content().exists(hosted, repoName, path), equalTo(false));
}
Aggregations