KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > component > lifecycle > mock > MockJBIDescriptorBuilder


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2006 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: MockJBIDescriptorBuilder.java 154 16 mai 2006 ofabre $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.jbi.component.lifecycle.mock;
23
24 import java.net.URI JavaDoc;
25 import java.util.ArrayList JavaDoc;
26 import java.util.List JavaDoc;
27
28 import javax.xml.namespace.QName JavaDoc;
29
30 import org.objectweb.petals.tools.jbicommon.descriptor.Connection;
31 import org.objectweb.petals.tools.jbicommon.descriptor.JBIDescriptor;
32 import org.objectweb.petals.tools.jbicommon.descriptor.JBIDescriptorBuilder;
33 import org.objectweb.petals.tools.jbicommon.descriptor.ServiceUnit;
34 import org.objectweb.util.monolog.api.Logger;
35
36 /**
37  *
38  * @author Olivier Fabre - EBM Websourcing
39  *
40  */

41 public class MockJBIDescriptorBuilder extends JBIDescriptorBuilder {
42
43     public MockJBIDescriptorBuilder(URI JavaDoc sourceUri, Logger logger) {
44         super(sourceUri, (java.util.logging.Logger JavaDoc) logger);
45     }
46
47     /**
48      * Create a light Component JBIDescriptor
49      *
50      * @return an empty JBIDescriptor
51      */

52     public static JBIDescriptor buildComponentDescriptor() {
53         JBIDescriptorMock descriptor = new JBIDescriptorMock();
54
55         ComponentDescriptionMock componentDescription = new ComponentDescriptionMock();
56         IdentificationMock identification = new IdentificationMock();
57         identification.setName("testComponent");
58         componentDescription.setIdentification(identification);
59         descriptor.setComponent(componentDescription);
60
61         return descriptor;
62     }
63
64     /**
65      * Create a light Component JBIDescriptor
66      *
67      * @return an empty JBIDescriptor
68      */

69     public static JBIDescriptor buildComponentDescriptorWithClasspath() {
70         JBIDescriptorMock descriptor = new JBIDescriptorMock();
71
72         ComponentDescriptionMock componentDescription = new ComponentDescriptionMock();
73         IdentificationMock identification = new IdentificationMock();
74         identification.setName("testComponent");
75         componentDescription.setIdentification(identification);
76         List JavaDoc<String JavaDoc> classpath = new ArrayList JavaDoc<String JavaDoc>();
77         classpath.add("Engine1.jar");
78         componentDescription.setComponentClassPath(classpath);
79         componentDescription.setBootstrapClassPath(classpath);
80         descriptor.setComponent(componentDescription);
81
82         return descriptor;
83     }
84
85     /**
86      * Create a light Component JBIDescriptor
87      *
88      * @return an empty JBIDescriptor
89      */

90     public static JBIDescriptor buildComponentDescriptorWithBadClasspath() {
91         JBIDescriptorMock descriptor = new JBIDescriptorMock();
92
93         ComponentDescriptionMock componentDescription = new ComponentDescriptionMock();
94         IdentificationMock identification = new IdentificationMock();
95         identification.setName("testComponent");
96         componentDescription.setIdentification(identification);
97         List JavaDoc<String JavaDoc> classpath = new ArrayList JavaDoc<String JavaDoc>();
98         classpath.add("");
99         componentDescription.setComponentClassPath(classpath);
100         componentDescription.setBootstrapClassPath(classpath);
101         descriptor.setComponent(componentDescription);
102
103         return descriptor;
104     }
105
106     /**
107      * Create a light SharedLib JBIDescriptor
108      *
109      * @return an empty JBIDescriptor
110      */

111     public static JBIDescriptor buildSharedLibDescriptor() {
112         JBIDescriptorMock descriptor = new JBIDescriptorMock();
113
114         SharedLibraryMock sharedLibrary = new SharedLibraryMock();
115         IdentificationMock identification = new IdentificationMock();
116         identification.setName("testSharedLib");
117         sharedLibrary.setIdentification(identification);
118         descriptor.setSharedLibrary(sharedLibrary);
119
120         return descriptor;
121     }
122
123     /**
124      * Create a light SharedLib JBIDescriptor
125      *
126      * @return an empty JBIDescriptor
127      */

128     public static JBIDescriptor buildSharedLibDescriptorWithClasspath() {
129         JBIDescriptorMock descriptor = new JBIDescriptorMock();
130
131         SharedLibraryMock sharedLibrary = new SharedLibraryMock();
132         IdentificationMock identification = new IdentificationMock();
133         identification.setName("testSharedLib");
134         sharedLibrary.setIdentification(identification);
135         List JavaDoc<String JavaDoc> classpath = new ArrayList JavaDoc<String JavaDoc>();
136         classpath.add("Lib01.jar");
137         sharedLibrary.setSharedLibraryClassPath(classpath);
138         descriptor.setSharedLibrary(sharedLibrary);
139
140         return descriptor;
141     }
142
143     /**
144      * Create a light ServiceAssembly JBIDescriptor
145      *
146      * @return an empty JBIDescriptor
147      */

148     public static JBIDescriptor buildServiceAssemblyDescriptor() {
149         JBIDescriptorMock descriptor = new JBIDescriptorMock();
150
151         ServiceAssemblyMock serviceAssembly = new ServiceAssemblyMock();
152         IdentificationMock identification = new IdentificationMock();
153         identification.setName("testServiceAssembly");
154         serviceAssembly.setIdentification(identification);
155         descriptor.setServiceAssembly(serviceAssembly);
156
157         return descriptor;
158     }
159
160     /**
161      * Create a light ServiceAssembly JBIDescriptor
162      *
163      * @return an empty JBIDescriptor
164      */

165     public static JBIDescriptor buildServiceAssemblyDescriptorWithSU() {
166         JBIDescriptorMock descriptor = new JBIDescriptorMock();
167
168         ServiceAssemblyMock serviceAssembly = new ServiceAssemblyMock();
169         IdentificationMock identification = new IdentificationMock();
170         identification.setName("testServiceAssembly");
171         serviceAssembly.setIdentification(identification);
172         List JavaDoc<ServiceUnit> units = new ArrayList JavaDoc<ServiceUnit>();
173         ServiceUnitMock serviceUnit = new ServiceUnitMock();
174         IdentificationMock identification1 = new IdentificationMock();
175         identification1.setName("testSU");
176         serviceUnit.setIdentification(identification1);
177         serviceUnit.setTargetArtifactsZip("serviceUnit.zip");
178         units.add(serviceUnit);
179         serviceAssembly.setServiceUnits(units);
180         descriptor.setServiceAssembly(serviceAssembly);
181
182         return descriptor;
183     }
184
185     /**
186      * Create a light ServiceAssembly JBIDescriptor
187      *
188      * @return an empty JBIDescriptor
189      */

190     public static JBIDescriptor buildServiceAssemblyDescriptorWithSUFoo() {
191         JBIDescriptorMock descriptor = new JBIDescriptorMock();
192
193         ServiceAssemblyMock serviceAssembly = new ServiceAssemblyMock();
194         IdentificationMock identification = new IdentificationMock();
195         identification.setName("testServiceAssembly");
196         serviceAssembly.setIdentification(identification);
197         List JavaDoc<ServiceUnit> units = new ArrayList JavaDoc<ServiceUnit>();
198         ServiceUnitMock serviceUnit = new ServiceUnitMock();
199         IdentificationMock identification1 = new IdentificationMock();
200         identification1.setName("testSU");
201         serviceUnit.setIdentification(identification1);
202         serviceUnit.setTargetArtifactsZip("serviceUnitFoo.zip");
203         units.add(serviceUnit);
204         serviceAssembly.setServiceUnits(units);
205         descriptor.setServiceAssembly(serviceAssembly);
206
207         return descriptor;
208     }
209
210     /**
211      * Create a light ServiceAssembly JBIDescriptor with connections
212      *
213      * @return an empty JBIDescriptor
214      */

215     public static JBIDescriptor buildServiceAssemblyDescriptorWithConnections() {
216         JBIDescriptorMock descriptor = new JBIDescriptorMock();
217
218         ServiceAssemblyMock serviceAssembly = new ServiceAssemblyMock();
219         IdentificationMock identification = new IdentificationMock();
220         identification.setName("testServiceAssembly");
221         serviceAssembly.setIdentification(identification);
222         List JavaDoc<Connection> connections = new ArrayList JavaDoc<Connection>();
223         ConnectionMock connection = new ConnectionMock();
224         connection.setConsumerServiceName(new QName JavaDoc("test"));
225         connection.setConsumerEndpointName("endpoint:test");
226         connection.setProviderEndpointName("endpoint:test");
227         connection.setProviderServiceName(new QName JavaDoc("test"));
228         connection.setConsumerInterfaceName(new QName JavaDoc("interfacename"));
229         connections.add(connection);
230         serviceAssembly.setConnections(connections);
231         descriptor.setServiceAssembly(serviceAssembly);
232
233         return descriptor;
234     }
235
236 }
237
Popular Tags