[testng] 71/160: Create dedicated interface SuiteParser
Eugene Zhukov
eugene-guest at moszumanska.debian.org
Tue Aug 18 10:22:23 UTC 2015
This is an automated email from the git hooks/post-receive script.
eugene-guest pushed a commit to annotated tag testng-6.9.5
in repository testng.
commit 327eccfdab58a581072a9661c8a7ef98e241a39b
Author: Julien Herr <julien.herr at alcatel-lucent.com>
Date: Fri Jun 5 00:33:37 2015 +0200
Create dedicated interface SuiteParser
---
src/main/java/org/testng/internal/YamlParser.java | 4 ++--
src/main/java/org/testng/xml/IFileParser.java | 1 -
src/main/java/org/testng/xml/Parser.java | 6 +++---
src/main/java/org/testng/xml/SuiteParser.java | 6 ++++++
src/main/java/org/testng/xml/SuiteXmlParser.java | 7 +++++--
src/main/java/org/testng/xml/XMLParser.java | 5 -----
src/main/java/org/testng/xml/dom/DomXmlParser.java | 8 +++++++-
7 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/testng/internal/YamlParser.java b/src/main/java/org/testng/internal/YamlParser.java
index 8562407..2877acd 100644
--- a/src/main/java/org/testng/internal/YamlParser.java
+++ b/src/main/java/org/testng/internal/YamlParser.java
@@ -1,13 +1,13 @@
package org.testng.internal;
import org.testng.TestNGException;
-import org.testng.xml.IFileParser;
+import org.testng.xml.SuiteParser;
import org.testng.xml.XmlSuite;
import java.io.FileNotFoundException;
import java.io.InputStream;
-public class YamlParser implements IFileParser<XmlSuite> {
+public class YamlParser implements SuiteParser {
@Override
public XmlSuite parse(String filePath, InputStream is, boolean loadClasses)
diff --git a/src/main/java/org/testng/xml/IFileParser.java b/src/main/java/org/testng/xml/IFileParser.java
index 20a5475..e18bc48 100644
--- a/src/main/java/org/testng/xml/IFileParser.java
+++ b/src/main/java/org/testng/xml/IFileParser.java
@@ -7,6 +7,5 @@ import java.io.InputStream;
public interface IFileParser<T> {
T parse(String filePath, InputStream is, boolean loadClasses) throws TestNGException;
- boolean accept(String fileName);
}
diff --git a/src/main/java/org/testng/xml/Parser.java b/src/main/java/org/testng/xml/Parser.java
index c10af28..908bdd8 100755
--- a/src/main/java/org/testng/xml/Parser.java
+++ b/src/main/java/org/testng/xml/Parser.java
@@ -33,8 +33,8 @@ public class Parser {
/** The default file name for the TestNG test suite if none is specified (testng.xml). */
public static final String DEFAULT_FILENAME = "testng.xml";
- private static final IFileParser<XmlSuite> DEFAULT_FILE_PARSER = new SuiteXmlParser();
- private static final List<IFileParser<XmlSuite>> PARSERS = Lists.newArrayList(DEFAULT_FILE_PARSER, new YamlParser());
+ private static final SuiteParser DEFAULT_FILE_PARSER = new SuiteXmlParser();
+ private static final List<SuiteParser> PARSERS = Lists.newArrayList(DEFAULT_FILE_PARSER, new YamlParser());
/** The file name of the xml suite being parsed. This may be null if the Parser
* has not been initialized with a file name. TODO CQ This member is never used. */
@@ -110,7 +110,7 @@ public class Parser {
// }
private static IFileParser getParser(String fileName) {
- for (IFileParser<XmlSuite> parser : PARSERS) {
+ for (SuiteParser parser : PARSERS) {
if (parser.accept(fileName)) {
return parser;
}
diff --git a/src/main/java/org/testng/xml/SuiteParser.java b/src/main/java/org/testng/xml/SuiteParser.java
new file mode 100644
index 0000000..7bb8de1
--- /dev/null
+++ b/src/main/java/org/testng/xml/SuiteParser.java
@@ -0,0 +1,6 @@
+package org.testng.xml;
+
+public interface SuiteParser extends IFileParser<XmlSuite> {
+
+ boolean accept(String fileName);
+}
diff --git a/src/main/java/org/testng/xml/SuiteXmlParser.java b/src/main/java/org/testng/xml/SuiteXmlParser.java
index 38ebfdc..bfe0144 100644
--- a/src/main/java/org/testng/xml/SuiteXmlParser.java
+++ b/src/main/java/org/testng/xml/SuiteXmlParser.java
@@ -7,7 +7,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-public class SuiteXmlParser extends XMLParser<XmlSuite> {
+public class SuiteXmlParser extends XMLParser<XmlSuite> implements SuiteParser {
@Override
public XmlSuite parse(String currentFile, InputStream inputStream, boolean loadClasses) {
@@ -22,5 +22,8 @@ public class SuiteXmlParser extends XMLParser<XmlSuite> {
}
}
-
+ @Override
+ public boolean accept(String fileName) {
+ return fileName.endsWith(".xml");
+ }
}
diff --git a/src/main/java/org/testng/xml/XMLParser.java b/src/main/java/org/testng/xml/XMLParser.java
index cce1352..9e59430 100644
--- a/src/main/java/org/testng/xml/XMLParser.java
+++ b/src/main/java/org/testng/xml/XMLParser.java
@@ -101,11 +101,6 @@ abstract public class XMLParser<T> implements IFileParser<T> {
return false;
}
- @Override
- public boolean accept(String fileName) {
- return fileName.endsWith(".xml");
- }
-
// private static void ppp(String s) {
// System.out.println("[Parser] " + s);
// }
diff --git a/src/main/java/org/testng/xml/dom/DomXmlParser.java b/src/main/java/org/testng/xml/dom/DomXmlParser.java
index 86dc3e8..1ad59c2 100644
--- a/src/main/java/org/testng/xml/dom/DomXmlParser.java
+++ b/src/main/java/org/testng/xml/dom/DomXmlParser.java
@@ -1,5 +1,6 @@
package org.testng.xml.dom;
+import org.testng.xml.SuiteParser;
import org.testng.xml.XMLParser;
import org.testng.xml.XmlSuite;
import org.w3c.dom.Document;
@@ -13,7 +14,7 @@ import javax.xml.xpath.XPathExpressionException;
import java.io.IOException;
import java.io.InputStream;
-public class DomXmlParser extends XMLParser<XmlSuite> {
+public class DomXmlParser extends XMLParser<XmlSuite> implements SuiteParser {
@Override
public XmlSuite parse(String currentFile, InputStream inputStream, boolean loadClasses) {
XmlSuite result = null;
@@ -26,6 +27,11 @@ public class DomXmlParser extends XMLParser<XmlSuite> {
return result;
}
+ @Override
+ public boolean accept(String fileName) {
+ return fileName.endsWith(".xml");
+ }
+
public XmlSuite parse2(String currentFile, InputStream inputStream,
boolean loadClasses) throws ParserConfigurationException, SAXException,
IOException, XPathExpressionException {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/testng.git
More information about the pkg-java-commits
mailing list