Exemplo n.º 1
0
  /** Test if estimate seems reasonable. */
  @Test
  public void testEstimate() {
    final TriplePatternElementParser<ConstantTermType, NamedVarType, AnonVarType> tpeParser =
        getTriplePatternElementParser();

    final ITriplePatternFragmentRequest<ConstantTermType, NamedVarType, AnonVarType> request =
        new ITriplePatternFragmentRequest<ConstantTermType, NamedVarType, AnonVarType>() {
          public boolean isPageRequest() {
            return true;
          }

          public long getPageNumber() {
            return 1L;
          }

          public String getFragmentURL() {
            return "http://example.org/f";
          }

          public String getDatasetURL() {
            return "http://example.org/";
          }

          public ITriplePatternElement<ConstantTermType, NamedVarType, AnonVarType> getSubject() {
            return tpeParser.parseIntoTriplePatternElement("http://data.gov.be/catalog/ckanvl");
          }

          public ITriplePatternElement<ConstantTermType, NamedVarType, AnonVarType> getPredicate() {
            return tpeParser.parseIntoTriplePatternElement(null);
          }

          public ITriplePatternElement<ConstantTermType, NamedVarType, AnonVarType> getObject() {
            return tpeParser.parseIntoTriplePatternElement(null);
          }
        };

    final IFragmentRequestProcessor proc = getDatasource().getRequestProcessor();
    final ILinkedDataFragment ldf = proc.createRequestedFragment(request);
    final ITriplePatternFragment tpf = (ITriplePatternFragment) ldf;

    long totalSize = tpf.getTotalSize();

    Assert.assertTrue("Estimate is too small : " + totalSize, totalSize > 100);
  }
Exemplo n.º 2
0
  /** Test total size of empty TPF */
  @Test
  public void testEmpty() {
    final TriplePatternElementParser<ConstantTermType, NamedVarType, AnonVarType> tpeParser =
        getTriplePatternElementParser();

    final ITriplePatternFragmentRequest<ConstantTermType, NamedVarType, AnonVarType> request =
        new TriplePatternFragmentRequestImpl<ConstantTermType, NamedVarType, AnonVarType>(
            "http://example.org/f", // fragmentURL
            "http://example.org/", // datasetURL,
            true, // pageNumberWasRequested,
            1L, // pageNumber,
            tpeParser.parseIntoTriplePatternElement("http://nothing.ldf.org"), // subject,
            tpeParser.parseIntoTriplePatternElement(null), // predicate,
            tpeParser.parseIntoTriplePatternElement(null)); // object

    final IFragmentRequestProcessor proc = getDatasource().getRequestProcessor();
    final ILinkedDataFragment ldf = proc.createRequestedFragment(request);
    final ITriplePatternFragment tpf = (ITriplePatternFragment) ldf;

    long totalSize = tpf.getTotalSize();

    Assert.assertTrue("Estimate is too big : " + totalSize, totalSize == 0);
  }