Ejemplo n.º 1
0
        public void ParsingUriLoader()
        {
            Skip.IfNot(TestConfigManager.GetSettingAsBoolean(TestConfigManager.UseRemoteParsing), "Test Config marks Remote Parsing as unavailable, test cannot be run");

            int defaultTimeout = Options.UriLoaderTimeout;

            try
            {
                Options.UriLoaderCaching = false;
                Options.UriLoaderTimeout = 45000;

                List <Uri> testUris = new List <Uri>()
                {
                    new Uri("http://www.bbc.co.uk/programmes/b0080bbs#programme"),
                    new Uri("http://dbpedia.org/resource/Southampton"),
                    new Uri("file:///resources\\MergePart1.ttl"),
                    new Uri("http://www.dotnetrdf.org/configuration#")
                };

                Console.WriteLine("## URI Loader Test Suite");

                foreach (Uri u in testUris)
                {
                    Console.WriteLine("# Testing URI '" + u.AbsoluteUri + "'");

                    //Load the Test RDF
                    Graph g = new Graph();
                    Assert.NotNull(g);
                    VDS.RDF.Parsing.UriLoader.Load(g, u);

                    if (!u.IsFile)
                    {
                        Assert.Equal(u, g.BaseUri);
                    }

                    Console.WriteLine();

                    Console.WriteLine("Following Triples were generated");
                    foreach (Triple t in g.Triples)
                    {
                        Console.WriteLine(t.ToString());
                    }
                    Console.WriteLine();
                }
            }
            finally
            {
                Options.UriLoaderCaching = true;
                Options.UriLoaderTimeout = defaultTimeout;
            }
        }
Ejemplo n.º 2
0
        public void GraphEquality()
        {
            Skip.IfNot(TestConfigManager.GetSettingAsBoolean(TestConfigManager.UseRemoteParsing), "Test Config marks Remote Parsing as unavailable, test cannot be run");

            try
            {
                Options.UriLoaderCaching = false;
                Console.WriteLine("Going to get two copies of a Graph from DBPedia and compare");
                Console.WriteLine("Using the DBPedia Graph for Barack Obama");

                Graph g      = new Graph();
                Graph h      = new Graph();
                Uri   target = new Uri("http://dbpedia.org/resource/Barack_Obama");

                VDS.RDF.Parsing.UriLoader.Load(g, target);
                Console.WriteLine("Loaded first copy OK - " + g.Triples.Count + " Triples");
                VDS.RDF.Parsing.UriLoader.Load(h, target);
                Console.WriteLine("Loaded second copy OK - " + h.Triples.Count + " Triples");

                //Should have same Base Uri
                Assert.Equal(g.BaseUri, h.BaseUri);

                //Do equality check
                Console.WriteLine("Checking the Equality of the Graphs");
                //TestTools.CompareGraphs(g, h, true);
                Dictionary <INode, INode> mapping;
                bool equals = g.Equals(h, out mapping);
                Assert.True(equals, "Graphs should have been equal");
                if (mapping != null)
                {
                    Console.WriteLine("Blank Node Mapping was:");
                    foreach (KeyValuePair <INode, INode> pair in mapping)
                    {
                        Console.WriteLine(pair.Key.ToString() + " => " + pair.Value.ToString());
                    }
                }
                Console.WriteLine();

                //Get a third graph of something different
                Console.WriteLine("Going to get a third Graph of something different and check it is non-equal");
                Uri   target2 = new Uri("http://dbpedia.org/resource/Nottingham");
                Graph i       = new Graph();
                VDS.RDF.Parsing.UriLoader.Load(i, target2);

                //Should have different Base URIs and be non-equal
                Assert.Equal(g.BaseUri, i.BaseUri);
                Assert.Equal(h.BaseUri, i.BaseUri);
                Assert.False(g.Equals(i));
                Assert.False(h.Equals(i));
                //TestTools.CompareGraphs(g, i, false);
                //TestTools.CompareGraphs(h, i, false);
            }
            catch (WebException webEx)
            {
                TestTools.ReportError("Web Exception", webEx);
                Console.WriteLine();
                Console.WriteLine("Unable to retrieve the Graphs from the Web successfully!");
                Skip.If(true, "Unable to retrieve the graphs from the web successfully.");
            }
            finally
            {
                Options.UriLoaderCaching = true;
            }
        }
Ejemplo n.º 3
0
        public void ParsingUriLoader()
        {
            if (!TestConfigManager.GetSettingAsBoolean(TestConfigManager.UseRemoteParsing))
            {
                Assert.Inconclusive("Test Config marks Remote Parsing as unavailable, test cannot be run");
            }

            int defaultTimeout = Options.UriLoaderTimeout;

            try
            {
#if !NO_URICACHE
                Options.UriLoaderCaching = false;
#endif
                Options.UriLoaderTimeout = 45000;

                List <Uri> testUris = new List <Uri>()
                {
#if !NO_HTMLAGILITYPACK // Resource returns RDFa
                    new Uri("http://www.bbc.co.uk/programmes/b0080bbs#programme"),
#endif
                    new Uri("http://dbpedia.org/resource/Southampton"),
#if !NO_FILE // file: urls not supported
                    new Uri("file:///resources\\MergePart1.ttl"),
#endif
                    new Uri("http://www.dotnetrdf.org/configuration#")
                };

                Console.WriteLine("## URI Loader Test Suite");

                foreach (Uri u in testUris)
                {
                    Console.WriteLine("# Testing URI '" + u.AbsoluteUri + "'");

                    //Load the Test RDF
                    Graph g = new Graph();
                    Assert.IsNotNull(g);
                    VDS.RDF.Parsing.UriLoader.Load(g, u);

                    if (!u.IsFile)
                    {
                        Assert.AreEqual(u, g.BaseUri);
                    }

                    Console.WriteLine();

                    Console.WriteLine("Following Triples were generated");
                    foreach (Triple t in g.Triples)
                    {
                        Console.WriteLine(t.ToString());
                    }
                    Console.WriteLine();
                }
            }
            finally
            {
#if !NO_URICACHE
                Options.UriLoaderCaching = true;
#endif
                Options.UriLoaderTimeout = defaultTimeout;
            }
        }