Search in sources :

Example 11 with BlockingStorage

use of com.artipie.asto.blocking.BlockingStorage in project maven-adapter by artipie.

the class ArtifactGetResponseTest method okIfArtifactExists.

@Test
void okIfArtifactExists() throws Exception {
    final Storage storage = new InMemoryStorage();
    final Key key = new Key.From("repo/artifact.jar");
    new BlockingStorage(storage).save(key, "something".getBytes());
    MatcherAssert.assertThat(new ArtifactGetResponse(storage, key), new RsHasStatus(RsStatus.OK));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Storage(com.artipie.asto.Storage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) RsHasStatus(com.artipie.http.hm.RsHasStatus) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 12 with BlockingStorage

use of com.artipie.asto.blocking.BlockingStorage in project maven-adapter by artipie.

the class ArtifactGetResponseTest method hasBodyIfExists.

@Test
void hasBodyIfExists() throws Exception {
    final Storage storage = new InMemoryStorage();
    final Key key = new Key.From("repo/artifact2.jar");
    final byte[] data = "data".getBytes(StandardCharsets.UTF_8);
    new BlockingStorage(storage).save(key, data);
    MatcherAssert.assertThat(new ArtifactGetResponse(storage, key), new RsHasBody(data));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Storage(com.artipie.asto.Storage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) RsHasBody(com.artipie.http.hm.RsHasBody) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 13 with BlockingStorage

use of com.artipie.asto.blocking.BlockingStorage in project maven-adapter by artipie.

the class ArtifactHeadResponseTest method okIfArtifactExists.

@Test
void okIfArtifactExists() throws Exception {
    final Storage storage = new InMemoryStorage();
    final Key key = new Key.From("repo/artifact.jar");
    new BlockingStorage(storage).save(key, "something".getBytes());
    MatcherAssert.assertThat(new ArtifactHeadResponse(storage, key), new RsHasStatus(RsStatus.OK));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Storage(com.artipie.asto.Storage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) RsHasStatus(com.artipie.http.hm.RsHasStatus) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 14 with BlockingStorage

use of com.artipie.asto.blocking.BlockingStorage in project front by artipie.

the class GetRepositoryPermissionsTest method init.

@BeforeEach
void init() {
    this.blsto = new BlockingStorage(new InMemoryStorage());
    this.snt = new RepoSettings("flat", this.blsto);
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) RepoSettings(com.artipie.front.settings.RepoSettings) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with BlockingStorage

use of com.artipie.asto.blocking.BlockingStorage in project front by artipie.

the class GetRepositoryTest method returnsRepositorySettings.

@ParameterizedTest
@CsvSource({ "yaml,my-maven", "yml,my-npm-proxy" })
void returnsRepositorySettings(final String ext, final String name) throws Exception {
    final BlockingStorage blsto = new BlockingStorage(new InMemoryStorage());
    final String file = String.format("%s.%s", name, ext);
    blsto.save(new Key.From(file), new TestResource(String.format("GetRepositoryTest/%s", file)).asBytes());
    final var resp = Mockito.mock(Response.class);
    final var rqs = Mockito.mock(Request.class);
    Mockito.when(rqs.params(GetRepository.NAME_PARAM.toString())).thenReturn(name);
    Mockito.when(rqs.attribute(RequestAttr.Standard.USER_ID.attrName())).thenReturn("any");
    JSONAssert.assertEquals(new GetRepository(new RepoSettings("flat", blsto)).handle(rqs, resp), new String(new TestResource(String.format("GetRepositoryTest/%s.json", name)).asBytes(), StandardCharsets.UTF_8), true);
    Mockito.verify(resp).type("application/json");
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) RepoSettings(com.artipie.front.settings.RepoSettings) TestResource(com.artipie.asto.test.TestResource) Key(com.artipie.asto.Key) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BlockingStorage (com.artipie.asto.blocking.BlockingStorage)19 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)15 Key (com.artipie.asto.Key)13 Test (org.junit.jupiter.api.Test)10 Storage (com.artipie.asto.Storage)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 TestResource (com.artipie.asto.test.TestResource)4 YamlUsers (com.artipie.front.auth.YamlUsers)3 RepoSettings (com.artipie.front.settings.RepoSettings)3 YamlMapping (com.amihaiemil.eoyaml.YamlMapping)2 ClientSlices (com.artipie.http.client.ClientSlices)2 JettyClientSlices (com.artipie.http.client.jetty.JettyClientSlices)2 RsHasBody (com.artipie.http.hm.RsHasBody)2 RsHasStatus (com.artipie.http.hm.RsHasStatus)2 FileStorage (com.artipie.asto.fs.FileStorage)1 SettingsCaches (com.artipie.cache.SettingsCaches)1 Path (java.nio.file.Path)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 CsvSource (org.junit.jupiter.params.provider.CsvSource)1