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.rdf;
1920import org.apache.any23.extractor.ExtractionContext;
21import org.apache.any23.extractor.ExtractionParameters;
22import org.apache.any23.extractor.ExtractionResult;
23import org.apache.any23.extractor.ExtractionResultImpl;
24import org.apache.any23.rdf.RDFUtils;
25import org.apache.any23.writer.RDFXMLWriter;
26import org.apache.any23.writer.TripleHandler;
27import org.junit.After;
28import org.junit.Before;
29import org.junit.Test;
30import org.eclipse.rdf4j.model.IRI;
31import org.slf4j.Logger;
32import org.slf4j.LoggerFactory;
3334import java.io.ByteArrayOutputStream;
35import java.nio.charset.StandardCharsets;
3637/**38 * Test case for {@link ManchesterSyntaxExtractor}.39 *40 * @author Peter Ansell41 */42publicclassManchesterSyntaxExtractorTest {
4344privatestaticfinal Logger logger = LoggerFactory.getLogger(ManchesterSyntaxExtractorTest.class);
4546private ManchesterSyntaxExtractor extractor;
4748 @Before
49publicvoid setUp() {
50 extractor = new ManchesterSyntaxExtractor();
51 }
5253 @After
54publicvoid tearDown() {
55 extractor = null;
56 }
5758 @Test
59publicvoid testExampleManchesterSyntax() throws Exception {
60final IRI uri = RDFUtils.iri("http://example.org/example-manchestersyntax.omn");
61 ByteArrayOutputStream baos = new ByteArrayOutputStream();
62final TripleHandler th = new RDFXMLWriter(baos);
63final ExtractionContext extractionContext = new ExtractionContext("owl-manchestersyntax-extractor", uri);
64final ExtractionResult result = new ExtractionResultImpl(extractionContext, extractor, th);
65 extractor.setStopAtFirstError(false);
66try {
67 extractor.run(ExtractionParameters.newDefault(), extractionContext,
68this.getClass().getResourceAsStream("/text/owl-manchester/example-manchestersyntax.omn"), result);
69 } finally {
70 logger.debug(baos.toString(StandardCharsets.UTF_8));
71 th.close();
72 result.close();
73 }
74 }
7576 }