1 22 package org.objectweb.petals.jbi.management.service.util; 23 24 import java.io.File ; 25 import java.io.FileInputStream ; 26 import java.io.FileNotFoundException ; 27 import java.net.MalformedURLException ; 28 29 import org.objectweb.petals.jbi.management.service.util.XMLResult.CauseFramework; 30 import org.objectweb.petals.jbi.management.service.util.XMLResult.MessageType; 31 import org.objectweb.petals.jbi.management.service.util.XMLResult.TaskResult; 32 33 import junit.framework.TestCase; 34 35 40 public class XMLResultTest extends TestCase { 41 42 public void testXMLResult() throws FileNotFoundException , 43 MalformedURLException { 44 String baseDir = this.getClass().getResource(".").toString(); 45 baseDir = baseDir.substring(0, baseDir.indexOf("target")); 46 baseDir = baseDir.substring(baseDir.indexOf(":") + 1); 47 XMLResult xmlResult = new XMLResult("test"); 48 xmlResult 49 .addFrameworkTaskResult(TaskResult.SUCCESS, CauseFramework.YES); 50 assertTrue(XMLResult.isValidComponentTask(xmlResult.getString(), 51 new FileInputStream (baseDir + "src" + File.separator + "resources" 52 + File.separator + "schema" + File.separator 53 + "management-message.xsd"))); 54 } 55 56 public void testXMLResult1() throws FileNotFoundException , 57 MalformedURLException { 58 String baseDir = this.getClass().getResource(".").toString(); 59 baseDir = baseDir.substring(0, baseDir.indexOf("target")); 60 baseDir = baseDir.substring(baseDir.indexOf(":") + 1); 61 XMLResult xmlResult = new XMLResult("test"); 62 xmlResult.addFrameworkTaskResult(TaskResult.SUCCESS, MessageType.INFO, 63 "test", new String [] {"test"}, CauseFramework.YES); 64 assertTrue(XMLResult.isValidComponentTask(xmlResult.getString(), 65 new FileInputStream (baseDir + "src" + File.separator + "resources" 66 + File.separator + "schema" + File.separator 67 + "management-message.xsd"))); 68 } 69 70 public void testXMLResult2() throws FileNotFoundException { 71 String baseDir = this.getClass().getResource(".").toString(); 72 baseDir = baseDir.substring(0, baseDir.indexOf("target")); 73 baseDir = baseDir.substring(baseDir.indexOf(":") + 1); 74 XMLResult xmlResult = new XMLResult("test"); 75 xmlResult.addFrameworkTaskResult(TaskResult.SUCCESS, MessageType.INFO, 76 "test", new String [] {"test"}, "1", "exception", 77 new String [] {"test"}, CauseFramework.YES); 78 assertTrue(XMLResult.isValidComponentTask(xmlResult.getString(), 79 new FileInputStream (baseDir + "src" + File.separator + "resources" 80 + File.separator + "schema" + File.separator 81 + "management-message.xsd"))); 82 } 83 84 } 85 | Popular Tags |