Search in sources :

Example 76 with HostedRepository

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));
}
Also used : Group(org.commonjava.indy.model.core.Group) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) AutoProxCalculation(org.commonjava.indy.autoprox.rest.dto.AutoProxCalculation) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Example 77 with HostedRepository

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));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IndyClientException(org.commonjava.indy.client.core.IndyClientException) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Aggregations

HostedRepository (org.commonjava.indy.model.core.HostedRepository)77 Test (org.junit.Test)47 Group (org.commonjava.indy.model.core.Group)44 ByteArrayInputStream (java.io.ByteArrayInputStream)37 Transfer (org.commonjava.maven.galley.model.Transfer)21 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)18 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)15 Before (org.junit.Before)15 InputStream (java.io.InputStream)13 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)11 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)11 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)10 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)9 PackageMetadata (org.commonjava.indy.pkg.npm.model.PackageMetadata)7 PathsPromoteRequest (org.commonjava.indy.promote.model.PathsPromoteRequest)7 PathsPromoteResult (org.commonjava.indy.promote.model.PathsPromoteResult)7 Metadata (org.apache.maven.artifact.repository.metadata.Metadata)6 Versioning (org.apache.maven.artifact.repository.metadata.Versioning)6 MetadataXpp3Reader (org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader)6 IndyDataException (org.commonjava.indy.data.IndyDataException)6