Require strict isomorphism in all microdata tests. Revert microdata 5.2.1.2-expected...
authorHans <firedrake93@gmail.com>
Tue, 30 Oct 2018 15:25:26 +0000 (10:25 -0500)
committerHans <firedrake93@gmail.com>
Tue, 30 Oct 2018 15:25:26 +0000 (10:25 -0500)
core/src/test/java/org/apache/any23/extractor/microdata/MicrodataExtractorTest.java
test-resources/src/test/resources/microdata/5.2.1-non-normative-example-2-expected.nquads

index 0e634de..01a0585 100644 (file)
@@ -29,9 +29,9 @@ import org.apache.any23.extractor.rdf.TurtleExtractorFactory;
 import org.apache.any23.rdf.RDFUtils;
 import org.apache.any23.source.DocumentSource;
 import org.apache.any23.source.HTTPDocumentSource;
-import org.apache.any23.vocab.SINDICE;
 import org.apache.any23.writer.TripleWriterHandler;
 import org.eclipse.rdf4j.model.IRI;
+import org.eclipse.rdf4j.model.Model;
 import org.eclipse.rdf4j.model.Value;
 import org.eclipse.rdf4j.model.Literal;
 import org.eclipse.rdf4j.model.Resource;
@@ -428,14 +428,38 @@ public class MicrodataExtractorTest extends AbstractExtractorTestCase {
         int actualStmtSize = getStatementsSize(null, null, null);
         Assert.assertEquals( expectedStatements.size(), actualStmtSize);
         for (Statement statement : expectedStatements) {
-            if (!statement.getPredicate().equals(SINDICE.getInstance().date)) {
-                assertContains(
-                        statement.getSubject() instanceof BNode ? null : statement.getSubject(),
-                        statement.getPredicate(),
-                        statement.getObject() instanceof BNode ? null : statement.getObject()
-                );
-            }
+            assertContains(
+                    statement.getSubject() instanceof BNode ? null : statement.getSubject(),
+                    statement.getPredicate(),
+                    statement.getObject() instanceof BNode ? null : statement.getObject()
+            );
+        }
+        Model expectedModel = new TreeModel();
+        for (Statement s : expectedStatements) {
+            expectedModel.add(s.getSubject(), s.getPredicate(), s.getObject());
         }
+
+        Model actualModel = new TreeModel();
+        conn.export(new RDFHandler() {
+            @Override
+            public void startRDF() throws RDFHandlerException {
+            }
+            @Override
+            public void endRDF() throws RDFHandlerException {
+            }
+            @Override
+            public void handleNamespace(String s, String s1) throws RDFHandlerException {
+            }
+            @Override
+            public void handleStatement(Statement statement) throws RDFHandlerException {
+                actualModel.add(statement.getSubject(), statement.getPredicate(), statement.getObject());
+            }
+            @Override
+            public void handleComment(String s) throws RDFHandlerException {
+            }
+        });
+
+        Assert.assertTrue("Models are not isomorphic", Models.isomorphic(expectedModel, actualModel));
     }
 
     private List<Statement> loadResultStatement(String resultFilePath)
index 8eedf33..a76ac84 100644 (file)
 #  limitations under the License.
 #
 
-_:nodebdb2c525cf8095abb6954b51432e6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://microformats.org/profile/hcard> <http://bob.example.com/> .
-_:nodebdb2c525cf8095abb6954b51432e6 <http://microformats.org/profile/hcard#fn> "Princeton" <http://bob.example.com/> .
-_:nodebdb2c525cf8095abb6954b51432e6 <http://microformats.org/profile/hcard#given-name> "Princeton" <http://bob.example.com/> .
-_:nodebdb2c525cf8095abb6954b51432e6 <http://microformats.org/profile/hcard#n> _:node5194c3bb9d7f53e4759c6f393d95f88 <http://bob.example.com/> .
-_:node1ffeb2699b75ba7aca5ee3d72adb55a8 <http://microformats.org/profile/hcard#street-address> "Avenue Q" <http://bob.example.com/> .
-_:nodebdb2c525cf8095abb6954b51432e6 <http://microformats.org/profile/hcard#adr> _:node1ffeb2699b75ba7aca5ee3d72adb55a8 <http://bob.example.com/> .
-<http://bob.example.com/> <http://www.w3.org/1999/xhtml/microdata#item> _:nodebdb2c525cf8095abb6954b51432e6 <http://bob.example.com/> .
-_:node7a12e48e321d29211c8b7c2ce396854 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://microformats.org/profile/hcard> <http://bob.example.com/> .
-_:node7a12e48e321d29211c8b7c2ce396854 <http://microformats.org/profile/hcard#fn> "Trekkie" <http://bob.example.com/> .
-_:node7a12e48e321d29211c8b7c2ce396854 <http://microformats.org/profile/hcard#given-name> "Trekkie" <http://bob.example.com/> .
-_:node7a12e48e321d29211c8b7c2ce396854 <http://microformats.org/profile/hcard#n> _:node45173ea18b736c2e9c3136e52ed3727e <http://bob.example.com/> .
-_:node7a12e48e321d29211c8b7c2ce396854 <http://microformats.org/profile/hcard#adr> _:node1ffeb2699b75ba7aca5ee3d72adb55a8 <http://bob.example.com/> .
-<http://bob.example.com/> <http://www.w3.org/1999/xhtml/microdata#item> _:node7a12e48e321d29211c8b7c2ce396854 <http://bob.example.com/> .
+<http://bob.example.com/> <http://www.w3.org/1999/xhtml/microdata#item> _:node161nd8236x293102 <http://bob.example.com/> .
+<http://bob.example.com/> <http://www.w3.org/1999/xhtml/microdata#item> _:node161nd8236x293103 <http://bob.example.com/> .
+_:node161nd8236x293102 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://microformats.org/profile/hcard> <http://bob.example.com/> .
+_:node161nd8236x293102 <http://microformats.org/profile/hcard#fn> "Princeton" <http://bob.example.com/> .
+_:node161nd8236x293102 <http://microformats.org/profile/hcard#n> _:node161nd8236x293104 <http://bob.example.com/> .
+_:node161nd8236x293102 <http://microformats.org/profile/hcard#adr> _:node161nd8236x293105 <http://bob.example.com/> .
+_:node161nd8236x293104 <http://microformats.org/profile/hcard#given-name> "Princeton" <http://bob.example.com/> .
+_:node161nd8236x293103 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://microformats.org/profile/hcard> <http://bob.example.com/> .
+_:node161nd8236x293103 <http://microformats.org/profile/hcard#fn> "Trekkie" <http://bob.example.com/> .
+_:node161nd8236x293103 <http://microformats.org/profile/hcard#n> _:node161nd8236x293106 <http://bob.example.com/> .
+_:node161nd8236x293103 <http://microformats.org/profile/hcard#adr> _:node161nd8236x293105 <http://bob.example.com/> .
+_:node161nd8236x293106 <http://microformats.org/profile/hcard#given-name> "Trekkie" <http://bob.example.com/> .
+_:node161nd8236x293105 <http://microformats.org/profile/hcard#street-address> "Avenue Q" <http://bob.example.com/> .