1 18 package sync4j.test.tools.ant; 19 20 import java.io.*; 21 import java.util.ArrayList ; 22 23 import org.apache.tools.ant.Project; 24 import org.apache.tools.ant.BuildException; 25 import org.apache.tools.ant.types.PatternSet; 26 import org.apache.tools.ant.taskdefs.*; 27 28 import sync4j.framework.tools.IOTools; 29 import sync4j.test.TestFailedException; 30 import sync4j.test.tools.PostWBXMLSyncML; 31 32 33 53 public class TestSyncMLWBXMLTask extends TestSyncMLBaseTask { 54 55 57 59 public void execute() throws BuildException { 60 validateAttributes(); 64 65 ArrayList allExcludeXPaths = new ArrayList (); 71 72 PatternSet ps = null; 73 String [] xpaths = null; 74 for (int i = 0; i < xpathPatterns.size(); i++) { 75 ps = (PatternSet) xpathPatterns.get(i); 76 xpaths = ps.getExcludePatterns(getProject()); 77 for (int j = 0; j < xpaths.length; ++j) { 78 allExcludeXPaths.add(xpaths[j]); 79 } 80 } 82 log("Initial URL: " + url ); 83 log("Test: " + test ); 84 log("Ignored XPaths: " + allExcludeXPaths); 85 86 xpaths = (String [])allExcludeXPaths.toArray(new String [0]); 87 88 Ant antTask = loadAntTask(test); 89 FilenameFilter filter = IOTools.getFileTypeFilter("wbxml"); 93 94 String [] msgFiles = new File(basedir, test).list(filter); 95 if (antTask != null) { 96 System.out.println("execute antTask != null"); 97 System.out.println("test: " + test); 98 99 msgFiles = removeBuildFile(msgFiles); 100 } 101 102 msgFiles = ordersAndFilterFiles(new File(basedir, test).list(filter)); 103 104 try { 105 new PostWBXMLSyncML( 106 url , 107 new File(basedir, test), 108 msgFiles , 109 xpaths , 110 antTask 111 ).syncAndTest(); 112 113 log("Test " + test + " passed!"); 114 } catch (IOException e) { 115 log(e.getMessage(), Project.MSG_ERR); 116 throw new BuildException("Error executing PostSyncMLTask", e); 117 } catch (TestFailedException e) { 118 log("Test " + test + " failed: " + e.getMessage(), Project.MSG_INFO); 119 } 120 } 121 122 } 123 | Popular Tags |