KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > kernel > mx4j > PetalsCommandProcessorTest


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: PetalsCommandProcessorTest.java 4:33:51 PM ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.kernel.mx4j;
23
24 import javax.management.MBeanServer JavaDoc;
25 import javax.xml.parsers.DocumentBuilder JavaDoc;
26
27 import junit.framework.TestCase;
28 import mx4j.tools.adaptor.http.ServerCommandProcessor;
29
30 import org.easymock.classextension.EasyMock;
31
32 /**
33  * Test of the PetalsCommandProcessor
34  *
35  * @author ddesjardins - eBMWebsourcing
36  */

37 public class PetalsCommandProcessorTest extends TestCase {
38
39 // public void testExecuteRequest() throws ParserConfigurationException,
40
// SAXException, IOException, JMException, TransformerException {
41
// String baseDir = this.getClass().getResource(".").toString();
42
// baseDir = baseDir.substring(0, baseDir.indexOf("target"));
43
// baseDir = baseDir.substring(baseDir.indexOf(":") + 1);
44
//
45
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
46
// DocumentBuilder builder = factory.newDocumentBuilder();
47
// Document document = builder.parse(new File(baseDir + File.separator
48
// + "src" + File.separator + "test-data" + File.separator + "mx4j"
49
// + File.separator + "server.xml"));
50
//
51
// PetalsCommandProcessor petalsCommandProcessor = new PetalsCommandProcessor();
52
//
53
// ServerCommandProcessor serverCommandProcessor = EasyMock
54
// .createMock(ServerCommandProcessor.class);
55
//
56
// EasyMock.expect(serverCommandProcessor.executeRequest(null)).andReturn(
57
// document).anyTimes();
58
//
59
// EasyMock.replay(serverCommandProcessor);
60
//
61
// petalsCommandProcessor.serverCommandProcessor = serverCommandProcessor;
62
// petalsCommandProcessor.documentBuilder = builder;
63
//
64
// Document doc = petalsCommandProcessor.executeRequest(null);
65
//
66
// String xmlResult = FileUtils
67
// .readFileToString(new File(baseDir + File.separator + "src"
68
// + File.separator + "test-data" + File.separator + "mx4j"
69
// + File.separator + "result.xml"), "UTF-8");
70
// assertEquals(xmlResult, XMLUtil.createStringFromDOMDocument(doc));
71
// }
72

73     public void testSetDocumentBuilder() {
74         PetalsCommandProcessor petalsCommandProcessor = new PetalsCommandProcessor();
75         DocumentBuilder JavaDoc documentBuilder = EasyMock
76             .createMock(DocumentBuilder JavaDoc.class);
77
78         petalsCommandProcessor.setDocumentBuilder(documentBuilder);
79
80         assertEquals(petalsCommandProcessor.documentBuilder, documentBuilder);
81     }
82
83     public void testSetMBeanServer() {
84         PetalsCommandProcessor petalsCommandProcessor = new PetalsCommandProcessor();
85         MBeanServer JavaDoc mBeanServer = EasyMock.createMock(MBeanServer JavaDoc.class);
86
87         ServerCommandProcessor serverCommandProcessor = EasyMock
88             .createMock(ServerCommandProcessor.class);
89         
90         serverCommandProcessor.setMBeanServer(mBeanServer);
91
92         EasyMock.replay(serverCommandProcessor);
93         petalsCommandProcessor.serverCommandProcessor = serverCommandProcessor;
94
95         petalsCommandProcessor.setMBeanServer(mBeanServer);
96     }
97
98 }
99
Popular Tags