Search in sources :

Example 26 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage in project maven-adapter by artipie.

the class ArtifactHeadResponseTest method noBodyIfExists.

@Test
void noBodyIfExists() throws Exception {
    final Storage storage = new InMemoryStorage();
    final Key key = new Key.From("repo/artifact2.jar");
    new BlockingStorage(storage).save(key, "data".getBytes(StandardCharsets.UTF_8));
    MatcherAssert.assertThat(new ArtifactHeadResponse(storage, key), new RsHasBody(new byte[0]));
}
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 27 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage in project artipie by artipie.

the class UsersFromStorageYamlTest method init.

@BeforeEach
void init() {
    this.storage = new InMemoryStorage();
    this.key = new Key.From("_cred.yaml");
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Key(com.artipie.asto.Key) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 28 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage in project artipie by artipie.

the class MetricSliceTest method shouldReturnMetricsInJsonArray.

@Test
void shouldReturnMetricsInJsonArray() {
    final String keyone = "one";
    final String keytwo = "two";
    final String json = "[{\"key\":\"%s\",\"value\":%s},{\"key\":\"%s\",\"value\":%s}]";
    final long valone = 1;
    final long valtwo = 2;
    final String dirorder = String.format(json, keyone, valone, keytwo, valtwo);
    final String revorder = String.format(json, keytwo, valtwo, keyone, valone);
    final Storage storage = new InMemoryStorage();
    storage.save(new Key.From(keyone), this.getContent(valone));
    storage.save(new Key.From(keytwo), this.getContent(valtwo));
    MatcherAssert.assertThat(new MetricSlice(storage), new SliceHasResponse(new AllOf<>(Arrays.asList(new RsHasStatus(RsStatus.OK), new AnyOf<>(Arrays.asList(new RsHasBody(dirorder, StandardCharsets.UTF_8), new RsHasBody(revorder, StandardCharsets.UTF_8))))), new RequestLine(RqMethod.GET, "/api/repositories/")));
}
Also used : SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) AnyOf(org.hamcrest.core.AnyOf) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) RequestLine(com.artipie.http.rq.RequestLine) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Storage(com.artipie.asto.Storage) RsHasBody(com.artipie.http.hm.RsHasBody) Key(com.artipie.asto.Key) AllOf(org.hamcrest.core.AllOf) Test(org.junit.jupiter.api.Test)

Example 29 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage in project artipie by artipie.

the class ConfigFileTest method existInStorageReturnsTrueWhenYamlExist.

@ParameterizedTest
@ValueSource(strings = { ".yaml", ".yml", "" })
void existInStorageReturnsTrueWhenYamlExist(final String extension) {
    final Storage storage = new InMemoryStorage();
    this.saveByKey(storage, ".yaml");
    MatcherAssert.assertThat(new ConfigFile(new Key.From(ConfigFileTest.NAME + extension)).existsIn(storage).toCompletableFuture().join(), new IsEqual<>(true));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Storage(com.artipie.asto.Storage) Key(com.artipie.asto.Key) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 30 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage in project artipie by artipie.

the class ConfigFileTest method valueFromStorageReturnsContentWhenYamlExist.

@ParameterizedTest
@ValueSource(strings = { ".yaml", ".yml", "" })
void valueFromStorageReturnsContentWhenYamlExist(final String extension) {
    final Storage storage = new InMemoryStorage();
    this.saveByKey(storage, ".yml");
    MatcherAssert.assertThat(new PublisherAs(new ConfigFile(new Key.From(ConfigFileTest.NAME + extension)).valueFrom(storage).toCompletableFuture().join()).bytes().toCompletableFuture().join(), new IsEqual<>(ConfigFileTest.CONTENT));
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) PublisherAs(com.artipie.asto.ext.PublisherAs) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Storage(com.artipie.asto.Storage) Key(com.artipie.asto.Key) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)30 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)17 Key (com.artipie.asto.Key)16 Storage (com.artipie.asto.Storage)14 BeforeEach (org.junit.jupiter.api.BeforeEach)14 Test (org.junit.jupiter.api.Test)13 RsHasStatus (com.artipie.http.hm.RsHasStatus)6 LoggingSlice (com.artipie.http.slice.LoggingSlice)4 VertxSliceServer (com.artipie.vertx.VertxSliceServer)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 PublisherAs (com.artipie.asto.ext.PublisherAs)3 TestResource (com.artipie.asto.test.TestResource)3 YamlUsers (com.artipie.front.auth.YamlUsers)3 RepoSettings (com.artipie.front.settings.RepoSettings)3 RsHasBody (com.artipie.http.hm.RsHasBody)3 Content (com.artipie.asto.Content)2 FromStorageCache (com.artipie.asto.cache.FromStorageCache)2 Authentication (com.artipie.http.auth.Authentication)2 JettyClientSlices (com.artipie.http.client.jetty.JettyClientSlices)2 RequestLine (com.artipie.http.rq.RequestLine)2