KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > service > TestBuilderFactoryBeanService


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.service;
16
17 import org.apache.hivemind.ApplicationRuntimeException;
18 import org.apache.hivemind.BeanA;
19 import org.apache.hivemind.Registry;
20 import org.apache.hivemind.Reverser;
21 import org.apache.hivemind.xml.XmlTestCase;
22
23 /**
24  * Integration tests to prove that the builderFactory supports JavaBeans classes as the "interface" of a
25  * service point.
26  *
27  * @author Howard M. Lewis Ship
28  * @since 1.1
29  */

30 public class TestBuilderFactoryBeanService extends XmlTestCase
31 {
32
33     private void attempt(String JavaDoc name) throws Exception JavaDoc
34     {
35         Registry reg = buildFrameworkRegistry("BeanService.xml");
36
37         Reverser r = (Reverser) reg.getService(name, Reverser.class);
38
39         assertEquals("DNIMEVIH", r.reverse("HIVEMIND"));
40         // Call reverse a second time to check for HIVEMIND-118
41
r.reverse("HIVEMIND");
42         reg.shutdown();
43
44         try
45         {
46             r.reverse("SHUTDOWN");
47             unreachable();
48         }
49         catch (ApplicationRuntimeException ex)
50         {
51         }
52     }
53
54     public void testFactory() throws Exception JavaDoc
55     {
56         attempt("bean.FactoryReverser");
57     }
58
59     public void testAutowireBeanServiceProperty() throws Exception JavaDoc
60     {
61         Registry reg = buildFrameworkRegistry("BeanService.xml");
62         BeanA beanA = ( BeanA )reg.getService( BeanA.class );
63         beanA.methodA();
64     }
65 }
Popular Tags