Search in sources :

Example 6 with TestResource

use of com.artipie.asto.test.TestResource in project artipie by artipie.

the class RepositoriesFromStorageCacheTest method readAliasesFromCache.

@Test
void readAliasesFromCache() {
    final Key alias = new Key.From("_storages.yaml");
    final Key config = new Key.From("bin.yaml");
    new TestResource(alias.string()).saveTo(this.storage);
    new BlockingStorage(this.storage).save(config, "repo:\n  storage: default".getBytes());
    final ClientSlices http = new JettyClientSlices();
    new RepositoriesFromStorage(http, this.storage).config(config.string()).toCompletableFuture().join();
    this.storage.save(alias, Content.EMPTY).join();
    MatcherAssert.assertThat(new RepositoriesFromStorage(http, this.storage).config(config.string()).toCompletableFuture().join().storageOpt().isPresent(), new IsEqual<>(true));
}
Also used : BlockingStorage(com.artipie.asto.blocking.BlockingStorage) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) TestResource(com.artipie.asto.test.TestResource) Key(com.artipie.asto.Key) ClientSlices(com.artipie.http.client.ClientSlices) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) Test(org.junit.jupiter.api.Test)

Example 7 with TestResource

use of com.artipie.asto.test.TestResource in project artipie by artipie.

the class CondaITCase method canInstallFromArtipie.

@Test
void canInstallFromArtipie() throws IOException {
    this.moveCondarc();
    this.containers.putBinaryToArtipie(new TestResource("conda/packages.json").asBytes(), "/var/artipie/data/my-conda/linux-64/repodata.json");
    this.containers.putBinaryToArtipie(new TestResource("conda/snappy-1.1.3-0.tar.bz2").asBytes(), "/var/artipie/data/my-conda/linux-64/snappy-1.1.3-0.tar.bz2");
    this.containers.assertExec("Package snappy-1.1.3-0 was not installed successfully", new ContainerResultMatcher(new IsEqual<>(0), Matchers.allOf(new StringContains("http://artipie:8080/my-conda"), new StringContains("linux-64::snappy-1.1.3-0"))), "conda", "install", "--verbose", "-y", "snappy");
}
Also used : TestResource(com.artipie.asto.test.TestResource) ContainerResultMatcher(com.artipie.test.ContainerResultMatcher) IsEqual(org.hamcrest.core.IsEqual) StringContains(org.hamcrest.core.StringContains) Test(org.junit.jupiter.api.Test)

Example 8 with TestResource

use of com.artipie.asto.test.TestResource in project maven-adapter by artipie.

the class MavenITCase method copyHellowordSourceToContainer.

private void copyHellowordSourceToContainer() throws IOException {
    FileUtils.copyDirectory(new TestResource("helloworld-src").asPath().toFile(), this.tmp.resolve("helloworld-src").toFile());
    Files.write(this.tmp.resolve("helloworld-src/pom.xml"), String.format(Files.readString(this.tmp.resolve("helloworld-src/pom.xml.template")), this.port).getBytes());
}
Also used : TestResource(com.artipie.asto.test.TestResource)

Example 9 with TestResource

use of com.artipie.asto.test.TestResource in project maven-adapter by artipie.

the class AstoMavenTest method addFilesToStorage.

private void addFilesToStorage(final Predicate<String> condition, final Key base) {
    final Storage resources = new FileStorage(new TestResource("com/artipie/asto").asPath());
    final BlockingStorage bsto = new BlockingStorage(resources);
    bsto.list(Key.ROOT).stream().map(Key::string).filter(condition).forEach(item -> new BlockingStorage(this.storage).save(new Key.From(base, item), bsto.value(new Key.From(item))));
}
Also used : BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Storage(com.artipie.asto.Storage) FileStorage(com.artipie.asto.fs.FileStorage) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) FileStorage(com.artipie.asto.fs.FileStorage) TestResource(com.artipie.asto.test.TestResource) Key(com.artipie.asto.Key)

Example 10 with TestResource

use of com.artipie.asto.test.TestResource in project maven-adapter by artipie.

the class AstoMavenTest method generatesMetadataForFirstArtifact.

