All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bigdata.rdf.lexicon.TestBlobsWriteTask Maven / Gradle / Ivy

There is a newer version: 2.1.4
Show newest version
/**

Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016.  All rights reserved.

Contact:
     SYSTAP, LLC DBA Blazegraph
     2501 Calvert ST NW #106
     Washington, DC 20008
     [email protected]

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
/*
 * Created on Jun 9, 2011
 */

package com.bigdata.rdf.lexicon;

import junit.framework.TestCase2;

import org.openrdf.model.Value;
import org.openrdf.model.impl.BNodeImpl;
import org.openrdf.model.impl.LiteralImpl;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.model.vocabulary.RDF;

import com.bigdata.btree.BTree;
import com.bigdata.btree.IIndex;
import com.bigdata.btree.keys.IKeyBuilder;
import com.bigdata.rawstore.IRawStore;
import com.bigdata.rawstore.SimpleMemoryRawStore;
import com.bigdata.rdf.internal.IV;
import com.bigdata.rdf.internal.VTE;
import com.bigdata.rdf.internal.impl.BlobIV;
import com.bigdata.rdf.model.BigdataValue;
import com.bigdata.rdf.model.BigdataValueFactory;
import com.bigdata.rdf.model.BigdataValueFactoryImpl;

/**
 * Test suite for the {@link BlobsWriteTask}.
 * 
 * @author Bryan Thompson
 * @version $Id$
 */
public class TestBlobsWriteTask extends TestCase2 {

    /**
     * 
     */
    public TestBlobsWriteTask() {
    }

    /**
     * @param name
     */
    public TestBlobsWriteTask(String name) {
        super(name);
    }

    public void test_add_abc() {

        // The values that we will be testing with.
        final Value[] valuesIn = new Value[] {//
          
                new LiteralImpl("abc") //
                
        };

        doAddTermsTest(valuesIn, false/* toldBNodes */);
        
    }
    
    public void test_add_emptyLiteral() {

        // The values that we will be testing with.
        final Value[] valuesIn = new Value[] {//
          
                new LiteralImpl("") //
                
        };

        doAddTermsTest(valuesIn, false/* toldBNodes */);
        
    }
    
    public void test_add_various_toldBNodes() {

        // The values that we will be testing with.
        final Value[] valuesIn = new Value[] {//
          
                new LiteralImpl("abc"), //
                RDF.TYPE,//
                RDF.PROPERTY,//
                new LiteralImpl("test"),//
                new LiteralImpl("test", "en"),//
                new LiteralImpl("10", new URIImpl("http://www.w3.org/2001/XMLSchema#int")),
                new LiteralImpl("12", new URIImpl("http://www.w3.org/2001/XMLSchema#float")),
                new LiteralImpl("12.", new URIImpl("http://www.w3.org/2001/XMLSchema#float")),
                new LiteralImpl("12.0", new URIImpl("http://www.w3.org/2001/XMLSchema#float")),
                new LiteralImpl("12.00", new URIImpl("http://www.w3.org/2001/XMLSchema#float")),
                new BNodeImpl("a"),//
                new BNodeImpl("12"),//
        };

        doAddTermsTest(valuesIn, true/* toldBNodes */);
        
    }

    /**
     * Note: Blank nodes are NOT included in this test since the test helper is
     * not smart enough to verify the blank nodes will not be unified when using
     * standard bnode semantics. However, {@link TestBlobsIndex} does verify
     * both standard and told bnode semantics.
     */
    public void test_add_various_standardBNodes() {

        /* The values that we will be testing with.
         */
        final Value[] valuesIn = new Value[] {//
          
                new LiteralImpl("abc"), //
                RDF.TYPE,//
                RDF.PROPERTY,//
                new LiteralImpl("test"),//
                new LiteralImpl("test", "en"),//
                new LiteralImpl("10", new URIImpl("http://www.w3.org/2001/XMLSchema#int")),
                new LiteralImpl("12", new URIImpl("http://www.w3.org/2001/XMLSchema#float")),
                new LiteralImpl("12.", new URIImpl("http://www.w3.org/2001/XMLSchema#float")),
                new LiteralImpl("12.0", new URIImpl("http://www.w3.org/2001/XMLSchema#float")),
                new LiteralImpl("12.00", new URIImpl("http://www.w3.org/2001/XMLSchema#float")),
//                new BNodeImpl("a"),//
//                new BNodeImpl("12"),//
        };

        doAddTermsTest(valuesIn, false/* toldBNodes */);
        
    }
    
    private void doAddTermsTest(final Value[] valuesIn, final boolean toldBNodes) {

        for(int i=0; i© 2015 - 2024 Weber Informatics LLC | Privacy Policy