@Test public void testCommitsSurviveShutDown() throws Exception { GeoGIG geogig = helper.getGeogig(); insert(); update(); List<RevCommit> expected = ImmutableList.copyOf(geogig.command(LogOp.class).call()); File repoDir = helper.getRepositoryDirectory(); assertTrue(repoDir.exists() && repoDir.isDirectory()); // shut down server destroyGeoServer(); TestPlatform testPlatform = new TestPlatform(repoDir); Context context = new CLITestContextBuilder(testPlatform).build(); geogig = new GeoGIG(context); try { assertNotNull(geogig.getRepository()); List<RevCommit> actual = ImmutableList.copyOf(geogig.command(LogOp.class).call()); assertEquals(expected, actual); } finally { geogig.close(); } }
/** * Test case to expose issue https://github.com/boundlessgeo/geogig/issues/310 "Editing Features * changes the feature type" * * @see #testUpdateDoesntChangeFeatureType() */ @Test public void testInsertDoesntChangeFeatureType() throws Exception { String xml = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\" " // + " xmlns:wfs=\"http://www.opengis.net/wfs\" " // + " xmlns:gml=\"http://www.opengis.net/gml\" " // + " xmlns:geogig=\"" + NAMESPACE + "\">" // + "<wfs:Insert>" // + "<geogig:Lines gml:id=\"Lines.1000\">" // + " <geogig:sp>added</geogig:sp>" // + " <geogig:ip>7</geogig:ip>" // + " <geogig:pp>" // + " <gml:LineString srsDimension=\"2\" srsName=\"EPSG:4326\">" // + " <gml:posList>1 2 3 4</gml:posList>" // + " </gml:LineString>" // + " </geogig:pp>" // + "</geogig:Lines>" // + "</wfs:Insert>" // + "</wfs:Transaction>"; GeoGIG geogig = helper.getGeogig(); final NodeRef initialTypeTreeRef = geogig.command(FindTreeChild.class).setChildPath("Lines").call().get(); assertFalse(initialTypeTreeRef.getMetadataId().isNull()); Document dom = postAsDOM("wfs", xml); try { assertEquals("wfs:TransactionResponse", dom.getDocumentElement().getNodeName()); } catch (AssertionError e) { print(dom); throw e; } try { assertEquals( "1", getFirstElementByTagName(dom, "wfs:totalInserted").getFirstChild().getNodeValue()); } catch (AssertionError e) { print(dom); throw e; } final NodeRef finalTypeTreeRef = geogig.command(FindTreeChild.class).setChildPath("Lines").call().get(); assertFalse(initialTypeTreeRef.equals(finalTypeTreeRef)); assertFalse(finalTypeTreeRef.getMetadataId().isNull()); assertEquals( "Feature type tree metadataId shouuldn't change upon edits", initialTypeTreeRef.getMetadataId(), finalTypeTreeRef.getMetadataId()); Iterator<NodeRef> featureRefs = geogig.command(LsTreeOp.class).setReference("Lines").call(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); assertEquals(finalTypeTreeRef.getMetadataId(), ref.getMetadataId()); assertFalse(ref.toString(), ref.getNode().getMetadataId().isPresent()); } }
/** * Test case to expose issue https://github.com/boundlessgeo/geogig/issues/310 "Editing Features * changes the feature type" * * @see #testInsertDoesntChangeFeatureType() */ @Test public void testUpdateDoesntChangeFeatureType() throws Exception { String xml = "<wfs:Transaction service=\"WFS\" version=\"1.1.0\"" // + " xmlns:geogig=\"" + NAMESPACE + "\"" // + " xmlns:ogc=\"http://www.opengis.net/ogc\"" // + " xmlns:gml=\"http://www.opengis.net/gml\"" // + " xmlns:wfs=\"http://www.opengis.net/wfs\">" // + " <wfs:Update typeName=\"geogig:Lines\">" // + " <wfs:Property>" // + " <wfs:Name>geogig:pp</wfs:Name>" // + " <wfs:Value>" + " <gml:LineString srsDimension=\"2\" srsName=\"EPSG:4326\">" // + " <gml:posList>3 4 5 6</gml:posList>" // + " </gml:LineString>" // + " </wfs:Value>" // + " </wfs:Property>" // + " <ogc:Filter>" // + " <ogc:PropertyIsEqualTo>" // + " <ogc:PropertyName>ip</ogc:PropertyName>" // + " <ogc:Literal>1000</ogc:Literal>" // + " </ogc:PropertyIsEqualTo>" // + " </ogc:Filter>" // + " </wfs:Update>" // + "</wfs:Transaction>"; GeoGIG geogig = helper.getGeogig(); final NodeRef initialTypeTreeRef = geogig.command(FindTreeChild.class).setChildPath("Lines").call().get(); assertFalse(initialTypeTreeRef.getMetadataId().isNull()); Document dom = postAsDOM("wfs", xml); assertEquals("wfs:TransactionResponse", dom.getDocumentElement().getNodeName()); assertEquals( "1", getFirstElementByTagName(dom, "wfs:totalUpdated").getFirstChild().getNodeValue()); final NodeRef finalTypeTreeRef = geogig.command(FindTreeChild.class).setChildPath("Lines").call().get(); assertFalse(initialTypeTreeRef.equals(finalTypeTreeRef)); assertFalse(finalTypeTreeRef.getMetadataId().isNull()); assertEquals( "Feature type tree metadataId shouuldn't change upon edits", initialTypeTreeRef.getMetadataId(), finalTypeTreeRef.getMetadataId()); Iterator<NodeRef> featureRefs = geogig.command(LsTreeOp.class).setReference("Lines").call(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); assertEquals(finalTypeTreeRef.getMetadataId(), ref.getMetadataId()); assertFalse(ref.toString(), ref.getNode().getMetadataId().isPresent()); } }