Skip to content

Commit

Permalink
Merge branch 'i312-novalidation-1.2.1' into release-1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed May 31, 2011
2 parents 5a164c6 + 687ec1c commit f5f8e86
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.io.File;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -98,25 +99,35 @@ public void doAction() {
project.addBuildListener(listener.getBuildListener());
debug("added build listener");
}
final Collection<INodeEntry> c;
try {
c = getFramework().filterNodes(getContext().getNodeSet(),getContext().getFrameworkProject());
} catch (NodeFileParserException e) {
throw new CoreException("Error parsing node resource file: " + e.getMessage(), e);
}
if (0 == c.size()) {
throw new NodesetEmptyException(getContext().getNodeSet());
}

debug("number of nodes to dispatch to: " + c.size() + ", (threadcount="
+ getContext().getNodeSet().getThreadCount() + ")");

final INodeEntry singleNode;
if (1 == c.size()) {
singleNode = c.iterator().next();
} else {
final Collection<INodeEntry> c;
if(null!=getContext().getNodeSet().getSingleNodeName()){
//get the single node
try{
singleNode= getFramework().getFrameworkProjectMgr().getFrameworkProject(getContext().getFrameworkProject()).getNodes().getNode(
getContext().getNodeSet().getSingleNodeName());
} catch (NodeFileParserException e) {
throw new CoreException("Error parsing node resource file: " + e.getMessage(), e);
}
if(null!=singleNode){
c = Collections.singleton(singleNode);
}else{
throw new NodesetEmptyException(getContext().getNodeSet());
}
}else{
try {
c = getFramework().filterNodes(getContext().getNodeSet(),getContext().getFrameworkProject());
} catch (NodeFileParserException e) {
throw new CoreException("Error parsing node resource file: " + e.getMessage(), e);
}
if (0 == c.size()) {
throw new NodesetEmptyException(getContext().getNodeSet());
}
singleNode = null;
debug("number of nodes to dispatch to: " + c.size() + ", (threadcount="
+ getContext().getNodeSet().getThreadCount() + ")");
}

final String fwkNodeName =
null != singleNode ? singleNode.getNodename() : getFramework().getFrameworkNodeName();
final String fwkUser = null != singleNode ? singleNode.extractUserName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ private static String joinStrings(final Set tags, final String delim) {
* @throws IOException
*/
public void generate() throws IOException {
final Document doc = DocumentFactory.getInstance().createDocument().addDocType("project",
DTD_PROJECT_DOCUMENT_1_0_EN, "project.dtd");
final Document doc = DocumentFactory.getInstance().createDocument();
final Element root = doc.addElement("project");
//iterate through entities in correct order
for (final ResourceXMLParser.Entity entity : entities) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public ResourceXMLParser(final boolean validate, final File file) {
*/
public void parse() throws ResourceXMLParserException, FileNotFoundException {
final EntityResolver resolver = createEntityResolver();
final SAXReader reader = new SAXReader(validate);
final SAXReader reader = new SAXReader(false);
reader.setEntityResolver(resolver);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ protected void setUp() throws Exception {
new File("build/test-target").mkdirs();
test1 = new File("build/test-target/TestResourceXMLGenerator-test1.xml");
test2 = new File("build/test-target/doesnotexist/test.xml");
reader = new SAXReader(true);
reader.setEntityResolver(ResourceXMLParser.createEntityResolver());
reader = new SAXReader(false);
}

protected void tearDown() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ public void resourcesParsed(ResourceXMLParser.EntitySet entities) {
final ResourceXMLParser resourceXMLParser = new ResourceXMLParser(false, testfile4);
resourceXMLParser.parse();
}
{ //testfile4 has no doctype declaration
/*{ //testfile4 has no doctype declaration
//do validate, should fail with no doctype
final ResourceXMLParser resourceXMLParser = new ResourceXMLParser(true, testfile4);
try {
Expand All @@ -586,7 +586,7 @@ public void resourcesParsed(ResourceXMLParser.EntitySet entities) {
} catch (ResourceXMLParserException e) {
assertNotNull(e);
}
}
}*/
{//testfile5 has valid doctype declaration
//do not validate, should parse fine
final ResourceXMLParser resourceXMLParser = new ResourceXMLParser(false, testfile5);
Expand All @@ -602,7 +602,7 @@ public void resourcesParsed(ResourceXMLParser.EntitySet entities) {
final ResourceXMLParser resourceXMLParser = new ResourceXMLParser(false, invalidfile1);
resourceXMLParser.parse();
}
{//invalidfile1 has incorrect root element
/*{//invalidfile1 has incorrect root element
//do validate, should fail validation
final ResourceXMLParser resourceXMLParser = new ResourceXMLParser(true, invalidfile1);
try {
Expand All @@ -611,13 +611,13 @@ public void resourcesParsed(ResourceXMLParser.EntitySet entities) {
} catch (ResourceXMLParserException e) {
assertNotNull(e);
}
}
}*/
{//invalidfile12 has incorrect child element
//do not validate, will not fail with extra XML content
final ResourceXMLParser resourceXMLParser = new ResourceXMLParser(false, invalidfile2);
resourceXMLParser.parse();
}
{//invalidfile2 has incorrect child element
/* {//invalidfile2 has incorrect child element
//do validate, should fail validation
final ResourceXMLParser resourceXMLParser = new ResourceXMLParser(true, invalidfile2);
try {
Expand All @@ -626,6 +626,6 @@ public void resourcesParsed(ResourceXMLParser.EntitySet entities) {
} catch (ResourceXMLParserException e) {
assertNotNull(e);
}
}
}*/
}
}

0 comments on commit f5f8e86

Please sign in to comment.