public void TestRdfImportExport() { var client = GetEmbeddedClient(); var storeName = "TestRdfImportExport_" + _runId; var importPath = Path.Combine(TestConfiguration.StoreLocation, "import"); if (!Directory.Exists(importPath)) { Directory.CreateDirectory(importPath); } _pm.CopyFile(Path.Combine(Path.Combine(NSBundle.MainBundle.BundlePath, "TestData"), "simple.txt"), Path.Combine(importPath, "simple.txt"), true); client.CreateStore(storeName); // RDF import var job = client.StartImport(storeName, "simple.txt"); AssertJobSuccessful(client, storeName, job); // RDF export job = client.StartExport(storeName, "simple.export.nt"); AssertJobSuccessful(client, storeName, job); var exportFilePath = Path.Combine(importPath, "simple.export.nt"); Assert.IsTrue(_pm.FileExists(exportFilePath)); }
public void TestCreateStore() { Configuration.ResourceCacheLimit = 10000; Configuration.PageCacheSize = 4; var client = GetEmbeddedClient(); var storeName = "TestCreateStore_" + _runId; var storePath = Path.Combine(TestConfiguration.StoreLocation, storeName); var dataPath = Path.Combine(storePath, "data.bs"); client.CreateStore(storeName); Assert.IsTrue(client.DoesStoreExist(storeName)); Assert.IsTrue(_pm.DirectoryExists(TestConfiguration.StoreLocation)); Assert.IsTrue(_pm.DirectoryExists(storePath)); Assert.IsTrue(_pm.FileExists(dataPath)); client.DeleteStore(storeName); Task.Delay(50).Wait(); // Wait to allow store to shutdown Assert.IsTrue(_pm.DirectoryExists(TestConfiguration.StoreLocation)); Assert.IsFalse(_pm.DirectoryExists(storePath)); Assert.IsFalse(_pm.FileExists(dataPath)); Assert.IsFalse(client.DoesStoreExist(storeName)); }
public override void Run() { try { Logging.LogInfo("Import job being run on file " + _contentFileName); StoreWorker.TransactionLog.LogStartTransaction(this); var parser = GetParser(_contentFileName); var storeDirectory = StoreWorker.WriteStore.DirectoryPath; var importDirectory = Path.Combine(Path.GetDirectoryName(storeDirectory), "import"); var filePath = Path.Combine(importDirectory, _contentFileName); var profiler = Logging.IsProfilingEnabled ? new BrightstarProfiler("Import " + _contentFileName) : null; Logging.LogDebug("Import file path calculated as '{0}'", filePath); using (_fileStream = GetImportFileStream(filePath)) { _importTripleSink = new StoreTripleSink(StoreWorker.WriteStore, JobId, Configuration.TransactionFlushTripleCount, profiler: profiler); parser.Parse(_fileStream, this, _graphUri); } StoreWorker.WriteStore.Commit(JobId, profiler); StoreWorker.InvalidateReadStore(); Logging.LogInfo("Import job completed successfully for " + _contentFileName); if (profiler != null) { Logging.LogInfo(profiler.GetLogString()); } StoreWorker.TransactionLog.LogEndSuccessfulTransaction(this); } catch (RdfParserException parserException) { ErrorMessage = parserException.Message; ExceptionDetail = new ExceptionDetailObject(parserException); Logging.LogInfo("Parser error processing import job on file " + _contentFileName + ". " + parserException.Message); throw; } catch (Exception ex) { ErrorMessage = "Error importing file " + _contentFileName + ". " + ex.Message; StoreWorker.TransactionLog.LogEndFailedTransaction(this); Logging.LogInfo("Error processing import job on file " + _contentFileName + ". Error Message: " + ex.Message + " Stack trace: " + ex.StackTrace); throw; } }
protected void CheckResult(string results, string expectedResultPath, bool laxCardinality) { try { Assert.IsNotNull(results); var resultExtension = Path.GetExtension(expectedResultPath).ToLower(); if (resultExtension.Equals(".srx")) { CompareSparqlResults(results, expectedResultPath, laxCardinality); } else if (resultExtension.Equals(".srj")) { CompareSparqlResults(results, expectedResultPath, laxCardinality, new SparqlJsonParser()); } else if (resultExtension.Equals(".tsv")) { CompareSparqlResults(results, expectedResultPath, laxCardinality, new SparqlTsvParser()); } else if (resultExtension.Equals(".csv")) { CompareSparqlResults(results, expectedResultPath, laxCardinality, new SparqlCsvParser()); } else if (resultExtension.Equals(".ttl") || resultExtension.Equals(".rdf")) { CompareResultGraphs(results, expectedResultPath, laxCardinality); } else { Assert.Fail("Don't know how to compare results to results file {0}", expectedResultPath); } } catch (AssertionException) { Console.WriteLine("Expected Results Path: {0}", expectedResultPath); Console.WriteLine("Actual Results:"); Console.WriteLine(results); throw; } }
public void TestRdfImportExport() { var client = GetEmbeddedClient(); var storeName = "TestRdfImportExport_" + _runId; var importPath = Path.Combine(TestConfiguration.StoreLocation, "import"); TestHelper.CopyFile("TestData\\simple.txt", importPath, "simple.txt"); client.CreateStore(storeName); // RDF import var job = client.StartImport(storeName, "simple.txt"); AssertJobSuccessful(client, storeName, job); // RDF export job = client.StartExport(storeName, "simple.export.nt"); AssertJobSuccessful(client, storeName, job); var exportFilePath = Path.Combine(importPath, "simple.export.nt"); Assert.IsTrue(_pm.FileExists(exportFilePath)); }
public void TestCreateAndDeleteStore() { var client = GetEmbeddedClient(); var storeName = "TestCreateStore_" + _runId; var storePath = Path.Combine(TestConfiguration.StoreLocation, storeName); var dataPath = Path.Combine(storePath, "data.bs"); client.CreateStore(storeName); Assert.IsTrue(client.DoesStoreExist(storeName), "Expected True from DoesStoreExist after store created."); Assert.IsTrue(_pm.DirectoryExists(TestConfiguration.StoreLocation), "Expected stores directory at {0}", TestConfiguration.StoreLocation); Assert.IsTrue(_pm.DirectoryExists(storePath), "Expected store directory at {0}", storePath); Assert.IsTrue(_pm.FileExists(dataPath), "Expected B* data file at {0}", dataPath); client.DeleteStore(storeName); Task.Delay(50).Wait(); // Wait to allow store to shutdown Assert.IsTrue(_pm.DirectoryExists(TestConfiguration.StoreLocation), "Expected stores directory at {0} after store deleted.", TestConfiguration.StoreLocation); Assert.IsFalse(_pm.FileExists(dataPath), "Expected data file to be deleted from {0}.", dataPath); Assert.IsFalse(_pm.DirectoryExists(storePath), "Expected store directory to be deleted from {0}.", storePath); Assert.IsFalse(client.DoesStoreExist(storeName), "Expected False from DoesStoreExist after store deleted."); }