You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rya.apache.org by mi...@apache.org on 2016/10/15 20:06:53 UTC
[33/69] [abbrv] [partial] incubator-rya git commit: RYA-198 Renaming
Files
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/DefineTripleQueryRangeFactoryTest.java
----------------------------------------------------------------------
diff --git a/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/DefineTripleQueryRangeFactoryTest.java b/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/DefineTripleQueryRangeFactoryTest.java
deleted file mode 100644
index 7c3331d..0000000
--- a/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/DefineTripleQueryRangeFactoryTest.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * 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 mvm.rya.accumulo;
-
-//
-//import junit.framework.TestCase;
-//import mvm.rya.accumulo.AccumuloRdfConfiguration;
-//import mvm.rya.accumulo.DefineTripleQueryRangeFactory;
-//import mvm.rya.accumulo.AccumuloRdfConfiguration;
-//import mvm.rya.accumulo.DefineTripleQueryRangeFactory;
-//import mvm.rya.api.domain.RangeValue;
-//import org.apache.accumulo.core.data.Range;
-//import org.openrdf.model.URI;
-//import org.openrdf.model.Value;
-//import org.openrdf.model.ValueFactory;
-//import org.openrdf.model.impl.ValueFactoryImpl;
-//
-//import java.util.Map;
-//
-//import static mvm.rya.api.RdfCloudTripleStoreConstants.*;
-//
-///**
-// */
-//public class DefineTripleQueryRangeFactoryTest extends TestCase {
-//
-// public static final String DELIM_BYTES_STR = new String(DELIM_BYTES);
-// public static final String URI_MARKER_STR = "\u0007";
-// public static final String RANGE_ENDKEY_SUFFIX = "\u0000";
-// DefineTripleQueryRangeFactory factory = new DefineTripleQueryRangeFactory();
-// ValueFactory vf = ValueFactoryImpl.getInstance();
-// static String litdupsNS = "urn:test:litdups#";
-//
-// private AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
-//
-// public void testSPOCases() throws Exception {
-// URI cpu = vf.createURI(litdupsNS, "cpu");
-// URI loadPerc = vf.createURI(litdupsNS, "loadPerc");
-// URI obj = vf.createURI(litdupsNS, "uri1");
-//
-// //spo
-// Map.Entry<TABLE_LAYOUT, Range> entry =
-// factory.defineRange(cpu, loadPerc, obj, conf);
-// assertEquals(TABLE_LAYOUT.SPO, entry.getKey());
-// String expected_start = URI_MARKER_STR + cpu.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + loadPerc.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + obj.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// assertEquals(expected_start + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-//
-//
-// //sp
-// entry = factory.defineRange(cpu, loadPerc, null, conf);
-// assertEquals(TABLE_LAYOUT.SPO, entry.getKey());
-// expected_start = URI_MARKER_STR + cpu.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + loadPerc.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// assertEquals(expected_start + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-//
-// //s
-// entry = factory.defineRange(cpu, null, null, conf);
-// assertEquals(TABLE_LAYOUT.SPO, entry.getKey());
-// expected_start = URI_MARKER_STR + cpu.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// assertEquals(expected_start + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-//
-// //all
-// entry = factory.defineRange(null, null, null, conf);
-// assertEquals(TABLE_LAYOUT.SPO, entry.getKey());
-// assertEquals("",
-// entry.getValue().getStartKey().getRow().toString());
-// assertEquals(new String(new byte[]{Byte.MAX_VALUE}) + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-// }
-//
-// public void testSPOCasesWithRanges() throws Exception {
-// URI subj_start = vf.createURI(litdupsNS, "subj_start");
-// URI subj_end = vf.createURI(litdupsNS, "subj_stop");
-// URI pred_start = vf.createURI(litdupsNS, "pred_start");
-// URI pred_end = vf.createURI(litdupsNS, "pred_stop");
-// URI obj_start = vf.createURI(litdupsNS, "obj_start");
-// URI obj_end = vf.createURI(litdupsNS, "obj_stop");
-//
-// Value subj = new RangeValue(subj_start, subj_end);
-// Value pred = new RangeValue(pred_start, pred_end);
-// Value obj = new RangeValue(obj_start, obj_end);
-//
-// //spo - o has range
-// Map.Entry<TABLE_LAYOUT, Range> entry =
-// factory.defineRange(subj_start, pred_start, obj, conf);
-// assertEquals(TABLE_LAYOUT.SPO, entry.getKey());
-// String expected_start = URI_MARKER_STR + subj_start.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + pred_start.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + obj_start.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// String expected_end = URI_MARKER_STR + subj_start.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + pred_start.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + obj_end.stringValue();
-// assertEquals(expected_end + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-//
-// //sp - p has range
-// entry = factory.defineRange(subj_start, pred, null, conf);
-// assertEquals(TABLE_LAYOUT.SPO, entry.getKey());
-// expected_start = URI_MARKER_STR + subj_start.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + pred_start.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// expected_end = URI_MARKER_STR + subj_start.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + pred_end.stringValue();
-// assertEquals(expected_end + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-//
-// //s - s has range
-// entry = factory.defineRange(subj, null, null, conf);
-// assertEquals(TABLE_LAYOUT.SPO, entry.getKey());
-// expected_start = URI_MARKER_STR + subj_start.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// expected_end = URI_MARKER_STR + subj_end.stringValue();
-// assertEquals(expected_end + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-// }
-//
-// public void testPOCases() throws Exception {
-// URI loadPerc = vf.createURI(litdupsNS, "loadPerc");
-// URI obj = vf.createURI(litdupsNS, "uri1");
-//
-// //po
-// Map.Entry<TABLE_LAYOUT, Range> entry =
-// factory.defineRange(null, loadPerc, obj, conf);
-// assertEquals(TABLE_LAYOUT.PO, entry.getKey());
-// String expected_start = URI_MARKER_STR + loadPerc.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + obj.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// assertEquals(expected_start + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-//
-// //p
-// entry = factory.defineRange(null, loadPerc, null, conf);
-// assertEquals(TABLE_LAYOUT.PO, entry.getKey());
-// expected_start = URI_MARKER_STR + loadPerc.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// assertEquals(expected_start + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-// }
-//
-// public void testPOCasesWithRanges() throws Exception {
-// URI pred_start = vf.createURI(litdupsNS, "pred_start");
-// URI pred_end = vf.createURI(litdupsNS, "pred_stop");
-// URI obj_start = vf.createURI(litdupsNS, "obj_start");
-// URI obj_end = vf.createURI(litdupsNS, "obj_stop");
-//
-// Value pred = new RangeValue(pred_start, pred_end);
-// Value obj = new RangeValue(obj_start, obj_end);
-//
-// //po
-// Map.Entry<TABLE_LAYOUT, Range> entry =
-// factory.defineRange(null, pred_start, obj, conf);
-// assertEquals(TABLE_LAYOUT.PO, entry.getKey());
-// String expected_start = URI_MARKER_STR + pred_start.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + obj_start.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// String expected_end = URI_MARKER_STR + pred_start.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + obj_end.stringValue();
-// assertEquals(expected_end + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-//
-// //p
-// entry = factory.defineRange(null, pred, null, conf);
-// assertEquals(TABLE_LAYOUT.PO, entry.getKey());
-// expected_start = URI_MARKER_STR + pred_start.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// expected_end = URI_MARKER_STR + pred_end.stringValue();
-// assertEquals(expected_end + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-// }
-//
-// public void testOSPCases() throws Exception {
-// URI cpu = vf.createURI(litdupsNS, "cpu");
-// URI obj = vf.createURI(litdupsNS, "uri1");
-//
-// //so
-// Map.Entry<TABLE_LAYOUT, Range> entry =
-// factory.defineRange(cpu, null, obj, conf);
-// assertEquals(TABLE_LAYOUT.OSP, entry.getKey());
-// String expected_start = URI_MARKER_STR + obj.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + cpu.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// assertEquals(expected_start + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-//
-// //o
-// entry = factory.defineRange(null, null, obj, conf);
-// assertEquals(TABLE_LAYOUT.OSP, entry.getKey());
-// expected_start = URI_MARKER_STR + obj.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// assertEquals(expected_start + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-// }
-//
-//
-// public void testOSPCasesWithRanges() throws Exception {
-// URI subj_start = vf.createURI(litdupsNS, "subj_start");
-// URI subj_end = vf.createURI(litdupsNS, "subj_stop");
-// URI obj_start = vf.createURI(litdupsNS, "obj_start");
-// URI obj_end = vf.createURI(litdupsNS, "obj_stop");
-//
-// Value subj = new RangeValue(subj_start, subj_end);
-// Value obj = new RangeValue(obj_start, obj_end);
-//
-// //so - s should be the range
-// Map.Entry<TABLE_LAYOUT, Range> entry =
-// factory.defineRange(subj, null, obj_start, conf);
-// assertEquals(TABLE_LAYOUT.OSP, entry.getKey());
-// String expected_start = URI_MARKER_STR + obj_start.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + subj_start.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// String expected_end = URI_MARKER_STR + obj_start.stringValue() + DELIM_BYTES_STR +
-// URI_MARKER_STR + subj_end.stringValue();
-// assertEquals(expected_end + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-//
-// //o - o is range
-// entry = factory.defineRange(null, null, obj, conf);
-// assertEquals(TABLE_LAYOUT.OSP, entry.getKey());
-// expected_start = URI_MARKER_STR + obj_start.stringValue();
-// assertEquals(expected_start,
-// entry.getValue().getStartKey().getRow().toString());
-// expected_end = URI_MARKER_STR + obj_end.stringValue();
-// assertEquals(expected_end + DELIM_STOP + RANGE_ENDKEY_SUFFIX,
-// entry.getValue().getEndKey().getRow().toString());
-// }
-//
-//}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/MiniAccumuloClusterInstance.java
----------------------------------------------------------------------
diff --git a/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/MiniAccumuloClusterInstance.java b/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/MiniAccumuloClusterInstance.java
deleted file mode 100644
index eb11ed8..0000000
--- a/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/MiniAccumuloClusterInstance.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * 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 mvm.rya.accumulo;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.minicluster.MiniAccumuloCluster;
-import org.apache.accumulo.minicluster.MiniAccumuloConfig;
-import org.apache.log4j.Logger;
-
-import com.google.common.io.Files;
-
-/**
- * Contains boilerplate code that can be used by an integration test that
- * uses a {@link MiniAccumuloCluster}.
- * <p>
- * You can just extend {@link AccumuloITBase} if your test only requires Accumulo.
- */
-public class MiniAccumuloClusterInstance {
-
- private static final Logger log = Logger.getLogger(MiniAccumuloClusterInstance.class);
-
- private static final String USERNAME = "root";
- private static final String PASSWORD = "password";
-
- /**
- * A mini Accumulo cluster that can be used by the tests.
- */
- private static MiniAccumuloCluster cluster = null;
-
- /**
- * Start the {@link MiniAccumuloCluster}.
- */
- public void startMiniAccumulo() throws IOException, InterruptedException, AccumuloException, AccumuloSecurityException {
- final File miniDataDir = Files.createTempDir();
-
- // Setup and start the Mini Accumulo.
- final MiniAccumuloConfig cfg = new MiniAccumuloConfig(miniDataDir, PASSWORD);
- cluster = new MiniAccumuloCluster(cfg);
- cluster.start();
- }
-
- /**
- * Stop the {@link MiniAccumuloCluster}.
- */
- public void stopMiniAccumulo() throws IOException, InterruptedException {
- if(cluster != null) {
- try {
- log.info("Shutting down the Mini Accumulo being used as a Rya store.");
- cluster.stop();
- log.info("Mini Accumulo being used as a Rya store shut down.");
- } catch(final Exception e) {
- log.error("Could not shut down the Mini Accumulo.", e);
- }
- }
- }
-
- /**
- * @return The {@link MiniAccumuloCluster} managed by this class.
- */
- public MiniAccumuloCluster getCluster() {
- return cluster;
- }
-
- /**
- * @return An accumulo connector that is connected to the mini cluster.
- */
- public Connector getConnector() throws AccumuloException, AccumuloSecurityException {
- return cluster.getConnector(USERNAME, PASSWORD);
- }
-
- /**
- * @return The root username.
- */
- public String getUsername() {
- return USERNAME;
- }
-
- /**
- * @return The root password.
- */
- public String getPassword() {
- return PASSWORD;
- }
-
- /**
- * @return The MiniAccumulo's zookeeper instance name.
- */
- public String getInstanceName() {
- return cluster.getInstanceName();
- }
-
- /**
- * @return The MiniAccumulo's zookeepers.
- */
- public String getZookeepers() {
- return cluster.getZooKeepers();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/instance/AccumuloRyaDetailsRepositoryIT.java
----------------------------------------------------------------------
diff --git a/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/instance/AccumuloRyaDetailsRepositoryIT.java b/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/instance/AccumuloRyaDetailsRepositoryIT.java
deleted file mode 100644
index bdd6059..0000000
--- a/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/instance/AccumuloRyaDetailsRepositoryIT.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * 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 mvm.rya.accumulo.instance;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.util.Date;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.ZooKeeperInstance;
-import org.apache.accumulo.core.client.mock.MockInstance;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.minicluster.MiniAccumuloCluster;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.zookeeper.ClientCnxn;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import com.google.common.base.Optional;
-
-import mvm.rya.accumulo.AccumuloITBase;
-import mvm.rya.accumulo.MiniAccumuloClusterInstance;
-import mvm.rya.api.instance.RyaDetails;
-import mvm.rya.api.instance.RyaDetails.EntityCentricIndexDetails;
-import mvm.rya.api.instance.RyaDetails.FreeTextIndexDetails;
-import mvm.rya.api.instance.RyaDetails.GeoIndexDetails;
-import mvm.rya.api.instance.RyaDetails.JoinSelectivityDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails;
-import mvm.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails.PCJUpdateStrategy;
-import mvm.rya.api.instance.RyaDetails.ProspectorDetails;
-import mvm.rya.api.instance.RyaDetails.TemporalIndexDetails;
-import mvm.rya.api.instance.RyaDetailsRepository;
-import mvm.rya.api.instance.RyaDetailsRepository.AlreadyInitializedException;
-import mvm.rya.api.instance.RyaDetailsRepository.ConcurrentUpdateException;
-import mvm.rya.api.instance.RyaDetailsRepository.NotInitializedException;
-import mvm.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException;
-
-/**
- * Tests the methods of {@link AccumuloRyaDetailsRepository} by using a {@link MiniAccumuloCluster}.
- */
-public class AccumuloRyaDetailsRepositoryIT extends AccumuloITBase {
-
- @Test
- public void initializeAndGet() throws AccumuloException, AccumuloSecurityException, AlreadyInitializedException, RyaDetailsRepositoryException {
- final String instanceName = "testInstance";
-
- // Create the metadata object the repository will be initialized with.
- final RyaDetails details = RyaDetails.builder()
- .setRyaInstanceName(instanceName)
- .setRyaVersion("1.2.3.4")
- .setEntityCentricIndexDetails( new EntityCentricIndexDetails(true) )
- .setGeoIndexDetails( new GeoIndexDetails(true) )
- .setTemporalIndexDetails( new TemporalIndexDetails(true) )
- .setFreeTextDetails( new FreeTextIndexDetails(true) )
- .setPCJIndexDetails(
- PCJIndexDetails.builder()
- .setEnabled(true)
- .setFluoDetails( new FluoDetails("test_instance_rya_pcj_updater") )
- .addPCJDetails(
- PCJDetails.builder()
- .setId("pcj 1")
- .setUpdateStrategy(PCJUpdateStrategy.BATCH)
- .setLastUpdateTime( new Date() ))
- .addPCJDetails(
- PCJDetails.builder()
- .setId("pcj 2")))
- .setProspectorDetails( new ProspectorDetails(Optional.of(new Date())) )
- .setJoinSelectivityDetails( new JoinSelectivityDetails(Optional.of(new Date())) )
- .build();
-
- // Setup the repository that will be tested using a mini instance of Accumulo.
- final Connector connector = getClusterInstance().getConnector();
- final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, instanceName);
-
- // Initialize the repository
- repo.initialize(details);
-
- // Fetch the stored details.
- final RyaDetails stored = repo.getRyaInstanceDetails();
-
- // Ensure the fetched object is equivalent to what was stored.
- assertEquals(details, stored);
- }
-
- @Test(expected = AlreadyInitializedException.class)
- public void initialize_alreadyInitialized() throws AlreadyInitializedException, RyaDetailsRepositoryException, AccumuloException, AccumuloSecurityException {
- final String instanceName = "testInstance";
-
- // Create the metadata object the repository will be initialized with.
- final RyaDetails details = RyaDetails.builder()
- .setRyaInstanceName(instanceName)
- .setRyaVersion("1.2.3.4")
- .setEntityCentricIndexDetails( new EntityCentricIndexDetails(true) )
- .setGeoIndexDetails( new GeoIndexDetails(true) )
- .setTemporalIndexDetails( new TemporalIndexDetails(true) )
- .setFreeTextDetails( new FreeTextIndexDetails(true) )
- .setPCJIndexDetails(
- PCJIndexDetails.builder()
- .setEnabled(true)
- .setFluoDetails( new FluoDetails("test_instance_rya_pcj_updater") )
- .addPCJDetails(
- PCJDetails.builder()
- .setId("pcj 1")
- .setUpdateStrategy(PCJUpdateStrategy.BATCH)
- .setLastUpdateTime( new Date() ))
- .addPCJDetails(
- PCJDetails.builder()
- .setId("pcj 2")))
- .setProspectorDetails( new ProspectorDetails(Optional.of(new Date())) )
- .setJoinSelectivityDetails( new JoinSelectivityDetails(Optional.of(new Date())) )
- .build();
-
- // Setup the repository that will be tested using a mini instance of Accumulo.
- final Connector connector = getClusterInstance().getConnector();
- final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, instanceName);
-
- // Initialize the repository
- repo.initialize(details);
-
- // Initialize it again.
- repo.initialize(details);
- }
-
- @Test(expected = NotInitializedException.class)
- public void getRyaInstance_notInitialized() throws AccumuloException, AccumuloSecurityException, NotInitializedException, RyaDetailsRepositoryException {
- // Setup the repository that will be tested using a mini instance of Accumulo.
- final Connector connector = getClusterInstance().getConnector();
- final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, "testInstance");
-
- // Try to fetch the details from the uninitialized repository.
- repo.getRyaInstanceDetails();
- }
-
- @Test
- public void isInitialized_true() throws AccumuloException, AccumuloSecurityException, AlreadyInitializedException, RyaDetailsRepositoryException {
- final String instanceName = "testInstance";
-
- // Create the metadata object the repository will be initialized with.
- final RyaDetails details = RyaDetails.builder()
- .setRyaInstanceName(instanceName)
- .setRyaVersion("1.2.3.4")
- .setEntityCentricIndexDetails( new EntityCentricIndexDetails(true) )
- .setGeoIndexDetails( new GeoIndexDetails(true) )
- .setTemporalIndexDetails( new TemporalIndexDetails(true) )
- .setFreeTextDetails( new FreeTextIndexDetails(true) )
- .setPCJIndexDetails(
- PCJIndexDetails.builder()
- .setEnabled(true)
- .setFluoDetails( new FluoDetails("test_instance_rya_pcj_updater") )
- .addPCJDetails(
- PCJDetails.builder()
- .setId("pcj 1")
- .setUpdateStrategy(PCJUpdateStrategy.BATCH)
- .setLastUpdateTime( new Date() ))
- .addPCJDetails(
- PCJDetails.builder()
- .setId("pcj 2")))
- .setProspectorDetails( new ProspectorDetails(Optional.of(new Date())) )
- .setJoinSelectivityDetails( new JoinSelectivityDetails(Optional.of(new Date())) )
- .build();
-
- // Setup the repository that will be tested using a mini instance of Accumulo.
- final MiniAccumuloClusterInstance clusterInstance = getClusterInstance();
- final Connector connector = clusterInstance.getConnector();
- final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, "testInstance");
-
- // Initialize the repository
- repo.initialize(details);
-
- // Ensure the repository reports that it has been initialized.
- assertTrue( repo.isInitialized() );
- }
-
- @Test
- public void isInitialized_false() throws AccumuloException, AccumuloSecurityException, RyaDetailsRepositoryException {
- // Setup the repository that will be tested using a mock instance of Accumulo.
- final Connector connector = getClusterInstance().getConnector();
- final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, "testInstance");
-
- // Ensure the repository reports that is has not been initialized.
- assertFalse( repo.isInitialized() );
- }
-
- @Test
- public void update() throws AlreadyInitializedException, RyaDetailsRepositoryException, AccumuloException, AccumuloSecurityException {
- final String instanceName = "testInstance";
-
- // Create the metadata object the repository will be initialized with.
- final RyaDetails details = RyaDetails.builder()
- .setRyaInstanceName(instanceName)
- .setRyaVersion("1.2.3.4")
- .setEntityCentricIndexDetails( new EntityCentricIndexDetails(true) )
- .setGeoIndexDetails( new GeoIndexDetails(true) )
- .setTemporalIndexDetails( new TemporalIndexDetails(true) )
- .setFreeTextDetails( new FreeTextIndexDetails(true) )
- .setPCJIndexDetails(
- PCJIndexDetails.builder()
- .setEnabled(true)
- .setFluoDetails( new FluoDetails("test_instance_rya_pcj_updater") )
- .addPCJDetails(
- PCJDetails.builder()
- .setId("pcj 1")
- .setUpdateStrategy(PCJUpdateStrategy.BATCH)
- .setLastUpdateTime( new Date() ))
- .addPCJDetails(
- PCJDetails.builder()
- .setId("pcj 2")))
- .setProspectorDetails( new ProspectorDetails(Optional.of(new Date())) )
- .setJoinSelectivityDetails( new JoinSelectivityDetails(Optional.of(new Date())) )
- .build();
-
- // Setup the repository that will be tested using a mini instance of Accumulo.
- final Connector connector = getClusterInstance().getConnector();
- final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, "testInstance");
-
- // Initialize the repository
- repo.initialize(details);
-
- // Create a new state for the details.
- final RyaDetails updated = new RyaDetails.Builder( details )
- .setGeoIndexDetails( new GeoIndexDetails(false) )
- .build();
-
- // Execute the update.
- repo.update(details, updated);
-
- // Show the new state that is stored matches the updated state.
- final RyaDetails fetched = repo.getRyaInstanceDetails();
- assertEquals(updated, fetched);
- }
-
- @Test(expected = ConcurrentUpdateException.class)
- public void update_outOfDate() throws AccumuloException, AccumuloSecurityException, AlreadyInitializedException, RyaDetailsRepositoryException {
- final String instanceName = "testInstance";
-
- // Create the metadata object the repository will be initialized with.
- final RyaDetails details = RyaDetails.builder()
- .setRyaInstanceName(instanceName)
- .setRyaVersion("1.2.3.4")
- .setEntityCentricIndexDetails( new EntityCentricIndexDetails(true) )
- .setGeoIndexDetails( new GeoIndexDetails(true) )
- .setTemporalIndexDetails( new TemporalIndexDetails(true) )
- .setFreeTextDetails( new FreeTextIndexDetails(true) )
- .setPCJIndexDetails(
- PCJIndexDetails.builder()
- .setEnabled(true)
- .setFluoDetails( new FluoDetails("test_instance_rya_pcj_updater") )
- .addPCJDetails(
- PCJDetails.builder()
- .setId("pcj 1")
- .setUpdateStrategy(PCJUpdateStrategy.BATCH)
- .setLastUpdateTime( new Date() ))
- .addPCJDetails(
- PCJDetails.builder()
- .setId("pcj 2")))
- .setProspectorDetails( new ProspectorDetails(Optional.of(new Date())) )
- .setJoinSelectivityDetails( new JoinSelectivityDetails(Optional.of(new Date())) )
- .build();
-
- // Setup the repository that will be tested using a mini instance of Accumulo.
- final Connector connector = getClusterInstance().getConnector();
- final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, "testInstance");
-
- // Initialize the repository
- repo.initialize(details);
-
- // Create a new state for the details.
- final RyaDetails updated = new RyaDetails.Builder( details )
- .setGeoIndexDetails( new GeoIndexDetails(false) )
- .build();
-
- // Try to execute the update where the old state is not the currently stored state.
- repo.update(updated, updated);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/utils/VisibilitySimplifierTest.java
----------------------------------------------------------------------
diff --git a/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/utils/VisibilitySimplifierTest.java b/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/utils/VisibilitySimplifierTest.java
deleted file mode 100644
index 3d22e2f..0000000
--- a/dao/accumulo.rya/src/test/java/mvm/rya/accumulo/utils/VisibilitySimplifierTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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 mvm.rya.accumulo.utils;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-/**
- * Tests the methods of {@link VisibilitySimplifier}.
- */
-public class VisibilitySimplifierTest {
-
- @Test
- public void noneRequired() {
- final String simplified = new VisibilitySimplifier().simplify("u");
- assertEquals("u", simplified);
- }
-
- @Test
- public void parenthesis() {
- final String simplified = new VisibilitySimplifier().simplify("(u&u)&u");
- assertEquals("u", simplified);
- }
-
- @Test
- public void manyAnds() {
- final String simplified = new VisibilitySimplifier().simplify("u&u&u");
- assertEquals("u", simplified);
- }
-
- @Test
- public void complex() {
- final String simplified = new VisibilitySimplifier().simplify("(a|b)|(a|b)|a|b");
- assertEquals("a|b", simplified);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloITBase.java
----------------------------------------------------------------------
diff --git a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloITBase.java b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloITBase.java
new file mode 100644
index 0000000..7dd23e6
--- /dev/null
+++ b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloITBase.java
@@ -0,0 +1,105 @@
+/**
+ * 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 mvm.rya.accumulo;
+
+import java.io.IOException;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.minicluster.MiniAccumuloCluster;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.zookeeper.ClientCnxn;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+/**
+ * Boilerplate code for a unit test that uses a {@link MiniAccumuloCluster}.
+ * <p>
+ * It uses the same instance of {@link MiniAccumuloCluster} and just clears out
+ * any tables that were added between tests.
+ */
+public class AccumuloITBase {
+
+ // Managed the MiniAccumuloCluster
+ private MiniAccumuloClusterInstance cluster = null;
+
+ @BeforeClass
+ public static void killLoudLogs() {
+ Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);
+ }
+
+ @Before
+ public void initCluster() throws IOException, InterruptedException, AccumuloException, AccumuloSecurityException {
+ cluster = new MiniAccumuloClusterInstance();
+ cluster.startMiniAccumulo();
+ }
+
+
+ @After
+ public void tearDownCluster() throws IOException, InterruptedException {
+ cluster.stopMiniAccumulo();
+ }
+
+ /**
+ * @return The {@link MiniAccumuloClusterInstance} used by the tests.
+ */
+ public MiniAccumuloClusterInstance getClusterInstance() {
+ return cluster;
+ }
+
+ /**
+ * @return The root username.
+ */
+ public String getUsername() {
+ return cluster.getUsername();
+ }
+
+ /**
+ * @return The root password.
+ */
+ public String getPassword() {
+ return cluster.getPassword();
+ }
+
+ /**
+ * @return The MiniAccumulo's zookeeper instance name.
+ */
+ public String getInstanceName() {
+ return cluster.getInstanceName();
+ }
+
+ /**
+ * @return The MiniAccumulo's zookeepers.
+ */
+ public String getZookeepers() {
+ return cluster.getZookeepers();
+ }
+
+ /**
+ * @return A {@link Connector} that creates connections to the mini accumulo cluster.
+ * @throws AccumuloException Could not connect to the cluster.
+ * @throws AccumuloSecurityException Could not connect to the cluster because of a security violation.
+ */
+ public Connector getConnector() throws AccumuloException, AccumuloSecurityException {
+ return cluster.getConnector();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRdfConfigurationTest.java
----------------------------------------------------------------------
diff --git a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRdfConfigurationTest.java b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRdfConfigurationTest.java
new file mode 100644
index 0000000..ffd316e
--- /dev/null
+++ b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRdfConfigurationTest.java
@@ -0,0 +1,75 @@
+package mvm.rya.accumulo;
+
+/*
+ * 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.
+ */
+
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.security.Authorizations;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AccumuloRdfConfigurationTest {
+ private static final Logger logger = LoggerFactory.getLogger(AccumuloRdfConfigurationTest.class);
+
+ @Test
+ public void testAuths() {
+ String[] arr = {"U", "FOUO"};
+ String str = "U,FOUO";
+ Authorizations auths = new Authorizations(arr);
+
+ AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
+
+ conf.setAuths(arr);
+ assertTrue(Arrays.equals(arr, conf.getAuths()));
+ assertEquals(str, conf.getAuth());
+ assertEquals(auths, conf.getAuthorizations());
+
+ conf.setAuth(str);
+ assertTrue(Arrays.equals(arr, conf.getAuths()));
+ assertEquals(str, conf.getAuth());
+ assertEquals(auths, conf.getAuthorizations());
+ }
+
+ @Test
+ public void testIterators() {
+ AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
+
+ Map<String, String> options = new HashMap<String, String>();
+ options.put("key1", "value1");
+ options.put("key2", "value2");
+ IteratorSetting setting = new IteratorSetting(1, "test", "test2", options);
+
+ conf.setAdditionalIterators(setting);
+ IteratorSetting[] iteratorSettings = conf.getAdditionalIterators();
+ assertTrue(iteratorSettings.length == 1);
+
+ assertEquals(setting, iteratorSettings[0]);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaDAOTest.java
----------------------------------------------------------------------
diff --git a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaDAOTest.java b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaDAOTest.java
new file mode 100644
index 0000000..8b55070
--- /dev/null
+++ b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaDAOTest.java
@@ -0,0 +1,713 @@
+package mvm.rya.accumulo;
+
+/*
+ * 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.
+ */
+
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import info.aduna.iteration.CloseableIteration;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+
+import mvm.rya.accumulo.query.AccumuloRyaQueryEngine;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.domain.RyaType;
+import mvm.rya.api.domain.RyaURI;
+import mvm.rya.api.persist.RyaDAOException;
+import mvm.rya.api.persist.query.RyaQuery;
+import mvm.rya.api.resolver.RdfToRyaConversions;
+import mvm.rya.api.resolver.RyaContext;
+
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.mock.MockInstance;
+import org.apache.accumulo.core.iterators.FirstEntryInRowIterator;
+import org.calrissian.mango.collect.FluentCloseableIterable;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.model.vocabulary.XMLSchema;
+
+/**
+ * Class AccumuloRdfDAOTest
+ * Date: Mar 7, 2012
+ * Time: 9:42:28 AM
+ */
+public class AccumuloRyaDAOTest {
+
+ private AccumuloRyaDAO dao;
+ private ValueFactory vf = new ValueFactoryImpl();
+ static String litdupsNS = "urn:test:litdups#";
+ private AccumuloRdfConfiguration conf;
+ private Connector connector;
+
+ @Before
+ public void setUp() throws Exception {
+ dao = new AccumuloRyaDAO();
+ connector = new MockInstance().getConnector("", "");
+ dao.setConnector(connector);
+ conf = new AccumuloRdfConfiguration();
+ dao.setConf(conf);
+ dao.init();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ dao.purge(conf);
+ dao.destroy();
+ }
+
+ @Test
+ public void testAdd() throws Exception {
+ RyaURI cpu = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "cpu"));
+ RyaURI loadPerc = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "loadPerc"));
+ RyaURI uri1 = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "uri1"));
+ dao.add(new RyaStatement(cpu, loadPerc, uri1));
+
+ CloseableIteration<RyaStatement, RyaDAOException> iter = dao.getQueryEngine().query(new RyaStatement(cpu, loadPerc, null), conf);
+ int count = 0;
+ while (iter.hasNext()) {
+ assertTrue(uri1.equals(iter.next().getObject()));
+ count++;
+ }
+ iter.close();
+ assertEquals(1, count);
+
+ dao.delete(new RyaStatement(cpu, loadPerc, null), conf);
+
+ iter = dao.getQueryEngine().query(new RyaStatement(cpu, loadPerc, null), conf);
+ count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ iter.close();
+ assertEquals(0, count);
+ }
+
+ @Test
+ public void testDeleteDiffVisibility() throws Exception {
+ RyaURI cpu = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "cpu"));
+ RyaURI loadPerc = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "loadPerc"));
+ RyaURI uri1 = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "uri1"));
+ RyaStatement stmt1 = new RyaStatement(cpu, loadPerc, uri1, null, "1", "vis1".getBytes());
+ dao.add(stmt1);
+ RyaStatement stmt2 = new RyaStatement(cpu, loadPerc, uri1, null, "2", "vis2".getBytes());
+ dao.add(stmt2);
+
+ AccumuloRdfConfiguration cloneConf = conf.clone();
+ cloneConf.setAuth("vis1,vis2");
+
+ CloseableIteration<RyaStatement, RyaDAOException> iter = dao.getQueryEngine().query(new RyaStatement(cpu, loadPerc, null), cloneConf);
+ int count = 0;
+ while (iter.hasNext()) {
+ iter.next();
+ count++;
+ }
+ iter.close();
+ assertEquals(2, count);
+
+ dao.delete(stmt1, cloneConf);
+
+ iter = dao.getQueryEngine().query(new RyaStatement(cpu, loadPerc, null), cloneConf);
+ count = 0;
+ while (iter.hasNext()) {
+ iter.next();
+ count++;
+ }
+ iter.close();
+ assertEquals(1, count);
+ }
+
+ @Test
+ public void testDeleteDiffTimestamp() throws Exception {
+ RyaURI cpu = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "cpu"));
+ RyaURI loadPerc = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "loadPerc"));
+ RyaURI uri1 = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "uri1"));
+ RyaStatement stmt1 = new RyaStatement(cpu, loadPerc, uri1, null, "1", null, null, 100l);
+ dao.add(stmt1);
+ RyaStatement stmt2 = new RyaStatement(cpu, loadPerc, uri1, null, "2", null, null, 100l);
+ dao.add(stmt2);
+
+ int resultSize = FluentCloseableIterable.from(dao.getQueryEngine().query(
+ RyaQuery.builder(new RyaStatement(cpu, loadPerc, null)).build())).autoClose().size();
+ assertEquals(2, resultSize);
+
+ final RyaStatement addStmt = new RyaStatement(cpu, loadPerc, uri1, null, "1",
+ null, null, 101l);
+ dao.delete(stmt1, conf);
+ dao.add(addStmt);
+
+ resultSize = FluentCloseableIterable.from(dao.getQueryEngine().query(
+ RyaQuery.builder(new RyaStatement(cpu, loadPerc, null)).build())).autoClose().size();
+ assertEquals(2, resultSize); //the delete marker should not delete the new stmt
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ RyaURI predicate = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "pred"));
+ RyaURI subj = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "subj"));
+
+ // create a "bulk load" of 10,000 statements
+ int statement_count = 10000;
+ for (int i = 0 ; i < statement_count ; i++){
+ //make the statement very large so we will get a lot of random flushes
+ RyaURI obj = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, String.format("object%050d",i)));
+ RyaStatement stmt = new RyaStatement(subj, predicate, obj);
+ dao.add(stmt);
+ }
+
+ CloseableIteration<RyaStatement, RyaDAOException> iter;
+
+ //check to see if all of the statements made it to the subj table
+ //delete based on the data in the subj table
+ RyaStatement subjQuery = new RyaStatement(subj, null, null);
+ iter = dao.getQueryEngine().query(subjQuery, conf);
+ List<RyaStatement> stmts = new ArrayList<RyaStatement>();
+ while (iter.hasNext()) {
+ stmts.add(iter.next());
+ }
+ assertEquals(statement_count, stmts.size());
+ dao.delete(stmts.iterator(), conf);
+
+ // check statements in the predicate table
+ RyaStatement predQuery = new RyaStatement(null, predicate, null);
+ iter = dao.getQueryEngine().query(predQuery, conf);
+ int count = 0;
+ while (iter.hasNext()) {
+ count++;
+ }
+ iter.close();
+ assertEquals(0, count);
+ }
+
+ @Test
+ public void testAddEmptyString() throws Exception {
+ RyaURI cpu = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "cpu"));
+ RyaURI loadPerc = RdfToRyaConversions.convertURI(vf.createURI(litdupsNS, "loadPerc"));
+ RyaType empty = new RyaType("");
+ dao.add(new RyaStatement(cpu, loadPerc, empty));
+
+ CloseableIteration<RyaStatement, RyaDAOException> iter = dao.getQueryEngine().query(new RyaStatement(cpu, loadPerc, null), conf);
+ while (iter.hasNext()) {
+ assertEquals("", iter.next().getObject().getData());
+ }
+ iter.close();
+ }
+
+ @Test
+ public void testMaxResults() throws Exception {
+ RyaURI cpu = new RyaURI(litdupsNS + "cpu");
+ RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
+ dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri1")));
+ dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri2")));
+ dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri3")));
+ dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri4")));
+ dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri5")));
+
+ AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
+ AccumuloRdfConfiguration queryConf = new AccumuloRdfConfiguration(conf);
+ long limit = 3l;
+ queryConf.setLimit(limit);
+
+ CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), queryConf);
+ int count = 0;
+ while (iter.hasNext()) {
+ iter.next().getObject();
+ count++;
+ }
+ iter.close();
+ assertEquals(limit, count);
+ }
+
+ @Test
+ public void testAddValue() throws Exception {
+ RyaURI cpu = new RyaURI(litdupsNS + "cpu");
+ RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
+ RyaURI uri1 = new RyaURI(litdupsNS + "uri1");
+ String myval = "myval";
+ dao.add(new RyaStatement(cpu, loadPerc, uri1, null, null, null, myval.getBytes()));
+
+ AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
+ CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), conf);
+ assertTrue(iter.hasNext());
+ assertEquals(myval, new String(iter.next().getValue()));
+ iter.close();
+ }
+
+ @Test
+ public void testAddCv() throws Exception {
+ RyaURI cpu = new RyaURI(litdupsNS + "cpu");
+ RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
+ RyaURI uri1 = new RyaURI(litdupsNS + "uri1");
+ RyaURI uri2 = new RyaURI(litdupsNS + "uri2");
+ RyaURI uri3 = new RyaURI(litdupsNS + "uri3");
+ byte[] colVisABC = "A|B|C".getBytes();
+ byte[] colVisAB = "A|B".getBytes();
+ byte[] colVisA = "A".getBytes();
+ dao.add(new RyaStatement(cpu, loadPerc, uri1, null, null, colVisABC));
+ dao.add(new RyaStatement(cpu, loadPerc, uri2, null, null, colVisAB));
+ dao.add(new RyaStatement(cpu, loadPerc, uri3, null, null, colVisA));
+
+ AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
+
+ //query with no auth
+ CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), conf);
+ int count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ assertEquals(0, count);
+ iter.close();
+
+ AccumuloRdfConfiguration queryConf = new AccumuloRdfConfiguration();
+ queryConf.setAuth("B");
+ iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), queryConf);
+ count = 0;
+ while (iter.hasNext()) {
+ iter.next();
+ count++;
+ }
+ iter.close();
+ assertEquals(2, count);
+
+ queryConf.setAuth("A");
+ iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), queryConf);
+ count = 0;
+ while (iter.hasNext()) {
+ iter.next();
+ count++;
+ }
+ iter.close();
+ assertEquals(3, count);
+ }
+
+ @Test
+ public void testTTL() throws Exception {
+ RyaURI cpu = new RyaURI(litdupsNS + "cpu");
+ RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
+ long current = System.currentTimeMillis();
+ dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri1"), null, null, null, null, current));
+ dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri2"), null, null, null, null, current - 1010l));
+ dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri3"), null, null, null, null, current - 2010l));
+ dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri4"), null, null, null, null, current - 3010l));
+ dao.add(new RyaStatement(cpu, loadPerc, new RyaURI(litdupsNS + "uri5"), null, null, null, null, current - 4010l));
+
+ AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
+ AccumuloRdfConfiguration queryConf = conf.clone();
+ queryConf.setTtl(3000l);
+
+ CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), queryConf);
+ int count = 0;
+ while (iter.hasNext()) {
+ iter.next().getObject();
+ count++;
+ }
+ iter.close();
+ assertEquals(3, count);
+
+ queryConf.setStartTime(current - 3000l);
+ iter = queryEngine.query(new RyaStatement(cpu, loadPerc, null), queryConf);
+ count = 0;
+ while (iter.hasNext()) {
+ iter.next().getObject();
+ count++;
+ }
+ iter.close();
+ assertEquals(2, count);
+ }
+
+ @Test
+ public void testGetNamespace() throws Exception {
+ dao.addNamespace("ns", litdupsNS);
+ assertEquals(litdupsNS, dao.getNamespace("ns"));
+ dao.removeNamespace("ns");
+ assertNull(dao.getNamespace("ns"));
+ }
+
+ //TOOD: Add test for set of queries
+ @Test
+ public void testQuery() throws Exception {
+ RyaURI cpu = new RyaURI(litdupsNS + "cpu");
+ RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
+ RyaURI uri1 = new RyaURI(litdupsNS + "uri1");
+ RyaURI uri2 = new RyaURI(litdupsNS + "uri2");
+ RyaURI uri3 = new RyaURI(litdupsNS + "uri3");
+ RyaURI uri4 = new RyaURI(litdupsNS + "uri4");
+ RyaURI uri5 = new RyaURI(litdupsNS + "uri5");
+ RyaURI uri6 = new RyaURI(litdupsNS + "uri6");
+ dao.add(new RyaStatement(cpu, loadPerc, uri1));
+ dao.add(new RyaStatement(cpu, loadPerc, uri2));
+ dao.add(new RyaStatement(cpu, loadPerc, uri3));
+ dao.add(new RyaStatement(cpu, loadPerc, uri4));
+ dao.add(new RyaStatement(cpu, loadPerc, uri5));
+ dao.add(new RyaStatement(cpu, loadPerc, uri6));
+
+ AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
+
+ Collection<RyaStatement> coll = new ArrayList();
+ coll.add(new RyaStatement(null, loadPerc, uri1));
+ coll.add(new RyaStatement(null, loadPerc, uri2));
+ CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.batchQuery(coll, conf);
+ int count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ iter.close();
+ assertEquals(2, count);
+
+ //now use batchscanner
+ AccumuloRdfConfiguration queryConf = new AccumuloRdfConfiguration(conf);
+ queryConf.setMaxRangesForScanner(2);
+
+ coll = new ArrayList();
+ coll.add(new RyaStatement(null, loadPerc, uri1));
+ coll.add(new RyaStatement(null, loadPerc, uri2));
+ coll.add(new RyaStatement(null, loadPerc, uri3));
+ coll.add(new RyaStatement(null, loadPerc, uri4));
+ iter = queryEngine.batchQuery(coll, queryConf);
+ assertTrue(iter.hasNext()); //old code had a weird behaviour that could not perform hasNext consecutively
+ assertTrue(iter.hasNext());
+ assertTrue(iter.hasNext());
+ count = 0;
+ while (iter.hasNext()) {
+ count++;
+ assertTrue(iter.hasNext());
+ iter.next();
+ }
+ iter.close();
+ assertEquals(4, count);
+ }
+
+ @Test
+ public void testQueryDates() throws Exception {
+ RyaURI cpu = new RyaURI(litdupsNS + "cpu");
+ RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
+ RyaType uri0 = new RyaType(XMLSchema.DATETIME, "1960-01-01"); // How handles local time
+ RyaType uri1 = new RyaType(XMLSchema.DATETIME, "1992-01-01T+10:00"); // See Magadan Time
+ RyaType uri2 = new RyaType(XMLSchema.DATETIME, "2000-01-01TZ"); // How it handles UTC.
+ RyaType uri3 = new RyaType(XMLSchema.DATETIME, "2000-01-01T00:00:01.111Z");
+ RyaType uri4 = new RyaType(XMLSchema.DATETIME, "2000-01-01T00:00:01.111Z"); // duplicate
+ RyaType uri5 = new RyaType(XMLSchema.DATETIME, "2000-01-01T00:00:01-00:00");
+ RyaType uri6 = new RyaType(XMLSchema.DATETIME, "2000-01-01T00:00:01Z"); // duplicate
+ RyaType uri7 = new RyaType(XMLSchema.DATETIME, "-2000-01-01T00:00:01Z");
+ RyaType uri8 = new RyaType(XMLSchema.DATETIME, "111-01-01T00:00:01Z");
+ RyaType uri9 = new RyaType(XMLSchema.DATETIME, "12345-01-01T00:00:01Z");
+
+ dao.add(new RyaStatement(cpu, loadPerc, uri0));
+ dao.add(new RyaStatement(cpu, loadPerc, uri1));
+ dao.add(new RyaStatement(cpu, loadPerc, uri2));
+ dao.add(new RyaStatement(cpu, loadPerc, uri3));
+ dao.add(new RyaStatement(cpu, loadPerc, uri4));
+ dao.add(new RyaStatement(cpu, loadPerc, uri5));
+ dao.add(new RyaStatement(cpu, loadPerc, uri6));
+ dao.add(new RyaStatement(cpu, loadPerc, uri7));
+ dao.add(new RyaStatement(cpu, loadPerc, uri8));
+ dao.add(new RyaStatement(cpu, loadPerc, uri9));
+
+ AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
+
+ Collection<RyaStatement> coll = new ArrayList();
+ coll.add(new RyaStatement(null, loadPerc, uri0));
+ coll.add(new RyaStatement(null, loadPerc, uri1));
+ coll.add(new RyaStatement(null, loadPerc, uri2));
+ CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.batchQuery(coll, conf);
+ int count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ iter.close();
+ assertEquals("Three time zones should be normalized when stored, then normalized same when queried.",3, count);
+
+ //now use batchscanner
+ AccumuloRdfConfiguration queryConf = new AccumuloRdfConfiguration(conf);
+ queryConf.setMaxRangesForScanner(2);
+
+ coll = new ArrayList();
+ coll.add(new RyaStatement(null, loadPerc, uri0));
+ coll.add(new RyaStatement(null, loadPerc, uri1));
+ coll.add(new RyaStatement(null, loadPerc, uri2));
+ coll.add(new RyaStatement(null, loadPerc, uri3));
+ coll.add(new RyaStatement(null, loadPerc, uri4));
+ coll.add(new RyaStatement(null, loadPerc, uri5));
+ coll.add(new RyaStatement(null, loadPerc, uri6));
+ coll.add(new RyaStatement(null, loadPerc, uri7));
+ coll.add(new RyaStatement(null, loadPerc, uri8));
+ coll.add(new RyaStatement(null, loadPerc, uri9));
+ iter = queryEngine.batchQuery(coll, queryConf);
+ count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ iter.close();
+ assertEquals("Variety of time specs, including BC, pre-1970, duplicate pair ovewrite,future, 3 digit year.",8, count);
+ }
+
+ @Test
+ public void testQueryCollectionRegex() throws Exception {
+ RyaURI cpu = new RyaURI(litdupsNS + "cpu");
+ RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
+ RyaURI uri1 = new RyaURI(litdupsNS + "uri1");
+ RyaURI uri2 = new RyaURI(litdupsNS + "uri2");
+ RyaURI uri3 = new RyaURI(litdupsNS + "uri3");
+ RyaURI uri4 = new RyaURI(litdupsNS + "uri4");
+ RyaURI uri5 = new RyaURI(litdupsNS + "uri5");
+ RyaURI uri6 = new RyaURI(litdupsNS + "uri6");
+ dao.add(new RyaStatement(cpu, loadPerc, uri1));
+ dao.add(new RyaStatement(cpu, loadPerc, uri2));
+ dao.add(new RyaStatement(cpu, loadPerc, uri3));
+ dao.add(new RyaStatement(cpu, loadPerc, uri4));
+ dao.add(new RyaStatement(cpu, loadPerc, uri5));
+ dao.add(new RyaStatement(cpu, loadPerc, uri6));
+
+ AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
+
+ Collection<RyaStatement> coll = new ArrayList();
+ coll.add(new RyaStatement(null, loadPerc, uri1));
+ coll.add(new RyaStatement(null, loadPerc, uri2));
+ conf.setRegexPredicate(loadPerc.getData());
+ CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.batchQuery(coll, conf);
+ int count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ iter.close();
+ assertEquals(2, count);
+
+ conf.setRegexPredicate("notLoadPerc");
+ iter = queryEngine.batchQuery(coll, conf);
+ count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ iter.close();
+ assertEquals(0, count);
+ }
+
+ @Test
+ public void testQueryCollectionRegexWBatchScanner() throws Exception {
+ RyaURI cpu = new RyaURI(litdupsNS + "cpu");
+ RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
+ RyaURI uri1 = new RyaURI(litdupsNS + "uri1");
+ RyaURI uri2 = new RyaURI(litdupsNS + "uri2");
+ RyaURI uri3 = new RyaURI(litdupsNS + "uri3");
+ RyaURI uri4 = new RyaURI(litdupsNS + "uri4");
+ RyaURI uri5 = new RyaURI(litdupsNS + "uri5");
+ RyaURI uri6 = new RyaURI(litdupsNS + "uri6");
+ dao.add(new RyaStatement(cpu, loadPerc, uri1));
+ dao.add(new RyaStatement(cpu, loadPerc, uri2));
+ dao.add(new RyaStatement(cpu, loadPerc, uri3));
+ dao.add(new RyaStatement(cpu, loadPerc, uri4));
+ dao.add(new RyaStatement(cpu, loadPerc, uri5));
+ dao.add(new RyaStatement(cpu, loadPerc, uri6));
+
+ AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
+ AccumuloRdfConfiguration queryConf = new AccumuloRdfConfiguration(conf);
+ queryConf.setMaxRangesForScanner(1);
+
+ Collection<RyaStatement> coll = new ArrayList();
+ coll.add(new RyaStatement(null, loadPerc, uri1));
+ coll.add(new RyaStatement(null, loadPerc, uri2));
+ conf.setRegexPredicate(loadPerc.getData());
+ CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.batchQuery(coll, queryConf);
+ int count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ iter.close();
+ assertEquals(2, count);
+
+ queryConf.setRegexPredicate("notLoadPerc");
+ iter = queryEngine.batchQuery(coll, queryConf);
+ count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ iter.close();
+ assertEquals(0, count);
+ }
+
+ @Test
+ public void testLiteralTypes() throws Exception {
+ RyaURI cpu = new RyaURI(litdupsNS + "cpu");
+ RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
+ RyaType longLit = new RyaType(XMLSchema.LONG, "3");
+
+ dao.add(new RyaStatement(cpu, loadPerc, longLit));
+
+ AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
+
+ CloseableIteration<RyaStatement, RyaDAOException> query = queryEngine.query(new RyaStatement(cpu, null, null), conf);
+ assertTrue(query.hasNext());
+ RyaStatement next = query.next();
+ assertEquals(new Long(longLit.getData()), new Long(next.getObject().getData()));
+ query.close();
+
+ RyaType doubleLit = new RyaType(XMLSchema.DOUBLE, "2.0");
+
+ dao.add(new RyaStatement(cpu, loadPerc, doubleLit));
+
+ query = queryEngine.query(new RyaStatement(cpu, loadPerc, doubleLit), conf);
+ assertTrue(query.hasNext());
+ next = query.next();
+ assertEquals(Double.parseDouble(doubleLit.getData()), Double.parseDouble(next.getObject().getData()), 0.001);
+ query.close();
+ }
+
+ @Test
+ public void testSameLiteralStringTypes() throws Exception {
+ RyaURI cpu = new RyaURI(litdupsNS + "cpu");
+ RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
+ RyaType longLit = new RyaType(XMLSchema.LONG, "10");
+ RyaType strLit = new RyaType(XMLSchema.STRING, new String(RyaContext.getInstance().serializeType(longLit)[0]));
+
+ RyaStatement expected = new RyaStatement(cpu, loadPerc, longLit);
+ dao.add(expected);
+ dao.add(new RyaStatement(cpu, loadPerc, strLit));
+
+ AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
+
+ CloseableIteration<RyaStatement, RyaDAOException> query = queryEngine.query(new RyaStatement(cpu, loadPerc, longLit), conf);
+ assertTrue(query.hasNext());
+ RyaStatement next = query.next();
+ assertEquals(new Long(longLit.getData()), new Long(next.getObject().getData()));
+ assertEquals(longLit.getDataType(), next.getObject().getDataType());
+ assertFalse(query.hasNext());
+ query.close();
+ }
+
+ @Test
+ public void testPurge() throws RyaDAOException, TableNotFoundException {
+ dao.add(newRyaStatement());
+ assertFalse("table should not be empty", areTablesEmpty());
+
+ dao.purge(conf);
+ assertTrue("table should be empty", areTablesEmpty());
+ //assertNotNull(dao.getVersion());
+ }
+
+ @Test
+ public void testPurgeDoesNotBreakBatchWriters() throws TableNotFoundException, RyaDAOException {
+ dao.purge(conf);
+ assertTrue("table should be empty", areTablesEmpty());
+
+ dao.add(newRyaStatement());
+ assertFalse("table should not be empty", areTablesEmpty());
+ }
+
+ @Test
+ public void testDropAndDestroy() throws RyaDAOException {
+ assertTrue(dao.isInitialized());
+ dao.dropAndDestroy();
+ for (String tableName : dao.getTables()) {
+ assertFalse(tableExists(tableName));
+ }
+ assertFalse(dao.isInitialized());
+ }
+
+ @Test
+ public void testQueryWithIterators() throws Exception {
+ RyaURI cpu = new RyaURI(litdupsNS + "cpu");
+ RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
+ RyaURI uri1 = new RyaURI(litdupsNS + "uri1");
+ dao.add(new RyaStatement(cpu, loadPerc, uri1, null, "qual1"));
+ dao.add(new RyaStatement(cpu, loadPerc, uri1, null, "qual2"));
+
+ AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
+
+ AccumuloRdfConfiguration queryConf = new AccumuloRdfConfiguration(conf);
+ IteratorSetting firstEntryInRow = new IteratorSetting(3 /* correct value?? */, FirstEntryInRowIterator.class);
+ queryConf.setAdditionalIterators(firstEntryInRow);
+
+ Collection<RyaStatement> coll = new ArrayList<>();
+ coll.add(new RyaStatement(null, loadPerc, uri1));
+ CloseableIteration<RyaStatement, RyaDAOException> iter = queryEngine.batchQuery(coll, queryConf);
+ int count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ iter.close();
+ assertEquals(1, count);
+
+ //Assert that without the iterator we get 2
+ coll = new ArrayList<>();
+ coll.add(new RyaStatement(null, loadPerc, uri1));
+ iter = queryEngine.batchQuery(coll, conf);
+ count = 0;
+ while (iter.hasNext()) {
+ count++;
+ iter.next();
+ }
+ iter.close();
+ assertEquals(2, count);
+
+ }
+
+ private boolean areTablesEmpty() throws TableNotFoundException {
+ for (String table : dao.getTables()) {
+ if (tableExists(table)) {
+ // TODO: filter out version
+ if (createScanner(table).iterator().hasNext()) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private boolean tableExists(String tableName) {
+ return dao.getConnector().tableOperations().exists(tableName);
+ }
+
+ private Scanner createScanner(String tableName) throws TableNotFoundException {
+ return dao.getConnector().createScanner(tableName, conf.getAuthorizations());
+ }
+
+ private RyaStatement newRyaStatement() {
+ RyaURI subject = new RyaURI(litdupsNS + randomString());
+ RyaURI predicate = new RyaURI(litdupsNS + randomString());
+ RyaType object = new RyaType(randomString());
+
+ return new RyaStatement(subject, predicate, object);
+ }
+
+ private String randomString() {
+ return UUID.randomUUID().toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaITBase.java
----------------------------------------------------------------------
diff --git a/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaITBase.java b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaITBase.java
new file mode 100644
index 0000000..dea227b
--- /dev/null
+++ b/dao/accumulo.rya/src/test/java/org/apache/rya/accumulo/AccumuloRyaITBase.java
@@ -0,0 +1,109 @@
+/**
+ * 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 mvm.rya.accumulo;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+import com.google.common.base.Optional;
+
+import mvm.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository;
+import mvm.rya.api.instance.RyaDetails;
+import mvm.rya.api.instance.RyaDetails.EntityCentricIndexDetails;
+import mvm.rya.api.instance.RyaDetails.FreeTextIndexDetails;
+import mvm.rya.api.instance.RyaDetails.GeoIndexDetails;
+import mvm.rya.api.instance.RyaDetails.JoinSelectivityDetails;
+import mvm.rya.api.instance.RyaDetails.PCJIndexDetails;
+import mvm.rya.api.instance.RyaDetails.ProspectorDetails;
+import mvm.rya.api.instance.RyaDetails.TemporalIndexDetails;
+import mvm.rya.api.instance.RyaDetailsRepository;
+import mvm.rya.api.instance.RyaDetailsRepository.AlreadyInitializedException;
+import mvm.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException;
+
+/**
+ * Contains boilerplate code for spinning up a Mini Accumulo Cluster and initializing
+ * some of the Rya stuff. We can not actually initialize an instance of Rya here
+ * because Sail is not available to us.
+ */
+public class AccumuloRyaITBase {
+
+ // Managed the MiniAccumuloCluster
+ private static final MiniAccumuloClusterInstance cluster = new MiniAccumuloClusterInstance();
+
+ // Manage the Rya instances that are hosted on the cluster
+ protected static final AtomicInteger ryaInstanceNameCounter = new AtomicInteger(1);
+ private String ryaInstanceName;
+
+ @BeforeClass
+ public static void initCluster() throws IOException, InterruptedException, AccumuloException, AccumuloSecurityException {
+ cluster.startMiniAccumulo();
+ }
+
+ @Before
+ public void prepareForNextTest() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, AlreadyInitializedException, RyaDetailsRepositoryException {
+ // Get the next Rya instance name.
+ ryaInstanceName = "testInstance" + ryaInstanceNameCounter.getAndIncrement() + "_";
+
+ // Create Rya Details for the instance name.
+ final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(cluster.getConnector(), ryaInstanceName);
+
+ final RyaDetails details = RyaDetails.builder()
+ .setRyaInstanceName(ryaInstanceName)
+ .setRyaVersion("0.0.0.0")
+ .setFreeTextDetails( new FreeTextIndexDetails(true) )
+ .setEntityCentricIndexDetails( new EntityCentricIndexDetails(true) )
+ .setGeoIndexDetails( new GeoIndexDetails(true) )
+ .setTemporalIndexDetails( new TemporalIndexDetails(true) )
+ .setPCJIndexDetails(
+ PCJIndexDetails.builder()
+ .setEnabled(true) )
+ .setJoinSelectivityDetails( new JoinSelectivityDetails( Optional.<Date>absent() ) )
+ .setProspectorDetails( new ProspectorDetails( Optional.<Date>absent() ))
+ .build();
+
+ detailsRepo.initialize(details);
+ }
+
+ @AfterClass
+ public static void tearDownCluster() throws IOException, InterruptedException {
+ cluster.stopMiniAccumulo();
+ }
+
+ /**
+ * @return The {@link MiniAccumuloClusterInstance} used by the tests.
+ */
+ public MiniAccumuloClusterInstance getClusterInstance() {
+ return cluster;
+ }
+
+ /**
+ * @return The name of the Rya instance that is being used for the current test.
+ */
+ public String getRyaInstanceName() {
+ return ryaInstanceName;
+ }
+}
\ No newline at end of file