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

com.bigdata.rdf.internal.TestFullyInlineURIIV Maven / Gradle / Ivy

There is a newer version: 2.1.4
Show newest version
package com.bigdata.rdf.internal;

import java.util.LinkedList;
import java.util.List;

import junit.framework.TestCase2;

import org.openrdf.model.impl.URIImpl;

import com.bigdata.btree.keys.IKeyBuilder;
import com.bigdata.rdf.internal.impl.uri.FullyInlineURIIV;
import com.bigdata.rdf.lexicon.BlobsIndexHelper;
import com.bigdata.rdf.model.BigdataURI;

/**
 * Test suite for {@link FullyInlineURIIV}.
 */
public class TestFullyInlineURIIV extends TestCase2 {

	public TestFullyInlineURIIV() {
	}

	public TestFullyInlineURIIV(String name) {
		super(name);
	}

	public void test_InlineURIIV() {

        doTest(new FullyInlineURIIV(new URIImpl("http://www.bigdata.com")));
        doTest(new FullyInlineURIIV(new URIImpl("http://www.bigdata.com/")));
        doTest(new FullyInlineURIIV(new URIImpl("http://www.bigdata.com/foo")));
        doTest(new FullyInlineURIIV(new URIImpl("http://www.bigdata.com:80/foo")));

	}

	private void doTest(final FullyInlineURIIV iv) {

		assertEquals(VTE.URI, iv.getVTE());
		
		assertTrue(iv.isInline());
		
		assertFalse(iv.isExtension());

		assertEquals(DTE.XSDString, iv.getDTE());
		
		final BlobsIndexHelper h = new BlobsIndexHelper();
		
		final IKeyBuilder keyBuilder = h.newKeyBuilder();
		
		final byte[] key = IVUtility.encode(keyBuilder, iv).getKey();
		
		final IV actual = IVUtility.decode(key);
		
		assertEquals(iv, actual);
		
		assertEquals(key.length, iv.byteLength());

		assertEquals(key.length, actual.byteLength());
		
	}
	
    public void test_encodeDecode_comparator() {
        
        final List> ivs = new LinkedList>();
        {

            ivs.add(new FullyInlineURIIV(new URIImpl("http://www.bigdata.com")));
            ivs.add(new FullyInlineURIIV(new URIImpl("http://www.bigdata.com/")));
            ivs.add(new FullyInlineURIIV(new URIImpl("http://www.bigdata.com/foo")));
            ivs.add(new FullyInlineURIIV(new URIImpl("http://www.bigdata.com:80/foo")));

        }
        
        final IV[] e = ivs.toArray(new IV[0]);

        AbstractEncodeDecodeKeysTestCase.doEncodeDecodeTest(e);

        AbstractEncodeDecodeKeysTestCase.doComparatorTest(e);
    
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy