http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/main/java/org/apache/jena/propertytable/util/IRILib.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/jena/propertytable/util/IRILib.java b/src/main/java/org/apache/jena/propertytable/util/IRILib.java deleted file mode 100644 index b535c88..0000000 --- a/src/main/java/org/apache/jena/propertytable/util/IRILib.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * 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.propertytable.util; - -import java.io.File ; -import java.io.IOException ; - -import org.apache.jena.atlas.AtlasException ; -import org.apache.jena.atlas.lib.Chars ; -import org.apache.jena.atlas.lib.StrUtils ; -import org.apache.jena.riot.SysRIOT ; - -/** - * Operations related to IRIs. - * Add support for '£', based on {@link org.apache.jena.riot.system.IRILib} - * - * This class should be merged into riot IRILib in future. - */ -public class IRILib -{ - // http://www.w3.org/TR/xpath-functions/#func-encode-for-uri - // Encodes delimiters. - - /* RFC 3986 - * - * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" - * gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" - * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" - / "*" / "+" / "," / ";" / "=" - */ - - private static char uri_reserved[] = - { - '!', '*', '"', '\'', '(', ')', ';', ':', '@', '&', - '=', '+', '$', ',', '/', '?', '%', '#', '[', ']'} ; - - // No allowed in URIs - private static char uri_non_chars[] = { '<', '>', '{', '}', '|', '\\', '`', '^', ' ', '\n', '\r', '\t', '£' } ; - - // RFC 2396 - //private static char uri_unwise[] = { '{' , '}', '|', '\\', '^', '[', ']', '`' } ; - - - private static char[] charsComponent = - // reserved, + non-chars + nasties. - { '!', '*', '"', '\'', '(', ')', ';', ':', '@', '&', - '=', '+', '$', ',', '/', '?', '%', '#', '[', ']', - '{', '}', '|', '\\', '`', '^', - ' ', '<', '>', '\n', '\r', '\t', '£' } ; - - private static char[] charsFilename = - // reserved, + non-chars + nasties. - // Leave : (Windows drive charcater) and / (separator) alone - // include SPC and ~ - { '!', '*', '"', '\'', '(', ')', ';', /*':',*/ '@', '&', - '=', '+', '$', ',', /*'/',*/ '?', '%', '#', '[', ']', - '{', '}', '|', '\\', '`', '^', - ' ', '<', '>', '\n', '\r', '\t', - '~'} ; - - private static char[] charsPath = - { - // Reserved except leave the separators alone. - // Leave the path separator alone. - // Leave the drive separator alone. - '!', '*', '"', '\'', '(', ')', ';', /*':',*/ '@', '&', - '=', '+', '$', ',', /*'/',*/ '?', '%', '#', '[', ']', - '{', '}', '|', '\\', '`', '^', - // Other junk - ' ', '<', '>', '\n', '\r', '\t' } ; - - // The initializers must have run. - static final String cwd ; - static final String cwdURL ; - - // Current directory, with trailing "/" - // This matters for resolution. - static { - String x = new File(".").getAbsolutePath() ; - x = x.substring(0, x.length()-1) ; - cwd = x ; - cwdURL = plainFilenameToURL(cwd) ; - } - - // See also IRIResolver - /** Return a string that is an IRI for the filename.*/ - public static String fileToIRI(File f) - { - return filenameToIRI(f.getAbsolutePath()) ; - } - - /** Create a string that is a IRI for the filename. - * The file name may already have file:. - * The file name may be relative. - * Encode using the rules for a path (e.g. ':' and'/' do not get encoded) - */ - public static String filenameToIRI(String fn) - { - if ( fn == null ) return cwdURL ; - - if ( fn.length() == 0 ) return cwdURL ; - - if ( fn.startsWith("file:") ) - return normalizeFilenameURI(fn) ; - return plainFilenameToURL(fn) ; - } - - /** Convert an IRI to a filename */ - public static String IRIToFilename(String iri) - { - if ( ! iri.startsWith("file:") ) - throw new AtlasException("Not a file: URI: "+iri) ; - - String fn ; - if ( iri.startsWith("file:///") ) - fn = iri.substring("file://".length()) ; - else - fn = iri.substring("file:".length()) ; - return decode(fn) ; - } - - /** Convert a plain file name (no file:) to a file: URL */ - private static String plainFilenameToURL(String fn) - { - // No "file:" - // Make Absolute filename. - boolean trailingSlash = fn.endsWith("/") ; - File file = new File(fn) ; - - try { fn = file.getCanonicalPath() ; } - catch (IOException e) { fn = file.getAbsolutePath() ; } - - if ( trailingSlash && ! fn.endsWith("/") ) - fn = fn + "/" ; - - if ( SysRIOT.isWindows ) - { - // C:\ => file:///C:/... - if ( fn.length() >= 2 && fn.charAt(1) == ':' ) - // Windows drive letter - already absolute path. - // Make "URI" absolute path - fn = "/"+fn ; - // Convert \ to / - // Maybe should do this on all platforms? i.e consistency. - fn = fn.replace('\\', '/' ) ; - } - - fn = encodeFileURL(fn) ; - return "file://"+fn ; - } - - - /** Sanitize a "file:" URL. Must start "file:" */ - private static String normalizeFilenameURI(String fn) - { - if ( ! fn.startsWith("file:/") ) - { - // Relative path. - String fn2 = fn.substring("file:".length()) ; - return plainFilenameToURL(fn2) ; - } - - // Starts file:/// - if ( fn.startsWith("file:///") ) - // Assume it's good as return as-is. - return fn ; - - if ( fn.startsWith("file://") ) - { - String fn2 = fn.substring("file:/".length()) ; // Leave one "/" - return plainFilenameToURL(fn2) ; - } - - // Must be file:/ - String fn2 = fn.substring("file:".length()) ; - return plainFilenameToURL(fn2) ; - } - - /** Encode using the rules for a component (e.g. ':' and '/' get encoded) - * Does not encode non-ASCII characters - */ - public static String encodeUriComponent(String string) - { - String encStr = StrUtils.encodeHex(string,'%', charsComponent) ; - return encStr ; - } - - /** Encode using the rules for a file: URL. - * Does not encode non-ASCII characters - */ - public static String encodeFileURL(String string) - { - String encStr = StrUtils.encodeHex(string,'%', charsFilename) ; - return encStr ; - } - - /** Encode using the rules for a path (e.g. ':' and '/' do not get encoded) */ - public static String encodeUriPath(String uri) - { - // Not perfect. - // Encode path. - // %-encode chars. - uri = StrUtils.encodeHex(uri, '%', charsPath) ; - return uri ; - } - - public static String decode(String string) - { - return StrUtils.decodeHex(string, '%') ; - } - - public static String encodeNonASCII(String string) - { - if ( ! containsNonASCII(string) ) - return string ; - - byte[] bytes = StrUtils.asUTF8bytes(string) ; - StringBuilder sw = new StringBuilder() ; - for ( byte b : bytes ) - { - // Signed bytes ... - if ( b > 0 ) - { - sw.append( (char) b ); - continue; - } - - int hi = ( b & 0xF0 ) >> 4; - int lo = b & 0xF; - sw.append( '%' ); - sw.append( Chars.hexDigitsUC[hi] ); - sw.append( Chars.hexDigitsUC[lo] ); - } - return sw.toString() ; - } - - public static boolean containsNonASCII(String string) - { - boolean clean = true ; - for ( int i = 0 ; i < string.length() ; i++ ) - { - char ch = string.charAt(i) ; - if ( ch >= 127 ) - return true; - } - return false ; - } -}
http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/main/java/riotcmd/LocatorOupputFile.java ---------------------------------------------------------------------- diff --git a/src/main/java/riotcmd/LocatorOupputFile.java b/src/main/java/riotcmd/LocatorOupputFile.java deleted file mode 100644 index 14caeeb..0000000 --- a/src/main/java/riotcmd/LocatorOupputFile.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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 riotcmd; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.security.AccessControlException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.hp.hpl.jena.util.FileManager; -import com.hp.hpl.jena.util.FileUtils; -import com.hp.hpl.jena.util.LocatorFile; - -class LocatorOupputFile { - static Logger log = LoggerFactory.getLogger(LocatorOupputFile.class) ; - private String thisDir = null ; - private String thisDirLogStr = "" ; - - public LocatorOupputFile(String dir) - { - if ( dir != null ) - { - if ( dir.endsWith("/") || dir.endsWith(java.io.File.separator) ) - dir = dir.substring(0,dir.length()-1) ; - thisDirLogStr = " ["+dir+"]" ; - } - thisDir = dir ; - } - - LocatorOupputFile() - { - this(null) ; - } - - @Override - public boolean equals( Object other ) - { - return - other instanceof LocatorFile - && equals( thisDir, ((LocatorOupputFile) other).thisDir ); - } - - private boolean equals( String a, String b ) - { - return a == null ? b == null : a.equals( b ); - } - - @Override - public int hashCode() - { - if ( thisDir == null ) - return 157 ; - return thisDir.hashCode(); - } - - private File toFile(String filenameOrURI) - { - String fn = FileUtils.toFilename(filenameOrURI) ; - if ( fn == null ) - return null ; - - if ( thisDir != null && ! fn.startsWith("/") && ! fn.startsWith(FileManager.filePathSeparator) ) - fn = thisDir+java.io.File.separator+fn ; - - return new File(fn) ; - } - - - public boolean exists(String filenameOrURI) - { - File f = toFile(filenameOrURI) ; - - if ( f == null ) - return false ; - - return f.exists() ; - } - - - public OutputStream open(String filenameOrURI) - { - // Worry about %20. - // toFile calls FileUtils.toFilename(filenameOrURI) ; - File f = toFile(filenameOrURI) ; - - try { - if ( f == null ) - { - if ( log.isTraceEnabled()) - log.trace("Not found: "+filenameOrURI+thisDirLogStr) ; - return null ; - } - } catch (AccessControlException e) { - log.warn("Security problem testing for file", e); - return null; - } - - try { - OutputStream out = new FileOutputStream(f) ; - - if ( log.isTraceEnabled() ) - log.trace("Found: "+filenameOrURI+thisDirLogStr) ; - - - // Create base -- Java 1.4-isms - //base = f.toURI().toURL().toExternalForm() ; - //base = base.replaceFirst("^file:/([^/])", "file:///$1") ; - return out ; - } catch (IOException ioEx) - { - // Includes FileNotFoundException - // We already tested whether the file exists or not. - // log.warn("File unreadable (but exists): "+f.getPath()+" Exception: "+ioEx.getMessage()) ; - return null ; - } - } - - public String getDir() { return thisDir ; } - - - public String getName() - { - String tmp = "LocatorFile" ; - if ( thisDir != null ) - tmp = tmp+"("+thisDir+")" ; - return tmp ; - } -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/main/java/riotcmd/ModDest.java ---------------------------------------------------------------------- diff --git a/src/main/java/riotcmd/ModDest.java b/src/main/java/riotcmd/ModDest.java deleted file mode 100644 index e5560f0..0000000 --- a/src/main/java/riotcmd/ModDest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 riotcmd; - -import arq.cmd.CmdException; -import arq.cmdline.ArgDecl; -import arq.cmdline.ArgModuleGeneral; -import arq.cmdline.CmdArgModule; -import arq.cmdline.CmdGeneral; - -class ModDest implements ArgModuleGeneral{ - - private ArgDecl argDest = new ArgDecl(ArgDecl.HasValue, "dest") ; - private String dest = null ; - - @Override - public void processArgs(CmdArgModule cmdLine) { - if ( cmdLine.contains(argDest) ) { - dest = cmdLine.getValue(argDest) ; - } else { - throw new CmdException("No destination output file! Please add '--dest=file' in the program arguements") ; - } - } - - @Override - public void registerWith(CmdGeneral cmdLine) { - cmdLine.getUsage().startCategory("Destination Output") ; - cmdLine.add(argDest, "--dest=file", "The destination output file") ; - } - - public String getDest() { - return dest ; - } - -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/main/java/riotcmd/csv2rdf.java ---------------------------------------------------------------------- diff --git a/src/main/java/riotcmd/csv2rdf.java b/src/main/java/riotcmd/csv2rdf.java deleted file mode 100644 index 882a29a..0000000 --- a/src/main/java/riotcmd/csv2rdf.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * 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 riotcmd; - -import java.io.OutputStream; - -import org.apache.jena.atlas.io.IO; -import org.apache.jena.atlas.web.ContentType; -import org.apache.jena.atlas.web.TypedInputStream; -import org.apache.jena.riot.Lang; -import org.apache.jena.riot.RDFDataMgr; -import org.apache.jena.riot.RDFLanguages; -import org.apache.jena.riot.ReaderRIOT; -import org.apache.jena.riot.RiotException; -import org.apache.jena.riot.SysRIOT; -import org.apache.jena.riot.lang.LabelToNode; -import org.apache.jena.riot.lang.StreamRDFCounting; -import org.apache.jena.riot.out.NodeToLabel; -import org.apache.jena.riot.process.inf.InfFactory; -import org.apache.jena.riot.system.ErrorHandler; -import org.apache.jena.riot.system.ErrorHandlerFactory; -import org.apache.jena.riot.system.RiotLib; -import org.apache.jena.riot.system.StreamRDF; -import org.apache.jena.riot.system.StreamRDF2; -import org.apache.jena.riot.system.StreamRDFLib; -import org.apache.jena.riot.system.SyntaxLabels; - -import arq.cmd.CmdException; - -import com.hp.hpl.jena.sparql.util.Utils; - -/** - * It's a command line tool for direct and scalable transforming from CSV to the formatted RDF syntax (i.e. N-Triples), - * with no intermediary Graph or PropertyTable. - * - * It reuses the parsing functions from CmdLangParse and sinks the triples into the destination output file. - * - */ -public class csv2rdf extends CmdLangParse{ - - protected ModDest modDest = new ModDest() ; - protected OutputStream destOut; - - public static void main(String... argv) - { - new csv2rdf(argv).mainRun() ; - } - - protected csv2rdf(String[] argv) - { - super(argv) ; - super.addModule(modDest) ; - - } - - @Override - protected Lang selectLang(String filename, ContentType contentType, - Lang dftLang) { - return RDFLanguages.CSV; - } - - @Override - protected String getCommandName() { - return Utils.classShortName(csv2rdf.class) ; - } - - @Override - protected String getSummary() - { - return getCommandName()+" --dest=outputFile inputFile ..." ; - } - - // override the original CmdLangParse.parseRIOT() - protected void parseRIOT(String baseURI, String filename, TypedInputStream in) - { - - String dest = modDest.getDest(); - LocatorOupputFile l = new LocatorOupputFile(); - destOut = l.open(dest); - - if (destOut == null){ - System.err.println("Can't write to destination output file: '"+dest+"' ") ; - return ; - } - - // I ti s shame we effectively duplicate deciding thelnaguage but we want to control the - // pasrer at a deep level (in validation, we want line numbers get into error message) - // This code predates RDFDataMgr. - - ContentType ct = in.getMediaType() ; - - baseURI = SysRIOT.chooseBaseIRI(baseURI, filename) ; - - boolean checking = true ; - if ( modLangParse.explicitChecking() ) checking = true ; - if ( modLangParse.explicitNoChecking() ) checking = false ; - - ErrorHandler errHandler = null ; - if ( checking ) - { - if ( modLangParse.stopOnBadTerm() ) - errHandler = ErrorHandlerFactory.errorHandlerStd ; - else - // Try to go on if possible. This is the default behaviour. - errHandler = ErrorHandlerFactory.errorHandlerWarn ; - } - - if ( modLangParse.skipOnBadTerm() ) - { - // TODO skipOnBadterm - } - - Lang lang = selectLang(filename, ct, RDFLanguages.NQUADS) ; - LangHandler handler = dispatch.get(lang) ; - if ( handler == null ) - throw new CmdException("Undefined language: "+lang) ; - - // If multiple files, choose the overall labels. - if ( langHandlerOverall == null ) - langHandlerOverall = handler ; - else - { - if ( langHandlerOverall != langHandlerAny ) - { - if ( langHandlerOverall != handler ) - langHandlerOverall = langHandlerAny ; - } - } - - // Make a flag. - // Input and output subflags. - // If input is "label, then output using NodeToLabel.createBNodeByLabelRaw() ; - // else use NodeToLabel.createBNodeByLabel() ; - // Also, as URI. - final boolean labelsAsGiven = false ; - - NodeToLabel labels = SyntaxLabels.createNodeToLabel() ; - if ( labelsAsGiven ) - labels = NodeToLabel.createBNodeByLabelEncoded() ; - - StreamRDF s = StreamRDFLib.sinkNull() ; - if ( ! modLangParse.toBitBucket() ) - s = StreamRDFLib.writer(output) ; - - // add dest output - if ( destOut != null) - s = new StreamRDF2(s, StreamRDFLib.writer(destOut)); - - if ( setup != null ) - s = InfFactory.inf(s, setup) ; - - StreamRDFCounting sink = StreamRDFLib.count(s) ; - s = null ; - - ReaderRIOT reader = RDFDataMgr.createReader(lang) ; - try { - if ( checking ) { - if ( lang == RDFLanguages.NTRIPLES || lang == RDFLanguages.NQUADS ) - reader.setParserProfile(RiotLib.profile(baseURI, false, true, errHandler)) ; - else - reader.setParserProfile(RiotLib.profile(baseURI, true, true, errHandler)) ; - } else - reader.setParserProfile(RiotLib.profile(baseURI, false, false, errHandler)) ; - - if ( labelsAsGiven ) - reader.getParserProfile().setLabelToNode(LabelToNode.createUseLabelAsGiven()) ; - modTime.startTimer() ; - reader.read(in, baseURI, ct, sink, null) ; - } catch (RiotException ex) { - // Should have handled the exception and logged a message by now. - // System.err.println("++++"+ex.getMessage()); - - if ( modLangParse.stopOnBadTerm() ) - return ; - } finally { - // Not close - we may write again to the underlying output stream in another call to parse a file. - sink.finish() ; - IO.close(in) ; - } - long x = modTime.endTimer() ; - long n = sink.countTriples()+sink.countQuads() ; - - if ( modTime.timingEnabled() ) - output(filename, n, x, handler) ; - - totalMillis += x ; - totalTuples += n ; - } -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/AbstractColumnTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/AbstractColumnTest.java b/src/test/java/org/apache/jena/propertytable/AbstractColumnTest.java deleted file mode 100644 index 90ff0af..0000000 --- a/src/test/java/org/apache/jena/propertytable/AbstractColumnTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.propertytable; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import com.hp.hpl.jena.graph.Node; -import com.hp.hpl.jena.graph.NodeFactory; - -/** - * Tests related to Column. - * - */ -public abstract class AbstractColumnTest extends BaseTest{ - - - @Test(expected = NullPointerException.class) - public void testCreateColumnWithArgNull() { - table.createColumn(null); - } - - @Test(expected = IllegalArgumentException.class) - public void testCreateListColumnWithAlreadyExistingCoulmnName() { - table.createColumn(URI("something")); - table.createColumn(URI("something")); - } - - @Test - public void testColumnCreate() { - table.createColumn(URI("something")); - Assert.assertEquals(1, table.getColumns().size()); - Assert.assertTrue(collectionContains(table.getColumns(), URI("something"))); - } - - @Test - public void testGetColumnValues() { - Column something = table.createColumn(URI("something")); - final Row row1 = table.createRow(NodeFactory.createAnon()); - row1.setValue(something, URI("apple")); - final Row row2 = table.createRow(NodeFactory.createAnon()); - row2.setValue(something, URI("orange")); - final List<Node> values = something.getValues(); - Assert.assertTrue(values.size() == 2); - Assert.assertTrue(values.contains( URI("apple"))); - Assert.assertTrue(values.contains( URI("orange"))); - } - - @Test - public void testGetColumn() { - table.createColumn(URI("something")); - Assert.assertNotNull(table.getColumn(URI("something"))); - Assert.assertNull(table.getColumn( URI("nonExistentColumnName"))); - } - - @Test - public void testGetTable() { - Column something = table.createColumn(URI("something")); - Assert.assertEquals(table, something.getTable()); - } - -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/AbstractPropertyTableTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/AbstractPropertyTableTest.java b/src/test/java/org/apache/jena/propertytable/AbstractPropertyTableTest.java deleted file mode 100644 index 3738d4e..0000000 --- a/src/test/java/org/apache/jena/propertytable/AbstractPropertyTableTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.propertytable; - -import java.util.Collection; - -import org.junit.Assert; -import org.junit.Test; - -import com.hp.hpl.jena.graph.NodeFactory; - -/** - * Tests related to PropertyTable. - * - */ -public abstract class AbstractPropertyTableTest extends AbstractRowTest{ - - @Test - public void testGetMatchingColumns() { - Column something = table.createColumn(URI("something") ); - final Row row1 = table.createRow(NodeFactory.createAnon()); - row1.setValue(something, URI("apple")); - final Row row2 = table.createRow(NodeFactory.createAnon()); - row2.setValue(something, URI("orange")); - Collection<Row> matchingRows = table.getMatchingRows(something, URI("apple")); - Assert.assertTrue(matchingRows.size() == 1); - matchingRows = table.getMatchingRows(something, URI("banana")); - Assert.assertTrue(matchingRows.isEmpty()); - } - - @Test - public void testGetAllRows() { - Assert.assertTrue(table.getAllRows().size() == 1); - table.createRow(NodeFactory.createAnon()); - Assert.assertTrue(table.getAllRows().size() == 2); - table.createRow(NodeFactory.createAnon()); - Assert.assertTrue(table.getAllRows().size() == 3); - } - - -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/AbstractRowTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/AbstractRowTest.java b/src/test/java/org/apache/jena/propertytable/AbstractRowTest.java deleted file mode 100644 index 9457375..0000000 --- a/src/test/java/org/apache/jena/propertytable/AbstractRowTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.propertytable; - -import org.junit.Assert; -import org.junit.Test; - -import com.hp.hpl.jena.graph.Node; -import com.hp.hpl.jena.graph.NodeFactory; - -/** - * Tests related to Row. - * - */ -public abstract class AbstractRowTest extends AbstractColumnTest{ - - @Test - public void testAddRowValue() { - - Column something = table.createColumn(URI("something")); - Column somethingElse = table.createColumn(URI("somethingElse")); - - row.setValue(something, URI("apple")); - row.setValue(somethingElse, URI("orange")); - - Assert.assertEquals(URI("apple"), row.getValue(something)); - Assert.assertEquals(URI("orange"), row.getValue(somethingElse)); - } - - @Test - public void testUnsetRowValue() { - Column something = table.createColumn(URI("something")); - row.setValue( something , URI("apple")); - Assert.assertEquals(URI("apple"), row.getValue(something)); - row.setValue( something , null); - Assert.assertEquals(null, row.getValue(something)); - } - - @Test(expected=NullPointerException.class) - public void testGetRowWithNullKey() { - table.getRow(null); - } - - @Test(expected = NullPointerException.class) - public void testAddValueToNotExistingColumn() { - row.setValue(table.getColumn(URI("something")), URI("apple")); - } - - - - @Test(expected=IllegalArgumentException.class) - public void testGetListWithANonExistantColumn() { - Assert.assertNull(row.getValue( NodeFactory.createAnon() )); - } - - @Test - public void testGetListWithAnMissingRowValue() { - Column something = table.createColumn(URI("something")); - Assert.assertNull(row.getValue(something)); - } - - @Test - public void testGetValue() { - Column something = table.createColumn(URI("something")); - row.setValue(something, URI("apple")); - Node value = row.getValue(something); - Assert.assertEquals(URI("apple"), value); - } - - @Test - public void testRowExistsFalse(){ - Assert.assertNull(table.getRow(NodeFactory.createAnon())); - } - - @Test - public void testRowExistsTrue() { - Assert.assertNotNull(table.getRow(rowSubject)); - } - - @Test - public void testGetRowFalseAndDoesntCreateRow() { - Assert.assertNull(table.getRow(NodeFactory.createAnon())); - Assert.assertNull(table.getRow(NodeFactory.createAnon())); - } - - @Test(expected=IllegalArgumentException.class) - public void testGetValueBeforeColumnExists() { - row.getValue(URI("nonexistentColumnX")); - } -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/BaseTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/BaseTest.java b/src/test/java/org/apache/jena/propertytable/BaseTest.java deleted file mode 100644 index 282f649..0000000 --- a/src/test/java/org/apache/jena/propertytable/BaseTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.propertytable; - -import java.util.Collection; - -import com.hp.hpl.jena.graph.Node; -import com.hp.hpl.jena.graph.NodeFactory; - -public abstract class BaseTest { - protected PropertyTable table; - protected PropertyTable table2; - protected Row row; - private static final String ns = "eh:foo/bar#"; - protected static final Node rowSubject = URI("rowSubject"); - protected static final String csvFilePath = "src/test/resources/test.csv"; - - - protected static Node URI(String localName) { - return NodeFactory.createURI(ns + localName); - } - - protected static boolean collectionContains( - final Collection<Column> columns, final Node columnkey) { - for (final Column column : columns) { - if (column.getColumnKey().equals(columnkey)) - return true; - } - return false; - } -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/TS_PropertyTable.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/TS_PropertyTable.java b/src/test/java/org/apache/jena/propertytable/TS_PropertyTable.java deleted file mode 100644 index 084365d..0000000 --- a/src/test/java/org/apache/jena/propertytable/TS_PropertyTable.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.propertytable; - -import org.apache.jena.propertytable.graph.GraphCSVTest; -import org.apache.jena.propertytable.impl.PropertyTableArrayImplTest; -import org.apache.jena.propertytable.impl.PropertyTableBuilderForArrayImplTest; -import org.apache.jena.propertytable.impl.PropertyTableBuilderForHashMapImplTest; -import org.apache.jena.propertytable.impl.PropertyTableHashMapImplTest; -import org.apache.jena.propertytable.lang.TestLangCSV; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - - -@RunWith(Suite.class) [email protected]( { - PropertyTableArrayImplTest.class, - PropertyTableHashMapImplTest.class, - GraphCSVTest.class, - PropertyTableBuilderForArrayImplTest.class, - PropertyTableBuilderForHashMapImplTest.class, - TestLangCSV.class -}) -public class TS_PropertyTable { - -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/graph/GraphCSVTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/graph/GraphCSVTest.java b/src/test/java/org/apache/jena/propertytable/graph/GraphCSVTest.java deleted file mode 100644 index 3d23f86..0000000 --- a/src/test/java/org/apache/jena/propertytable/graph/GraphCSVTest.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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.propertytable.graph; - -import org.apache.jena.propertytable.graph.GraphCSV; -import org.apache.jena.propertytable.lang.LangCSV; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.hp.hpl.jena.query.ARQ; -import com.hp.hpl.jena.query.Query; -import com.hp.hpl.jena.query.QueryExecution; -import com.hp.hpl.jena.query.QueryExecutionFactory; -import com.hp.hpl.jena.query.QueryFactory; -import com.hp.hpl.jena.query.QuerySolution; -import com.hp.hpl.jena.query.ResultSet; -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.ModelFactory; -import com.hp.hpl.jena.sparql.engine.main.StageBuilder; -import com.hp.hpl.jena.sparql.engine.main.StageGenerator; - -/** - * Tests related to GraphCSV with some real world data. - * - */ -public class GraphCSVTest extends Assert { - - @BeforeClass - public static void init(){ - LangCSV.register(); - } - - @Test - public void testGraphCSV() throws Exception { - //String file = "src/test/resources/HEFCE_organogram_senior_data_31032011.csv";test.csv - String file = "src/test/resources/test.csv"; - - Model csv = ModelFactory.createModelForGraph(new GraphCSV(file)); - assertEquals(12, csv.size()); - - Query query = QueryFactory - .create("PREFIX : <src/test/resources/test.csv#> SELECT ?townName ?pop {?x :Town ?townName ; :Population ?pop ; :Predicate%20With%20Space 'PredicateWithSpace2' . FILTER(?pop > 500000)}"); - - QueryExecution qexec = QueryExecutionFactory.create(query, csv); - ResultSet results = qexec.execSelect(); - - assertTrue(results.hasNext()); - QuerySolution soln = results.nextSolution(); - assertEquals( "Northville", soln.getLiteral("townName").getString()); - assertTrue( 654000 == soln.getLiteral("pop").getInt()); - - assertFalse(results.hasNext()); - } - - @Test - public void stageGeneratorTest() throws Exception{ - wireIntoExecution(); - testGraphCSV(); - } - - private static void wireIntoExecution() { - StageGenerator orig = (StageGenerator)ARQ.getContext().get(ARQ.stageGenerator) ; - StageGenerator stageGenerator = new StageGeneratorPropertyTable(orig) ; - StageBuilder.setGenerator(ARQ.getContext(), stageGenerator) ; - } - - //http://www.w3.org/TR/csvw-ucr/#UC-OrganogramData - //2.4 Use Case #4 - Publication of public sector roles and salaries - @Test - public void testUseCase4(){ - String file = "src/test/resources/HEFCE_organogram_senior_data_31032011.csv"; - - Model csv = ModelFactory.createModelForGraph(new GraphCSV(file)); - assertEquals(72, csv.size()); - - Query query = QueryFactory - .create("PREFIX : <src/test/resources/HEFCE_organogram_senior_data_31032011.csv#> SELECT ?name ?unit {?x :Name ?name ; :Unit ?unit ; :Actual%20Pay%20Floor%20%28%A3%29 ?floor ; :Actual%20Pay%20Ceiling%20%28%A3%29 ?ceiling . FILTER(?floor > 100000 && ?ceiling <120000 )}"); - - QueryExecution qexec = QueryExecutionFactory.create(query, csv); - ResultSet results = qexec.execSelect(); - - assertTrue(results.hasNext()); - QuerySolution soln = results.nextSolution(); - assertEquals( "David Sweeney", soln.getLiteral("name").getString()); - assertEquals( "Research, Innovation and Skills", soln.getLiteral("unit").getString()); - - assertFalse(results.hasNext()); - } - - - //http://www.w3.org/TR/csvw-ucr/#UC-JournalArticleSearch - //2.6 Use Case #6 - Journal Article Solr Search Results - @Test - public void testUseCase6(){ - String file = "src/test/resources/PLOSone-search-results.csv"; - - Model csv = ModelFactory.createModelForGraph(new GraphCSV(file)); - assertEquals(30, csv.size()); - - Query query = QueryFactory - .create("PREFIX : <src/test/resources/PLOSone-search-results.csv#> SELECT ?author {?x :author ?author ; :doi '10.1371/journal.pone.0095156' }"); - - QueryExecution qexec = QueryExecutionFactory.create(query, csv); - ResultSet results = qexec.execSelect(); - - assertTrue(results.hasNext()); - QuerySolution soln = results.nextSolution(); - assertEquals( "Oshrat Raz,Dorit L Lev,Alexander Battler,Eli I Lev", soln.getLiteral("author").getString()); - - assertFalse(results.hasNext()); - } - - //http://www.w3.org/TR/csvw-ucr/#UC-PaloAltoTreeData - //2.11 Use Case #11 - City of Palo Alto Tree Data - @Test - public void testUseCase11(){ - String file = "src/test/resources/Palo_Alto_Trees.csv"; - - Model csv = ModelFactory.createModelForGraph(new GraphCSV(file)); - assertEquals(199, csv.size()); - - Query query = QueryFactory - .create("PREFIX : <src/test/resources/Palo_Alto_Trees.csv#> SELECT ?longitude ?latitude {?x :Longitude ?longitude ; :Latitude ?latitude ; :Distance%20from%20Property ?distance . FILTER(?distance > 50 )}"); - - QueryExecution qexec = QueryExecutionFactory.create(query, csv); - ResultSet results = qexec.execSelect(); - - assertTrue(results.hasNext()); - QuerySolution soln = results.nextSolution(); - assertEquals( -122.1566921, soln.getLiteral("longitude").getDouble(), 0); - assertEquals( 37.4408948, soln.getLiteral("latitude").getDouble(), 0); - - assertFalse(results.hasNext()); - } - -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/impl/AbstractPropertyTableBuilderTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/impl/AbstractPropertyTableBuilderTest.java b/src/test/java/org/apache/jena/propertytable/impl/AbstractPropertyTableBuilderTest.java deleted file mode 100644 index f7a1e02..0000000 --- a/src/test/java/org/apache/jena/propertytable/impl/AbstractPropertyTableBuilderTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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.propertytable.impl; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; - -import org.apache.jena.atlas.csv.CSVTokenIterator; -import org.apache.jena.propertytable.BaseTest; -import org.apache.jena.propertytable.Row; -import org.junit.Assert; -import org.junit.Test; - -import com.hp.hpl.jena.graph.Node; -import com.hp.hpl.jena.graph.NodeFactory; - - -/** - * Tests related to PropertyTableBuilder, or more explicitly for the CSV parser in the current release. - * - */ -public abstract class AbstractPropertyTableBuilderTest extends BaseTest { - - @Test - public void testFillPropertyTable() { - CSVTokenIterator iterator = csv("a,b\nc,d\ne,f"); - PropertyTableBuilder.fillPropertyTable(table, iterator, csvFilePath); - - Assert.assertEquals(3, table.getColumns().size()); - containsColumn(PropertyTableBuilder.CSV_ROW_NODE); - containsColumn("a"); - containsColumn("b"); - - Assert.assertEquals(2, table.getAllRows().size()); - containsValue(0, "a", "c"); - containsValue(0, "b", "d"); - - containsValue(1, "a", "e"); - containsValue(1, "b", "f"); - - } - - @Test - public void testIrregularTable1() { - CSVTokenIterator iterator = csv("a,b\nc\ne,f"); - PropertyTableBuilder.fillPropertyTable(table, iterator, csvFilePath); - - Assert.assertEquals(3, table.getColumns().size()); - containsColumn(PropertyTableBuilder.CSV_ROW_NODE); - containsColumn("a"); - containsColumn("b"); - - Assert.assertEquals(2, table.getAllRows().size()); - containsValue(0, "a", "c"); - nullValue(0, "b"); - - containsValue(1, "a", "e"); - containsValue(1, "b", "f"); - } - - @Test - public void testIrregularTable2() { - CSVTokenIterator iterator = csv("a,b\nc,d1,d2\ne,f"); - PropertyTableBuilder.fillPropertyTable(table, iterator, csvFilePath); - - Assert.assertEquals(3, table.getColumns().size()); - containsColumn(PropertyTableBuilder.CSV_ROW_NODE); - containsColumn("a"); - containsColumn("b"); - - Assert.assertEquals(2, table.getAllRows().size()); - containsValue(0, "a", "c"); - containsValue(0, "b", "d1"); - - containsValue(1, "a", "e"); - containsValue(1, "b", "f"); - } - - @Test - public void testIrregularTable3() { - CSVTokenIterator iterator = csv("a,b\n,d\ne,f"); - PropertyTableBuilder.fillPropertyTable(table, iterator, csvFilePath); - - Assert.assertEquals(3, table.getColumns().size()); - containsColumn(PropertyTableBuilder.CSV_ROW_NODE); - containsColumn("a"); - containsColumn("b"); - - Assert.assertEquals(2, table.getAllRows().size()); - nullValue(0, "a"); - containsValue(0, "b", "d"); - - containsValue(1, "a", "e"); - containsValue(1, "b", "f"); - } - - private void nullValue(int rowIndex, String column) { - Row row = table.getAllRows().get(rowIndex); - Node v = row.getValue(NodeFactory.createURI(getColumnKey(column))); - Assert.assertEquals(null, v); - } - - private void containsValue(int rowIndex, String column, String value) { - Row row = table.getAllRows().get(rowIndex); - Node v = row.getValue(NodeFactory.createURI(getColumnKey(column))); - Assert.assertEquals(value, v.getLiteralValue()); - } - - private String getColumnKey(String column) { - return PropertyTableBuilder.createColumnKeyURI(csvFilePath, column); - } - - private void containsColumn(String column) { - containsColumn(NodeFactory.createURI(getColumnKey(column))); - } - - private void containsColumn(Node columnKey) { - Assert.assertTrue(collectionContains(table.getColumns(), columnKey)); - } - - private CSVTokenIterator csv(String input) { - try { - InputStream in = new ByteArrayInputStream(input.getBytes("UTF-8")); - CSVTokenIterator iterator = new CSVTokenIterator(in); - return iterator; - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/impl/PropertyTableArrayImplTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/impl/PropertyTableArrayImplTest.java b/src/test/java/org/apache/jena/propertytable/impl/PropertyTableArrayImplTest.java deleted file mode 100644 index ba1ca2d..0000000 --- a/src/test/java/org/apache/jena/propertytable/impl/PropertyTableArrayImplTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.propertytable.impl; - -import org.apache.jena.propertytable.AbstractPropertyTableTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * Tests for PropertyTableArrayImpl - * - */ -public class PropertyTableArrayImplTest extends AbstractPropertyTableTest{ - - private static int rowNum = 10; - private static int columnNum = 10 ; - - @Before - public void setUp() { - table = new PropertyTableArrayImpl(rowNum, columnNum); - table2 = new PropertyTableArrayImpl(rowNum, columnNum); - row = table.createRow(rowSubject); - - } - - @After - public void tearDown() { - table = null; - table2 = null; - row = null; - } - - @Test - public void testColumnOutofBounds1() { - for (int i=0;i<columnNum;i++){ - table.createColumn(URI("something_"+i)); - } - Assert.assertEquals(columnNum, table.getColumns().size()); - } - - @Test(expected = IllegalArgumentException.class) - public void testColumnOutofBounds2() { - for (int i=0;i<columnNum+1;i++){ - table.createColumn(URI("something_"+i)); - } - } - - @Test - public void testRowOutofBounds1() { - - // we've already created a new Row in @Before - for (int i=0;i<rowNum-1;i++){ - table.createRow(URI("something_"+i)); - } - Assert.assertEquals(rowNum, table.getAllRows().size()); - } - - @Test(expected = IllegalArgumentException.class) - public void testRowOutofBounds2() { - - // we've already created a new Row in @Before - for (int i=0;i<rowNum;i++){ - table.createRow(URI("something_"+i)); - } - } -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/impl/PropertyTableBuilderForArrayImplTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/impl/PropertyTableBuilderForArrayImplTest.java b/src/test/java/org/apache/jena/propertytable/impl/PropertyTableBuilderForArrayImplTest.java deleted file mode 100644 index 7b7e0c8..0000000 --- a/src/test/java/org/apache/jena/propertytable/impl/PropertyTableBuilderForArrayImplTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.propertytable.impl; - -import org.junit.After; -import org.junit.Before; - -public class PropertyTableBuilderForArrayImplTest extends AbstractPropertyTableBuilderTest{ - - private static int rowNum = 10; - private static int columnNum = 10 ; - - @Before - public void setUp() { - table = new PropertyTableArrayImpl(rowNum, columnNum); - } - - @After - public void tearDown() { - table = null; - } - -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/impl/PropertyTableBuilderForHashMapImplTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/impl/PropertyTableBuilderForHashMapImplTest.java b/src/test/java/org/apache/jena/propertytable/impl/PropertyTableBuilderForHashMapImplTest.java deleted file mode 100644 index f2768f5..0000000 --- a/src/test/java/org/apache/jena/propertytable/impl/PropertyTableBuilderForHashMapImplTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.propertytable.impl; - -import org.junit.After; -import org.junit.Before; - -public class PropertyTableBuilderForHashMapImplTest extends AbstractPropertyTableBuilderTest{ - @Before - public void setUp() { - table = new PropertyTableHashMapImpl(); - } - - @After - public void tearDown() { - table = null; - } -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/impl/PropertyTableHashMapImplTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/impl/PropertyTableHashMapImplTest.java b/src/test/java/org/apache/jena/propertytable/impl/PropertyTableHashMapImplTest.java deleted file mode 100644 index 33d95ae..0000000 --- a/src/test/java/org/apache/jena/propertytable/impl/PropertyTableHashMapImplTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.propertytable.impl; - -import org.apache.jena.propertytable.AbstractPropertyTableTest; -import org.junit.After; -import org.junit.Before; - -/** - * Tests for PropertyTableHashMapImpl - * - */ -public class PropertyTableHashMapImplTest extends AbstractPropertyTableTest{ - - @Before - public void setUp() { - table = new PropertyTableHashMapImpl(); - table2 = new PropertyTableHashMapImpl(); - row = table.createRow(rowSubject); - - } - - @After - public void tearDown() { - table = null; - table2 = null; - row = null; - } - -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/java/org/apache/jena/propertytable/lang/TestLangCSV.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/jena/propertytable/lang/TestLangCSV.java b/src/test/java/org/apache/jena/propertytable/lang/TestLangCSV.java deleted file mode 100644 index 697ba27..0000000 --- a/src/test/java/org/apache/jena/propertytable/lang/TestLangCSV.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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.propertytable.lang; - -import java.io.StringReader; - -import org.apache.jena.atlas.junit.BaseTest; -import org.apache.jena.atlas.lib.StrUtils; -import org.apache.jena.riot.Lang; -import org.apache.jena.riot.RDFDataMgr; -import org.apache.jena.riot.RDFLanguages; -import org.apache.jena.riot.system.IRIResolver; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.ModelFactory; - - -/** - * Tests for the registered LangCSV in RIOT. - * - */ -public class TestLangCSV extends BaseTest { - - private static final String FILE_NAME = "src/test/resources/test.csv"; - private static final String FILE_URI = IRIResolver.resolveString(FILE_NAME); - - @BeforeClass - public static void init(){ - LangCSV.register(); - } - - @Test - public void testPredicateWithSpace() { - String[] s1 = { "Predicate With Space", "PredicateWithSpace" }; - String[] s2 = { - //"<"+ LangCSV.caculateSubject(1, FILE_NAME) + "> <" + FILE_URI + "#Predicate+With+Space> 'PredicateWithSpace' ; ", - " [] <" + FILE_URI + "#Predicate%20With%20Space> 'PredicateWithSpace' ; ", - " <http://w3c/future-csv-vocab/row> 1 ." }; - assertIsomorphicWith(s1, s2); - } - - @Test - public void testNonURICharacters() { - String[] s1 = { "`~!@#$%^&*()-_=+[{]}|\\;:'\"<.>/?", "NonURICharacters" }; - String[] s2 = { - //"<"+ LangCSV.caculateSubject(1, FILE_NAME) + "> <" + FILE_URI + "#%60%7E%21%40%23%24%25%5E%26*%28%29-_%3D%2B%5B%7B%5D%7D%7C%5C%3B%3A%27%22%3C.%3E%2F%3F> 'NonURICharacters' ; ", - " [] <" + FILE_URI + "#%60~%21%40%23%24%25%5E%26%2A%28%29-_%3D%2B%5B%7B%5D%7D%7C%5C%3B%3A%27%22%3C.%3E%2F%3F> 'NonURICharacters' ; ", - " <http://w3c/future-csv-vocab/row> 1 ." }; - assertIsomorphicWith(s1, s2); - } - - @Test - public void testDigitalLocalName() { - String[] s1 = { "1234", "DigitalLocalName" }; - String[] s2 = { - //"<"+ LangCSV.caculateSubject(1, FILE_NAME) + "> <" + FILE_URI + "#1234> 'DigitalLocalName' ; ", - " [] <" + FILE_URI + "#1234> 'DigitalLocalName' ; ", - " <http://w3c/future-csv-vocab/row> 1 ." }; - assertIsomorphicWith(s1, s2); - } - - @Test - public void testMoney() { - String[] s1 = { "£", "£" }; - String[] s2 = { - //"<"+ LangCSV.caculateSubject(1, FILE_NAME) + "> <" + FILE_URI + "#1234> 'DigitalLocalName' ; ", - " [] <" + FILE_URI + "#%A3> '£' ; ", - " <http://w3c/future-csv-vocab/row> 1 ." }; - assertIsomorphicWith(s1, s2); - } - - @Test - public void RDFDataMgrReadTest() { - Model m1 = RDFDataMgr.loadModel(FILE_NAME, RDFLanguages.CSV); - Model m2 = ModelFactory.createDefaultModel(); - m2.read(FILE_NAME, "CSV"); - assertEquals(12, m1.size()); - assertTrue(m1.isIsomorphicWith(m2)); - } - - private Model parseToModel(String[] strings, Lang lang) { - String string = StrUtils.strjoin("\n", strings); - StringReader r = new StringReader(string); - Model model = ModelFactory.createDefaultModel(); - RDFDataMgr.read(model, r, FILE_NAME, lang); - return model; - } - - private void assertIsomorphicWith(String[] s1, String[] s2){ - Model m1 = parseToModel(s1, RDFLanguages.CSV); - Model m2 = parseToModel(s2, RDFLanguages.TURTLE); - assertTrue(m1.isIsomorphicWith(m2)); - } - -} http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/resources/HEFCE_organogram_senior_data_31032011.csv ---------------------------------------------------------------------- diff --git a/src/test/resources/HEFCE_organogram_senior_data_31032011.csv b/src/test/resources/HEFCE_organogram_senior_data_31032011.csv deleted file mode 100644 index 77df38f..0000000 --- a/src/test/resources/HEFCE_organogram_senior_data_31032011.csv +++ /dev/null @@ -1,5 +0,0 @@ -Post Unique Reference,Name,Grade,Job Title,Job/Team Function,Parent Department,Organisation,Unit,Contact Phone,Contact E-mail,Reports to Senior Post,Salary Cost of Reports (£),FTE,Actual Pay Floor (£),Actual Pay Ceiling (£),,Profession,Notes,Valid? -90115,Steve Egan,SCS1A,Deputy Chief Executive,Finance and Corporate Resources,Department for Business Innovation and Skills,Higher Education Funding Council for England,Finance and Corporate Resources,0117 931 7408,[email protected],90334,5883433,1,120000,124999,,Finance,,1 -90250,David Sweeney,SCS1A,Director,"Research, Innovation and Skills",Department for Business Innovation and Skills,Higher Education Funding Council for England,"Research, Innovation and Skills",0117 931 7304,[email protected],90334,1207171,1,110000,114999,,Policy,,1 -90284,Heather Fry,SCS1A,Director,Education and Participation,Department for Business Innovation and Skills,Higher Education Funding Council for England,Education and Participation,0117 931 7280,[email protected],90334,1645195,1,100000,104999,,Policy,,1 -90334,Sir Alan Langlands,SCS4,Chief Executive,Chief Executive,Department for Business Innovation and Skills,Higher Education Funding Council for England,HEFCE,0117 931 7300/7341,[email protected],xx,0,1,230000,234999,,Policy,,1 http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/resources/PLOSone-search-results.csv ---------------------------------------------------------------------- diff --git a/src/test/resources/PLOSone-search-results.csv b/src/test/resources/PLOSone-search-results.csv deleted file mode 100644 index ab6ae2c..0000000 --- a/src/test/resources/PLOSone-search-results.csv +++ /dev/null @@ -1,6 +0,0 @@ -id,doi,publication_date,title_display,author -10.1371/journal.pone.0095131,10.1371/journal.pone.0095131,2014-06-05T00:00:00Z,"Genotyping of French <i>Bacillus anthracis</i> Strains Based on 31-Loci Multi Locus VNTR Analysis: Epidemiology, Marker Evaluation, and Update of the Internet Genotype Database","Simon Thierry,Christophe Tourterel,Philippe Le Flèche,Sylviane Derzelle,Neira Dekhil,Christiane Mendy,Cécile Colaneri,Gilles Vergnaud,Nora Madani" -10.1371/journal.pone.0095156,10.1371/journal.pone.0095156,2014-06-05T00:00:00Z,Pathways Mediating the Interaction between Endothelial Progenitor Cells (EPCs) and Platelets,"Oshrat Raz,Dorit L Lev,Alexander Battler,Eli I Lev" -10.1371/journal.pone.0095275,10.1371/journal.pone.0095275,2014-06-05T00:00:00Z,Identification of Divergent Protein Domains by Combining HMM-HMM Comparisons and Co-Occurrence Detection,"Amel Ghouila,Isabelle Florent,Fatma Zahra Guerfali,Nicolas Terrapon,Dhafer Laouini,Sadok Ben Yahia,Olivier Gascuel,Laurent Bréhélin" -10.1371/journal.pone.0096098,10.1371/journal.pone.0096098,2014-06-05T00:00:00Z,Baseline CD4 Cell Counts of Newly Diagnosed HIV Cases in China: 2006â2012,"Houlin Tang,Yurong Mao,Cynthia X Shi,Jing Han,Liyan Wang,Juan Xu,Qianqian Qin,Roger Detels,Zunyou Wu" -10.1371/journal.pone.0097475,10.1371/journal.pone.0097475,2014-06-05T00:00:00Z,Crystal Structure of the Open State of the <i>Neisseria gonorrhoeae</i> MtrE Outer Membrane Channel,"Hsiang-Ting Lei,Tsung-Han Chou,Chih-Chia Su,Jani Reddy Bolla,Nitin Kumar,Abhijith Radhakrishnan,Feng Long,Jared A Delmar,Sylvia V Do,Kanagalaghatta R Rajashankar,William M Shafer,Edward W Yu" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/resources/Palo_Alto_Trees.csv ---------------------------------------------------------------------- diff --git a/src/test/resources/Palo_Alto_Trees.csv b/src/test/resources/Palo_Alto_Trees.csv deleted file mode 100644 index c534c47..0000000 --- a/src/test/resources/Palo_Alto_Trees.csv +++ /dev/null @@ -1,6 +0,0 @@ -GID,Private,Tree ID,Admin Area,Side of Street,On Street,From Street,To Street,Street_Name,Situs Number,Address Estimated,Lot Side,Serial Number,Tree Site,Species,Trim Cycle,Diameter at Breast Ht,Trunk Count,Height Code,Canopy Width,Trunk Condition,Structure Condition,Crown Condition,Pest Condition,Condition Calced,Condition Rating,Vigor,Cable Presence,Stake Presence,Grow Space,Utility Presence,Distance from Property,Inventory Date,Staff Name,Comments,Zip,City Name,Longitude,Latitude,Protected,Designated,Heritage,Appraised Value,Hardscape,Identifier,Location Feature ID,Install Date,Feature Name,KML,FusionMarkerIcon -1,True,29,,,ADDISON AV,EMERSON ST,RAMONA ST,ADDISON AV,203,,Front,,2,Celtis australis,Large Tree Routine Prune,11,1,25-30,15-30,,Good,5,,,Good,2,False,False,Planting Strip,,44,10/18/2010,BK,,,Palo Alto,-122.1565172,37.4409561,False,False,False,,None,40,13872,,"Tree: 29 site 2 at 203 ADDISON AV, on ADDISON AV 44 from pl","<Point><coordinates>-122.156485,37.440963</coordinates></Point>",small_green -2,True,30,,,EMERSON ST,CHANNING AV,ADDISON AV,ADDISON AV,203,,Left,,1,Liquidambar styraciflua,Large Tree Routine Prune,11,1,50-55,15-30,Good,Good,5,,,Good,2,False,False,Planting Strip,,21,6/2/2010,BK,,,Palo Alto,-122.1567812,37.440951,False,False,False,,None,41,13872,,"Tree: 30 site 1 at 203 ADDISON AV, on EMERSON ST 21 from pl","<Point><coordinates>-122.156749,37.440958</coordinates></Point>",small_green -3,True,31,,,EMERSON ST,CHANNING AV,ADDISON AV,ADDISON AV,203,,Left,,2,Liquidambar styraciflua,Large Tree Routine Prune,11,1,40-45,15-30,Good,Good,5,,,Good,2,False,False,Planting Strip,,54,6/2/2010,BK,,,Palo Alto,-122.1566921,37.4408948,False,False,False,,Low,42,13872,,"Tree: 31 site 2 at 203 ADDISON AV, on EMERSON ST 54 from pl","<Point><coordinates>-122.156659,37.440902</coordinates></Point>",small_green -4,True,32,,,ADDISON AV,EMERSON ST,RAMONA ST,ADDISON AV,209,,Front,,1,Ulmus parvifolia,Large Tree Routine Prune,18,1,35-40,30-45,Good,Good,5,,,Good,2,False,False,Planting Strip,,21,6/2/2010,BK,,,Palo Alto,-122.1564595,37.4410143,False,False,False,,Medium,43,13873,,"Tree: 32 site 1 at 209 ADDISON AV, on ADDISON AV 21 from pl","<Point><coordinates>-122.156427,37.441022</coordinates></Point>",small_green -5,True,33,,,ADDISON AV,EMERSON ST,RAMONA ST,ADDISON AV,219,,Front,,1,Eriobotrya japonica,Large Tree Routine Prune,7,1,15-20,0-15,Good,Good,3,,,Good,1,False,False,Planting Strip,,16,6/1/2010,BK,,,Palo Alto,-122.1563676,37.441107,False,False,False,,None,44,13874,,"Tree: 33 site 1 at 219 ADDISON AV, on ADDISON AV 16 from pl","<Point><coordinates>-122.156335,37.441114</coordinates></Point>",small_green http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/src/test/resources/log4j.properties b/src/test/resources/log4j.properties deleted file mode 100644 index 6d3889d..0000000 --- a/src/test/resources/log4j.properties +++ /dev/null @@ -1,19 +0,0 @@ -log4j.rootLogger=INFO, stdlog - -log4j.appender.stdlog=org.apache.log4j.ConsoleAppender -## log4j.appender.stdlog.target=System.err -log4j.appender.stdlog.layout=org.apache.log4j.PatternLayout -log4j.appender.stdlog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-25c{1} :: %m%n - -# Execution logging -log4j.logger.com.hp.hpl.jena.arq.info=INFO -log4j.logger.com.hp.hpl.jena.arq.exec=INFO - -# Everything else in Jena -log4j.logger.com.hp.hpl.jena=WARN -log4j.logger.org.openjena=WARN -log4j.logger.org.openjena.riot=INFO - -# Apache Commons HTTP -# May be useful to turn up to DEBUG if debugging HTTP communication issues -log4j.logger.org.apache.http=WARN http://git-wip-us.apache.org/repos/asf/jena/blob/e7ac8b4d/src/test/resources/test.csv ---------------------------------------------------------------------- diff --git a/src/test/resources/test.csv b/src/test/resources/test.csv deleted file mode 100644 index b9ac0e1..0000000 --- a/src/test/resources/test.csv +++ /dev/null @@ -1,3 +0,0 @@ -Town,Population,Predicate With Space,`~!@#$%^&*()-_=+[{]}|\;:'"<.>/?,1234 -Southton,123000.0,PredicateWithSpace1,NonURICharacters1,DigitalLocalName1 -Northville,654000,PredicateWithSpace2,NonURICharacters2,DigitalLocalName2
