KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > management > service > util > XMLResultTest


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: XMLManagementMessageTest.java 17:20:10 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.jbi.management.service.util;
23
24 import java.io.File JavaDoc;
25 import java.io.FileInputStream JavaDoc;
26 import java.io.FileNotFoundException JavaDoc;
27 import java.net.MalformedURLException JavaDoc;
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 /**
36  * Test of the XMLManagementMessage
37  *
38  * @author ddesjardins - eBMWebsourcing
39  */

40 public class XMLResultTest extends TestCase {
41
42     public void testXMLResult() throws FileNotFoundException JavaDoc,
43         MalformedURLException JavaDoc {
44         String JavaDoc 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 JavaDoc(baseDir + "src" + File.separator + "resources"
52                 + File.separator + "schema" + File.separator
53                 + "management-message.xsd")));
54     }
55
56     public void testXMLResult1() throws FileNotFoundException JavaDoc,
57         MalformedURLException JavaDoc {
58         String JavaDoc 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 JavaDoc[] {"test"}, CauseFramework.YES);
64         assertTrue(XMLResult.isValidComponentTask(xmlResult.getString(),
65             new FileInputStream JavaDoc(baseDir + "src" + File.separator + "resources"
66                 + File.separator + "schema" + File.separator
67                 + "management-message.xsd")));
68     }
69
70     public void testXMLResult2() throws FileNotFoundException JavaDoc {
71         String JavaDoc 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 JavaDoc[] {"test"}, "1", "exception",
77             new String JavaDoc[] {"test"}, CauseFramework.YES);
78         assertTrue(XMLResult.isValidComponentTask(xmlResult.getString(),
79             new FileInputStream JavaDoc(baseDir + "src" + File.separator + "resources"
80                 + File.separator + "schema" + File.separator
81                 + "management-message.xsd")));
82     }
83
84 }
85
Popular Tags