http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/BZippedTriGInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/BZippedTriGInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/BZippedTriGInputTest.java new file mode 100644 index 0000000..b2b3c33 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/BZippedTriGInputTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.compressed.trig; + +import org.apache.hadoop.io.compress.BZip2Codec; + +/** + * Tests for BZipped TriG input + * + * + * + */ +public class BZippedTriGInputTest extends AbstractCompressedTriGInputFormatTests { + + /** + * Creates new tests + */ + public BZippedTriGInputTest() { + super(".trig.bz2", new BZip2Codec()); + } +}
http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/DeflatedTriGInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/DeflatedTriGInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/DeflatedTriGInputTest.java new file mode 100644 index 0000000..c9579a9 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/DeflatedTriGInputTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.compressed.trig; + +import org.apache.hadoop.io.compress.DefaultCodec; + +/** + * Tests for Deflated TriG input + * + * + * + */ +public class DeflatedTriGInputTest extends AbstractCompressedTriGInputFormatTests { + + /** + * Creates new tests + */ + public DeflatedTriGInputTest() { + super(".trig.deflate", new DefaultCodec()); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/GZippedTriGInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/GZippedTriGInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/GZippedTriGInputTest.java new file mode 100644 index 0000000..c3e4106 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trig/GZippedTriGInputTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.compressed.trig; + +import org.apache.hadoop.io.compress.GzipCodec; + +/** + * Tests for GZipped TriG input + * + * + * + */ +public class GZippedTriGInputTest extends AbstractCompressedTriGInputFormatTests { + + /** + * Creates new tests + */ + public GZippedTriGInputTest() { + super(".trig.gz", new GzipCodec()); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/AbstractCompressedTriXInputFormatTests.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/AbstractCompressedTriXInputFormatTests.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/AbstractCompressedTriXInputFormatTests.java new file mode 100644 index 0000000..ad98e35 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/AbstractCompressedTriXInputFormatTests.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.compressed.trix; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.io.compress.CompressionCodec; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.compressed.AbstractCompressedWholeFileQuadInputFormatTests; +import org.apache.jena.hadoop.rdf.io.input.trix.TriXInputFormat; +import org.apache.jena.hadoop.rdf.types.QuadWritable; +import org.apache.jena.riot.Lang; + + +/** + * Abstract compressed TriX input tests + */ +public abstract class AbstractCompressedTriXInputFormatTests extends + AbstractCompressedWholeFileQuadInputFormatTests { + + private String ext; + private CompressionCodec codec; + + /** + * Creates new tests + * + * @param ext + * File extension + * @param codec + * Compression codec + */ + public AbstractCompressedTriXInputFormatTests(String ext, CompressionCodec codec) { + this.ext = ext; + this.codec = codec; + } + + @Override + protected final String getFileExtension() { + return this.ext; + } + + @Override + protected final CompressionCodec getCompressionCodec() { + return this.codec; + } + + @Override + protected final Lang getRdfLanguage() { + return Lang.TRIX; + } + + @Override + protected final InputFormat<LongWritable, QuadWritable> getInputFormat() { + return new TriXInputFormat(); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/BZippedTriXInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/BZippedTriXInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/BZippedTriXInputTest.java new file mode 100644 index 0000000..fc51ec8 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/BZippedTriXInputTest.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.compressed.trix; + +import org.apache.hadoop.io.compress.BZip2Codec; +import org.apache.jena.hadoop.rdf.io.input.compressed.trig.AbstractCompressedTriGInputFormatTests; + +/** + * Tests for BZipped TriX input + */ +public class BZippedTriXInputTest extends AbstractCompressedTriGInputFormatTests { + + /** + * Creates new tests + */ + public BZippedTriXInputTest() { + super(".trix.bz2", new BZip2Codec()); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/DeflatedTriXInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/DeflatedTriXInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/DeflatedTriXInputTest.java new file mode 100644 index 0000000..a1a078d --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/DeflatedTriXInputTest.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.compressed.trix; + +import org.apache.hadoop.io.compress.DefaultCodec; +import org.apache.jena.hadoop.rdf.io.input.compressed.trig.AbstractCompressedTriGInputFormatTests; + +/** + * Tests for Deflated TriX input + */ +public class DeflatedTriXInputTest extends AbstractCompressedTriGInputFormatTests { + + /** + * Creates new tests + */ + public DeflatedTriXInputTest() { + super(".trix.deflate", new DefaultCodec()); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/GZippedTriXInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/GZippedTriXInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/GZippedTriXInputTest.java new file mode 100644 index 0000000..10c6980 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/trix/GZippedTriXInputTest.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.compressed.trix; + +import org.apache.hadoop.io.compress.GzipCodec; +import org.apache.jena.hadoop.rdf.io.input.compressed.trig.AbstractCompressedTriGInputFormatTests; + +/** + * Tests for GZipped TriX input + */ +public class GZippedTriXInputTest extends AbstractCompressedTriGInputFormatTests { + + /** + * Creates new tests + */ + public GZippedTriXInputTest() { + super(".trix.gz", new GzipCodec()); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/AbstractCompressedTurtleInputFormatTests.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/AbstractCompressedTurtleInputFormatTests.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/AbstractCompressedTurtleInputFormatTests.java new file mode 100644 index 0000000..68d776a --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/AbstractCompressedTurtleInputFormatTests.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.compressed.turtle; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.io.compress.CompressionCodec; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.compressed.AbstractCompressedWholeFileTripleInputFormatTests; +import org.apache.jena.hadoop.rdf.io.input.turtle.TurtleInputFormat; +import org.apache.jena.hadoop.rdf.types.TripleWritable; +import org.apache.jena.riot.Lang; + + +/** + * Abstract compressed Turtle input tests + * + * + * + */ +public abstract class AbstractCompressedTurtleInputFormatTests extends + AbstractCompressedWholeFileTripleInputFormatTests { + + private String ext; + private CompressionCodec codec; + + /** + * Creates new tests + * + * @param ext + * File extension + * @param codec + * Compression codec + */ + public AbstractCompressedTurtleInputFormatTests(String ext, CompressionCodec codec) { + this.ext = ext; + this.codec = codec; + } + + @Override + protected final String getFileExtension() { + return this.ext; + } + + @Override + protected final CompressionCodec getCompressionCodec() { + return this.codec; + } + + @Override + protected final Lang getRdfLanguage() { + return Lang.TURTLE; + } + + @Override + protected final InputFormat<LongWritable, TripleWritable> getInputFormat() { + return new TurtleInputFormat(); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/BZippedTurtleInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/BZippedTurtleInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/BZippedTurtleInputTest.java new file mode 100644 index 0000000..724b847 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/BZippedTurtleInputTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.compressed.turtle; + +import org.apache.hadoop.io.compress.BZip2Codec; + +/** + * Tests for BZipped NTriples input + * + * + * + */ +public class BZippedTurtleInputTest extends AbstractCompressedTurtleInputFormatTests { + + /** + * Creates new tests + */ + public BZippedTurtleInputTest() { + super(".nt.bz2", new BZip2Codec()); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/DeflatedTurtleInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/DeflatedTurtleInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/DeflatedTurtleInputTest.java new file mode 100644 index 0000000..eb5ee03 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/DeflatedTurtleInputTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.compressed.turtle; + +import org.apache.hadoop.io.compress.DefaultCodec; + +/** + * Tests for Deflated NTriples input + * + * + * + */ +public class DeflatedTurtleInputTest extends AbstractCompressedTurtleInputFormatTests { + + /** + * Creates new tests + */ + public DeflatedTurtleInputTest() { + super(".nt.deflate", new DefaultCodec()); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/GZippedTurtleInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/GZippedTurtleInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/GZippedTurtleInputTest.java new file mode 100644 index 0000000..817805c --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/compressed/turtle/GZippedTurtleInputTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.compressed.turtle; + +import org.apache.hadoop.io.compress.GzipCodec; + +/** + * Tests for GZipped NTriples input + * + * + * + */ +public class GZippedTurtleInputTest extends AbstractCompressedTurtleInputFormatTests { + + /** + * Creates new tests + */ + public GZippedTurtleInputTest() { + super(".nt.gz", new GzipCodec()); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/jsonld/JsonLDQuadInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/jsonld/JsonLDQuadInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/jsonld/JsonLDQuadInputTest.java new file mode 100644 index 0000000..92aac53 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/jsonld/JsonLDQuadInputTest.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.jsonld; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractWholeFileQuadInputFormatTests; +import org.apache.jena.hadoop.rdf.types.QuadWritable; +import org.apache.jena.riot.Lang; + + +/** + * Tests for JSON-LD input + * + * + */ +public class JsonLDQuadInputTest extends AbstractWholeFileQuadInputFormatTests { + + @Override + protected Lang getRdfLanguage() { + return Lang.JSONLD; + } + + @Override + protected String getFileExtension() { + return ".jsonld"; + } + + @Override + protected InputFormat<LongWritable, QuadWritable> getInputFormat() { + return new JsonLDQuadInputFormat(); + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/jsonld/JsonLDTripleInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/jsonld/JsonLDTripleInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/jsonld/JsonLDTripleInputTest.java new file mode 100644 index 0000000..63b6738 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/jsonld/JsonLDTripleInputTest.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.jsonld; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractWholeFileTripleInputFormatTests; +import org.apache.jena.hadoop.rdf.types.TripleWritable; +import org.apache.jena.riot.Lang; + + +/** + * Tests for JSON-LD input + * + * + */ +public class JsonLDTripleInputTest extends AbstractWholeFileTripleInputFormatTests { + + @Override + protected Lang getRdfLanguage() { + return Lang.JSONLD; + } + + @Override + protected String getFileExtension() { + return ".jsonld"; + } + + @Override + protected InputFormat<LongWritable, TripleWritable> getInputFormat() { + return new JsonLDTripleInputFormat(); + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/BlockedNQuadsInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/BlockedNQuadsInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/BlockedNQuadsInputTest.java new file mode 100644 index 0000000..6d1d02a --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/BlockedNQuadsInputTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.nquads; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractBlockedQuadInputFormatTests; +import org.apache.jena.hadoop.rdf.types.QuadWritable; +import org.apache.jena.riot.Lang; + + +/** + * Tests for blocked NTriples input + * + * + * + */ +public class BlockedNQuadsInputTest extends AbstractBlockedQuadInputFormatTests { + + @Override + protected Lang getRdfLanguage() { + return Lang.NQUADS; + } + + @Override + protected String getFileExtension() { + return ".nq"; + } + + @Override + protected InputFormat<LongWritable, QuadWritable> getInputFormat() { + return new BlockedNQuadsInputFormat(); + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/NQuadsInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/NQuadsInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/NQuadsInputTest.java new file mode 100644 index 0000000..3823728 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/NQuadsInputTest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.nquads; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractQuadsInputFormatTests; +import org.apache.jena.hadoop.rdf.types.QuadWritable; + + +/** + * Tests for the NQuads input format + * + * + */ +public class NQuadsInputTest extends AbstractQuadsInputFormatTests { + + @Override + protected InputFormat<LongWritable, QuadWritable> getInputFormat() { + return new NQuadsInputFormat(); + } + + @Override + protected String getFileExtension() { + return ".nq"; + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/WholeFileNQuadsInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/WholeFileNQuadsInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/WholeFileNQuadsInputTest.java new file mode 100644 index 0000000..50b8bcf --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/nquads/WholeFileNQuadsInputTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.nquads; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractWholeFileQuadInputFormatTests; +import org.apache.jena.hadoop.rdf.types.QuadWritable; +import org.apache.jena.riot.Lang; + + +/** + * Tests for NQuads input + * + * + * + */ +public class WholeFileNQuadsInputTest extends AbstractWholeFileQuadInputFormatTests { + + @Override + protected Lang getRdfLanguage() { + return Lang.NQUADS; + } + + @Override + protected String getFileExtension() { + return ".nq"; + } + + @Override + protected InputFormat<LongWritable, QuadWritable> getInputFormat() { + return new WholeFileNQuadsInputFormat(); + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/BlockedNTriplesInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/BlockedNTriplesInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/BlockedNTriplesInputTest.java new file mode 100644 index 0000000..ab92873 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/BlockedNTriplesInputTest.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.ntriples; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractBlockedTripleInputFormatTests; +import org.apache.jena.hadoop.rdf.types.TripleWritable; +import org.apache.jena.riot.Lang; + + +/** + * Tests for blocked NTriples input + * + * + */ +public class BlockedNTriplesInputTest extends AbstractBlockedTripleInputFormatTests { + + @Override + protected Lang getRdfLanguage() { + return Lang.NTRIPLES; + } + + @Override + protected String getFileExtension() { + return ".nt"; + } + + @Override + protected InputFormat<LongWritable, TripleWritable> getInputFormat() { + return new BlockedNTriplesInputFormat(); + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/NTriplesInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/NTriplesInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/NTriplesInputTest.java new file mode 100644 index 0000000..24fb731 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/NTriplesInputTest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.ntriples; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractTriplesInputFormatTests; +import org.apache.jena.hadoop.rdf.types.TripleWritable; + + +/** + * Tests for the {@link NTriplesInputFormat} + * + * + * + */ +public class NTriplesInputTest extends AbstractTriplesInputFormatTests { + + @Override + protected InputFormat<LongWritable, TripleWritable> getInputFormat() { + return new NTriplesInputFormat(); + } + + @Override + protected String getFileExtension() { + return ".nt"; + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/WholeFileNTriplesInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/WholeFileNTriplesInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/WholeFileNTriplesInputTest.java new file mode 100644 index 0000000..fcec570 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/ntriples/WholeFileNTriplesInputTest.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.ntriples; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractWholeFileTripleInputFormatTests; +import org.apache.jena.hadoop.rdf.types.TripleWritable; +import org.apache.jena.riot.Lang; + + +/** + * Tests for the {@link NTriplesInputFormat} + * + * + * + */ +public class WholeFileNTriplesInputTest extends AbstractWholeFileTripleInputFormatTests { + + @Override + protected InputFormat<LongWritable, TripleWritable> getInputFormat() { + return new WholeFileNTriplesInputFormat(); + } + + @Override + protected String getFileExtension() { + return ".nt"; + } + + @Override + protected Lang getRdfLanguage() { + return Lang.NTRIPLES; + } + + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/rdfjson/RdfJsonInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/rdfjson/RdfJsonInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/rdfjson/RdfJsonInputTest.java new file mode 100644 index 0000000..4731832 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/rdfjson/RdfJsonInputTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.rdfjson; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractWholeFileTripleInputFormatTests; +import org.apache.jena.hadoop.rdf.types.TripleWritable; +import org.apache.jena.riot.Lang; + + +/** + * Tests for RDF/JSON input + * + * + * + */ +public class RdfJsonInputTest extends AbstractWholeFileTripleInputFormatTests { + + @Override + protected Lang getRdfLanguage() { + return Lang.RDFJSON; + } + + @Override + protected String getFileExtension() { + return ".rj"; + } + + @Override + protected InputFormat<LongWritable, TripleWritable> getInputFormat() { + return new RdfJsonInputFormat(); + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/rdfxml/RdfXmlInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/rdfxml/RdfXmlInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/rdfxml/RdfXmlInputTest.java new file mode 100644 index 0000000..f8edcc4 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/rdfxml/RdfXmlInputTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.rdfxml; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractWholeFileTripleInputFormatTests; +import org.apache.jena.hadoop.rdf.types.TripleWritable; +import org.apache.jena.riot.Lang; + + +/** + * Tests for RDF/XML input + * + * + * + */ +public class RdfXmlInputTest extends AbstractWholeFileTripleInputFormatTests { + + @Override + protected Lang getRdfLanguage() { + return Lang.RDFXML; + } + + @Override + protected String getFileExtension() { + return ".rdf"; + } + + @Override + protected InputFormat<LongWritable, TripleWritable> getInputFormat() { + return new RdfXmlInputFormat(); + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/thrift/ThriftQuadInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/thrift/ThriftQuadInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/thrift/ThriftQuadInputTest.java new file mode 100644 index 0000000..8d79295 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/thrift/ThriftQuadInputTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.thrift; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractWholeFileQuadInputFormatTests; +import org.apache.jena.hadoop.rdf.types.QuadWritable; +import org.apache.jena.riot.Lang; +import org.apache.jena.riot.RDFLanguages; + + +/** + * Tests for JSON-LD input + * + * + */ +public class ThriftQuadInputTest extends AbstractWholeFileQuadInputFormatTests { + + @Override + protected Lang getRdfLanguage() { + return RDFLanguages.THRIFT; + } + + @Override + protected String getFileExtension() { + return ".trdf"; + } + + @Override + protected InputFormat<LongWritable, QuadWritable> getInputFormat() { + return new ThriftQuadInputFormat(); + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/thrift/ThriftTripleInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/thrift/ThriftTripleInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/thrift/ThriftTripleInputTest.java new file mode 100644 index 0000000..6b5e0b7 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/thrift/ThriftTripleInputTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.thrift; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractWholeFileTripleInputFormatTests; +import org.apache.jena.hadoop.rdf.types.TripleWritable; +import org.apache.jena.riot.Lang; +import org.apache.jena.riot.RDFLanguages; + + +/** + * Tests for JSON-LD input + * + * + */ +public class ThriftTripleInputTest extends AbstractWholeFileTripleInputFormatTests { + + @Override + protected Lang getRdfLanguage() { + return RDFLanguages.THRIFT; + } + + @Override + protected String getFileExtension() { + return ".trdf"; + } + + @Override + protected InputFormat<LongWritable, TripleWritable> getInputFormat() { + return new ThriftTripleInputFormat(); + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/trig/TriGInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/trig/TriGInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/trig/TriGInputTest.java new file mode 100644 index 0000000..1fad0dc --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/trig/TriGInputTest.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.trig; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractWholeFileQuadInputFormatTests; +import org.apache.jena.hadoop.rdf.types.QuadWritable; +import org.apache.jena.riot.Lang; + + +/** + * Tests for TriG input + * + * + */ +public class TriGInputTest extends AbstractWholeFileQuadInputFormatTests { + + @Override + protected Lang getRdfLanguage() { + return Lang.TRIG; + } + + @Override + protected String getFileExtension() { + return ".trig"; + } + + @Override + protected InputFormat<LongWritable, QuadWritable> getInputFormat() { + return new TriGInputFormat(); + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/trix/TriXInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/trix/TriXInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/trix/TriXInputTest.java new file mode 100644 index 0000000..4a3a66a --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/trix/TriXInputTest.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.trix; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractWholeFileQuadInputFormatTests; +import org.apache.jena.hadoop.rdf.types.QuadWritable; +import org.apache.jena.riot.Lang; + + +/** + * Tests for TriX input + * + * + */ +public class TriXInputTest extends AbstractWholeFileQuadInputFormatTests { + + @Override + protected Lang getRdfLanguage() { + return Lang.TRIX; + } + + @Override + protected String getFileExtension() { + return ".trix"; + } + + @Override + protected InputFormat<LongWritable, QuadWritable> getInputFormat() { + return new TriXInputFormat(); + } + +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/turtle/TurtleInputTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/turtle/TurtleInputTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/turtle/TurtleInputTest.java new file mode 100644 index 0000000..e6211ba --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/turtle/TurtleInputTest.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.turtle; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.mapreduce.InputFormat; +import org.apache.jena.hadoop.rdf.io.input.AbstractWholeFileTripleInputFormatTests; +import org.apache.jena.hadoop.rdf.types.TripleWritable; +import org.apache.jena.riot.Lang; + + +/** + * Tests for turtle input format + * + * + * + */ +public class TurtleInputTest extends AbstractWholeFileTripleInputFormatTests { + + @Override + protected final String getFileExtension() { + return ".ttl"; + } + + @Override + protected final Lang getRdfLanguage() { + return Lang.TURTLE; + } + + @Override + protected InputFormat<LongWritable, TripleWritable> getInputFormat() { + return new TurtleInputFormat(); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/util/AbstractTrackableInputStreamTests.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/util/AbstractTrackableInputStreamTests.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/util/AbstractTrackableInputStreamTests.java new file mode 100644 index 0000000..9532d56 --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/util/AbstractTrackableInputStreamTests.java @@ -0,0 +1,701 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.util; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.jena.hadoop.rdf.io.input.util.TrackableInputStream; +import org.junit.Assert; +import org.junit.Test; + +/** + * Abstract tests for {@link TrackableInputStream} implementations + * + * + * + */ +public abstract class AbstractTrackableInputStreamTests { + + protected static final int KILO = 1024; + protected static final int BYTES_PER_KB = KILO; + protected static final int BYTES_PER_MB = BYTES_PER_KB * KILO; + + /** + * Gets the instance to test using the given input as the stream to track + * + * @param input + * Input Stream + * @return Trackable Input Stream + */ + protected abstract TrackableInputStream getInstance(InputStream input); + + /** + * Generates an input stream containing the given number of bytes + * + * @param length + * Number of bytes + * @return Input stream + */ + protected final InputStream generateData(int length) { + ByteArrayOutputStream output = new ByteArrayOutputStream(length); + byte b = (byte) 'b'; + for (int i = 0; i < length; i++) { + output.write(b); + } + return new ByteArrayInputStream(output.toByteArray()); + } + + protected final void testSingleByteRead(int length) throws IOException { + InputStream input = this.generateData(length); + TrackableInputStream trackable = this.getInstance(input); + long count = 0; + while (trackable.read() >= 0) { + count++; + } + Assert.assertEquals(length, count); + Assert.assertEquals(length, trackable.getBytesRead()); + trackable.close(); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void trackable_input_read_single_01() throws IOException { + this.testSingleByteRead(0); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void trackable_input_read_single_02() throws IOException { + this.testSingleByteRead(100); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void trackable_input_read_single_03() throws IOException { + // 1KB + this.testSingleByteRead(BYTES_PER_KB); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void trackable_input_read_single_04() throws IOException { + // 1 MB + this.testSingleByteRead(BYTES_PER_MB); + } + + protected final void testMultiByteRead(int length, int bufferSize) throws IOException { + if (bufferSize < 1) + throw new IllegalArgumentException("bufferSize must be >= 1"); + InputStream input = this.generateData(length); + TrackableInputStream trackable = this.getInstance(input); + long count = 0; + byte[] buffer = new byte[bufferSize]; + long read; + do { + read = trackable.read(buffer); + if (read > 0) + count += read; + } while (read >= 0); + Assert.assertEquals(length, count); + Assert.assertEquals(length, trackable.getBytesRead()); + trackable.close(); + } + + /** + * Test reading multiple bytes i.e. calling {@link InputStream#read(byte[])} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_01() throws IOException { + this.testMultiByteRead(0, 1); + } + + /** + * Test reading multiple bytes i.e. calling {@link InputStream#read(byte[])} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_02() throws IOException { + this.testMultiByteRead(0, 16); + } + + /** + * Test reading multiple bytes i.e. calling {@link InputStream#read(byte[])} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_03() throws IOException { + this.testMultiByteRead(0, BYTES_PER_KB); + } + + /** + * Test reading multiple bytes i.e. calling {@link InputStream#read(byte[])} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_04() throws IOException { + // 1KB + this.testMultiByteRead(BYTES_PER_KB, 1); + } + + /** + * Test reading multiple bytes i.e. calling {@link InputStream#read(byte[])} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_05() throws IOException { + // 1KB + this.testMultiByteRead(BYTES_PER_KB, 16); + } + + /** + * Test reading multiple bytes i.e. calling {@link InputStream#read(byte[])} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_06() throws IOException { + // 1KB + this.testMultiByteRead(BYTES_PER_KB, BYTES_PER_KB); + } + + /** + * Test reading multiple bytes i.e. calling {@link InputStream#read(byte[])} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_07() throws IOException { + // 1MB + this.testMultiByteRead(BYTES_PER_MB, 1); + } + + /** + * Test reading multiple bytes i.e. calling {@link InputStream#read(byte[])} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_08() throws IOException { + // 1MB + this.testMultiByteRead(BYTES_PER_MB, 16); + } + + /** + * Test reading multiple bytes i.e. calling {@link InputStream#read(byte[])} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_09() throws IOException { + // 1MB + this.testMultiByteRead(BYTES_PER_MB, BYTES_PER_KB); + } + + protected final void testMultiByteRead(int length, int bufferSize, int readSize) throws IOException { + if (bufferSize < 1) + throw new IllegalArgumentException("bufferSize must be >= 1"); + if (readSize < 1 || readSize > bufferSize) + throw new IllegalArgumentException("readSize must be >= 1 and <= bufferSize"); + InputStream input = this.generateData(length); + TrackableInputStream trackable = this.getInstance(input); + long count = 0; + byte[] buffer = new byte[bufferSize]; + long read; + do { + read = trackable.read(buffer, 0, readSize); + if (read > 0) + count += read; + } while (read >= 0); + Assert.assertEquals(length, count); + Assert.assertEquals(length, trackable.getBytesRead()); + trackable.close(); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_01() throws IOException { + this.testMultiByteRead(0, 1, 1); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_02() throws IOException { + this.testMultiByteRead(0, 16, 1); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_03() throws IOException { + this.testMultiByteRead(0, 16, 16); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_04() throws IOException { + this.testMultiByteRead(0, BYTES_PER_KB, 1); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_05() throws IOException { + this.testMultiByteRead(0, BYTES_PER_KB, 16); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_06() throws IOException { + this.testMultiByteRead(0, BYTES_PER_KB, BYTES_PER_KB); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_07() throws IOException { + // 1KB + this.testMultiByteRead(BYTES_PER_KB, 1, 1); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_08() throws IOException { + // 1KB + this.testMultiByteRead(BYTES_PER_KB, 16, 1); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_09() throws IOException { + // 1KB + this.testMultiByteRead(BYTES_PER_KB, 16, 16); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_10() throws IOException { + // 1KB + this.testMultiByteRead(BYTES_PER_KB, BYTES_PER_KB, 1); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_11() throws IOException { + // 1KB + this.testMultiByteRead(BYTES_PER_KB, BYTES_PER_KB, 16); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_12() throws IOException { + // 1KB + this.testMultiByteRead(BYTES_PER_KB, BYTES_PER_KB, BYTES_PER_KB); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_13() throws IOException { + // 1MB + this.testMultiByteRead(BYTES_PER_MB, 1, 1); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_14() throws IOException { + // 1MB + this.testMultiByteRead(BYTES_PER_MB, 16, 1); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_15() throws IOException { + // 1MB + this.testMultiByteRead(BYTES_PER_MB, 16, 16); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_16() throws IOException { + // 1MB + this.testMultiByteRead(BYTES_PER_MB, BYTES_PER_KB, 1); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_17() throws IOException { + // 1MB + this.testMultiByteRead(BYTES_PER_MB, BYTES_PER_KB, 16); + } + + /** + * Test reading multiple bytes while reading less than the buffer size bytes + * i.e. calling {@link InputStream#read(byte[], int, int)} + * + * @throws IOException + */ + @Test + public final void trackable_input_read_multiple_partial_18() throws IOException { + // 1MB + this.testMultiByteRead(BYTES_PER_MB, BYTES_PER_KB, BYTES_PER_KB); + } + + protected final void testSkip(int length, long skipSize) throws IOException { + if (skipSize < 1) + throw new IllegalArgumentException("skipSize must be >= 1"); + InputStream input = this.generateData(length); + TrackableInputStream trackable = this.getInstance(input); + long count = 0; + long skipped; + do { + skipped = trackable.skip(skipSize); + if (skipped > 0) + count += skipped; + } while (skipped > 0); + Assert.assertEquals(length, count); + Assert.assertEquals(length, trackable.getBytesRead()); + trackable.close(); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_01() throws IOException { + this.testSkip(0, 1); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_02() throws IOException { + this.testSkip(100, 1); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_03() throws IOException { + this.testSkip(100, 16); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_04() throws IOException { + this.testSkip(100, BYTES_PER_KB); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_05() throws IOException { + // 1KB + this.testSkip(BYTES_PER_KB, 1); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_06() throws IOException { + // 1KB + this.testSkip(BYTES_PER_KB, 16); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_07() throws IOException { + // 1KB + this.testSkip(BYTES_PER_KB, BYTES_PER_KB); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_08() throws IOException { + // 1KB + this.testSkip(BYTES_PER_KB, BYTES_PER_MB); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_09() throws IOException { + // 1 MB + this.testSkip(BYTES_PER_MB, 1); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_10() throws IOException { + // 1 MB + this.testSkip(BYTES_PER_MB, 16); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_11() throws IOException { + // 1 MB + this.testSkip(BYTES_PER_MB, BYTES_PER_KB); + } + + /** + * Test skipping + * + * @throws IOException + */ + @Test + public final void trackable_input_skip_single_12() throws IOException { + // 1 MB + this.testSkip(BYTES_PER_MB, BYTES_PER_MB); + } + + /** + * Tests behaviour after closing + * + * @throws IOException + */ + @Test + public final void trackable_input_post_close_01() throws IOException { + InputStream input = this.generateData(0); + TrackableInputStream trackable = this.getInstance(input); + trackable.close(); + Assert.assertEquals(-1, trackable.read()); + } + + /** + * Tests behaviour after closing + * + * @throws IOException + */ + @Test + public final void trackable_input_post_close_02() throws IOException { + InputStream input = this.generateData(0); + TrackableInputStream trackable = this.getInstance(input); + trackable.close(); + Assert.assertEquals(0, trackable.read(new byte[0])); + } + + /** + * Tests behaviour after closing + * + * @throws IOException + */ + @Test + public final void trackable_input_post_close_03() throws IOException { + InputStream input = this.generateData(0); + TrackableInputStream trackable = this.getInstance(input); + trackable.close(); + Assert.assertEquals(-1, trackable.read(new byte[1])); + } + + /** + * Tests behaviour after closing + * + * @throws IOException + */ + @Test + public final void trackable_input_post_close_04() throws IOException { + InputStream input = this.generateData(0); + TrackableInputStream trackable = this.getInstance(input); + trackable.close(); + Assert.assertEquals(0, trackable.read(new byte[16], 0, 0)); + } + + /** + * Tests behaviour after closing + * + * @throws IOException + */ + @Test + public final void trackable_input_post_close_05() throws IOException { + InputStream input = this.generateData(0); + TrackableInputStream trackable = this.getInstance(input); + trackable.close(); + Assert.assertEquals(-1, trackable.read(new byte[16], 0, 8)); + } + + /** + * Tests behaviour after closing + * + * @throws IOException + */ + @Test + public final void trackable_input_post_close_06() throws IOException { + InputStream input = this.generateData(0); + TrackableInputStream trackable = this.getInstance(input); + trackable.close(); + Assert.assertEquals(0, trackable.skip(0)); + } + + /** + * Tests exceptions are thrown trying to perform actions after closing the + * input + * + * @throws IOException + */ + @Test + public final void trackable_input_post_close_07() throws IOException { + InputStream input = this.generateData(0); + TrackableInputStream trackable = this.getInstance(input); + trackable.close(); + Assert.assertEquals(0, trackable.skip(1)); + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/a6c0fefc/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/util/BlockInputStreamTest.java ---------------------------------------------------------------------- diff --git a/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/util/BlockInputStreamTest.java b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/util/BlockInputStreamTest.java new file mode 100644 index 0000000..f8819bc --- /dev/null +++ b/jena-hadoop-rdf/jena-elephas-io/src/test/java/org/apache/jena/hadoop/rdf/io/input/util/BlockInputStreamTest.java @@ -0,0 +1,240 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.hadoop.rdf.io.input.util; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.jena.hadoop.rdf.io.input.util.BlockInputStream; +import org.apache.jena.hadoop.rdf.io.input.util.TrackableInputStream; +import org.junit.Assert; +import org.junit.Test; + +/** + * Tests for the {@link BlockInputStream} + * + * + * + */ +public class BlockInputStreamTest extends AbstractTrackableInputStreamTests { + + @Override + protected TrackableInputStream getInstance(InputStream input) { + return new BlockInputStream(input, Long.MAX_VALUE); + } + + /** + * Gets an instance of a block input stream + * + * @param input + * Underlying input stream + * @param limit + * Limit on bytes to read + * @return Block input stream + */ + protected BlockInputStream getInstance(InputStream input, long limit) { + return new BlockInputStream(input, limit); + } + + protected final void testSingleByteRead(int length, long limit) throws IOException { + InputStream input = this.generateData(length); + TrackableInputStream trackable = this.getInstance(input, limit); + long count = 0; + while (trackable.read() >= 0) { + count++; + } + int expected = (int) Math.min(length, limit); + Assert.assertEquals(expected, count); + Assert.assertEquals(expected, trackable.getBytesRead()); + trackable.close(); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_01() throws IOException { + this.testSingleByteRead(0, 0); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_02() throws IOException { + this.testSingleByteRead(100, 0); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_03() throws IOException { + this.testSingleByteRead(100, 50); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_04() throws IOException { + this.testSingleByteRead(100, 100); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_05() throws IOException { + // 1KB + this.testSingleByteRead(BYTES_PER_KB, 1); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_06() throws IOException { + // 1KB + this.testSingleByteRead(BYTES_PER_KB, 100); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_07() throws IOException { + // 1KB + this.testSingleByteRead(BYTES_PER_KB, BYTES_PER_KB / 2); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_08() throws IOException { + // 1KB + this.testSingleByteRead(BYTES_PER_KB, BYTES_PER_KB); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_09() throws IOException { + // 1KB + this.testSingleByteRead(BYTES_PER_KB, BYTES_PER_MB); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_10() throws IOException { + // 1KB + this.testSingleByteRead(BYTES_PER_KB, BYTES_PER_MB * 10); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_11() throws IOException { + // 1MB + this.testSingleByteRead(BYTES_PER_MB, 1); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_12() throws IOException { + // 1MB + this.testSingleByteRead(BYTES_PER_MB, 100); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_13() throws IOException { + // 1MB + this.testSingleByteRead(BYTES_PER_MB, BYTES_PER_KB); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_14() throws IOException { + // 1MB + this.testSingleByteRead(BYTES_PER_MB, BYTES_PER_MB / 2); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_15() throws IOException { + // 1MB + this.testSingleByteRead(BYTES_PER_MB, BYTES_PER_MB); + } + + /** + * Test reading byte by byte + * + * @throws IOException + */ + @Test + public final void block_input_read_single_16() throws IOException { + // 1MB + this.testSingleByteRead(BYTES_PER_MB, BYTES_PER_MB * 10); + } + +}
