Package com.moesol.geoserver.sync.json

Examples of com.moesol.geoserver.sync.json.Sha1SyncJson


    Sha1Value valueSha1 = m_featureSha1Evaluator.computeValueSha1(feature);
    IdAndValueSha1s pair = new IdAndValueSha1s(idSha1, valueSha1);
    m_featureSha1s.add(pair);
    Sha1Value prefixSha1 = versionFeatures.getBucketPrefixSha1(pair);
   
    Sha1SyncJson remoteSha1Sync = REMOTE_SHA1_SYNC.get();
    if (remoteSha1Sync.max() > 1) {
      return LITERAL_TRUE; // Keep all features, we are not deep enough in search tree
    }
    if (remoteSha1Sync.hashes() == null) {
      return LITERAL_TRUE; // Missing all...
    }
   
    Sha1SyncPositionHash sha1Position = new Sha1SyncPositionHash().position(prefixSha1.toString());
    int idx = Collections.binarySearch(remoteSha1Sync.hashes(), sha1Position, POSITION_COMPARATOR);
    if (idx < 0) {
      idx = -idx - 2; // position on shorter prefix
    }
    if (idx < 0 || remoteSha1Sync.hashes().size() < idx) {
      return LITERAL_FALSE;
    }
    Sha1SyncPositionHash remoteGroup = remoteSha1Sync.hashes().get(idx);
    if (!prefixSha1.toString().startsWith(remoteGroup.position())) {
      return LITERAL_FALSE; // Missing position means remote side thinks position is synchronized.
    }
    Sha1Value sha1OfSha1 = m_featureSha1Evaluator.sha1OfSha1(valueSha1);
    if (sha1OfSha1.toString().equals(remoteGroup.summary())) {
View Full Code Here


   
        // NOTE: If this test fails check to see if the geoserver sample data changed.
        //

    Sha1SyncJson sync = new Gson().fromJson(result, Sha1SyncJson.class);
   
    assertEquals(0, sync.level());
    assertEquals(1, sync.hashes().size());
    assertEquals("", sync.hashes().get(0).position());
    assertEquals("d3659f943fcdda512093d1c573856e8295201c23", sync.hashes().get(0).summary());
        assertEquals(2L, sync.max());
    }
View Full Code Here

      // Version 2.0.1 of geoserver does not support : in the format_options value via \\
      // "&outputFormat=sha1Sync&format_options=ATTRIBUTES:-all;SYNC:{l\\:0}");
      SyncChecksumOutputFormat.JUNIT_SHA1_SYNC.set("{l:0, h:[{p:''}]}");
        String result = getAsString("wfs?request=GetFeature&typeName=cite:Buildings" +
          "&outputFormat=SyncChecksum&format_options=ATTRIBUTES:-all");
      Sha1SyncJson sync = new Gson().fromJson(result, Sha1SyncJson.class);
        assertEquals(1, sync.level());
        assertEquals("1b", sync.hashes().get(0).position());
        assertEquals(EXPECTED1_SHA1, sync.hashes().get(0).summary());
        assertEquals("52", sync.hashes().get(1).position());
        assertEquals(EXPECTED2_SHA1, sync.hashes().get(1).summary());
        assertEquals(1L, sync.max());
    }
View Full Code Here

      // Version 2.0.1 of geoserver does not support : in the format_options value via \\
      // "&outputFormat=sha1Sync&format_options=ATTRIBUTES:-all;SYNC:{l\\:1}");
      SyncChecksumOutputFormat.JUNIT_SHA1_SYNC.set("{l:1,h:[{p:'1b'},{p:'52'}]}");
        String result = getAsString("wfs?request=GetFeature&typeName=cite:Buildings" +
            "&outputFormat=SyncChecksum&format_options=ATTRIBUTES:-all");
        Sha1SyncJson sync = new Gson().fromJson(result, Sha1SyncJson.class);
        assertEquals(2, sync.level());
        assertEquals(2, sync.hashes().size());
        assertEquals("1bc8", sync.hashes().get(0).position());
        assertEquals(EXPECTED1_SHA1, sync.hashes().get(0).summary());
        assertEquals("5259", sync.hashes().get(1).position());
        assertEquals(EXPECTED2_SHA1, sync.hashes().get(1).summary());
        assertEquals(1L, sync.max());
    }
