KickJava   Java API By Example, From Geeks To Geeks.

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


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.ServiceAssembly;
24 import org.apache.servicemix.jbi.deployment.ServiceUnit;
25 import org.springframework.context.support.AbstractXmlApplicationContext;
26
27 import java.util.Arrays JavaDoc;
28
29 import javax.xml.namespace.QName JavaDoc;
30
31 /**
32  * @version $Revision: 426415 $
33  */

34 public class ServiceAssemblyTest extends DeploymentTest {
35
36     public void testParse() throws Exception JavaDoc {
37
38         // lets force the JBI container to be constructed first
39
Descriptor root = (Descriptor) context.getBean("jbi");
40         assertNotNull("JBI Container not found in spring!", root);
41
42         ServiceAssembly serviceAssembly = root.getServiceAssembly();
43         assertNotNull("serviceAssembly is null", serviceAssembly);
44
45         Identification identification = serviceAssembly.getIdentification();
46         assertNotNull("identification is null", identification);
47         assertEquals("getName", "ServiceAssembly_041207153211-0800_saId", identification.getName());
48         assertEquals("getDescription", "Description of Service Assembly : ServiceAssembly", identification.getDescription());
49
50         ServiceUnit[] serviceUnits = serviceAssembly.getServiceUnits();
51         assertNotNull("serviceUnits are null", serviceUnits);
52         assertEquals("serviceUnits size", 4, serviceUnits.length);
53
54         assertEquals("getIdentification().getName() for 0", "TransformationSU_041207152821-0800_suId", serviceUnits[0].getIdentification().getName());
55         assertEquals("getIdentification().getDescription() for 0", "Description of Serviceunit: TransformationSU", serviceUnits[0].getIdentification().getDescription());
56         assertEquals("getTarget().getArtifactsZip() for 0", "TransformationSU.zip", serviceUnits[0].getTarget().getArtifactsZip());
57         assertEquals("getTarget().getComponentName() for 0", "SunTransformationEngine", serviceUnits[0].getTarget().getComponentName());
58
59         assertEquals("getIdentification().getName() for 3", "SequencingEngineSU_041207152507-0800_suId", serviceUnits[3].getIdentification().getName());
60         assertEquals("getIdentification().getDescription() for 3", "Description of Serviceunit: SequencingEngineSU", serviceUnits[3].getIdentification().getDescription());
61         assertEquals("getTarget().getArtifactsZip() for 3", "SequencingEngineSU.zip", serviceUnits[3].getTarget().getArtifactsZip());
62         assertEquals("getTarget().getComponentName() for 3", "SunSequencingEngine", serviceUnits[3].getTarget().getComponentName());
63         
64         Connection[] connections = serviceAssembly.getConnections().getConnections();
65         assertNotNull("connections are null", connections);
66         assertEquals("connections size", 2, connections.length);
67         
68         assertEquals("getConsumer().getServiceName() for 0", new QName JavaDoc("http://www.gaiati.com/emee/ns/csi", "csi-service"), connections[0].getConsumer().getServiceName());
69     }
70
71     protected AbstractXmlApplicationContext createBeanFactory() throws Exception JavaDoc {
72         return new DebugClassPathXmlApplicationContext("org/apache/servicemix/jbi/deployment/serviceAssembly.xml",
73                                                        Arrays.asList(new Object JavaDoc[] { new XBeanProcessor() }));
74     }
75
76 }
77
Popular Tags