Search in sources :

Example 11 with InMemoryStorage

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

the class RepositoryChecksumsTest method findsArtifactChecksums.

@Test
void findsArtifactChecksums() throws Exception {
    // @checkstyle LocalFinalVariableNameCheck (20 lines)
    final Storage storage = new InMemoryStorage();
    final BlockingStorage bsto = new BlockingStorage(storage);
    final Key.From artifact = new Key.From("com/test/1.0/my-package.jar");
    bsto.save(artifact, "artifact".getBytes());
    final String sha1 = "c71de136f9377eca14b4218cc7001c8060c6974f";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.sha1"), sha1.getBytes(StandardCharsets.UTF_8));
    final String sha256 = "62090f2241986a8361242e47cf541657099fdccc0c08e34cd694922bdcf31893";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.sha256"), sha256.getBytes(StandardCharsets.UTF_8));
    // @checkstyle LineLengthCheck (1 line)
    final String sha512 = "cf713dd3f077719375e646a23dee1375725652f5f275b0bf25d326062b3a64535575acde6d27b547fcd735c870cf94badc4b2215aba9c3af5085567b4561ac28";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.sha512"), sha512.getBytes(StandardCharsets.UTF_8));
    final String mdfive = "dc829bf0d79e690c59cee708b527e6b7";
    bsto.save(new Key.From("com/test/1.0/my-package.jar.md5"), mdfive.getBytes(StandardCharsets.UTF_8));
    MatcherAssert.assertThat(new RepositoryChecksums(storage).checksums(artifact).toCompletableFuture().get(), Matchers.allOf(Matchers.hasEntry("sha1", sha1), Matchers.hasEntry("sha256", sha256), Matchers.hasEntry("sha512", sha512), Matchers.hasEntry("md5", mdfive)));
}
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) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 12 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage 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 13 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage 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 14 with InMemoryStorage

use of com.artipie.asto.memory.InMemoryStorage 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 15 with InMemoryStorage

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

the class PutMetadataSliceTest method init.

@BeforeEach
void init() {
    this.asto = new InMemoryStorage();
    this.pms = new PutMetadataSlice(this.asto);
}
Also used : InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BeforeEach(org.junit.jupiter.api.BeforeEach)

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