Package org.openrdf.sail.nativerdf

Source Code of org.openrdf.sail.nativerdf.DefaultIndexTest

/*
* Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
*
* Licensed under the Aduna BSD-style license.
*/
package org.openrdf.sail.nativerdf;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

import junit.framework.TestCase;

import info.aduna.io.FileUtil;

public class DefaultIndexTest extends TestCase {

  public void testDefaultIndex()
    throws Exception
  {
    File dir = FileUtil.createTempDir("nativerdf");
    TripleStore store = new TripleStore(dir, null);
    store.close();
    // check that the triple store used the default index
    assertEquals("spoc,posc", findIndex(dir));
    FileUtil.deleteDir(dir);
  }

  public void testExistingIndex()
    throws Exception
  {
    File dir = FileUtil.createTempDir("nativerdf");
    // set a non-default index
    TripleStore store = new TripleStore(dir, "spoc,opsc");
    store.close();
    String before = findIndex(dir);
    // check that the index is preserved with a null value
    store = new TripleStore(dir, null);
    store.close();
    assertEquals(before, findIndex(dir));
    FileUtil.deleteDir(dir);
  }

  private String findIndex(File dir)
    throws Exception
  {
    Properties properties = new Properties();
    InputStream in = new FileInputStream(new File(dir, "triples.prop"));
    try {
      properties.clear();
      properties.load(in);
    }
    finally {
      in.close();
    }
    return (String)properties.get("triple-indexes");
  }

}
TOP

Related Classes of org.openrdf.sail.nativerdf.DefaultIndexTest

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.