fmc = new XmlRpcFileManagerClient(new URL("http://localhost:" + FM_PORT));
} catch (Exception e) {
fail(e.getMessage());
}
Metadata met = null;
try {
met = fmc.getMetadata(fmc.getProductByName("test.txt"));
} catch (CatalogException e) {
e.printStackTrace();
fail(e.getMessage());
}
assertNotNull(met);
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_ID));
assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_ID));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_NAME));
assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_NAME));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_STRUCTURE));
assertEquals("Flat", met.getMetadata(ProductMetKeys.PRODUCT_STRUCTURE));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_TRANSFER_STATUS));
assertEquals(Product.STATUS_RECEIVED, met
.getMetadata(ProductMetKeys.PRODUCT_TRANSFER_STATUS));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_ORIG_REFS));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_DATASTORE_REFS));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_FILE_SIZES));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_MIME_TYPES));
assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_ORIG_REFS).size());
assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_DATASTORE_REFS)
.size());
assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_FILE_SIZES)
.size());
assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_MIME_TYPES)
.size());
URL refUrl = this.getClass().getResource("/ingest/test.txt");
String origPath = null;
try {
origPath = new File(refUrl.getFile()).getCanonicalPath();
} catch (IOException e) {
fail(e.getMessage());
}
assertEquals(origPath, met.getMetadata(ProductMetKeys.PRODUCT_ORIG_REFS));
assertEquals("/tmp/test.txt/test.txt", met
.getMetadata(ProductMetKeys.PRODUCT_DATASTORE_REFS));
assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_FILE_SIZES));
assertEquals("text/plain", met
.getMetadata(ProductMetKeys.PRODUCT_MIME_TYPES));
try {
met = fmc.getReducedMetadata(fmc.getProductByName("test.txt"),
Collections.EMPTY_LIST);
} catch (CatalogException e) {
e.printStackTrace();
fail(e.getMessage());
}
assertNotNull(met);
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_ID));
assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_ID));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_NAME));
assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_NAME));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_STRUCTURE));
assertEquals("Flat", met.getMetadata(ProductMetKeys.PRODUCT_STRUCTURE));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_TRANSFER_STATUS));
assertEquals(Product.STATUS_RECEIVED, met
.getMetadata(ProductMetKeys.PRODUCT_TRANSFER_STATUS));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_ORIG_REFS));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_DATASTORE_REFS));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_FILE_SIZES));
assertTrue(met.containsKey(ProductMetKeys.PRODUCT_MIME_TYPES));
assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_ORIG_REFS).size());
assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_DATASTORE_REFS)
.size());
assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_FILE_SIZES)
.size());
assertEquals(1, met.getAllMetadata(ProductMetKeys.PRODUCT_MIME_TYPES)
.size());
origPath = null;
try {
origPath = new File(refUrl.getFile()).getCanonicalPath();
} catch (IOException e) {
fail(e.getMessage());
}
assertEquals(origPath, met.getMetadata(ProductMetKeys.PRODUCT_ORIG_REFS));
assertEquals("/tmp/test.txt/test.txt", met
.getMetadata(ProductMetKeys.PRODUCT_DATASTORE_REFS));
assertNotNull(met.getMetadata(ProductMetKeys.PRODUCT_FILE_SIZES));
assertEquals("text/plain", met
.getMetadata(ProductMetKeys.PRODUCT_MIME_TYPES));
}