View Full Code Here

      // Version 2.0.1 of geoserver does not support : in the format_options value via \\
      // "&outputFormat=sha1Sync&format_options=ATTRIBUTES:-all;SYNC:{l\\:2}");
      SyncChecksumOutputFormat.JUNIT_SHA1_SYNC.set("{l:2,h:[{p:'1bc8'},{p:'5259'}]}");
        String result = getAsString("wfs?request=GetFeature&typeName=cite:Buildings" +
        "&outputFormat=SyncChecksum&format_options=ATTRIBUTES:-all");
        Sha1SyncJson sync = new Gson().fromJson(result, Sha1SyncJson.class);
        assertEquals(3, sync.level());
        assertEquals(2, sync.hashes().size());
        assertEquals("1bc80f", sync.hashes().get(0).position());
        assertEquals(EXPECTED1_SHA1, sync.hashes().get(0).summary());
        assertEquals("525983", sync.hashes().get(1).position());
        assertEquals(EXPECTED2_SHA1, sync.hashes().get(1).summary());
        assertEquals(1L, sync.max());
    }
View Full Code Here

      // Version 2.0.1 of geoserver does not support : in the format_options value via \\
      // "&outputFormat=sha1Sync&format_options=ATTRIBUTES:-all;SYNC:{l\\:2}");
      SyncChecksumOutputFormat.JUNIT_SHA1_SYNC.set("{l:2,h:[{p:'1bc8'}]}");
        String result = getAsString("wfs?request=GetFeature&typeName=cite:Buildings" +
          "&outputFormat=SyncChecksum&format_options=ATTRIBUTES:-all");
        Sha1SyncJson sync = new Gson().fromJson(result, Sha1SyncJson.class);
        assertEquals(3, sync.level());
        assertEquals(1, sync.hashes().size());
        assertEquals("1bc80f", sync.hashes().get(0).position());
        assertEquals(EXPECTED1_SHA1, sync.hashes().get(0).summary());
        assertEquals(1L, sync.max());
    }
View Full Code Here

      // Version 2.0.1 of geoserver does not support : in the format_options value via \\
      // "&outputFormat=sha1Sync&format_options=ATTRIBUTES:-all;SYNC:{l\\:2}");
      SyncChecksumOutputFormat.JUNIT_SHA1_SYNC.set("{l:2}");
        String result = getAsString("wfs?request=GetFeature&typeName=cite:Buildings" +
          "&outputFormat=SyncChecksum&format_options=ATTRIBUTES:-all");
        Sha1SyncJson sync = new Gson().fromJson(result, Sha1SyncJson.class);
        assertEquals(3, sync.level());
        assertEquals(0, sync.hashes().size());
        assertEquals(1L, sync.max());
    }
View Full Code Here

      // "&outputFormat=sha1Sync&format_options=ATTRIBUTES:-all;SYNC:{l\\:-1}");
      SyncChecksumOutputFormat.JUNIT_SHA1_SYNC.set("{l: -1}");
        String result = getAsString("wfs?request=GetFeature&typeName=cite:Buildings" +
        "&outputFormat=SyncChecksum&format_options=ATTRIBUTES:-all");
        System.out.println("result: " + result);
        Sha1SyncJson sync = new Gson().fromJson(result, Sha1SyncJson.class);
        assertEquals(0, sync.level());
        assertEquals(1, sync.hashes().size());
        assertEquals("", sync.hashes().get(0).position());
        assertEquals("103d2f424918116a0e95dffd91f9ca36e1657ad0", sync.hashes().get(0).summary());
        assertEquals(2L, sync.max());
    }
View Full Code Here

    }
    @Test
    public void testOutputFormat3() throws Exception {
        String result = getAsString("wfs?request=GetFeature&typeName=cite:Buildings" +
            "&outputFormat=SyncChecksum");
        Sha1SyncJson sync = new Gson().fromJson(result, Sha1SyncJson.class);
        assertEquals(0, sync.level());
        assertEquals(1, sync.hashes().size());
        assertEquals("", sync.hashes().get(0).position());
        assertEquals("883aa2473212d6cd9c40db6df655b803b6b69de3", sync.hashes().get(0).summary());
        assertEquals(2L, sync.max());
    }
View Full Code Here

          +      "<ogc:Literal>true</ogc:Literal> "
          +    "</ogc:PropertyIsEqualTo> "
          +   "</ogc:Filter> "
          "</wfs:Query> "
          + "</wfs:GetFeature>";
        Sha1SyncJson client = new Sha1SyncJson().level(0).hashes(
            new Sha1SyncPositionHash().position("").summary("abc123")
        );
        String clientJson = new Gson().toJson(client);
        String xml = String.format(tmpl, clientJson);
//        System.out.println(xml);
       
        String result = postAsServletResponse("wfs", xml).getOutputStreamContent();
        Sha1SyncJson sync = new Gson().fromJson(result, Sha1SyncJson.class);
        assertEquals(1, sync.level());
        assertEquals(2, sync.hashes().size());
        assertEquals("1b", sync.hashes().get(0).position());
        assertEquals(EXPECTED1_SHA1, sync.hashes().get(0).summary());
        assertEquals(1L, sync.max());
    }
View Full Code Here

TOP

Related Classes of com.moesol.geoserver.sync.json.Sha1SyncJson

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.