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.PostSyncML; 31 32 33 54 public class TestSyncMLTask extends TestSyncMLBaseTask { 55 56 58 59 61 public void execute() throws BuildException { 62 validateAttributes(); 66 67 ArrayList allExcludeXPaths = new ArrayList (); 73 74 PatternSet ps = null; 75 String [] xpaths = null; 76 for (int i = 0; i < xpathPatterns.size(); i++) { 77 ps = (PatternSet) xpathPatterns.get(i); 78 xpaths = ps.getExcludePatterns(getProject()); 79 for (int j = 0; j < xpaths.length; ++j) { 80 allExcludeXPaths.add(xpaths[j]); 81 } 82 } 84 log("Initial URL: " + url ); 85 log("Test: " + test ); 86 log("Ignored XPaths: " + allExcludeXPaths); 87 88 xpaths = (String [])allExcludeXPaths.toArray(new String [0]); 89 90 Ant antTask = loadAntTask(test); 91 FilenameFilter filter = IOTools.getFileTypeFilter(".xml"); 95 96 String [] msgFiles = new File(basedir, test).list(filter); 97 98 if (antTask != null) { 99 System.out.println("execute antTask != null"); 100 System.out.println("test: " + test); 101 102 msgFiles = removeBuildFile(msgFiles); 103 } 104 105 msgFiles = ordersAndFilterFiles(new File(basedir, test).list(filter)); 106 107 try { 108 new PostSyncML( 109 url , 110 new File(basedir, test), 111 msgFiles , 112 xpaths , 113 antTask 114 ).syncAndTest(); 115 116 log("Test " + test + " passed!"); 117 } catch (IOException e) { 118 log(e.getMessage(), Project.MSG_ERR); 119 throw new BuildException("Error executing PostSyncMLTask", e); 120 } catch (TestFailedException e) { 121 log("Test " + test + " failed: " + e.getMessage(), Project.MSG_INFO); 122 } 123 } 124 125 } 126 | Popular Tags |