Package org.apache.jena.query.spatial.assembler

Source Code of org.apache.jena.query.spatial.assembler.TestSpatialDatasetAssembler

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.jena.query.spatial.assembler;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.apache.jena.query.spatial.SpatialIndexLucene;
import org.apache.jena.query.spatial.SpatialQuery;
import org.junit.Test;

import com.hp.hpl.jena.assembler.Assembler;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.tdb.assembler.AssemblerTDB;
import com.hp.hpl.jena.vocabulary.RDF;

/**
* Test the spatial dataset assembler.
*/
public class TestSpatialDatasetAssembler extends AbstractTestSpatialAssembler {
 
  private static final String TESTBASE = "http://example.org/testDatasetAssembler/";
 
  private static final Resource spec1;
  private static final Resource noDatasetPropertySpec;
  private static final Resource noIndexPropertySpec;
 
  @Test public void testSimpleDatasetAssembler() {
    Dataset dataset = (Dataset) Assembler.general.open(spec1);
    assertTrue(dataset.getContext().get(SpatialQuery.spatialIndex) instanceof SpatialIndexLucene);
  }
 
  @Test public void testErrorOnNoDataset() {
    try {
        Assembler.general.open(noDatasetPropertySpec);
        fail("should have thrown an exception");
    } catch (Exception e) {}
  }
 
  @Test public void testErrorOnNoIndex() {
    try {
        Assembler.general.open(noIndexPropertySpec);
        fail("should have thrown an exception");
    } catch (Exception e) {}
  }
 
  static {
    SpatialAssembler.init();
    AssemblerTDB.init();
    spec1 =
        model.createResource(TESTBASE + "spec1")
             .addProperty(RDF.type, SpatialVocab.spatialDataset)
             .addProperty(SpatialVocab.pDataset, SIMPLE_DATASET_SPEC)
             .addProperty(SpatialVocab.pIndex, SIMPLE_LUCENE_INDEX_SPEC);
    noDatasetPropertySpec =
        model.createResource(TESTBASE + "noDatasetPropertySpec")
             .addProperty(RDF.type, SpatialVocab.spatialDataset)
             .addProperty(SpatialVocab.pIndex, SIMPLE_LUCENE_INDEX_SPEC);
    noIndexPropertySpec =
        model.createResource(TESTBASE + "noIndexPropertySpec")
             .addProperty(RDF.type, SpatialVocab.spatialDataset)
             .addProperty(SpatialVocab.pDataset, SIMPLE_DATASET_SPEC);
   
  }

}
TOP

Related Classes of org.apache.jena.query.spatial.assembler.TestSpatialDatasetAssembler

TOP
Copyright © 2018 www.massapi.com. 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.