6782bfb6a9a3ae84e8f8a73d54c8da1c3bfedd90
[lispflowmapping.git] / mappingservice / integrationtest / src / test / java / org / opendaylight / lispflowmapping / integrationtest / MappingServiceIntegrationTest.java
1 package org.opendaylight.lispflowmapping.integrationtest;
2
3 import static org.junit.Assert.assertArrayEquals;
4 import static org.junit.Assert.assertEquals;
5 import static org.junit.Assert.assertNotNull;
6 import static org.junit.Assert.assertTrue;
7 import static org.junit.Assert.fail;
8 import static org.ops4j.pax.exam.CoreOptions.junitBundles;
9 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
10 import static org.ops4j.pax.exam.CoreOptions.options;
11 import static org.ops4j.pax.exam.CoreOptions.systemPackages;
12 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
13
14 import java.io.BufferedReader;
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.io.InputStreamReader;
18 import java.io.OutputStreamWriter;
19 import java.net.DatagramPacket;
20 import java.net.DatagramSocket;
21 import java.net.HttpURLConnection;
22 import java.net.InetAddress;
23 import java.net.InetSocketAddress;
24 import java.net.MalformedURLException;
25 import java.net.ProtocolException;
26 import java.net.SocketException;
27 import java.net.SocketTimeoutException;
28 import java.net.URL;
29 import java.net.UnknownHostException;
30 import java.nio.ByteBuffer;
31 import java.nio.charset.Charset;
32 import java.util.ArrayList;
33 import java.util.Arrays;
34 import java.util.List;
35
36 import javax.inject.Inject;
37
38 import org.apache.commons.codec.binary.Base64;
39 import org.codehaus.jettison.json.JSONException;
40 import org.codehaus.jettison.json.JSONObject;
41 import org.codehaus.jettison.json.JSONTokener;
42 import org.junit.After;
43 import org.junit.Before;
44 import org.junit.Ignore;
45 import org.junit.Test;
46 import org.junit.runner.RunWith;
47 import org.opendaylight.lispflowmapping.implementation.serializer.LispMessage;
48 import org.opendaylight.lispflowmapping.implementation.serializer.MapNotifySerializer;
49 import org.opendaylight.lispflowmapping.implementation.serializer.MapRegisterSerializer;
50 import org.opendaylight.lispflowmapping.implementation.serializer.MapReplySerializer;
51 import org.opendaylight.lispflowmapping.implementation.serializer.MapRequestSerializer;
52 import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
53 import org.opendaylight.lispflowmapping.type.lisp.EidRecord;
54 import org.opendaylight.lispflowmapping.type.lisp.EidToLocatorRecord;
55 import org.opendaylight.lispflowmapping.type.lisp.LocatorRecord;
56 import org.opendaylight.lispflowmapping.type.lisp.MapNotify;
57 import org.opendaylight.lispflowmapping.type.lisp.MapRegister;
58 import org.opendaylight.lispflowmapping.type.lisp.MapReply;
59 import org.opendaylight.lispflowmapping.type.lisp.MapRequest;
60 import org.opendaylight.lispflowmapping.type.lisp.address.LispAddress;
61 import org.opendaylight.lispflowmapping.type.lisp.address.LispApplicationDataLCAFAddress;
62 import org.opendaylight.lispflowmapping.type.lisp.address.LispDistinguishedNameAddress;
63 import org.opendaylight.lispflowmapping.type.lisp.address.LispIpv4Address;
64 import org.opendaylight.lispflowmapping.type.lisp.address.LispIpv6Address;
65 import org.opendaylight.lispflowmapping.type.lisp.address.LispLCAFAddress;
66 import org.opendaylight.lispflowmapping.type.lisp.address.LispListLCAFAddress;
67 import org.opendaylight.lispflowmapping.type.lisp.address.LispMACAddress;
68 import org.opendaylight.lispflowmapping.type.lisp.address.LispSegmentLCAFAddress;
69 import org.opendaylight.lispflowmapping.type.lisp.address.LispSourceDestLCAFAddress;
70 import org.opendaylight.lispflowmapping.type.lisp.address.LispTrafficEngineeringLCAFAddress;
71 import org.opendaylight.lispflowmapping.type.lisp.address.ReencapHop;
72 import org.ops4j.pax.exam.Option;
73 import org.ops4j.pax.exam.junit.Configuration;
74 import org.ops4j.pax.exam.junit.PaxExam;
75 import org.ops4j.pax.exam.util.PathUtils;
76 import org.osgi.framework.Bundle;
77 import org.osgi.framework.BundleContext;
78 import org.osgi.framework.InvalidSyntaxException;
79 import org.osgi.framework.ServiceReference;
80 import org.slf4j.Logger;
81 import org.slf4j.LoggerFactory;
82
83 @RunWith(PaxExam.class)
84 public class MappingServiceIntegrationTest {
85
86     private IFlowMapping lms;
87     protected static final Logger logger = LoggerFactory.getLogger(MappingServiceIntegrationTest.class);
88     private byte[] mapRequestPacket;
89     private byte[] mapRegisterPacketWithNotify;
90     private byte[] mapRegisterPacketWithoutNotify;
91     int lispPortNumber = LispMessage.PORT_NUM;
92     String lispBindAddress = "127.0.0.1";
93     String ourAddress = "127.0.0.2";
94     private DatagramSocket socket;
95     private byte[] mapRegisterPacketWithAuthenticationAndMapNotify;
96     private byte[] mapRegisterPacketWithNotifyWithListLCAFAndDistinguishedName;
97
98     public static final String ODL = "org.opendaylight.controller";
99     public static final String YANG = "org.opendaylight.yangtools";
100     public static final String JERSEY = "com.sun.jersey";
101
102     @After
103     public void after() {
104         if (socket != null) {
105             socket.close();
106         }
107         if (connection != null) {
108             connection.disconnect();
109         }
110     }
111
112     @Before
113     public void before() throws Exception {
114         socket = initSocket(socket);
115         // mapResolver = context.mock(IMapResolver.class);
116         // mapServer = context.mock(IMapServer.class);
117
118         // SRC: 127.0.0.1:58560 to 127.0.0.1:4342
119         // LISP(Type = 8 - Encapsulated)
120         // IP: 192.168.136.10 -> 1.2.3.4
121         // UDP: 56756
122         // LISP(Type = 1 Map-Request
123         // Record Count: 1
124         // ITR-RLOC count: 0
125         // Source EID AFI: 0
126         // Source EID not present
127         // Nonce: 0x3d8d2acd39c8d608
128         // ITR-RLOC AFI=1 Address=192.168.136.10
129         // Record 1: 1.2.3.4/32
130         mapRequestPacket = extractWSUdpByteArray(new String("0000   00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 " //
131                 + "0010   00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 "
132                 + "0020   00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 "
133                 + "0030   00 38 d4 31 00 00 ff 11 56 f3 7f 00 00 02 01 02 "
134                 + "0040   03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d "
135                 + "0050   2a cd 39 c8 d6 08 00 00 00 01 7f 00 00 02 00 20 " //
136                 + "0060   00 01 01 02 03 04"));
137
138         // IP: 192.168.136.10 -> 128.223.156.35
139         // UDP: 49289 -> 4342
140         // LISP(Type = 3 Map-Register, P=1, M=1
141         // Record Counter: 1
142         // Nonce: 0
143         // Key ID: 0x0001
144         // AuthDataLength: 20 Data:
145         // e8:f5:0b:c5:c5:f2:b0:21:27:a8:21:41:04:f3:46:5a:a5:68:89:ec
146         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
147         // No-Action
148         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
149         // Priority/Weight: 1/100, Multicast Priority/Weight:
150         // 255/0
151         //
152
153         mapRegisterPacketWithAuthenticationAndMapNotify = extractWSUdpByteArray(new String("0000   00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " //
154                 + "0010   00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
155                 + "0020   9c 23 d6 40 10 f6 00 48 59 a4 38 00 01 01 00 00 "
156                 + "0030   00 00 00 00 00 00 00 01 00 14 0e a4 c6 d8 a4 06 "
157                 + "0040   71 7c 33 a4 5c 4a 83 1c de 74 53 03 0c ad 00 00 "
158                 + "0050   00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
159                 + "0060   ff 00 00 05 00 01 c0 a8 88 0a"));
160
161         // IP: 192.168.136.10 -> 128.223.156.35
162         // UDP: 49289 -> 4342
163         // LISP(Type = 3 Map-Register, P=1, M=1
164         // Record Counter: 1
165         // Nonce: 7
166         // Key ID: 0x0000 NO AUTHENTICATION!!
167         // AuthDataLength: 00 Data:
168         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
169         // No-Action
170         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
171         // Priority/Weight: 1/100, Multicast Priority/Weight:
172         // 255/0
173         //
174
175         mapRegisterPacketWithNotify = extractWSUdpByteArray(new String("0000   00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " //
176                 + "0010   00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
177                 + "0020   9c 23 d6 40 10 f6 00 48 59 a4 38 00 01 01 00 00 "
178                 + "0030   00 00 00 00 00 07 00 00 00 14 0e a4 c6 d8 a4 06 "
179                 + "0040   71 7c 33 a4 5c 4a 83 1c de 74 53 03 0c ad 00 00 "
180                 + "0050   00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
181                 + "0060   ff 00 00 05 00 01 c0 a8 88 0a"));
182
183         // IP: 192.168.136.10 -> 128.223.156.35
184         // UDP: 49289 -> 4342
185         // LISP(Type = 3 Map-Register, P=1, M=1
186         // Record Counter: 1
187         // Nonce: 7
188         // Key ID: 0x0000 NO AUTHENTICATION!!
189         // AuthDataLength: 00 Data:
190         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
191         // No-Action
192         // LIST LCAF
193         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
194         // Local RLOC: Distinguished Name("david"), Reachable,
195         // Priority/Weight: 1/100, Multicast Priority/Weight:
196         // 255/0
197         //
198
199         mapRegisterPacketWithNotifyWithListLCAFAndDistinguishedName = extractWSUdpByteArray(new String(
200                 "0000   00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " //
201                         + "0010   00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
202                         + "0020   9c 23 d6 40 10 f6 00 48 59 a4 38 00 01 01 00 00 "
203                         + "0030   00 00 00 00 00 07 00 00 00 14 0e a4 c6 d8 a4 06 "
204                         + "0040   71 7c 33 a4 5c 4a 83 1c de 74 53 03 0c ad 00 00 "
205                         + "0050   00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
206                         + "0060   ff 00 00 05 40 03 00 00 01 00 00 16 00 01 c0 a8 " //
207                         + "0070   88 0a 40 03 00 00 01 00 00 08 00 11 64 61 76 69 " //
208                         + "0080   64 00"));
209
210         // IP: 192.168.136.10 -> 128.223.156.35
211         // UDP: 49289 -> 4342
212         // LISP(Type = 3 Map-Register, P=1, M=1
213         // Record Counter: 1
214         // Nonce: 7
215         // Key ID: 0x0000 NO AUTHENTICATION!!
216         // AuthDataLength: 00 Data:
217         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
218         // No-Action
219         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
220         // Priority/Weight: 1/100, Multicast Priority/Weight:
221         // 255/0
222         //
223
224         mapRegisterPacketWithoutNotify = extractWSUdpByteArray(new String("0000   00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " //
225                 + "0010   00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
226                 + "0020   9c 23 d6 40 10 f6 00 48 59 a4 38 00 00 01 00 00 "
227                 + "0030   00 00 00 00 00 07 00 00 00 14 0e a4 c6 d8 a4 06 "
228                 + "0040   71 7c 33 a4 5c 4a 83 1c de 74 53 03 0c ad 00 00 "
229                 + "0050   00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
230                 + "0060   ff 00 00 05 00 01 c0 a8 88 0a"));
231     }
232
233     @Inject
234     private BundleContext bc;
235     private HttpURLConnection connection;
236
237     // Configure the OSGi container
238     @Configuration
239     public Option[] config() {
240         return options(
241                 //
242                 systemProperty("logback.configurationFile").value("file:" + PathUtils.getBaseDir() + "/src/test/resources/logback.xml"),
243                 // To start OSGi console for inspection remotely
244                 systemProperty("osgi.console").value("2401"),
245                 systemProperty("org.eclipse.gemini.web.tomcat.config.path").value(PathUtils.getBaseDir() + "/src/test/resources/tomcat-server.xml"),
246
247                 // setting default level. Jersey bundles will need to be started
248                 // earlier.
249                 systemProperty("osgi.bundles.defaultStartLevel").value("4"),
250
251                 // Set the systemPackages (used by clustering)
252                 systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc", "javax.crypto", "javax.crypto.spec"),
253
254                 // OSGI infra
255                 mavenBundle("org.jboss.spec.javax.transaction", "jboss-transaction-api_1.1_spec").versionAsInProject(),
256                 mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
257                 mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager").versionAsInProject(),
258
259                 // List logger bundles
260                 mavenBundle("org.slf4j", "jcl-over-slf4j").versionAsInProject(),
261                 mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
262                 mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(),
263                 mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(),
264                 mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(),
265
266                 mavenBundle(ODL, "config-api").versionAsInProject(), //
267                 mavenBundle(ODL, "config-manager").versionAsInProject(), //
268                 mavenBundle("commons-io", "commons-io").versionAsInProject(),
269
270                 mavenBundle("commons-fileupload", "commons-fileupload").versionAsInProject(),
271
272                 mavenBundle("equinoxSDK381", "javax.servlet").versionAsInProject(),
273                 mavenBundle("equinoxSDK381", "javax.servlet.jsp").versionAsInProject(),
274                 mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds").versionAsInProject(),
275
276                 mavenBundle("equinoxSDK381", "org.eclipse.equinox.util").versionAsInProject(),
277                 mavenBundle("equinoxSDK381", "org.eclipse.osgi.services").versionAsInProject(),
278                 mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject(),
279                 mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject(),
280                 mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject(),
281                 mavenBundle("equinoxSDK381", "org.eclipse.equinox.cm").versionAsInProject(),
282                 mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject(),
283                 mavenBundle("equinoxSDK381", "org.eclipse.equinox.launcher").versionAsInProject(),
284
285                 mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager").versionAsInProject(),
286                 mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager.shell").versionAsInProject(),
287
288                 mavenBundle("com.google.code.gson", "gson").versionAsInProject(),
289                 mavenBundle("org.jboss.spec.javax.transaction", "jboss-transaction-api_1.1_spec").versionAsInProject(),
290                 mavenBundle("org.apache.felix", "org.apache.felix.fileinstall").versionAsInProject(),
291                 mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
292                 mavenBundle("commons-codec", "commons-codec").versionAsInProject(),
293                 mavenBundle("virgomirror", "org.eclipse.jdt.core.compiler.batch").versionAsInProject(),
294                 mavenBundle("eclipselink", "javax.persistence").versionAsInProject(),
295                 mavenBundle("eclipselink", "javax.resource").versionAsInProject(),
296
297                 mavenBundle("orbit", "javax.activation").versionAsInProject(),
298                 mavenBundle("orbit", "javax.annotation").versionAsInProject(),
299                 mavenBundle("orbit", "javax.ejb").versionAsInProject(),
300                 mavenBundle("orbit", "javax.el").versionAsInProject(),
301                 mavenBundle("orbit", "javax.mail.glassfish").versionAsInProject(),
302                 mavenBundle("orbit", "javax.xml.rpc").versionAsInProject(),
303                 mavenBundle("orbit", "org.apache.catalina").versionAsInProject(),
304
305                 mavenBundle("orbit", "org.apache.catalina.ha").versionAsInProject().noStart(),
306                 mavenBundle("orbit", "org.apache.catalina.tribes").versionAsInProject().noStart(),
307                 mavenBundle("orbit", "org.apache.coyote").versionAsInProject().noStart(),
308                 mavenBundle("orbit", "org.apache.jasper").versionAsInProject().noStart(),
309
310                 mavenBundle("orbit", "org.apache.el").versionAsInProject(),
311                 mavenBundle("orbit", "org.apache.juli.extras").versionAsInProject(),
312                 mavenBundle("orbit", "org.apache.tomcat.api").versionAsInProject(),
313                 mavenBundle("orbit", "org.apache.tomcat.util").versionAsInProject().noStart(),
314                 mavenBundle("orbit", "javax.servlet.jsp.jstl").versionAsInProject(),
315                 mavenBundle("orbit", "javax.servlet.jsp.jstl.impl").versionAsInProject(),
316
317                 // Basic bundles needed
318                 mavenBundle("org.opendaylight.controller", "containermanager").versionAsInProject(),
319                 mavenBundle("org.opendaylight.controller", "containermanager.it.implementation").versionAsInProject(),
320
321                 // Specific bundles
322                 mavenBundle(ODL, "sal-binding-api").versionAsInProject(), //
323                 mavenBundle(ODL, "sal-binding-config").versionAsInProject(),
324                 mavenBundle(ODL, "sal-binding-broker-impl").versionAsInProject(), //
325                 mavenBundle(ODL, "sal-common").versionAsInProject(), //
326                 mavenBundle(ODL, "sal-common-api").versionAsInProject(), //
327                 mavenBundle(ODL, "sal-common-impl").versionAsInProject(),
328                 mavenBundle(ODL, "sal-common-util").versionAsInProject(), //
329                 mavenBundle(YANG, "concepts").versionAsInProject(),
330                 mavenBundle(YANG, "yang-binding").versionAsInProject(), //
331                 mavenBundle(YANG, "yang-common").versionAsInProject(), //
332                 mavenBundle(YANG + ".thirdparty", "xtend-lib-osgi").versionAsInProject(),//
333                 mavenBundle("com.google.guava", "guava").versionAsInProject(), //
334                 mavenBundle("org.javassist", "javassist").versionAsInProject(), //
335
336                 // Northbound bundles
337                 mavenBundle("org.opendaylight.controller", "commons.northbound").versionAsInProject(), //
338                 mavenBundle(ODL + ".thirdparty", "com.sun.jersey.jersey-servlet").versionAsInProject(), //
339                 mavenBundle(ODL + ".thirdparty", "net.sf.jung2").versionAsInProject(), //
340                 mavenBundle(ODL + ".thirdparty", "org.apache.catalina.filters.CorsFilter").versionAsInProject().noStart(),
341                 mavenBundle(JERSEY, "jersey-client").versionAsInProject(),
342                 mavenBundle(JERSEY, "jersey-server").versionAsInProject().startLevel(2),
343                 mavenBundle(JERSEY, "jersey-core").versionAsInProject().startLevel(2),
344                 mavenBundle(JERSEY, "jersey-json").versionAsInProject().startLevel(2),
345                 mavenBundle("org.codehaus.jackson", "jackson-mapper-asl").versionAsInProject(),//
346                 mavenBundle("org.codehaus.jackson", "jackson-core-asl").versionAsInProject(),//
347                 mavenBundle("org.codehaus.jackson", "jackson-jaxrs").versionAsInProject(),//
348                 mavenBundle("org.codehaus.jackson", "jackson-xc").versionAsInProject(),//
349                 mavenBundle("org.codehaus.jettison", "jettison").versionAsInProject(),//
350                 mavenBundle("org.ow2.asm", "asm-all").versionAsInProject(), //
351                 mavenBundle("org.opendaylight.controller", "bundlescanner").versionAsInProject(),//
352                 mavenBundle("org.opendaylight.controller", "bundlescanner.implementation").versionAsInProject(),//
353                 mavenBundle("org.opendaylight.controller", "switchmanager").versionAsInProject(),//
354                 mavenBundle("org.opendaylight.controller", "connectionmanager").versionAsInProject(),//
355                 mavenBundle("org.opendaylight.controller", "connectionmanager.implementation").versionAsInProject(),//
356                 mavenBundle("org.opendaylight.controller", "commons.httpclient").versionAsInProject(), //
357                 mavenBundle("org.opendaylight.controller", "configuration").versionAsInProject(),//
358                 mavenBundle("org.opendaylight.controller", "configuration.implementation").versionAsInProject(),//
359                 mavenBundle("org.opendaylight.controller", "usermanager").versionAsInProject(), //
360                 mavenBundle("org.opendaylight.controller", "usermanager.implementation").versionAsInProject(), //
361                 mavenBundle("org.springframework", "org.springframework.asm").versionAsInProject(),
362                 mavenBundle("org.springframework", "org.springframework.aop").versionAsInProject(),
363                 mavenBundle("org.springframework", "org.springframework.context").versionAsInProject(),
364                 mavenBundle("org.springframework", "org.springframework.context.support").versionAsInProject(),
365                 mavenBundle("org.springframework", "org.springframework.core").versionAsInProject(),
366                 mavenBundle("org.springframework", "org.springframework.beans").versionAsInProject(),
367                 mavenBundle("org.springframework", "org.springframework.expression").versionAsInProject(),
368                 mavenBundle("org.springframework", "org.springframework.web").versionAsInProject(),
369
370                 mavenBundle("org.aopalliance", "com.springsource.org.aopalliance").versionAsInProject(),
371                 mavenBundle("org.springframework", "org.springframework.web.servlet").versionAsInProject(),
372                 mavenBundle("org.springframework.security", "spring-security-config").versionAsInProject(),
373                 mavenBundle("org.springframework.security", "spring-security-core").versionAsInProject(),
374                 mavenBundle("org.springframework.security", "spring-security-web").versionAsInProject(),
375                 mavenBundle("org.springframework.security", "spring-security-taglibs").versionAsInProject(),
376                 mavenBundle("org.springframework", "org.springframework.transaction").versionAsInProject(),
377                 mavenBundle("org.opendaylight.controller", "sal.connection").versionAsInProject(),
378                 mavenBundle("org.opendaylight.controller", "sal.connection.implementation").versionAsInProject(),
379                 mavenBundle("org.opendaylight.controller", "security").versionAsInProject().noStart(),
380
381                 // Tomcat for northbound
382                 mavenBundle("geminiweb", "org.eclipse.gemini.web.core").versionAsInProject(),
383                 mavenBundle("geminiweb", "org.eclipse.gemini.web.extender").versionAsInProject(),
384                 mavenBundle("geminiweb", "org.eclipse.gemini.web.tomcat").versionAsInProject(),
385                 mavenBundle("geminiweb", "org.eclipse.virgo.kernel.equinox.extensions").versionAsInProject().noStart(),
386                 mavenBundle("geminiweb", "org.eclipse.virgo.util.common").versionAsInProject(),
387                 mavenBundle("geminiweb", "org.eclipse.virgo.util.io").versionAsInProject(),
388                 mavenBundle("geminiweb", "org.eclipse.virgo.util.math").versionAsInProject(),
389                 mavenBundle("geminiweb", "org.eclipse.virgo.util.osgi").versionAsInProject(),
390                 mavenBundle("geminiweb", "org.eclipse.virgo.util.osgi.manifest").versionAsInProject(),
391                 mavenBundle("geminiweb", "org.eclipse.virgo.util.parser.manifest").versionAsInProject(),
392
393                 // Our bundles
394                 mavenBundle("org.opendaylight.controller", "clustering.stub").versionAsInProject(),
395                 mavenBundle("org.opendaylight.controller", "clustering.services").versionAsInProject(),
396                 mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(),
397                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.api").versionAsInProject(),
398                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.implementation").versionAsInProject(), //
399                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.southbound").versionAsInProject(), //
400                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.northbound").versionAsInProject(), //
401                 junitBundles());
402     }
403
404     @Test
405     public void mapRequestSimple() throws SocketTimeoutException {
406         sendPacket(mapRequestPacket);
407         ByteBuffer readBuf = ByteBuffer.wrap(receivePacket().getData());
408         MapReply reply = MapReplySerializer.getInstance().deserialize(readBuf);
409         assertEquals(4435248268955932168L, reply.getNonce());
410
411     }
412
413     @Test
414     public void mapRegisterWithMapNotify() throws SocketTimeoutException {
415         sendPacket(mapRegisterPacketWithNotify);
416         MapNotify reply = recieveMapNotify();
417         assertEquals(7, reply.getNonce());
418     }
419
420     @Test
421     public void northboundGetPassword() throws Exception {
422         LispIpv4Address address = new LispIpv4Address("10.0.0.1");
423         int mask = 32;
424         String pass = "pass";
425         lms.addAuthenticationKey(address, mask, pass);
426         URL url = createGetURL(address, mask);
427
428         JSONObject json = callURL(url);
429         // test that the password matches what was we expected.
430         assertEquals(pass, json.get("key"));
431
432     }
433
434     private URL createGetURL(LispIpv4Address address, int mask) throws MalformedURLException {
435         String restUrl = String.format("http://localhost:8080/lispflowmapping/default/key/%d/%s/%d", address.getAfi().getIanaCode(), address
436                 .getAddress().getHostAddress(), mask);
437         URL url = new URL(restUrl);
438         return url;
439     }
440
441     private String createAuthenticationString() {
442         String authString = "admin:admin";
443         byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
444         String authStringEnc = new String(authEncBytes);
445         return authStringEnc;
446     }
447
448     private JSONObject callURL(URL url) throws IOException, JSONException {
449         String authStringEnc = createAuthenticationString();
450         connection = (HttpURLConnection) url.openConnection();
451         connection.setRequestMethod("GET");
452         connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
453         connection.setRequestProperty("Content-Type", "application/json");
454         connection.setRequestProperty("Accept", "application/json");
455         connection.connect();
456
457         // getting the result, first check response code
458         Integer httpResponseCode = connection.getResponseCode();
459         if (httpResponseCode > 299)
460             fail();
461         InputStream is = connection.getInputStream();
462         BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
463         StringBuilder sb = new StringBuilder();
464         int cp;
465         while ((cp = rd.read()) != -1) {
466             sb.append((char) cp);
467         }
468         is.close();
469         JSONTokener jt = new JSONTokener(sb.toString());
470         JSONObject json = new JSONObject(jt);
471         return json;
472     }
473
474     private MapReply registerAddressAndQuery(LispAddress eid) throws SocketTimeoutException {
475         return registerAddressAndQuery(eid, -1);
476     }
477
478     private LispAddress locatorEid = new LispIpv4Address("4.3.2.1");
479
480     // takes an address, packs it in a MapRegister, sends it, returns the
481     // MapReply
482     private MapReply registerAddressAndQuery(LispAddress eid, int maskLength) throws SocketTimeoutException {
483         MapRegister mapRegister = new MapRegister();
484         mapRegister.setWantMapNotify(true);
485         mapRegister.setNonce(8);
486         EidToLocatorRecord etlr = new EidToLocatorRecord();
487         etlr.setPrefix(eid);
488         if (maskLength != -1) {
489             etlr.setMaskLength(maskLength);
490         }
491         etlr.setRecordTtl(254);
492         LocatorRecord record = new LocatorRecord();
493         record.setLocator(locatorEid);
494         etlr.addLocator(record);
495         mapRegister.addEidToLocator(etlr);
496         sendMapRegister(mapRegister);
497         MapNotify mapNotify = recieveMapNotify();
498         assertEquals(8, mapNotify.getNonce());
499         MapRequest mapRequest = new MapRequest();
500         mapRequest.setNonce(4);
501         mapRequest.addEidRecord(new EidRecord((byte) 32, eid));
502         mapRequest.addItrRloc(new LispIpv4Address(ourAddress));
503         sendMapRequest(mapRequest);
504         return recieveMapReply();
505     }
506
507     @Test
508     public void mapRegisterWithMapNotifyAndMapRequest() throws SocketTimeoutException {
509
510         LispIpv4Address eid = new LispIpv4Address("1.2.3.4");
511
512         MapReply mapReply = registerAddressAndQuery(eid, 32);
513
514         assertEquals(4, mapReply.getNonce());
515         assertEquals(locatorEid, mapReply.getEidToLocatorRecords().get(0).getLocators().get(0).getLocator());
516
517     }
518
519     @Test
520     public void registerAndQuery__MAC() throws SocketTimeoutException {
521         byte[] macAddress = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6 };
522
523         LispMACAddress eid = new LispMACAddress(macAddress);
524         MapReply reply = registerAddressAndQuery(eid);
525
526         LispAddress addressFromNetwork = reply.getEidToLocatorRecords().get(0).getPrefix();
527         assertTrue(addressFromNetwork instanceof LispMACAddress);
528         byte[] macAddressFromReply = ((LispMACAddress) addressFromNetwork).getMAC();
529
530         assertArrayEquals(macAddress, macAddressFromReply);
531     }
532
533     @Test
534     public void registerAndQuery__SrcDestLCAF() throws SocketTimeoutException {
535         String ipString = "10.20.30.200";
536         LispAddress addrToSend1 = new LispIpv4Address(ipString);
537         byte[] fakeMAC = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6 };
538         LispAddress addrToSend2 = new LispMACAddress(fakeMAC);
539         LispLCAFAddress address = new LispSourceDestLCAFAddress((byte) 0, (short) 0, (byte) 32, (byte) 0, addrToSend1, addrToSend2);
540
541         MapReply reply = registerAddressAndQuery(address);
542
543         LispAddress fromNetwork = reply.getEidToLocatorRecords().get(0).getPrefix();
544         assertTrue(fromNetwork instanceof LispSourceDestLCAFAddress);
545         LispSourceDestLCAFAddress sourceDestFromNetwork = (LispSourceDestLCAFAddress) fromNetwork;
546
547         LispAddress receivedAddr1 = sourceDestFromNetwork.getSrcAddress();
548         LispAddress receivedAddr2 = sourceDestFromNetwork.getDstAddress();
549
550         assertTrue(receivedAddr1 instanceof LispIpv4Address);
551         assertTrue(receivedAddr2 instanceof LispMACAddress);
552
553         LispIpv4Address receivedIP = (LispIpv4Address) receivedAddr1;
554         LispMACAddress receivedMAC = (LispMACAddress) receivedAddr2;
555
556         assertEquals(ipString, receivedIP.getAddress().getHostAddress());
557         assertArrayEquals(fakeMAC, receivedMAC.getMAC());
558     }
559
560     @Test
561     public void registerAndQuery__ListLCAF() throws SocketTimeoutException {
562         byte[] macAddress = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6 };
563         String ipAddress = "10.20.255.30";
564         List<LispAddress> list = new ArrayList<LispAddress>();
565         list.add(new LispMACAddress(macAddress));
566         list.add(new LispIpv4Address(ipAddress));
567
568         LispListLCAFAddress listAddrToSend = new LispListLCAFAddress((byte) 0, list);
569
570         MapReply reply = registerAddressAndQuery(listAddrToSend);
571
572         LispAddress receivedAddress = reply.getEidToLocatorRecords().get(0).getPrefix();
573
574         assertTrue(receivedAddress instanceof LispListLCAFAddress);
575
576         LispListLCAFAddress listAddrFromNetwork = (LispListLCAFAddress) receivedAddress;
577         LispAddress receivedAddr1 = listAddrFromNetwork.getAddresses().get(0);
578         LispAddress receivedAddr2 = listAddrFromNetwork.getAddresses().get(1);
579
580         assertTrue(receivedAddr1 instanceof LispMACAddress);
581         assertTrue(receivedAddr2 instanceof LispIpv4Address);
582
583         assertArrayEquals(macAddress, ((LispMACAddress) receivedAddr1).getMAC());
584         assertEquals(ipAddress, ((LispIpv4Address) receivedAddr2).getAddress().getHostAddress());
585     }
586
587     @Test
588     public void registerAndQuerySegmentLCAF() throws SocketTimeoutException {
589         String ipAddress = "10.20.255.30";
590         int instanceId = 6;
591         LispIpv4Address lispIpAddress = new LispIpv4Address(ipAddress);
592         LispSegmentLCAFAddress addressToSend = new LispSegmentLCAFAddress((byte) 0, instanceId, lispIpAddress);
593
594         MapReply reply = registerAddressAndQuery(addressToSend);
595
596         LispAddress receivedAddress = reply.getEidToLocatorRecords().get(0).getPrefix();
597         assertTrue(receivedAddress instanceof LispSegmentLCAFAddress);
598
599         LispSegmentLCAFAddress segmentfromNetwork = (LispSegmentLCAFAddress) receivedAddress;
600         LispAddress addrFromSegment = segmentfromNetwork.getAddress();
601         assertTrue(addrFromSegment instanceof LispIpv4Address);
602         assertEquals(ipAddress, ((LispIpv4Address) addrFromSegment).getAddress().getHostAddress());
603
604         assertEquals(instanceId, segmentfromNetwork.getInstanceId());
605     }
606
607     @Test
608     public void registerAndQuery__TrafficEngineering() throws SocketTimeoutException {
609         byte[] macAddress = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6 };
610         String ipAddress = "10.20.255.30";
611         List<ReencapHop> hops = new ArrayList<ReencapHop>();
612         boolean f = false;
613         boolean t = true;
614         hops.add(new ReencapHop(new LispMACAddress(macAddress), (short) 0, t, t, t));
615         hops.add(new ReencapHop(new LispIpv4Address(ipAddress), (short) 0, f, f, f));
616
617         LispTrafficEngineeringLCAFAddress addressToSend = new LispTrafficEngineeringLCAFAddress((byte) 0, hops);
618
619         MapReply reply = registerAddressAndQuery(addressToSend);
620
621         assertTrue(reply.getEidToLocatorRecords().get(0).getPrefix() instanceof LispTrafficEngineeringLCAFAddress);
622
623         LispTrafficEngineeringLCAFAddress receivedAddress = (LispTrafficEngineeringLCAFAddress) reply.getEidToLocatorRecords().get(0).getPrefix();
624
625         ReencapHop hop1 = receivedAddress.getHops().get(0);
626         ReencapHop hop2 = receivedAddress.getHops().get(1);
627
628         assertEquals(t, hop1.isLookup());
629         assertEquals(t, hop1.isRLOCProbe());
630         assertEquals(t, hop1.isStrict());
631
632         assertEquals(f, hop2.isLookup());
633         assertEquals(f, hop2.isRLOCProbe());
634         assertEquals(f, hop2.isStrict());
635
636         assertTrue(hop1.getHop() instanceof LispMACAddress);
637         assertTrue(hop2.getHop() instanceof LispIpv4Address);
638
639         LispMACAddress receivedMACAddress = (LispMACAddress) hop1.getHop();
640         LispIpv4Address receivedIPAddress = (LispIpv4Address) hop2.getHop();
641
642         assertArrayEquals(macAddress, receivedMACAddress.getMAC());
643         assertEquals(ipAddress, receivedIPAddress.getAddress().getHostAddress());
644     }
645
646     @Test
647     public void registerAndQuery__ApplicationData() throws SocketTimeoutException {
648         String ipAddress = "1.2.3.4";
649         byte protocol = (byte) 1;
650         int ipTOs = 2;
651         short localPort = (short) 3;
652         short remotePort = (short) 4;
653
654         LispApplicationDataLCAFAddress addressToSend = new LispApplicationDataLCAFAddress((byte) 0, protocol, ipTOs, localPort, remotePort,
655                 new LispIpv4Address(ipAddress));
656
657         MapReply reply = registerAddressAndQuery(addressToSend);
658
659         LispAddress receivedAddress = reply.getEidToLocatorRecords().get(0).getPrefix();
660
661         assertTrue(receivedAddress instanceof LispApplicationDataLCAFAddress);
662
663         LispApplicationDataLCAFAddress receivedApplicationDataAddress = (LispApplicationDataLCAFAddress) receivedAddress;
664         assertEquals(protocol, receivedApplicationDataAddress.getProtocol());
665         assertEquals(ipTOs, receivedApplicationDataAddress.getIPTos());
666         assertEquals(localPort, receivedApplicationDataAddress.getLocalPort());
667         assertEquals(remotePort, receivedApplicationDataAddress.getRemotePort());
668
669         LispIpv4Address ipAddressReceived = (LispIpv4Address) receivedApplicationDataAddress.getAddress();
670         assertEquals(ipAddress, ipAddressReceived.getAddress().getHostAddress());
671     }
672
673     @Test
674     public void eidPrefixLookupIPv4() throws SocketTimeoutException {
675         runPrefixTest(new LispIpv4Address("1.2.3.4"), 16, new LispIpv4Address("1.2.3.2"), new LispIpv4Address("1.1.1.1"), (byte) 32);
676     }
677
678     @Test
679     public void eidPrefixLookupIPv6() throws SocketTimeoutException {
680         runPrefixTest(new LispIpv6Address("1:2:3:4:5:6:7:8"), 64, new LispIpv6Address("1:2:3:4:5:1:2:3"), new LispIpv6Address("1:2:3:1:2:3:1:2"),
681                 (byte) 128);
682     }
683
684     private void runPrefixTest(LispAddress registerEID, int registerdMask, LispAddress matchedAddress, LispAddress unMatchedAddress, byte mask)
685             throws SocketTimeoutException {
686         MapRegister mapRegister = new MapRegister();
687         mapRegister.setWantMapNotify(true);
688         mapRegister.setNonce(8);
689         EidToLocatorRecord etlr = new EidToLocatorRecord();
690         etlr.setPrefix(registerEID);
691         etlr.setMaskLength(registerdMask);
692         etlr.setRecordTtl(254);
693         LocatorRecord record = new LocatorRecord();
694         record.setLocator(new LispIpv4Address("4.3.2.1"));
695         etlr.addLocator(record);
696         mapRegister.addEidToLocator(etlr);
697         sendMapRegister(mapRegister);
698         MapNotify mapNotify = recieveMapNotify();
699         assertEquals(8, mapNotify.getNonce());
700         MapRequest mapRequest = new MapRequest();
701         mapRequest.setNonce(4);
702         mapRequest.addEidRecord(new EidRecord(mask, matchedAddress));
703         mapRequest.addItrRloc(new LispIpv4Address(ourAddress));
704         sendMapRequest(mapRequest);
705         MapReply mapReply = recieveMapReply();
706         assertEquals(4, mapReply.getNonce());
707         assertEquals(record.getLocator(), mapReply.getEidToLocatorRecords().get(0).getLocators().get(0).getLocator());
708         mapRequest.getEids().get(0).setPrefix(unMatchedAddress);
709         sendMapRequest(mapRequest);
710         mapReply = recieveMapReply();
711         assertEquals(0, mapReply.getEidToLocatorRecords().get(0).getLocators().size());
712     }
713
714     public void mapRequestMapRegisterAndMapRequest() throws SocketTimeoutException {
715
716         LispIpv4Address eid = new LispIpv4Address("1.2.3.4");
717         MapRequest mapRequest = new MapRequest();
718         mapRequest.setNonce(4);
719         mapRequest.addEidRecord(new EidRecord((byte) 32, eid));
720         mapRequest.addItrRloc(new LispIpv4Address(ourAddress));
721         sendMapRequest(mapRequest);
722         MapReply mapReply = recieveMapReply();
723         assertEquals(4, mapReply.getNonce());
724         assertEquals(0, mapReply.getEidToLocatorRecords().get(0).getLocators().size());
725         MapRegister mapRegister = new MapRegister();
726         mapRegister.setWantMapNotify(true);
727         mapRegister.setNonce(8);
728         EidToLocatorRecord etlr = new EidToLocatorRecord();
729         etlr.setPrefix(eid);
730         etlr.setMaskLength(32);
731         etlr.setRecordTtl(254);
732         LocatorRecord record = new LocatorRecord();
733         record.setLocator(new LispIpv4Address("4.3.2.1"));
734         etlr.addLocator(record);
735         mapRegister.addEidToLocator(etlr);
736         sendMapRegister(mapRegister);
737         MapNotify mapNotify = recieveMapNotify();
738         assertEquals(8, mapNotify.getNonce());
739         sendMapRequest(mapRequest);
740         mapReply = recieveMapReply();
741         assertEquals(4, mapReply.getNonce());
742         assertEquals(record.getLocator(), mapReply.getEidToLocatorRecords().get(0).getLocators().get(0).getLocator());
743
744     }
745
746     private MapReply recieveMapReply() throws SocketTimeoutException {
747         return MapReplySerializer.getInstance().deserialize(ByteBuffer.wrap(receivePacket().getData()));
748     }
749
750     private MapNotify recieveMapNotify() throws SocketTimeoutException {
751         return MapNotifySerializer.getInstance().deserialize(ByteBuffer.wrap(receivePacket().getData()));
752     }
753
754     private void sendMapRequest(MapRequest mapRequest) {
755         sendPacket(MapRequestSerializer.getInstance().serialize(mapRequest).array());
756     }
757
758     private void sendMapRegister(MapRegister mapRegister) {
759         sendPacket(MapRegisterSerializer.getInstance().serialize(mapRegister).array());
760     }
761
762     @Test
763     public void mapRegisterWithAuthenticationWithoutConfiguringAKey() throws SocketTimeoutException {
764         sendPacket(mapRegisterPacketWithAuthenticationAndMapNotify);
765         try {
766             receivePacket(3000);
767             // If didn't timeout then fail:
768             fail();
769         } catch (SocketTimeoutException ste) {
770         }
771     }
772
773     @Test
774     public void mapRegisterWithMapNotifyWithListLcaf() throws SocketTimeoutException {
775         sendPacket(mapRegisterPacketWithNotifyWithListLCAFAndDistinguishedName);
776         ByteBuffer readBuf = ByteBuffer.wrap(receivePacket().getData());
777         MapNotify reply = MapNotifySerializer.getInstance().deserialize(readBuf);
778         EidToLocatorRecord etlr = reply.getEidToLocatorRecords().get(0);
779         List<LocatorRecord> locators = etlr.getLocators();
780         assertEquals(true, (locators.get(0).getLocator() instanceof LispListLCAFAddress));
781         LispListLCAFAddress listLCAF = (LispListLCAFAddress) locators.get(0).getLocator();
782         LispListLCAFAddress innerList = (LispListLCAFAddress) listLCAF.getAddresses().get(1);
783         LispDistinguishedNameAddress dn = new LispDistinguishedNameAddress("david");
784         assertEquals(dn, ((LispDistinguishedNameAddress) innerList.getAddresses().get(0)));
785         assertEquals(7, reply.getNonce());
786     }
787
788     @Test
789     public void mapRegisterWithoutMapNotify() {
790         sendPacket(mapRegisterPacketWithoutNotify);
791         try {
792             receivePacket(3000);
793             // If didn't timeout then fail:
794             fail();
795         } catch (SocketTimeoutException ste) {
796         }
797     }
798
799     private void sendPacket(byte[] bytesToSend) {
800         try {
801             DatagramPacket packet = new DatagramPacket(bytesToSend, bytesToSend.length);
802             initPacketAddress(packet);
803             logger.info("Sending MapRegister to LispPlugin on socket");
804             socket.send(packet);
805         } catch (Throwable t) {
806             t.printStackTrace();
807             fail();
808         }
809     }
810
811     private DatagramPacket receivePacket() throws SocketTimeoutException {
812         return receivePacket(6000);
813     }
814
815     private DatagramPacket receivePacket(int timeout) throws SocketTimeoutException {
816         try {
817             byte[] buffer = new byte[4096];
818             DatagramPacket receivePacket = new DatagramPacket(buffer, buffer.length);
819             logger.info("Waiting for packet from socket...");
820             socket.setSoTimeout(timeout);
821             socket.receive(receivePacket);
822             logger.info("Recieved packet from socket!");
823             return receivePacket;
824         } catch (SocketTimeoutException ste) {
825             throw ste;
826         } catch (Throwable t) {
827             t.printStackTrace();
828             fail();
829             return null;
830         }
831     }
832
833     private void initPacketAddress(DatagramPacket packet) throws UnknownHostException {
834         packet.setAddress(InetAddress.getByName(lispBindAddress));
835         packet.setPort(lispPortNumber);
836     }
837
838     private DatagramSocket initSocket(DatagramSocket socket) {
839         try {
840             socket = new DatagramSocket(new InetSocketAddress(ourAddress, LispMessage.PORT_NUM));
841         } catch (SocketException e) {
842             e.printStackTrace();
843             fail();
844         }
845         return socket;
846     }
847
848     private byte[] extractWSUdpByteArray(String wiresharkHex) {
849         final int HEADER_LEN = 42;
850         byte[] res = new byte[1000];
851         String[] split = wiresharkHex.split(" ");
852         int counter = 0;
853         for (String cur : split) {
854             cur = cur.trim();
855             if (cur.length() == 2) {
856                 ++counter;
857                 if (counter > HEADER_LEN) {
858                     res[counter - HEADER_LEN - 1] = (byte) Integer.parseInt(cur, 16);
859                 }
860
861             }
862         }
863         return Arrays.copyOf(res, counter - HEADER_LEN);
864     }
865
866     private String stateToString(int state) {
867         switch (state) {
868         case Bundle.ACTIVE:
869             return "ACTIVE";
870         case Bundle.INSTALLED:
871             return "INSTALLED";
872         case Bundle.RESOLVED:
873             return "RESOLVED";
874         case Bundle.UNINSTALLED:
875             return "UNINSTALLED";
876         default:
877             return "Not CONVERTED";
878         }
879     }
880
881     @Before
882     public void areWeReady() throws InvalidSyntaxException {
883         assertNotNull(bc);
884         boolean debugit = false;
885         Bundle b[] = bc.getBundles();
886         for (Bundle element : b) {
887             int state = element.getState();
888             if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
889                 System.out.println("Bundle:" + element.getSymbolicName() + " state:" + stateToString(state));
890
891                 // UNCOMMENT to see why bundles didn't resolve!
892                 /*
893                  * try { String host =
894                  * element.getHeaders().get(Constants.FRAGMENT_HOST); if (host
895                  * != null) { logger.warn("Bundle " + element.getSymbolicName()
896                  * + " is a fragment which is part of: " + host);
897                  * logger.warn("Required imports are: " +
898                  * element.getHeaders().get(Constants.IMPORT_PACKAGE)); } else {
899                  * element.start(); } } catch (BundleException e) {
900                  * logger.error("BundleException:", e); fail(); }
901                  * 
902                  * debugit = true;
903                  */
904             }
905         }
906         if (debugit) {
907             logger.warn(("Do some debugging because some bundle is unresolved"));
908         }
909         ServiceReference r = bc.getServiceReference(IFlowMapping.class.getName());
910         if (r != null) {
911             this.lms = (IFlowMapping) bc.getService(r);
912         }
913         // If LispMappingServer is null, cannot work
914         assertNotNull(this.lms);
915
916         // Uncomment this code to Know which services were actually loaded to
917         // BundleContext
918         /*
919          * for (ServiceReference sr : bc.getAllServiceReferences(null, null)) {
920          * logger.info(sr.getBundle().getSymbolicName());
921          * logger.info(sr.toString()); }
922          */
923     }
924 }