1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */1718package org.apache.any23.extractor.rdfa;
1920import org.apache.any23.extractor.ExtractorFactory;
21import org.junit.Assert;
22import org.junit.Test;
23import org.eclipse.rdf4j.model.Statement;
24import org.eclipse.rdf4j.repository.RepositoryException;
25import org.eclipse.rdf4j.rio.RDFHandlerException;
26import org.eclipse.rdf4j.rio.RDFParseException;
2728import java.io.IOException;
29import java.util.List;
3031/**32 * Reference Test Class for {@link RDFaExtractor}.33 */34publicclassRDFaExtractorTestextendsAbstractRDFaExtractorTestCase {
3536/**37 * Taken from the <a href="http://www.heppnetz.de/rdfa4google/testcases.html">GoodRelations test cases</a>. It38 * checks if the extraction is the same when the namespaces are defined in <i>RDFa1.0</i> or <i>RDFa1.1</i>39 * respectively.40 *41 * @throws org.eclipse.rdf4j.repository.RepositoryException42 * if an error is encountered whilst loading content from a storage connection43 * @throws java.io.IOException44 * if there is an error interpreting the input data45 * @throws org.eclipse.rdf4j.rio.RDFHandlerException46 * if there is an error within the {@link org.eclipse.rdf4j.rio.RDFHandler}47 * @throws org.eclipse.rdf4j.rio.RDFParseException48 * if there is an exception parsing an RDF Stream49 */50 @Test
51publicvoid testRDFa11PrefixBackwardCompatibility()
52throws RepositoryException, RDFHandlerException, IOException, RDFParseException {
53finalint EXPECTED_STATEMENTS = 31;
5455 assertExtract("/html/rdfa/goodrelations-rdfa10.html");
56 logger.debug("Model 1 " + dumpHumanReadableTriples());
57 Assert.assertEquals(EXPECTED_STATEMENTS, dumpAsListOfStatements().size());
58 List<Statement> rdfa10Stmts = dumpAsListOfStatements();
5960// assertContainsModel("/html/rdfa/goodrelations-rdfa10-expected.nq");6162 assertExtract("/html/rdfa/goodrelations-rdfa11.html");
63 logger.debug("Model 2 " + dumpHumanReadableTriples());
64 Assert.assertTrue(dumpAsListOfStatements().size() >= EXPECTED_STATEMENTS);
6566for (Statement stmt : rdfa10Stmts) {
67 assertContains(stmt);
68 }
69 }
7071 @Test
72publicvoid testRDFa11CURIEs() throws Exception {
73 }
7475/**76 * Tests that the default parser settings enable tolerance in data type parsing.77 */78 @Test
79publicvoid testTolerantParsing() {
80 assertExtract("/html/rdfa/oreilly-invalid-datatype.html");
81 }
8283 @Override
84protected ExtractorFactory<?> getExtractorFactory() {
85returnnew RDFaExtractorFactory();
86 }
8788 }