KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > jbi > deployment > SharedLibraryTest


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

17 package org.apache.servicemix.jbi.deployment;
18
19 import org.apache.servicemix.jbi.config.DebugClassPathXmlApplicationContext;
20 import org.apache.servicemix.jbi.config.spring.XBeanProcessor;
21 import org.apache.servicemix.jbi.deployment.Descriptor;
22 import org.apache.servicemix.jbi.deployment.Identification;
23 import org.apache.servicemix.jbi.deployment.SharedLibrary;
24 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
25 import org.springframework.context.support.AbstractXmlApplicationContext;
26
27 import java.util.Arrays JavaDoc;
28
29 import junit.framework.TestCase;
30
31 /**
32  * @version $Revision: 426415 $
33  */

34 public class SharedLibraryTest extends TestCase {
35
36     protected AbstractXmlApplicationContext context;
37     protected SourceTransformer transformer = new SourceTransformer();
38
39     public void testParse() throws Exception JavaDoc {
40
41         // lets force the JBI container to be constructed first
42
Descriptor root = (Descriptor) context.getBeansOfType(Descriptor.class).values().iterator().next();
43         assertNotNull("JBI Container not found in spring!", root);
44
45         SharedLibrary sl = root.getSharedLibrary();
46         Identification identification = sl.getIdentification();
47         assertEquals("getName", "TestSharedLibrary", identification.getName());
48         assertEquals("getDescription", "This is a test shared library.", identification.getDescription());
49         
50     }
51
52     protected String JavaDoc toString(Object JavaDoc[] objects) {
53         if (objects == null) {
54             return "null Object[]";
55         }
56         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("[");
57         for (int i = 0; i < objects.length; i++) {
58             Object JavaDoc object = objects[i];
59             if (i > 0) {
60                 buffer.append(", ");
61             }
62             buffer.append(object);
63         }
64         buffer.append("]");
65         return buffer.toString();
66     }
67
68     protected void setUp() throws Exception JavaDoc {
69         context = createBeanFactory();
70     }
71
72     protected AbstractXmlApplicationContext createBeanFactory() throws Exception JavaDoc {
73         return new DebugClassPathXmlApplicationContext("org/apache/servicemix/jbi/deployment/SharedLibrary.xml",
74                                                        Arrays.asList(new Object JavaDoc[] { new XBeanProcessor() }));
75     }
76
77 }
78
Popular Tags