@Test
void generatesMetadataForFirstArtifact() {
    final String version = "1.0";
    new TestResource("maven-metadata.xml.example").saveTo(this.storage, new Key.From(AstoMavenTest.LGR_UPLOAD, version, PutMetadataSlice.SUB_META, "maven-metadata.xml"));
    new AstoMaven(this.storage).update(new Key.From(AstoMavenTest.LGR_UPLOAD, version), AstoMavenTest.LGR).toCompletableFuture().join();
    MatcherAssert.assertThat("Maven metadata xml is not correct", new XMLDocument(this.storage.value(new Key.From(AstoMavenTest.LGR, "maven-metadata.xml")).thenCompose(content -> new PublisherAs(content).string(StandardCharsets.UTF_8)).join()), new AllOf<>(new ListOf<Matcher<? super XML>>(XhtmlMatchers.hasXPath("/metadata/groupId[text() = 'com.test']"), XhtmlMatchers.hasXPath("/metadata/artifactId[text() = 'logger']"), XhtmlMatchers.hasXPath("/metadata/versioning/latest[text() = '1.0']"), XhtmlMatchers.hasXPath("/metadata/versioning/release[text() = '1.0']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions/version[text() = '1.0']"), XhtmlMatchers.hasXPath("/metadata/versioning/versions[count(//version) = 1]"), XhtmlMatchers.hasXPath("/metadata/versioning/lastUpdated"))));
    MatcherAssert.assertThat("Upload directory was not cleaned up", this.storage.list(new Key.From(AstoMavenTest.LGR_UPLOAD, version)).join().size(), new IsEqual<>(0));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) MetadataXml(com.artipie.maven.MetadataXml) XhtmlMatchers(com.jcabi.matchers.XhtmlMatchers) AllOf(org.hamcrest.core.AllOf) Storage(com.artipie.asto.Storage) FileStorage(com.artipie.asto.fs.FileStorage) ListOf(org.cactoos.list.ListOf) IsEqual(org.hamcrest.core.IsEqual) TestResource(com.artipie.asto.test.TestResource) XMLDocument(com.jcabi.xml.XMLDocument) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Predicate(java.util.function.Predicate) KeyLastPart(com.artipie.asto.ext.KeyLastPart) Matchers(org.hamcrest.Matchers) PutMetadataSlice(com.artipie.maven.http.PutMetadataSlice) Content(com.artipie.asto.Content) Key(com.artipie.asto.Key) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) PublisherAs(com.artipie.asto.ext.PublisherAs) Stream(java.util.stream.Stream) MatcherAssert(org.hamcrest.MatcherAssert) Matcher(org.hamcrest.Matcher) Optional(java.util.Optional) XML(com.jcabi.xml.XML) PublisherAs(com.artipie.asto.ext.PublisherAs) ListOf(org.cactoos.list.ListOf) TestResource(com.artipie.asto.test.TestResource) Key(com.artipie.asto.Key) XMLDocument(com.jcabi.xml.XMLDocument) Test(org.junit.jupiter.api.Test)

Aggregations

TestResource (com.artipie.asto.test.TestResource)20 Test (org.junit.jupiter.api.Test)16 IsEqual (org.hamcrest.core.IsEqual)10 Key (com.artipie.asto.Key)9 ContainerResultMatcher (com.artipie.test.ContainerResultMatcher)9 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)6 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)6 Storage (com.artipie.asto.Storage)5 StringContains (org.hamcrest.core.StringContains)5 StringContainsInOrder (org.hamcrest.text.StringContainsInOrder)5 Content (com.artipie.asto.Content)3 FileStorage (com.artipie.asto.fs.FileStorage)3 MatcherAssert (org.hamcrest.MatcherAssert)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 KeyLastPart (com.artipie.asto.ext.KeyLastPart)2 PublisherAs (com.artipie.asto.ext.PublisherAs)2 RepoSettings (com.artipie.front.settings.RepoSettings)2 JettyClientSlices (com.artipie.http.client.jetty.JettyClientSlices)2 MetadataXml (com.artipie.maven.MetadataXml)2