1 7 package fr.jayasoft.ivy.report; 8 9 import java.io.ByteArrayOutputStream ; 10 import java.io.File ; 11 12 import junit.framework.TestCase; 13 14 import org.apache.tools.ant.Project; 15 import org.apache.tools.ant.taskdefs.Delete; 16 17 import fr.jayasoft.ivy.Ivy; 18 19 public class XmlReportOutputterTest extends TestCase { 20 private final Ivy _ivy; 21 private File _cache; 22 23 public XmlReportOutputterTest() throws Exception { 24 _ivy = new Ivy(); 25 _ivy.configure(new File ("test/repositories/ivyconf.xml")); 26 } 27 28 protected void setUp() throws Exception { 29 createCache(); 30 } 31 32 private void createCache() { 33 _cache = new File ("build/cache"); 34 _cache.mkdirs(); 35 } 36 37 protected void tearDown() throws Exception { 38 cleanCache(); 39 } 40 41 private void cleanCache() { 42 Delete del = new Delete(); 43 del.setProject(new Project()); 44 del.setDir(_cache); 45 del.execute(); 46 } 47 48 public void testWriteOrigin() throws Exception { 49 ResolveReport report = _ivy.resolve(new File ("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURL(), 50 null, new String [] {"default"}, _cache, null, true); 51 assertNotNull(report); 52 53 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 54 XmlReportOutputter outputter = new XmlReportOutputter(); 55 outputter.output(report.getConfigurationReport("default"), buffer); 56 buffer.flush(); 57 String xml = buffer.toString(); 58 59 String expectedLocation = "location=\"" + new File ("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").getAbsolutePath() + "\""; 60 String expectedIsLocal = "is-local=\"true\""; 61 62 assertTrue("XML doesn't contain artifact location attribute", xml.indexOf(expectedLocation) != -1); 63 assertTrue("XML doesn't contain artifact is-local attribute", xml.indexOf(expectedIsLocal) != -1); 64 } 65 } 66 | Popular Tags |