Repository: vxquery Updated Branches: refs/heads/master 95c7cd2b9 -> 9e4e99050
Updated rat configuration and a bunch of sonar fixes. The sonar fixes were an attempt to locate an issue that creates to many open files while running junit tests. Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/9e4e9905 Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/9e4e9905 Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/9e4e9905 Branch: refs/heads/master Commit: 9e4e990503843cb1764483bf9aa0b7e03820b0a3 Parents: 95c7cd2 Author: Preston Carman <[email protected]> Authored: Wed Jun 22 16:34:38 2016 -0700 Committer: Preston Carman <[email protected]> Committed: Thu Jun 23 15:48:52 2016 -0700 ---------------------------------------------------------------------- pom.xml | 1 + vxquery-cli/pom.xml | 13 +-- .../java/org/apache/vxquery/cli/VXQuery.java | 32 +++---- vxquery-core/pom.xml | 23 ++---- .../org/apache/vxquery/hdfs2/HDFSFunctions.java | 84 +++++++++---------- .../hdfs2/XmlCollectionWithTagInputFormat.java | 28 +++---- .../metadata/VXQueryCollectionDataSource.java | 15 ++-- .../VXQueryCollectionOperatorDescriptor.java | 9 +- .../runtime/functions/util/FunctionHelper.java | 45 +++++----- vxquery-xtest/pom.xml | 20 +---- .../vxquery/xtest/AbstractTestCaseFactory.java | 44 +++++----- .../vxquery/xtest/HTMLFileReporterImpl.java | 87 ++++++++++---------- .../java/org/apache/vxquery/xtest/MiniDFS.java | 1 + .../java/org/apache/vxquery/xtest/TestCase.java | 6 +- .../apache/vxquery/xtest/TestCaseFactory.java | 7 +- .../apache/vxquery/xtest/TestCaseResult.java | 28 +++---- .../apache/vxquery/xtest/TestConfiguration.java | 2 +- .../org/apache/vxquery/xtest/TestRunner.java | 9 +- .../apache/vxquery/xtest/TestRunnerFactory.java | 2 +- 19 files changed, 212 insertions(+), 244 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index feabafe..7a734dc 100644 --- a/pom.xml +++ b/pom.xml @@ -569,6 +569,7 @@ <exclude>.gitignore</exclude> <exclude>.rat-excludes</exclude> <exclude>.project</exclude> + <exclude>.pydevproject</exclude> <exclude>.classpath</exclude> <exclude>.basex</exclude> <exclude>**/ExpectedTestResults/**</exclude> http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-cli/pom.xml ---------------------------------------------------------------------- diff --git a/vxquery-cli/pom.xml b/vxquery-cli/pom.xml index 907bab3..52c32ad 100644 --- a/vxquery-cli/pom.xml +++ b/vxquery-cli/pom.xml @@ -126,19 +126,19 @@ <groupId>org.apache.hyracks</groupId> <artifactId>hyracks-dataflow-std</artifactId> </dependency> - + <dependency> <groupId>org.apache.hyracks</groupId> <artifactId>hyracks-hdfs-core</artifactId> </dependency> - + <dependency> <groupId>org.apache.hyracks</groupId> <artifactId>hyracks-hdfs-2.x</artifactId> </dependency> </dependencies> - - + + <reporting> <plugins> @@ -160,11 +160,6 @@ </configuration> </plugin> <plugin> - <groupId>org.apache.rat</groupId> - <artifactId>apache-rat-plugin</artifactId> - <version>${apache-rat-plugin.version}</version> - </plugin> - <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <configuration> http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java ---------------------------------------------------------------------- diff --git a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java index 17287c6..e18332e 100644 --- a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java +++ b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.io.StringReader; +import java.net.InetAddress; import java.nio.file.Files; import java.util.ArrayList; import java.util.Date; @@ -72,7 +73,7 @@ public class VXQuery { private IHyracksDataset hds; private ResultSetId resultSetId; - private static List<String> timingMessages = new ArrayList<String>(); + private static List<String> timingMessages = new ArrayList<>(); private static long sumTiming; private static long sumSquaredTiming; private static long minTiming = Long.MAX_VALUE; @@ -117,13 +118,11 @@ public class VXQuery { Date end = new Date(); timingMessage("Execution time: " + (end.getTime() - start.getTime()) + " ms"); if (opts.repeatExec > opts.timingIgnoreQueries) { - long mean = sumTiming / (opts.repeatExec - opts.timingIgnoreQueries); - double sd = Math - .sqrt(sumSquaredTiming / (opts.repeatExec - new Integer(opts.timingIgnoreQueries).doubleValue()) - - mean * mean); + Double mean = (double) (sumTiming) / (opts.repeatExec - opts.timingIgnoreQueries); + double sd = Math.sqrt(sumSquaredTiming / (opts.repeatExec - opts.timingIgnoreQueries) - mean * mean); timingMessage("Average execution time: " + mean + " ms"); timingMessage("Standard deviation: " + String.format("%.4f", sd)); - timingMessage("Coefficient of variation: " + String.format("%.4f", (sd / mean))); + timingMessage("Coefficient of variation: " + String.format("%.4f", sd / mean)); timingMessage("Minimum execution time: " + minTiming + " ms"); timingMessage("Maximum execution time: " + maxTiming + " ms"); } @@ -169,9 +168,9 @@ public class VXQuery { * @throws SystemException * @throws Exception */ - private void runQueries() throws IOException, SystemException, Exception { - Date start = null; - Date end = null; + private void runQueries() throws Exception { + Date start; + Date end; for (String query : opts.arguments) { String qStr = slurp(query); if (opts.showQuery) { @@ -286,10 +285,11 @@ public class VXQuery { * @throws Exception */ public void startLocalHyracks() throws Exception { + String localAddress = InetAddress.getLocalHost().getHostAddress(); CCConfig ccConfig = new CCConfig(); - ccConfig.clientNetIpAddress = "127.0.0.1"; + ccConfig.clientNetIpAddress = localAddress; ccConfig.clientNetPort = 39000; - ccConfig.clusterNetIpAddress = "127.0.0.1"; + ccConfig.clusterNetIpAddress = localAddress; ccConfig.clusterNetPort = 39001; ccConfig.httpPort = 39002; ccConfig.profileDumpPeriod = 10000; @@ -301,9 +301,9 @@ public class VXQuery { NCConfig ncConfig = new NCConfig(); ncConfig.ccHost = "localhost"; ncConfig.ccPort = 39001; - ncConfig.clusterNetIPAddress = "127.0.0.1"; - ncConfig.dataIPAddress = "127.0.0.1"; - ncConfig.resultIPAddress = "127.0.0.1"; + ncConfig.clusterNetIPAddress = localAddress; + ncConfig.dataIPAddress = localAddress; + ncConfig.resultIPAddress = localAddress; ncConfig.nodeId = "nc" + (i + 1); ncConfig.ioDevices = Files.createTempDirectory(ncConfig.nodeId).toString(); ncs[i] = new NodeControllerService(ncConfig); @@ -409,13 +409,13 @@ public class VXQuery { private int timingIgnoreQueries = 2; @Option(name = "-x", usage = "Bind an external variable") - private Map<String, String> bindings = new HashMap<String, String>(); + private Map<String, String> bindings = new HashMap<>(); @Option(name = "-hdfs-conf", usage = "Directory path to Hadoop configuration files") private String hdfsConf = null; @Argument - private List<String> arguments = new ArrayList<String>(); + private List<String> arguments = new ArrayList<>(); } } http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-core/pom.xml ---------------------------------------------------------------------- diff --git a/vxquery-core/pom.xml b/vxquery-core/pom.xml index 56eb45f..920a195 100644 --- a/vxquery-core/pom.xml +++ b/vxquery-core/pom.xml @@ -121,12 +121,12 @@ <redirectTestOutputToFile>true</redirectTestOutputToFile> </configuration> </plugin> - <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> + <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> </plugin> --> </plugins> <pluginManagement> <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings + <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> @@ -341,24 +341,11 @@ <dependencyLocationsEnabled>false</dependencyLocationsEnabled> </configuration> </plugin> - <!-- <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> - <version>2.5.2</version> <configuration> <effort>Min</effort> <threshold>Normal</threshold> - <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile> </configuration> + <!-- <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> + <version>2.5.2</version> <configuration> <effort>Min</effort> <threshold>Normal</threshold> + <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile> </configuration> </plugin> --> <plugin> - <groupId>org.apache.rat</groupId> - <artifactId>apache-rat-plugin</artifactId> - <version>${apache-rat-plugin.version}</version> - <configuration> - <excludes> - <exclude>testsuites/**/*</exclude> - <exclude>reports/**/*</exclude> - </excludes> - <numUnapprovedLicenses>0</numUnapprovedLicenses> - <maxmemory>2g</maxmemory> - </configuration> - </plugin> - <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.9</version> http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-core/src/main/java/org/apache/vxquery/hdfs2/HDFSFunctions.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/hdfs2/HDFSFunctions.java b/vxquery-core/src/main/java/org/apache/vxquery/hdfs2/HDFSFunctions.java index dcbfe94..3558e93 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/hdfs2/HDFSFunctions.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/hdfs2/HDFSFunctions.java @@ -73,7 +73,7 @@ public class HDFSFunctions { /** * Create the configuration and add the paths for core-site and hdfs-site as resources. * Initialize an instance of HDFS FileSystem for this configuration. - * + * * @param nodeControllerInfos * @param hdfsConf */ @@ -86,7 +86,7 @@ public class HDFSFunctions { /** * Create the needed objects for reading the splits of the filepath given as argument. * This method should run before the scheduleSplits method. - * + * * @param filepath */ @SuppressWarnings({ "deprecation", "unchecked" }) @@ -110,7 +110,7 @@ public class HDFSFunctions { /** * Returns true if the file path exists or it is located somewhere in the home directory of the user that called the function. * Searches in subdirectories of the home directory too. - * + * * @param filename * @return * @throws IOException @@ -126,7 +126,7 @@ public class HDFSFunctions { /** * Searches the given directory for the file. - * + * * @param directory * to search * @param filename @@ -157,7 +157,7 @@ public class HDFSFunctions { /** * Read the cluster properties file and locate the HDFS_CONF variable that is the directory path for the * hdfs configuration if the system environment variable HDFS_CONF is not set. - * + * * @return true if is successfully finds the Hadoop/HDFS home directory */ private boolean locateConf() { @@ -171,7 +171,7 @@ public class HDFSFunctions { /** * Upload a file/directory to HDFS.Filepath is the path in the local file system.dir is the destination path. - * + * * @param filepath * @param dir * @return @@ -203,7 +203,7 @@ public class HDFSFunctions { /** * Get instance of the HDFSfile system if it is configured correctly. * Return null if there is no instance. - * + * * @return */ public FileSystem getFileSystem() { @@ -228,50 +228,48 @@ public class HDFSFunctions { /** * Create a HashMap that has as key the hostname and values the splits that belong to this hostname; - * + * * @return * @throws IOException */ public HashMap<String, ArrayList<Integer>> getLocationsOfSplits() throws IOException { - HashMap<String, ArrayList<Integer>> splits_map = new HashMap<String, ArrayList<Integer>>(); + HashMap<String, ArrayList<Integer>> splitsMap = new HashMap<>(); ArrayList<Integer> temp; int i = 0; String hostname; for (InputSplit s : this.splits) { SplitLocationInfo info[] = s.getLocationInfo(); hostname = info[0].getLocation(); - if (splits_map.containsKey(hostname)) { - temp = splits_map.get(hostname); + if (splitsMap.containsKey(hostname)) { + temp = splitsMap.get(hostname); temp.add(i); } else { - temp = new ArrayList<Integer>(); + temp = new ArrayList<>(); temp.add(i); - splits_map.put(hostname, temp); + splitsMap.put(hostname, temp); } i++; } - return splits_map; + return splitsMap; } public void scheduleSplits() throws IOException, ParserConfigurationException, SAXException { - schedule = new HashMap<Integer, String>(); - ArrayList<String> empty = new ArrayList<String>(); - HashMap<String, ArrayList<Integer>> splits_map = this.getLocationsOfSplits(); + schedule = new HashMap<>(); + ArrayList<String> empty = new ArrayList<>(); + HashMap<String, ArrayList<Integer>> splitsMap = this.getLocationsOfSplits(); readNodesFromXML(); int count = this.splits.size(); - ArrayList<Integer> splits; String node; for (ArrayList<String> info : this.nodes) { node = info.get(1); - if (splits_map.containsKey(node)) { - splits = splits_map.get(node); - for (Integer split : splits) { + if (splitsMap.containsKey(node)) { + for (Integer split : splitsMap.get(node)) { schedule.put(split, node); count--; } - splits_map.remove(node); + splitsMap.remove(node); } else { empty.add(node); } @@ -279,7 +277,7 @@ public class HDFSFunctions { //Check if every split got assigned to a node if (count != 0) { - ArrayList<Integer> remaining = new ArrayList<Integer>(); + ArrayList<Integer> remaining = new ArrayList<>(); // Find remaining splits for (InputSplit s : this.splits) { int i = 0; @@ -288,14 +286,14 @@ public class HDFSFunctions { } } - if (empty.size() != 0) { - int node_number = 0; + if (!empty.isEmpty()) { + int nodeNumber = 0; for (int split : remaining) { - if (node_number == empty.size()) { - node_number = 0; + if (nodeNumber == empty.size()) { + nodeNumber = 0; } - schedule.put(split, empty.get(node_number)); - node_number++; + schedule.put(split, empty.get(nodeNumber)); + nodeNumber++; } } } @@ -304,19 +302,12 @@ public class HDFSFunctions { /** * Read the hostname and the ip address of every node from the xml cluster configuration file. * Save the information inside nodes. - * - * @throws ParserConfigurationException - * @throws IOException - * @throws SAXException */ - public void readNodesFromXML() throws ParserConfigurationException, SAXException, IOException { - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dBuilder; - dBuilder = dbFactory.newDocumentBuilder(); - nodes = new ArrayList<ArrayList<String>>(); + public void readNodesFromXML() { + nodes = new ArrayList<>(); for (NodeControllerInfo ncInfo : nodeControllerInfos.values()) { //Will this include the master node? Is that bad? - ArrayList<String> info = new ArrayList<String>(); + ArrayList<String> info = new ArrayList<>(); info.add(ncInfo.getNodeId()); info.add(ncInfo.getNetworkAddress().getAddress()); nodes.add(info); @@ -325,13 +316,12 @@ public class HDFSFunctions { /** * Writes the schedule to a temporary file, then uploads the file to the HDFS. - * + * * @throws UnsupportedEncodingException * @throws FileNotFoundException */ public void addScheduleToDistributedCache() throws FileNotFoundException, UnsupportedEncodingException { - PrintWriter writer; - writer = new PrintWriter(filepath, "UTF-8"); + PrintWriter writer = new PrintWriter(filepath, "UTF-8"); for (int split : this.schedule.keySet()) { writer.write(split + "," + this.schedule.get(split)); } @@ -342,7 +332,7 @@ public class HDFSFunctions { public RecordReader getReader() { - List<FileSplit> fileSplits = new ArrayList<FileSplit>(); + List<FileSplit> fileSplits = new ArrayList<>(); for (int i = 0; i < splits.size(); i++) { fileSplits.add((FileSplit) splits.get(i)); } @@ -385,18 +375,18 @@ public class HDFSFunctions { /** * Return the splits belonging to this node for the existing schedule. - * + * * @param node * @return */ public ArrayList<Integer> getScheduleForNode(String node) { - ArrayList<Integer> node_schedule = new ArrayList<Integer>(); + ArrayList<Integer> nodeSchedule = new ArrayList<>(); for (int split : this.schedule.keySet()) { if (node.equals(this.schedule.get(split))) { - node_schedule.add(split); + nodeSchedule.add(split); } } - return node_schedule; + return nodeSchedule; } public List<InputSplit> getSplits() { http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-core/src/main/java/org/apache/vxquery/hdfs2/XmlCollectionWithTagInputFormat.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/hdfs2/XmlCollectionWithTagInputFormat.java b/vxquery-core/src/main/java/org/apache/vxquery/hdfs2/XmlCollectionWithTagInputFormat.java index 1d053b6..326a8c2 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/hdfs2/XmlCollectionWithTagInputFormat.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/hdfs2/XmlCollectionWithTagInputFormat.java @@ -60,8 +60,8 @@ public class XmlCollectionWithTagInputFormat extends TextInputFormat { */ public static class XmlRecordReader extends RecordReader<LongWritable, Text> { - private final byte[] end_tag; - private final byte[] start_tag; + private final byte[] endTag; + private final byte[] startTag; private final long start; private final long end; private final FSDataInputStream fsin; @@ -69,11 +69,11 @@ public class XmlCollectionWithTagInputFormat extends TextInputFormat { private LongWritable currentKey; private Text currentValue; BlockLocation[] blocks; - public static byte[] nl = "\n".getBytes(); + protected static byte[] nl = "\n".getBytes(); public XmlRecordReader(FileSplit split, Configuration conf) throws IOException { - end_tag = ENDING_TAG.getBytes(Charsets.UTF_8); - start_tag = STARTING_TAG.getBytes(Charsets.UTF_8); + endTag = ENDING_TAG.getBytes(Charsets.UTF_8); + startTag = STARTING_TAG.getBytes(Charsets.UTF_8); // open the file and seek to the start of the split start = split.getStart(); @@ -90,7 +90,7 @@ public class XmlCollectionWithTagInputFormat extends TextInputFormat { /** * Get next block item - * + * * @param key * @param value * @return @@ -123,7 +123,7 @@ public class XmlCollectionWithTagInputFormat extends TextInputFormat { /** * Read the block from start till end and after that until you find a closing tag - * + * * @param withinBlock * @return * @throws IOException @@ -133,9 +133,9 @@ public class XmlCollectionWithTagInputFormat extends TextInputFormat { while (true) { if (fsin.getPos() < end) { - if (readUntilMatch(start_tag, false)) { - buffer.write(start_tag); - readUntilMatch(end_tag, true); + if (readUntilMatch(startTag, false)) { + buffer.write(startTag); + readUntilMatch(endTag, true); read = true; } } else { @@ -146,7 +146,7 @@ public class XmlCollectionWithTagInputFormat extends TextInputFormat { /** * Read from block(s) until you reach the end of file or find a matching bytes with match[] - * + * * @param match * @param withinBlock * @return @@ -183,10 +183,10 @@ public class XmlCollectionWithTagInputFormat extends TextInputFormat { private int nextBlock() throws IOException { long pos = fsin.getPos(); - long block_length; + long blockLength; for (int i = 0; i < blocks.length; i++) { - block_length = blocks[i].getOffset() + blocks[i].getLength(); - if (pos == block_length) { + blockLength = blocks[i].getOffset() + blocks[i].getLength(); + if (pos == blockLength) { return i + 1; } } http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionDataSource.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionDataSource.java b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionDataSource.java index 3c2d6aa..4d0e7a4 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionDataSource.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionDataSource.java @@ -43,27 +43,28 @@ public class VXQueryCollectionDataSource implements IDataSource<String> { private IDataSourcePropertiesProvider propProvider; - public static VXQueryCollectionDataSource create(int id, String file, Object type) { - return new VXQueryCollectionDataSource(id, file, new Object[] { type }); - } - private VXQueryCollectionDataSource(int id, String file, Object[] types) { this.dataSourceId = id; this.collectionName = file; collectionPartitions = collectionName.split(DELIMITER); this.types = types; - final IPhysicalPropertiesVector vec = new StructuralPropertiesVector(new RandomPartitioningProperty( - new CollectionFileDomain(collectionName)), new ArrayList<ILocalStructuralProperty>()); + final IPhysicalPropertiesVector vec = new StructuralPropertiesVector( + new RandomPartitioningProperty(new CollectionFileDomain(collectionName)), + new ArrayList<ILocalStructuralProperty>()); propProvider = new IDataSourcePropertiesProvider() { @Override public IPhysicalPropertiesVector computePropertiesVector(List<LogicalVariable> scanVariables) { return vec; } }; - this.childSeq = new ArrayList<Integer>(); + this.childSeq = new ArrayList<>(); this.tag = null; } + public static VXQueryCollectionDataSource create(int id, String file, Object type) { + return new VXQueryCollectionDataSource(id, file, new Object[] { type }); + } + public int getTotalDataSources() { return totalDataSources; } http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java index ef51cee..acd74b1 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryCollectionOperatorDescriptor.java @@ -159,7 +159,7 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO ArrayList<Integer> schedule = hdfs .getScheduleForNode(InetAddress.getLocalHost().getHostAddress()); List<InputSplit> splits = hdfs.getSplits(); - List<FileSplit> fileSplits = new ArrayList<FileSplit>(); + List<FileSplit> fileSplits = new ArrayList<>(); for (int i : schedule) { fileSplits.add((FileSplit) splits.get(i)); } @@ -181,13 +181,14 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO value = reader.getCurrentValue().toString(); //Split value if it contains more than one item with the tag if (StringUtils.countMatches(value, tag) > 1) { - String items[] = value.split(tag); + String[] items = value.split(tag); for (String item : items) { if (item.length() > 0) { item = START_TAG + tag + item; stream = new ByteArrayInputStream( item.getBytes(StandardCharsets.UTF_8)); parser.parseHDFSElements(stream, writer, fta, i); + stream.close(); } } } else { @@ -195,9 +196,10 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO //create an input stream to the file currently reading and send it to parser stream = new ByteArrayInputStream(value.getBytes(StandardCharsets.UTF_8)); parser.parseHDFSElements(stream, writer, fta, i); + stream.close(); } } - + reader.close(); } } catch (Exception e) { @@ -220,6 +222,7 @@ public class VXQueryCollectionOperatorDescriptor extends AbstractSingleActivityO //create an input stream to the file currently reading and send it to parser InputStream in = fs.open(xmlDocument).getWrappedStream(); parser.parseHDFSElements(in, writer, fta, tupleIndex); + in.close(); } } } http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java ---------------------------------------------------------------------- diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java index b6668ba..5b9504e 100644 --- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java +++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java @@ -19,7 +19,6 @@ package org.apache.vxquery.runtime.functions.util; import java.io.DataInputStream; import java.io.DataOutput; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; @@ -56,6 +55,9 @@ import org.apache.vxquery.xmlparser.XMLParser; public class FunctionHelper { + private FunctionHelper() { + } + public static void arithmeticOperation(AbstractArithmeticOperation aOp, DynamicContext dCtx, TaggedValuePointable tvp1, TaggedValuePointable tvp2, IPointable result, TypedPointables tp1, TypedPointables tp2) throws SystemException { @@ -480,7 +482,7 @@ public class FunctionHelper { public static boolean compareTaggedValues(AbstractValueComparisonOperation aOp, TaggedValuePointable tvp1, TaggedValuePointable tvp2, DynamicContext dCtx, TypedPointables tp1, TypedPointables tp2) - throws SystemException { + throws SystemException { int tid1 = getBaseTypeForComparisons(tvp1.getTag()); int tid2 = getBaseTypeForComparisons(tvp2.getTag()); @@ -852,7 +854,8 @@ public class FunctionHelper { } } - public static int getBaseTypeForComparisons(int tid) throws SystemException { + public static int getBaseTypeForComparisons(int tidArg) throws SystemException { + int tid = tidArg; while (true) { switch (tid) { case ValueTag.XS_ANY_URI_TAG: @@ -903,7 +906,8 @@ public class FunctionHelper { } } - public static int getBaseTypeForGeneralComparisons(int tid) throws SystemException { + public static int getBaseTypeForGeneralComparisons(int tidArg) throws SystemException { + int tid = tidArg; while (true) { switch (tid) { case ValueTag.NODE_TREE_TAG: @@ -1115,8 +1119,8 @@ public class FunctionHelper { } } - public static long getPowerOf10(double value, long max, long min) { - value = Math.abs(value); + public static long getPowerOf10(double valueArg, long max, long min) { + double value = Math.abs(valueArg); for (long i = min; i < max; i++) { if (Math.pow(10, i) > value) return i; @@ -1146,8 +1150,9 @@ public class FunctionHelper { case ValueTag.XS_DOUBLE_TAG: case ValueTag.XS_FLOAT_TAG: return true; + default: + return isDerivedFromInteger(tid); } - return isDerivedFromInteger(tid); } public static boolean isDerivedFromInteger(int tid) { @@ -1166,8 +1171,9 @@ public class FunctionHelper { case ValueTag.XS_BYTE_TAG: case ValueTag.XS_UNSIGNED_BYTE_TAG: return true; + default: + return false; } - return false; } public static boolean isDerivedFromString(int tid) { @@ -1184,8 +1190,9 @@ public class FunctionHelper { case ValueTag.XS_IDREF_TAG: case ValueTag.XS_ENTITY_TAG: return true; + default: + return false; } - return false; } /** @@ -1196,7 +1203,7 @@ public class FunctionHelper { * @return boolean */ public static boolean isNumberPostive(long value) { - return ((value & 0x8000000000000000L) == 0 ? true : false); + return (value & 0x8000000000000000L) == 0 ? true : false; } public static void printUTF8String(UTF8StringPointable stringp) { @@ -1230,22 +1237,20 @@ public class FunctionHelper { } //else check in HDFS file system else { - fName = fName.replaceAll("hdfs:/", ""); HDFSFunctions hdfs = new HDFSFunctions(null, null); FileSystem fs = hdfs.getFileSystem(); if (fs != null) { - Path xmlDocument = new Path(fName); try { + String fHdfsName = fName.replaceAll("hdfs:/", ""); + Path xmlDocument = new Path(fHdfsName); if (fs.exists(xmlDocument)) { InputStream in = fs.open(xmlDocument).getWrappedStream(); parser.parseHDFSDocument(in, abvs); + in.close(); } - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - System.err.println(e); + fs.close(); } catch (IOException e) { - // TODO Auto-generated catch block - System.err.println(e); + throw new HyracksDataException(e); } } } @@ -1352,7 +1357,9 @@ public class FunctionHelper { * data output */ - public static void writeNumberWithPadding(long value, int padding, DataOutput dOut) { + public static void writeNumberWithPadding(long valueArg, int paddingArg, DataOutput dOut) { + long value = valueArg; + int padding = paddingArg; if (value < 0) { writeChar('-', dOut); value = Math.abs(value); @@ -1366,7 +1373,7 @@ public class FunctionHelper { } // Write the actual number. - long pow10 = (long) Math.pow(10, nDigits - 1); + long pow10 = (long) Math.pow(10, nDigits - 1.0); for (int i = nDigits - 1; i >= 0; --i) { writeChar((char) ('0' + (value / pow10)), dOut); value %= pow10; http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-xtest/pom.xml ---------------------------------------------------------------------- diff --git a/vxquery-xtest/pom.xml b/vxquery-xtest/pom.xml index 23095f1..990bf31 100644 --- a/vxquery-xtest/pom.xml +++ b/vxquery-xtest/pom.xml @@ -50,10 +50,6 @@ <mainClass>org.apache.vxquery.xtest.Main</mainClass> <name>xtest</name> </program> - <program> - <mainClass>org.apache.vxquery.xtest.util.DiskPerformance</mainClass> - <name>diskperformance</name> - </program> </programs> <repositoryLayout>flat</repositoryLayout> <repositoryName>lib</repositoryName> @@ -156,7 +152,7 @@ <groupId>org.apache.hyracks</groupId> <artifactId>hyracks-dataflow-std</artifactId> </dependency> - + <dependency> <groupId>org.apache.hyracks</groupId> <artifactId>hyracks-hdfs-2.x</artifactId> @@ -199,20 +195,6 @@ </configuration> </plugin> <plugin> - <groupId>org.apache.rat</groupId> - <artifactId>apache-rat-plugin</artifactId> - <version>${apache-rat-plugin.version}</version> - <configuration> - <excludes> - <exclude>**/ExpectedTestResults/**/*</exclude> - <exclude>**/xqts.txt</exclude> - <exclude>test-suite*/**/*</exclude> - </excludes> - <numUnapprovedLicenses>0</numUnapprovedLicenses> - <maxmemory>2g</maxmemory> - </configuration> - </plugin> - <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <configuration> http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/AbstractTestCaseFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/AbstractTestCaseFactory.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/AbstractTestCaseFactory.java index b38f0ab..cf52171 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/AbstractTestCaseFactory.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/AbstractTestCaseFactory.java @@ -38,23 +38,23 @@ import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; public abstract class AbstractTestCaseFactory { - public TestConfiguration tConfig; - public File catalog; - public String baseDirectory; - public TestCase tc; - public Pattern include; - public Pattern exclude; - public Set<String> previousTestResults; - public XTestOptions opts; - public String nextVariable; - public boolean expectedError; - public boolean outputFile; - public int currPathLen; - public int count; + protected TestConfiguration tConfig; + protected File catalog; + protected String baseDirectory; + protected TestCase tc; + protected Pattern include; + protected Pattern exclude; + protected Set<String> previousTestResults; + protected XTestOptions opts; + protected String nextVariable; + protected boolean expectedError; + protected boolean outputFile; + protected int currPathLen; + protected int count; - static int TEST_NAME_INDEX = 0; - static int TEST_RESULT_INDEX = 1; - static List<String> PASSING_TESTS = Arrays.asList("EXPECTED_RESULT_GOT_SAME_RESULT", + protected static final int TEST_NAME_INDEX = 0; + protected static final int TEST_RESULT_INDEX = 1; + protected static final List<String> PASSING_TESTS = Arrays.asList("EXPECTED_RESULT_GOT_SAME_RESULT", "EXPECTED_ERROR_GOT_SAME_ERROR"); public AbstractTestCaseFactory(XTestOptions opts) { @@ -113,8 +113,8 @@ public abstract class AbstractTestCaseFactory { @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { URL url = new URL(systemId); - return new InputSource(baseDirectory - + new File(url.getFile()).getCanonicalPath().substring(currPathLen)); + return new InputSource( + baseDirectory + new File(url.getFile()).getCanonicalPath().substring(currPathLen)); } }); try { @@ -252,10 +252,10 @@ public abstract class AbstractTestCaseFactory { File srcFile = new File(tConfig.testRoot, atts.getValue("", "FileName")); tConfig.sourceFileMap.put(id, srcFile); } else if ("test-suite".equals(localName)) { - tConfig.testRoot = new File(new File(baseDirectory).getCanonicalFile(), atts.getValue("", - "SourceOffsetPath")); - tConfig.xqueryQueryOffsetPath = new File(tConfig.testRoot, atts.getValue("", - "XQueryQueryOffsetPath")); + tConfig.testRoot = new File(new File(baseDirectory).getCanonicalFile(), + atts.getValue("", "SourceOffsetPath")); + tConfig.xqueryQueryOffsetPath = new File(tConfig.testRoot, + atts.getValue("", "XQueryQueryOffsetPath")); tConfig.resultOffsetPath = new File(tConfig.testRoot, atts.getValue("", "ResultOffsetPath")); tConfig.xqueryFileExtension = atts.getValue("", "XQueryFileExtension"); tConfig.xqueryxFileExtension = atts.getValue("", "XQueryXFileExtension"); http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/HTMLFileReporterImpl.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/HTMLFileReporterImpl.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/HTMLFileReporterImpl.java index 6548287..d9e85e3 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/HTMLFileReporterImpl.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/HTMLFileReporterImpl.java @@ -50,17 +50,17 @@ public class HTMLFileReporterImpl implements ResultReporter { private long endTime; private PrintWriter out; - + private File reportFile; public HTMLFileReporterImpl(File file) { - results = new ArrayList<TestCaseResult>(); + results = new ArrayList<>(); count = 0; userErrors = 0; internalErrors = 0; startTime = -1; - exDistribution = new HashMap<Class<?>, Integer>(); - stDistribution = new HashMap<TestCaseResult.State, Integer>(); + exDistribution = new HashMap<>(); + stDistribution = new HashMap<>(); reportFile = file; } @@ -105,20 +105,19 @@ public class HTMLFileReporterImpl implements ResultReporter { } } } - + private static File createResultDir(File file) { String fileName = file.getName(); int dot = file.getName().lastIndexOf('.'); String resultDirName = (dot < 0 ? fileName : fileName.substring(0, dot)) + "_results"; - return file.getParent() != null - ? new File(file.getParent() + File.separator + resultDirName) - : new File(resultDirName); + return file.getParent() != null ? new File(file.getParent() + File.separator + resultDirName) + : new File(resultDirName); } - + public void writeHTML(PrintWriter out) { writeHTML(out, null); } - + public void writeHTML(PrintWriter out, File resultDir) { long start = System.currentTimeMillis(); out.println("<html><body>"); @@ -133,8 +132,8 @@ public class HTMLFileReporterImpl implements ResultReporter { System.err.println("HTML generation time: " + (System.currentTimeMillis() - start)); } - private static void writeSummary(PrintWriter out, int count, int userErrors, - int internalErrors, long startTime, long endTime) { + private static void writeSummary(PrintWriter out, int count, int userErrors, int internalErrors, long startTime, + long endTime) { out.println("<table>"); out.println("<tr><td>Test Count</td><td>"); out.println(count); @@ -149,11 +148,11 @@ public class HTMLFileReporterImpl implements ResultReporter { out.println(endTime - startTime); out.println("</td></tr>"); out.println("</table>"); - } + } private static void writeExceptionDistribution(PrintWriter out, Map<Class<?>, Integer> exDistribution) { out.println("<table>"); - List<Entry<Class<?>, Integer>> entryList = new ArrayList<Entry<Class<?>, Integer>>(exDistribution.entrySet()); + List<Entry<Class<?>, Integer>> entryList = new ArrayList<>(exDistribution.entrySet()); Comparator<Entry<Class<?>, Integer>> comp = new Comparator<Entry<Class<?>, Integer>>() { public int compare(Entry<Class<?>, Integer> o1, Entry<Class<?>, Integer> o2) { return o1.getKey().getName().compareTo(o2.getKey().getName()); @@ -172,14 +171,13 @@ public class HTMLFileReporterImpl implements ResultReporter { private static void writeStateDistribution(PrintWriter out, Map<TestCaseResult.State, Integer> stDistribution) { out.println("<table>"); - List<Map.Entry<TestCaseResult.State, Integer>> entryList - = new ArrayList<Map.Entry<TestCaseResult.State, Integer>>(stDistribution.entrySet()); - Comparator<Map.Entry<TestCaseResult.State, Integer>> comp - = new Comparator<Map.Entry<TestCaseResult.State, Integer>>() { - public int compare(Map.Entry<TestCaseResult.State, Integer> o1, Map.Entry<TestCaseResult.State, Integer> o2) { - return o1.getKey().compareTo(o2.getKey()); - } - }; + List<Map.Entry<TestCaseResult.State, Integer>> entryList = new ArrayList<>(stDistribution.entrySet()); + Comparator<Map.Entry<TestCaseResult.State, Integer>> comp = new Comparator<Map.Entry<TestCaseResult.State, Integer>>() { + public int compare(Map.Entry<TestCaseResult.State, Integer> o1, + Map.Entry<TestCaseResult.State, Integer> o2) { + return o1.getKey().compareTo(o2.getKey()); + } + }; Collections.sort(entryList, comp); for (Map.Entry<TestCaseResult.State, Integer> e : entryList) { State key = e.getKey(); @@ -227,22 +225,22 @@ public class HTMLFileReporterImpl implements ResultReporter { out.println("</table>"); rfw.close(); } - + } -/** - * writes results into several HTML files of manageable size +/** + * writes results into several HTML files of manageable size */ class ResultManager { - - /** + + /** * if the length of a file passes this length, a new file will be used - * for the next result + * for the next result */ private static final long MAX_LEN = 1000000; - + private final File dir; - + private File curFile; private URI curURI; private FileWriter curFileWriter; @@ -251,13 +249,16 @@ class ResultManager { ResultManager(File dir) { this.dir = dir; } - + /** * writes an HTML serialization of a test result into a temp HTML file - * inside the given directory - * @param res the result data for 1 test case - * @param linkName the name of the (internal) HTML link that points to - * the test result inside the HTML file + * inside the given directory + * + * @param res + * the result data for 1 test case + * @param linkName + * the name of the (internal) HTML link that points to + * the test result inside the HTML file * @return the full URI that references the test result in the HTML file */ String writeResult(TestCaseResult res, String linkName) { @@ -284,9 +285,7 @@ class ResultManager { return null; } - curPrintWriter.println( - "<a style=\"background: " + res.state.getColor() - + "\" name=\"" + linkName + curPrintWriter.println("<a style=\"background: " + res.state.getColor() + "\" name=\"" + linkName + "\"> </a>"); curPrintWriter.println(linkName); curPrintWriter.println("<pre>"); @@ -305,12 +304,12 @@ class ResultManager { writeDocFooter(curPrintWriter); curPrintWriter.flush(); curFileWriter.close(); - } + } } catch (IOException e) { e.printStackTrace(); } } - + private static void ensureDir(File dir) throws IOException { if (!dir.isDirectory() && !dir.mkdirs()) { throw new IOException("could not create dir " + dir); @@ -328,7 +327,7 @@ class ResultManager { resOut.println("</body></html>"); } - /* this should not be necessary anymore, when the XQuery serialization + /* this should not be necessary anymore, when the XQuery serialization * works right */ private static String escape(String s) { @@ -347,15 +346,15 @@ class ResultManager { sb.append(ca, start, i - start); sb.append(">"); start = i + 1; - break; + break; case '&': sb.append(ca, start, i - start); sb.append("&"); start = i + 1; - break; + break; } } - return start > 0 ? sb.toString() : s; + return start > 0 ? sb.toString() : s; } } http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/MiniDFS.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/MiniDFS.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/MiniDFS.java index 345a6b5..880ca2c 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/MiniDFS.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/MiniDFS.java @@ -59,6 +59,7 @@ public class MiniDFS { if (dfs.exists(dest)) { System.err.println("Test files copied to HDFS successfully"); } + dfs.close(); } public void shutdownHDFS() { http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCase.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCase.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCase.java index 1fd051a..d6046f1 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCase.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCase.java @@ -17,7 +17,6 @@ package org.apache.vxquery.xtest; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -36,8 +35,8 @@ public class TestCase { public TestCase(TestConfiguration config) { this.tConfig = config; - extVars = new HashMap<QName, File>(); - expectedResults = new ArrayList<ExpectedResult>(); + extVars = new HashMap<>(); + expectedResults = new ArrayList<>(); } public TestConfiguration getConfig() { @@ -92,6 +91,7 @@ public class TestCase { this.expectedResults.add(expectedResult); } + @Override public String toString() { return getXQueryDisplayName(); } http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseFactory.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseFactory.java index a948e23..8fbcb7e 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseFactory.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseFactory.java @@ -18,15 +18,16 @@ import java.util.concurrent.ExecutorService; public class TestCaseFactory extends AbstractTestCaseFactory { - public TestRunnerFactory trf; - public ExecutorService eSvc; + private TestRunnerFactory trf; + private ExecutorService eSvc; public TestCaseFactory(TestRunnerFactory trf, ExecutorService eSvc, XTestOptions opts) { super(opts); this.trf = trf; this.eSvc = eSvc; } - + + @Override protected void submit(TestCase tc) { if (submitTestCase(tc)) { if (opts.verbose) { http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseResult.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseResult.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseResult.java index 86c8530..48e4f00 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseResult.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestCaseResult.java @@ -17,7 +17,6 @@ package org.apache.vxquery.xtest; import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.io.StringWriter; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,7 +25,11 @@ import org.apache.vxquery.exceptions.SystemException; public class TestCaseResult { private static final int DISPLAY_LEN = 1000; - private static Pattern XML_RES_PREFIX = Pattern.compile("<\\?[xX][mM][lL][^\\?]*\\?>"); + private static final Pattern XML_RES_PREFIX = Pattern.compile("<\\?[xX][mM][lL][^\\?]*\\?>"); + + private static final String RED = "#FF9900"; + private static final String ORANGE = "#FFCC00"; + private static final String GREEN = "#99CC00"; TestCase testCase; @@ -122,12 +125,13 @@ public class TestCaseResult { if (cmp) { return Pair.<Boolean, String> of(Boolean.TRUE, "Got expected result"); } else { - return Pair.<Boolean, String> of(Boolean.FALSE, "Expected: " + truncate(expRes) + " Got: " - + truncate(actRes)); + return Pair.<Boolean, String> of(Boolean.FALSE, + "Expected: " + truncate(expRes) + " Got: " + truncate(actRes)); } } - private String truncate(String str) { + private String truncate(String strArg) { + String str = strArg; if (str == null) { return "<NULL>"; } @@ -172,25 +176,22 @@ public class TestCaseResult { } private String slurpFile(File f) { - StringWriter out = new StringWriter(); + StringBuilder content = new StringBuilder(); try { FileReader in = new FileReader(f); try { char[] buffer = new char[8192]; int c; while ((c = in.read(buffer)) >= 0) { - out.write(buffer, 0, c); + content.append(buffer, 0, c); } } finally { - try { - in.close(); - } catch (IOException e) { - } + in.close(); } } catch (IOException e) { return null; } - return out.toString(); + return content.toString(); } public enum State { @@ -215,7 +216,4 @@ public class TestCaseResult { } } - private static final String RED = "#FF9900"; - private static final String ORANGE = "#FFCC00"; - private static final String GREEN = "#99CC00"; } http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestConfiguration.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestConfiguration.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestConfiguration.java index 80ebe4d..5c3a442 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestConfiguration.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestConfiguration.java @@ -33,5 +33,5 @@ public class TestConfiguration { String xqueryxFileExtension; - Map<String, File> sourceFileMap = new HashMap<String, File>(); + Map<String, File> sourceFileMap = new HashMap<>(); } http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java index 5b6ddff..4f7962e 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunner.java @@ -19,6 +19,7 @@ import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.InetAddress; +import java.net.UnknownHostException; import java.util.EnumSet; import java.util.Map; import java.util.regex.Matcher; @@ -66,10 +67,11 @@ public class TestRunner { private NodeControllerService nc1; private IHyracksClientConnection hcc; private IHyracksDataset hds; - private final String publicAddress = InetAddress.getLocalHost().getHostAddress(); + private final String publicAddress; - public TestRunner(XTestOptions opts) throws Exception { + public TestRunner(XTestOptions opts) throws UnknownHostException { this.opts = opts; + this.publicAddress = InetAddress.getLocalHost().getHostAddress(); } public void open() throws Exception { @@ -111,10 +113,11 @@ public class TestRunner { try { try { - FileInputStream query = new FileInputStream(testCase.getXQueryFile()); if (opts.showQuery) { + FileInputStream query = new FileInputStream(testCase.getXQueryFile()); System.err.println("***Query for " + testCase.getXQueryDisplayName() + ": "); System.err.println(IOUtils.toString(query, "UTF-8")); + query.close(); } VXQueryCompilationListener listener = new VXQueryCompilationListener(opts.showAST, opts.showTET, http://git-wip-us.apache.org/repos/asf/vxquery/blob/9e4e9905/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java ---------------------------------------------------------------------- diff --git a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java index 197e9ae..45b2276 100644 --- a/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java +++ b/vxquery-xtest/src/main/java/org/apache/vxquery/xtest/TestRunnerFactory.java @@ -26,7 +26,7 @@ public class TestRunnerFactory { public TestRunnerFactory(XTestOptions opts) throws Exception { tr = new TestRunner(opts); tr.open(); - reporters = new ArrayList<ResultReporter>(); + reporters = new ArrayList<>(); } public void registerReporter(ResultReporter reporter) {
