Ejemplo n.º 1
0
  private void configureGeogigDataStore() throws Exception {

    helper.insertAndAdd(helper.lines1);
    helper.getGeogig().command(CommitOp.class).call();

    Catalog catalog = getCatalog();
    CatalogFactory factory = catalog.getFactory();
    NamespaceInfo ns = factory.createNamespace();
    ns.setPrefix(WORKSPACE);
    ns.setURI(NAMESPACE);
    catalog.add(ns);
    WorkspaceInfo ws = factory.createWorkspace();
    ws.setName(ns.getName());
    catalog.add(ws);

    DataStoreInfo ds = factory.createDataStore();
    ds.setEnabled(true);
    ds.setDescription("Test Geogig DataStore");
    ds.setName(STORE);
    ds.setType(GeoGigDataStoreFactory.DISPLAY_NAME);
    ds.setWorkspace(ws);
    Map<String, Serializable> connParams = ds.getConnectionParameters();

    Optional<URI> geogigDir = helper.getGeogig().command(ResolveGeogigURI.class).call();
    File repositoryUrl = new File(geogigDir.get()).getParentFile();
    assertTrue(repositoryUrl.exists() && repositoryUrl.isDirectory());

    connParams.put(GeoGigDataStoreFactory.REPOSITORY.key, repositoryUrl);
    connParams.put(GeoGigDataStoreFactory.DEFAULT_NAMESPACE.key, ns.getURI());
    catalog.add(ds);

    DataStoreInfo dsInfo = catalog.getDataStoreByName(WORKSPACE, STORE);
    assertNotNull(dsInfo);
    assertEquals(GeoGigDataStoreFactory.DISPLAY_NAME, dsInfo.getType());
    DataAccess<? extends FeatureType, ? extends Feature> dataStore = dsInfo.getDataStore(null);
    assertNotNull(dataStore);
    assertTrue(dataStore instanceof GeoGigDataStore);

    FeatureTypeInfo fti = factory.createFeatureType();
    fti.setNamespace(ns);
    fti.setCatalog(catalog);
    fti.setStore(dsInfo);
    fti.setSRS("EPSG:4326");
    fti.setName("Lines");
    fti.setAdvertised(true);
    fti.setEnabled(true);
    fti.setCqlFilter("INCLUDE");
    fti.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED);
    ReferencedEnvelope bounds = new ReferencedEnvelope(-180, 180, -90, 90, CRS.decode("EPSG:4326"));
    fti.setNativeBoundingBox(bounds);
    fti.setLatLonBoundingBox(bounds);
    catalog.add(fti);

    fti = catalog.getFeatureType(fti.getId());

    FeatureSource<? extends FeatureType, ? extends Feature> featureSource;
    featureSource = fti.getFeatureSource(null, null);
    assertNotNull(featureSource);
  }
Ejemplo n.º 2
0
  @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();
    }
  }
Ejemplo n.º 3
0
  /**
   * 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());
    }
  }
Ejemplo n.º 4
0
  /**
   * 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());
    }
  }