KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > kernel > registry > RegistryServerTest


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

22 package org.objectweb.petals.kernel.registry;
23
24 import java.lang.reflect.Method JavaDoc;
25 import java.util.HashMap JavaDoc;
26 import java.util.Map JavaDoc;
27
28 import junit.framework.TestCase;
29
30 import org.easymock.classextension.EasyMock;
31 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
32 import org.objectweb.petals.kernel.registry.msg.response.ExceptionResponse;
33 import org.objectweb.petals.util.LoggingUtil;
34
35 /**
36  * Tests of the RegistryServer
37  *
38  * @author ddesjardins - eBMWebsourcing
39  */

40 public class RegistryServerTest extends TestCase {
41
42     public void testProcessResponseException() {
43         RegistryServer server = new RegistryServer();
44         ExceptionResponse exceptionResponse = new ExceptionResponse(
45             new RuntimeException JavaDoc(), 0, 0);
46         assertNull(server.processResponse(exceptionResponse));
47     }
48
49     public void testSetData() {
50         RegistryServer server = new RegistryServer();
51         Map JavaDoc<String JavaDoc, Map JavaDoc<String JavaDoc, Object JavaDoc>> map = new HashMap JavaDoc<String JavaDoc, Map JavaDoc<String JavaDoc, Object JavaDoc>>();
52         server.setData(map);
53         assertEquals(server.getData(), map);
54     }
55
56     public void testStart() throws SecurityException JavaDoc, NoSuchMethodException JavaDoc,
57         IllegalLifeCycleException {
58         RegistryServer server = EasyMock.createMock(RegistryServer.class,
59             new Method JavaDoc[] {RegistryServer.class.getDeclaredMethod("startServer",
60                 new Class JavaDoc[0])});
61         LoggingUtil loggingUtil = EasyMock.createMock(LoggingUtil.class);
62
63         loggingUtil.call();
64         server.startServer();
65
66         EasyMock.replay(loggingUtil);
67         EasyMock.replay(server);
68
69         server.log = loggingUtil;
70
71         server.start();
72     }
73
74     public void testStop() throws SecurityException JavaDoc, NoSuchMethodException JavaDoc,
75         IllegalLifeCycleException {
76         RegistryServer server = EasyMock.createMock(RegistryServer.class,
77             new Method JavaDoc[] {RegistryServer.class.getDeclaredMethod("stopServer",
78                 new Class JavaDoc[0])});
79         LoggingUtil loggingUtil = EasyMock.createMock(LoggingUtil.class);
80
81         loggingUtil.start();
82         server.stopServer();
83         loggingUtil.end();
84
85         EasyMock.replay(loggingUtil);
86         EasyMock.replay(server);
87
88         server.log = loggingUtil;
89
90         server.stop();
91     }
92
93 }
94
Popular Tags