Search in sources :

Example 21 with CreateStorageResponse

use of ddf.catalog.content.operation.CreateStorageResponse in project ddf by codice.

the class FileSystemStorageProviderTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    CreateStorageResponse createResponse = assertContentItem(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME);
    String id = createResponse.getCreatedContentItems().get(0).getId();
    ByteSource byteSource = new ByteSource() {

        @Override
        public InputStream openStream() throws IOException {
            return IOUtils.toInputStream("Updated NITF");
        }
    };
    ContentItem updateItem = new ContentItemImpl(id, byteSource, NITF_MIME_TYPE, mock(Metacard.class));
    submitAndVerifySuccessfulUpdateStorageRequest(updateItem);
}
Also used : CreateStorageResponse(ddf.catalog.content.operation.CreateStorageResponse) Metacard(ddf.catalog.data.Metacard) ByteSource(com.google.common.io.ByteSource) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) ContentItem(ddf.catalog.content.data.ContentItem) ContentItemImpl(ddf.catalog.content.data.impl.ContentItemImpl) Test(org.junit.Test)

Example 22 with CreateStorageResponse

use of ddf.catalog.content.operation.CreateStorageResponse in project ddf by codice.

the class FileSystemStorageProviderTest method testCreateAndReadReference.

@Test
public void testCreateAndReadReference() throws Exception {
    String path = baseTmpDir + File.separator + TEST_INPUT_FILENAME;
    FileUtils.writeStringToFile(new File(path), TEST_INPUT_CONTENTS);
    Map<String, Serializable> properties = new HashMap<>();
    properties.put(Constants.STORE_REFERENCE_KEY, path);
    CreateStorageResponse createResponse = assertContentItem(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME, properties);
    String uriString = createResponse.getCreatedContentItems().get(0).getUri();
    assertReadRequest(uriString, NITF_MIME_TYPE, true);
}
Also used : CreateStorageResponse(ddf.catalog.content.operation.CreateStorageResponse) Serializable(java.io.Serializable) HashMap(java.util.HashMap) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) File(java.io.File) Test(org.junit.Test)

Example 23 with CreateStorageResponse

use of ddf.catalog.content.operation.CreateStorageResponse in project ddf by codice.

the class FileSystemStorageProviderTest method testRead.

@Test
public void testRead() throws Exception {
    CreateStorageResponse createResponse = assertContentItem(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME);
    String uriString = createResponse.getCreatedContentItems().get(0).getUri();
    assertReadRequest(uriString, NITF_MIME_TYPE);
}
Also used : CreateStorageResponse(ddf.catalog.content.operation.CreateStorageResponse) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Test(org.junit.Test)

Example 24 with CreateStorageResponse

use of ddf.catalog.content.operation.CreateStorageResponse in project ddf by codice.

the class FileSystemStorageProviderTest method testReadWithMultipleItems.

@Test
public void testReadWithMultipleItems() throws Exception {
    CreateStorageResponse createResponse = assertContentItem(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME);
    String unqualifiedUriString = createResponse.getCreatedContentItems().get(0).getUri();
    createResponse = assertContentItemWithQualifier(TEST_INPUT_CONTENTS, NITF_MIME_TYPE, TEST_INPUT_FILENAME, createResponse.getCreatedContentItems().get(0).getId(), QUALIFIER);
    String qualifiedUriString = createResponse.getCreatedContentItems().get(0).getUri();
    assertReadRequest(unqualifiedUriString, NITF_MIME_TYPE);
    assertReadRequest(qualifiedUriString, NITF_MIME_TYPE);
}
Also used : CreateStorageResponse(ddf.catalog.content.operation.CreateStorageResponse) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Test(org.junit.Test)

Aggregations

CreateStorageResponse (ddf.catalog.content.operation.CreateStorageResponse)24 ContentItem (ddf.catalog.content.data.ContentItem)18 Test (org.junit.Test)17 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)16 Metacard (ddf.catalog.data.Metacard)11 ByteSource (com.google.common.io.ByteSource)9 ContentItemImpl (ddf.catalog.content.data.impl.ContentItemImpl)9 CreateStorageRequestImpl (ddf.catalog.content.operation.impl.CreateStorageRequestImpl)7 StorageException (ddf.catalog.content.StorageException)5 CreateStorageRequest (ddf.catalog.content.operation.CreateStorageRequest)5 DeleteStorageRequest (ddf.catalog.content.operation.DeleteStorageRequest)5 DeleteStorageResponse (ddf.catalog.content.operation.DeleteStorageResponse)5 DeleteStorageRequestImpl (ddf.catalog.content.operation.impl.DeleteStorageRequestImpl)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 ReadStorageResponse (ddf.catalog.content.operation.ReadStorageResponse)4 ReadStorageRequestImpl (ddf.catalog.content.operation.impl.ReadStorageRequestImpl)4 IOException (java.io.IOException)4 URI (java.net.URI)4 ReadStorageRequest (ddf.catalog.content.operation.ReadStorageRequest)3