KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > management > impl > TestObjectNameEditor


1 // Copyright 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.management.impl;
16
17 import javax.management.ObjectName JavaDoc;
18
19 import junit.framework.TestCase;
20
21 /**
22  * Test of {@link org.apache.hivemind.management.impl.ObjectNameEditor}
23  *
24  * @author Achim Huegen
25  */

26 public class TestObjectNameEditor extends TestCase
27 {
28     public void testSetAsText()
29     {
30         ObjectNameEditor editor = new ObjectNameEditor();
31         editor.setAsText("Hivemind:name=test");
32         ObjectName JavaDoc objectName = (ObjectName JavaDoc) editor.getValue();
33
34         assertEquals("Hivemind:name=test", objectName.toString());
35     }
36
37     public void testMalformed()
38     {
39         ObjectNameEditor editor = new ObjectNameEditor();
40         try
41         {
42             editor.setAsText("Hivemind=test:fail");
43             fail();
44         }
45         catch (IllegalArgumentException JavaDoc ignore)
46         {
47         }
48     }
49
50     public void testGetAsText() throws Exception JavaDoc
51     {
52         ObjectNameEditor editor = new ObjectNameEditor();
53         editor.setValue(new ObjectName JavaDoc("Hivemind:name=test"));
54
55         assertEquals("Hivemind:name=test", editor.getAsText());
56     }
57 }
58
Popular Tags