Search in sources :

Example 6 with MetadataXml

use of com.artipie.maven.MetadataXml in project maven-adapter by artipie.

the class PutMetadataSliceTest method returnsCreatedAndSavesSnapshotMetadata.

@Test
void returnsCreatedAndSavesSnapshotMetadata() {
    final byte[] xml = new MetadataXml("com.example", "abc").get(new MetadataXml.VersionTags("0.1-SNAPSHOT", "0.2-SNAPSHOT")).getBytes(StandardCharsets.UTF_8);
    this.asto.save(new Key.From(UploadSlice.TEMP, "com/example/abc/0.2-SNAPSHOT/abc.jar"), Content.EMPTY).join();
    MatcherAssert.assertThat("Incorrect response status, CREATED is expected", this.pms, new SliceHasResponse(new RsHasStatus(RsStatus.CREATED), new RequestLine(RqMethod.PUT, "/com/example/abc/maven-metadata.xml"), new Headers.From(new ContentLength(xml.length)), new Content.OneTime(new Content.From(xml))));
    MatcherAssert.assertThat("Metadata file was not saved to storage", this.asto.value(new Key.From(".upload/com/example/abc/0.2-SNAPSHOT/meta/maven-metadata.xml")).join(), new ContentIs(xml));
}
Also used : SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) ContentIs(com.artipie.asto.test.ContentIs) RequestLine(com.artipie.http.rq.RequestLine) MetadataXml(com.artipie.maven.MetadataXml) Content(com.artipie.asto.Content) ContentLength(com.artipie.http.headers.ContentLength) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 7 with MetadataXml

use of com.artipie.maven.MetadataXml in project maven-adapter by artipie.

the class PutMetadataSliceTest method returnsCreatedAndSavesSnapshotMetadataWhenReleaseIsPresent.

@Test
void returnsCreatedAndSavesSnapshotMetadataWhenReleaseIsPresent() {
    final byte[] xml = new MetadataXml("com.example", "any").get(new MetadataXml.VersionTags(Optional.empty(), Optional.of("0.2"), new ListOf<String>("0.1", "0.2", "0.3-SNAPSHOT"))).getBytes(StandardCharsets.UTF_8);
    this.asto.save(new Key.From(UploadSlice.TEMP, "com/example/any/0.3-SNAPSHOT/any.jar"), Content.EMPTY).join();
    MatcherAssert.assertThat("Incorrect response status, CREATED is expected", this.pms, new SliceHasResponse(new RsHasStatus(RsStatus.CREATED), new RequestLine(RqMethod.PUT, "/com/example/any/maven-metadata.xml"), new Headers.From(new ContentLength(xml.length)), new Content.OneTime(new Content.From(xml))));
    MatcherAssert.assertThat("Metadata file was not saved to storage", this.asto.value(new Key.From(".upload/com/example/any/0.3-SNAPSHOT/meta/maven-metadata.xml")).join(), new ContentIs(xml));
}
Also used : SliceHasResponse(com.artipie.http.hm.SliceHasResponse) RsHasStatus(com.artipie.http.hm.RsHasStatus) ContentIs(com.artipie.asto.test.ContentIs) RequestLine(com.artipie.http.rq.RequestLine) MetadataXml(com.artipie.maven.MetadataXml) Content(com.artipie.asto.Content) ContentLength(com.artipie.http.headers.ContentLength) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 8 with MetadataXml

use of com.artipie.maven.MetadataXml in project maven-adapter by artipie.

the class AstoValidUploadTest method returnsFalseWhenMetadataIsNotValid.

@Test
void returnsFalseWhenMetadataIsNotValid() throws InterruptedException {
    final Key upload = new Key.From(".upload/com/test/logger");
    final Key artifact = new Key.From("com/test/logger");
    final Key jar = new Key.From("com/test/logger/1.0/my-package.jar");
    final byte[] bytes = "artifact".getBytes();
    this.bsto.save(jar, bytes);
    new MetadataXml("com.test", "jogger").addXmlToStorage(this.storage, new Key.From(upload, PutMetadataSlice.SUB_META, "maven-metadata.xml"), new MetadataXml.VersionTags("1.0", "1.0", "1.0"));
    this.addMetadata(artifact);
    this.bsto.save(jar, bytes);
    new RepositoryChecksums(this.storage).generate(jar).toCompletableFuture().join();
    MatcherAssert.assertThat(this.validupload.validate(upload, artifact).toCompletableFuture().join(), new IsEqual<>(false));
}
Also used : MetadataXml(com.artipie.maven.MetadataXml) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

MetadataXml (com.artipie.maven.MetadataXml)8 Content (com.artipie.asto.Content)7 Key (com.artipie.asto.Key)7 Test (org.junit.jupiter.api.Test)7 RsHasStatus (com.artipie.http.hm.RsHasStatus)6 SliceHasResponse (com.artipie.http.hm.SliceHasResponse)6 RequestLine (com.artipie.http.rq.RequestLine)6 ContentIs (com.artipie.asto.test.ContentIs)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 ContentDigest (com.artipie.asto.ext.ContentDigest)3 ContentLength (com.artipie.http.headers.ContentLength)3 Maven (com.artipie.maven.Maven)3 Storage (com.artipie.asto.Storage)1 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)1 KeyLastPart (com.artipie.asto.ext.KeyLastPart)1 PublisherAs (com.artipie.asto.ext.PublisherAs)1 FileStorage (com.artipie.asto.fs.FileStorage)1 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)1 TestResource (com.artipie.asto.test.TestResource)1 PutMetadataSlice (com.artipie.maven.http.PutMetadataSlice)1