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.csv;
1920import org.junit.Assert;
21import org.junit.Test;
2223import java.io.BufferedInputStream;
24import java.io.IOException;
2526/**27 * Test case for {@link CSVReaderBuilder}.28 *29 * @author Michele Mostarda (mostarda@fbk.eu)30 */31publicclassCSVReaderBuilderTest {
3233/**34 * Tests positive CSV detection.35 *36 * @throws IOException37 * if there is an error interpreting the input data38 */39 @Test
40publicvoid testPositiveCSVDetection() throws IOException {
41 Assert.assertTrue("Builder cannot detect CVS stream.",
42 CSVReaderBuilder.isCSV(new BufferedInputStream(this.getClass().getResourceAsStream("test-comma.csv"))));
43 Assert.assertTrue("Builder cannot detect CVS stream.", CSVReaderBuilder
44 .isCSV(new BufferedInputStream(this.getClass().getResourceAsStream("test-semicolon.csv"))));
45 Assert.assertTrue("Builder cannot detect CVS stream.",
46 CSVReaderBuilder.isCSV(new BufferedInputStream(this.getClass().getResourceAsStream("test-tab.csv"))));
47 }
4849/**50 * Tests negative CSV detection.51 *52 * @throws IOException53 * if there is an error interpreting the input data54 */55 @Test
56publicvoid testNegativeCSVDetection() throws IOException {
57 Assert.assertFalse("Wrong CSV detection.", CSVReaderBuilder
58 .isCSV(new BufferedInputStream(this.getClass().getResourceAsStream("/application/nquads/test1.nq"))));
59 Assert.assertFalse("Wrong CSV detection.", CSVReaderBuilder
60 .isCSV(new BufferedInputStream(this.getClass().getResourceAsStream("/application/nquads/test2.nq"))));
61 Assert.assertFalse("Wrong CSV detection.", CSVReaderBuilder.isCSV(new BufferedInputStream(
62this.getClass().getResourceAsStream("/org/apache/any23/extractor/rdf/example-ntriples.nt"))));
63 }
6465 }