1 22 package org.objectweb.petals.jbi.component.lifecycle.mock; 23 24 import java.net.URI ; 25 import java.util.ArrayList ; 26 import java.util.List ; 27 28 import javax.xml.namespace.QName ; 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 41 public class MockJBIDescriptorBuilder extends JBIDescriptorBuilder { 42 43 public MockJBIDescriptorBuilder(URI sourceUri, Logger logger) { 44 super(sourceUri, (java.util.logging.Logger ) logger); 45 } 46 47 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 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 <String > classpath = new ArrayList <String >(); 77 classpath.add("Engine1.jar"); 78 componentDescription.setComponentClassPath(classpath); 79 componentDescription.setBootstrapClassPath(classpath); 80 descriptor.setComponent(componentDescription); 81 82 return descriptor; 83 } 84 85 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 <String > classpath = new ArrayList <String >(); 98 classpath.add(""); 99 componentDescription.setComponentClassPath(classpath); 100 componentDescription.setBootstrapClassPath(classpath); 101 descriptor.setComponent(componentDescription); 102 103 return descriptor; 104 } 105 106 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 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 <String > classpath = new ArrayList <String >(); 136 classpath.add("Lib01.jar"); 137 sharedLibrary.setSharedLibraryClassPath(classpath); 138 descriptor.setSharedLibrary(sharedLibrary); 139 140 return descriptor; 141 } 142 143 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 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 <ServiceUnit> units = new ArrayList <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 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 <ServiceUnit> units = new ArrayList <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 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 <Connection> connections = new ArrayList <Connection>(); 223 ConnectionMock connection = new ConnectionMock(); 224 connection.setConsumerServiceName(new QName ("test")); 225 connection.setConsumerEndpointName("endpoint:test"); 226 connection.setProviderEndpointName("endpoint:test"); 227 connection.setProviderServiceName(new QName ("test")); 228 connection.setConsumerInterfaceName(new QName ("interfacename")); 229 connections.add(connection); 230 serviceAssembly.setConnections(connections); 231 descriptor.setServiceAssembly(serviceAssembly); 232 233 return descriptor; 234 } 235 236 } 237 | Popular Tags |