KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > impl > TestTranslatorManager


1 // Copyright 2004, 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.impl;
16
17 import java.util.Collections JavaDoc;
18 import java.util.List JavaDoc;
19
20 import org.apache.hivemind.ApplicationRuntimeException;
21 import org.apache.hivemind.ErrorHandler;
22 import org.apache.hivemind.test.HiveMindTestCase;
23
24 /**
25  * Tests for {@link org.apache.hivemind.impl.TranslatorManagerImpl}.
26  *
27  * @author Howard Lewis Ship
28  */

29 public class TestTranslatorManager extends HiveMindTestCase
30 {
31     public void testNoClassOrService()
32     {
33         TranslatorContribution tc = new TranslatorContribution();
34         tc.setName("invalid");
35
36         List JavaDoc l = Collections.singletonList(tc);
37
38         ErrorHandler eh = (ErrorHandler) newMock(ErrorHandler.class);
39
40         eh
41                 .error(
42                         TranslatorManagerImpl.LOG,
43                         "Translator contribution 'invalid' must specify either the service-id or class attribute.",
44                         null,
45                         null);
46
47         replayControls();
48
49         TranslatorManagerImpl tm = new TranslatorManagerImpl(l, eh);
50
51         try
52         {
53             tm.getTranslator("invalid");
54             unreachable();
55         }
56         catch (ApplicationRuntimeException ex)
57         {
58             assertExceptionSubstring(
59                     ex,
60                     "No translator named 'invalid' has been registered in configuration point hivemind.Translators.");
61         }
62
63         verifyControls();
64     }
65 }
Popular Tags