Search in sources :

Example 1 with Content

use of org.sonatype.nexus.repository.view.Content in project nexus-repository-r by sonatype-nexus-community.

the class RFacetUtilsTest method content.

@Test
public void content() throws Exception {
    Content content = toContent(asset, blob);
    assertThat(content.getAttributes().get("lastModified"), is(notNullValue()));
}
Also used : RFacetUtils.toContent(org.sonatype.nexus.repository.r.internal.RFacetUtils.toContent) Content(org.sonatype.nexus.repository.view.Content) Test(org.junit.Test)

Example 2 with Content

use of org.sonatype.nexus.repository.view.Content in project nexus-repository-r by sonatype-nexus-community.

the class RHostedFacetImplTest method getPackagesReturnsCorrectContentType.

@Test
public void getPackagesReturnsCorrectContentType() throws Exception {
    Content packages = underTest.getPackages(PACKAGE_PATH);
    assertThat(packages.getContentType(), is(equalTo("application/x-gzip")));
}
Also used : Content(org.sonatype.nexus.repository.view.Content) Test(org.junit.Test)

Example 3 with Content

use of org.sonatype.nexus.repository.view.Content in project nexus-repository-r by sonatype-nexus-community.

the class RHostedFacetImplTest method getArchive.

@Test
public void getArchive() throws Exception {
    Content archive = underTest.getArchive(PACKAGE_PATH);
    assertThat(archive, is(notNullValue()));
}
Also used : Content(org.sonatype.nexus.repository.view.Content) Test(org.junit.Test)

Example 4 with Content

use of org.sonatype.nexus.repository.view.Content in project nexus-repository-r by sonatype-nexus-community.

the class RFacetUtils method toContent.

/**
 * Convert an asset blob to {@link Content}.
 *
 * @return content of asset blob
 */
static Content toContent(final Asset asset, final Blob blob) {
    Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
    Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes());
    return content;
}
Also used : BlobPayload(org.sonatype.nexus.repository.view.payloads.BlobPayload) Content(org.sonatype.nexus.repository.view.Content)

Example 5 with Content

use of org.sonatype.nexus.repository.view.Content in project nexus-repository-r by sonatype-nexus-community.

the class RHostedFacetImplTest method getContentReturnsCorrectContentType.

@Test
public void getContentReturnsCorrectContentType() throws Exception {
    when(asset.requireContentType()).thenReturn("application/x-gzip");
    Content packages = underTest.getStoredContent(PACKAGE_PATH);
    assertThat(packages.getContentType(), is(equalTo("application/x-gzip")));
}
Also used : Content(org.sonatype.nexus.repository.view.Content) Test(org.junit.Test)

Aggregations

Content (org.sonatype.nexus.repository.view.Content)17 Test (org.junit.Test)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 OutputStreamWriter (java.io.OutputStreamWriter)3 InternetHeaders (javax.mail.internet.InternetHeaders)3 CompressorException (org.apache.commons.compress.compressors.CompressorException)3 CompressorOutputStream (org.apache.commons.compress.compressors.CompressorOutputStream)3 CompressorStreamFactory (org.apache.commons.compress.compressors.CompressorStreamFactory)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Map (java.util.Map)2 AttributesMap (org.sonatype.nexus.common.collect.AttributesMap)2 RFacetUtils.toContent (org.sonatype.nexus.repository.r.internal.RFacetUtils.toContent)2 RFacetUtils.toContent (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.toContent)2 Asset (org.sonatype.nexus.repository.storage.Asset)2 Bucket (org.sonatype.nexus.repository.storage.Bucket)2 StorageTx (org.sonatype.nexus.repository.storage.StorageTx)2 TransactionalTouchMetadata (org.sonatype.nexus.repository.transaction.TransactionalTouchMetadata)2 BlobPayload (org.sonatype.nexus.repository.view.payloads.BlobPayload)2 BytesPayload (org.sonatype.nexus.repository.view.payloads.BytesPayload)2