@Test() public void testIPhone() throws IOException, CatalogTransformerException, UnsupportedQueryException, SourceUnavailableException, FederationException, ParseException { File file = new File(TEST_DATA_PATH + "Apple iPhone 4.jpg"); FileInputStream fis = FileUtils.openInputStream(file); Metacard metacard = createTransformer().transform(fis); assertNotNull(metacard); assertNotNull(metacard.getCreatedDate()); assertThat(metacard.getCreatedDate().getYear() + 1900, is(2011)); assertThat(metacard.getCreatedDate().getMonth() + 1, is(1)); assertThat(metacard.getCreatedDate().getDate(), is(13)); assertThat(metacard.getCreatedDate().getHours(), is(14)); assertThat(metacard.getCreatedDate().getMinutes(), is(33)); assertThat(metacard.getCreatedDate().getSeconds(), is(39)); assertEquals(metacard.getCreatedDate(), metacard.getModifiedDate()); WKTReader reader = new WKTReader(); Geometry geometry = reader.read(metacard.getLocation()); assertEquals(12.488833, geometry.getCoordinate().x, 0.00001); assertEquals(41.853, geometry.getCoordinate().y, 0.00001); }
@Test() public void testSonyDSCHXV5() throws IOException, CatalogTransformerException, UnsupportedQueryException, SourceUnavailableException, FederationException, ParseException { File file = new File(TEST_DATA_PATH + "Sony DSC-HX5V.jpg"); FileInputStream fis = FileUtils.openInputStream(file); Metacard metacard = createTransformer().transform(fis); assertNotNull(metacard); assertNotNull(metacard.getCreatedDate()); assertThat(metacard.getCreatedDate().getYear() + 1900, is(2010)); assertThat(metacard.getCreatedDate().getMonth() + 1, is(7)); assertThat(metacard.getCreatedDate().getDate(), is(14)); assertThat(metacard.getCreatedDate().getHours(), is(11)); assertThat(metacard.getCreatedDate().getMinutes(), is(00)); assertThat(metacard.getCreatedDate().getSeconds(), is(23)); assertNotNull(metacard.getModifiedDate()); assertThat(metacard.getModifiedDate().getYear() + 1900, is(2010)); assertThat(metacard.getModifiedDate().getMonth() + 1, is(7)); assertThat(metacard.getModifiedDate().getDate(), is(14)); assertThat(metacard.getModifiedDate().getHours(), is(11)); assertThat(metacard.getModifiedDate().getMinutes(), is(00)); assertThat(metacard.getModifiedDate().getSeconds(), is(23)); WKTReader reader = new WKTReader(); Geometry geometry = reader.read(metacard.getLocation()); assertEquals(-104.303846389, geometry.getCoordinate().x, 0.00001); assertEquals(39.5698783333, geometry.getCoordinate().y, 0.00001); byte[] thumbnail = metacard.getThumbnail(); assertNotNull(thumbnail); assertThat(thumbnail.length, is(11490)); }
/** Test where the subsample count is missing from the configuration. */ @Test public void testMissingConfiguration() { locationKlvProcessor.process(handlers, metacard, klvConfiguration); assertThat(metacard.getLocation(), nullValue()); }
@Test public void testProcess() { klvConfiguration.set(KlvProcessor.Configuration.SUBSAMPLE_COUNT, 50); locationKlvProcessor.process(handlers, metacard, klvConfiguration); assertThat(metacard.getLocation(), is(wkt)); }
/** Test a subsample count that is below the minimum required by LocationKlvProcessor. */ @Test public void testBadConfiguration() { klvConfiguration.set( KlvProcessor.Configuration.SUBSAMPLE_COUNT, LocationKlvProcessor.MIN_SUBSAMPLE_COUNT - 1); locationKlvProcessor.process(handlers, metacard, klvConfiguration); assertThat(metacard.getLocation(), nullValue()); }
private Geometry getBounds(List<Metacard> metacards) { if (metacards != null) { List<Geometry> geometries = new ArrayList<Geometry>(); for (Metacard card : metacards) { if (null != card.getLocation()) { Geometry geo = XmlNode.readGeometry(card.getLocation()); if (null != geo) { geometries.add(geo); } } } Geometry allGeometry = new GeometryCollection(geometries.toArray(new Geometry[0]), new GeometryFactory()); return allGeometry; } else { LOGGER.warn("Metacard list is null"); return null; } }
@Test public void testFailingInput() throws IOException, CatalogTransformerException, ParseException, Exception { Metacard metacard = createTransformer().transform(new ByteArrayInputStream(sampleNMEAString2().getBytes())); assertEquals("FEDERAL ST LAURENT(8PNN)", metacard.getTitle()); WKTReader reader = new WKTReader(); assertEquals(metacard.getLocation(), null); }
private void assertMetacard(Metacard mc, Map<String, Object> expectedValues) { assertThat(mc.getId(), equalTo((String) expectedValues.get(Metacard.ID))); assertListStringAttribute( mc, CswRecordMetacardType.CSW_IDENTIFIER, (String[]) expectedValues.get(CswRecordMetacardType.CSW_IDENTIFIER)); assertThat(mc.getTitle(), equalTo((String) expectedValues.get(Metacard.TITLE))); assertListStringAttribute( mc, CswRecordMetacardType.CSW_TITLE, (String[]) expectedValues.get(CswRecordMetacardType.CSW_TITLE)); assertThat(mc.getModifiedDate(), equalTo((Date) expectedValues.get(Metacard.MODIFIED))); assertListStringAttribute( mc, CswRecordMetacardType.CSW_MODIFIED, (String[]) expectedValues.get(CswRecordMetacardType.CSW_MODIFIED)); assertListStringAttribute( mc, CswRecordMetacardType.CSW_SUBJECT, (String[]) expectedValues.get(CswRecordMetacardType.CSW_SUBJECT)); assertListStringAttribute( mc, CswRecordMetacardType.CSW_ABSTRACT, (String[]) expectedValues.get(CswRecordMetacardType.CSW_ABSTRACT)); assertListStringAttribute( mc, CswRecordMetacardType.CSW_RIGHTS, (String[]) expectedValues.get(CswRecordMetacardType.CSW_RIGHTS)); assertListStringAttribute( mc, CswRecordMetacardType.CSW_LANGUAGE, (String[]) expectedValues.get(CswRecordMetacardType.CSW_LANGUAGE)); assertThat( (String) mc.getAttribute(CswRecordMetacardType.CSW_TYPE).getValue(), equalTo((String) expectedValues.get(CswRecordMetacardType.CSW_TYPE))); assertListStringAttribute( mc, CswRecordMetacardType.CSW_FORMAT, (String[]) expectedValues.get(CswRecordMetacardType.CSW_FORMAT)); assertThat(mc.getLocation(), equalTo((String) expectedValues.get(Metacard.GEOGRAPHY))); assertListStringAttribute( mc, CswRecordMetacardType.OWS_BOUNDING_BOX, (String[]) expectedValues.get(CswRecordMetacardType.OWS_BOUNDING_BOX)); }
@Test() public void testPointGeo() throws IOException, CatalogTransformerException, Exception { AISInputTransformer transformer = createTransformer(); Metacard metacard = transformer.transform(new ByteArrayInputStream(sampleNMEAString3().getBytes())); WKTReader reader = new WKTReader(); Geometry geometry = reader.read(metacard.getLocation()); assertEquals( geometry.getCoordinate().x + " doesn't equal " + "-19.046145", String.valueOf(geometry.getCoordinate().x), "-19.046145"); assertEquals( geometry.getCoordinate().y + " doesn't equal " + "-18.227776666666667", String.valueOf(geometry.getCoordinate().y), "-18.227776666666667"); }