Merge "HostTracker Fixes"
[controller.git] / opendaylight / northbound / integrationtest / src / test / java / org / opendaylight / controller / northbound / integrationtest / NorthboundIT.java
1 package org.opendaylight.controller.northbound.integrationtest;
2
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 import org.osgi.framework.ServiceReference;
6 import org.osgi.framework.Bundle;
7 import javax.inject.Inject;
8
9 import org.junit.Assert;
10 import org.junit.Test;
11 import org.junit.Before;
12 import org.junit.runner.RunWith;
13 import org.ops4j.pax.exam.junit.PaxExam;
14 import org.osgi.framework.BundleContext;
15 import static org.junit.Assert.*;
16 import org.ops4j.pax.exam.junit.Configuration;
17 import static org.ops4j.pax.exam.CoreOptions.*;
18 import org.ops4j.pax.exam.Option;
19 import org.ops4j.pax.exam.util.PathUtils;
20 import java.io.BufferedReader;
21 import java.io.InputStream;
22 import java.io.InputStreamReader;
23 import java.io.OutputStreamWriter;
24 import java.net.HttpURLConnection;
25 import java.net.URL;
26 import java.nio.charset.Charset;
27 import java.util.Arrays;
28
29 import org.apache.commons.codec.binary.Base64;
30
31 import org.codehaus.jettison.json.JSONArray;
32 import org.codehaus.jettison.json.JSONException;
33 import org.codehaus.jettison.json.JSONObject;
34 import org.codehaus.jettison.json.JSONTokener;
35
36 import org.opendaylight.controller.hosttracker.IfIptoHost;
37 import org.opendaylight.controller.sal.core.ConstructionException;
38 import org.opendaylight.controller.sal.core.Node;
39 import org.opendaylight.controller.sal.core.NodeConnector;
40 import org.opendaylight.controller.sal.core.UpdateType;
41 import org.opendaylight.controller.switchmanager.IInventoryListener;
42 import org.opendaylight.controller.usermanager.IUserManager;
43
44
45 @RunWith(PaxExam.class)
46 public class NorthboundIT {
47     private Logger log = LoggerFactory
48             .getLogger(NorthboundIT.class);
49     // get the OSGI bundle context
50     @Inject
51     private BundleContext bc;
52     private IUserManager users = null;
53     private IInventoryListener invtoryListener = null;
54
55     private String stateToString(int state) {
56         switch (state) {
57         case Bundle.ACTIVE:
58             return "ACTIVE";
59         case Bundle.INSTALLED:
60             return "INSTALLED";
61         case Bundle.RESOLVED:
62             return "RESOLVED";
63         case Bundle.UNINSTALLED:
64             return "UNINSTALLED";
65         default:
66             return "Not CONVERTED";
67         }
68     }
69
70     @Before
71     public void areWeReady() {
72         assertNotNull(bc);
73         boolean debugit = false;
74         Bundle b[] = bc.getBundles();
75         for (int i = 0; i < b.length; i++) {
76             int state = b[i].getState();
77             if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
78                 log.debug("Bundle:" + b[i].getSymbolicName() + " state:"
79                         + stateToString(state));
80                 debugit = true;
81             }
82         }
83         if (debugit) {
84             log.debug("Do some debugging because some bundle is "
85                     + "unresolved");
86         }
87         // Assert if true, if false we are good to go!
88         assertFalse(debugit);
89
90         ServiceReference r = bc.getServiceReference(IUserManager.class
91                 .getName());
92         if (r != null) {
93             this.users = (IUserManager) bc.getService(r);
94         }
95         // If UserManager is null, cannot login to run tests.
96         assertNotNull(this.users);
97
98         r = bc.getServiceReference(IfIptoHost.class.getName());
99         if (r != null) {
100             this.invtoryListener = (IInventoryListener) bc.getService(r);
101         }
102
103         // If inventoryListener is null, cannot run hosttracker tests.
104         assertNotNull(this.invtoryListener);
105
106     }
107
108     // static variable to pass response code from getJsonResult()
109     private static Integer httpResponseCode = null;
110
111     private String getJsonResult(String restUrl) {
112         return getJsonResult(restUrl, "GET", null);
113     }
114
115     private String getJsonResult(String restUrl, String method) {
116         return getJsonResult(restUrl, method, null);
117     }
118
119     private String getJsonResult(String restUrl, String method, String body) {
120         // initialize response code to indicate error
121         httpResponseCode = 400;
122
123         try {
124             URL url = new URL(restUrl);
125             this.users.getAuthorizationList();
126             this.users.authenticate("admin", "admin");
127             String authString = "admin:admin";
128             byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
129             String authStringEnc = new String(authEncBytes);
130
131             HttpURLConnection connection = (HttpURLConnection) url
132                     .openConnection();
133             connection.setRequestMethod(method);
134             connection.setRequestProperty("Authorization", "Basic "
135                     + authStringEnc);
136             connection.setRequestProperty("Content-Type", "application/json");
137             connection.setRequestProperty("Accept", "application/json");
138
139             if (body != null) {
140                 connection.setDoOutput(true);
141                 OutputStreamWriter wr = new OutputStreamWriter(
142                         connection.getOutputStream());
143                 wr.write(body);
144                 wr.flush();
145             }
146             connection.connect();
147             connection.getContentType();
148
149             // Response code for success should be 2xx
150             httpResponseCode = connection.getResponseCode();
151             if (httpResponseCode > 299)
152                 return httpResponseCode.toString();
153
154             InputStream is = connection.getInputStream();
155             BufferedReader rd = new BufferedReader(new InputStreamReader(is,
156                     Charset.forName("UTF-8")));
157             StringBuilder sb = new StringBuilder();
158             int cp;
159             while ((cp = rd.read()) != -1) {
160                 sb.append((char) cp);
161             }
162             is.close();
163             connection.disconnect();
164             return sb.toString();
165         } catch (Exception e) {
166             return null;
167         }
168     }
169
170     private void testNodeProperties(JSONObject node, Integer nodeId,
171             String nodeType, Integer timestamp, String timestampName,
172             Integer actionsValue, Integer capabilitiesValue,
173             Integer tablesValue, Integer buffersValue) throws JSONException {
174
175         JSONObject nodeInfo = node.getJSONObject("node");
176         Assert.assertEquals(nodeId, (Integer) nodeInfo.getInt("@id"));
177         Assert.assertEquals(nodeType, nodeInfo.getString("@type"));
178
179         JSONObject properties = node.getJSONObject("properties");
180
181         if (timestamp == null || timestampName == null) {
182             Assert.assertFalse(properties.has("timeStamp"));
183         } else {
184             Assert.assertEquals(
185                     timestamp,
186                     (Integer) properties.getJSONObject("timeStamp").getInt(
187                             "timestamp"));
188             Assert.assertEquals(
189                     timestampName,
190                     properties.getJSONObject("timeStamp").getString(
191                             "timestampName"));
192         }
193         if (actionsValue == null) {
194             Assert.assertFalse(properties.has("actions"));
195         } else {
196             Assert.assertEquals(actionsValue, (Integer) properties
197                     .getJSONObject("actions").getInt("actionsValue"));
198         }
199         if (capabilitiesValue == null) {
200             Assert.assertFalse(properties.has("capabilities"));
201         } else {
202             Assert.assertEquals(capabilitiesValue, (Integer) properties
203                     .getJSONObject("capabilities").getInt("capabilitiesValue"));
204         }
205         if (tablesValue == null) {
206             Assert.assertFalse(properties.has("tables"));
207         } else {
208             Assert.assertEquals(tablesValue, (Integer) properties
209                     .getJSONObject("tables").getInt("tablesValue"));
210         }
211         if (buffersValue == null) {
212             Assert.assertFalse(properties.has("buffers"));
213         } else {
214             Assert.assertEquals(buffersValue, (Integer) properties
215                     .getJSONObject("buffers").getInt("buffersValue"));
216         }
217     }
218
219     private void testNodeConnectorProperties(
220             JSONObject nodeConnectorProperties, Integer ncId, String ncType,
221             Integer nodeId, String nodeType, Integer state,
222             Integer capabilities, Integer bandwidth) throws JSONException {
223
224         JSONObject nodeConnector = nodeConnectorProperties
225                 .getJSONObject("nodeconnector");
226         JSONObject node = nodeConnector.getJSONObject("node");
227         JSONObject properties = nodeConnectorProperties
228                 .getJSONObject("properties");
229
230         Assert.assertEquals(ncId, (Integer) nodeConnector.getInt("@id"));
231         Assert.assertEquals(ncType, nodeConnector.getString("@type"));
232         Assert.assertEquals(nodeId, (Integer) node.getInt("@id"));
233         Assert.assertEquals(nodeType, node.getString("@type"));
234         if (state == null) {
235             Assert.assertFalse(properties.has("state"));
236         } else {
237             Assert.assertEquals(
238                     state,
239                     (Integer) properties.getJSONObject("state").getInt(
240                             "stateValue"));
241         }
242         if (capabilities == null) {
243             Assert.assertFalse(properties.has("capabilities"));
244         } else {
245             Assert.assertEquals(capabilities, (Integer) properties
246                     .getJSONObject("capabilities").getInt("capabilitiesValue"));
247         }
248         if (bandwidth == null) {
249             Assert.assertFalse(properties.has("bandwidth"));
250         } else {
251             Assert.assertEquals(
252                     bandwidth,
253                     (Integer) properties.getJSONObject("bandwidth").getInt(
254                             "bandwidthValue"));
255         }
256
257     }
258
259     @Test
260     public void testSwitchManager() {
261         String baseURL = "http://127.0.0.1:8080/controller/nb/v2/switch/default/";
262
263         // define Node/NodeConnector attributes for test
264         int nodeId_1 = 51966;
265         int nodeId_2 = 3366;
266         int nodeId_3 = 4477;
267         int nodeConnectorId_1 = 51966;
268         int nodeConnectorId_2 = 12;
269         int nodeConnectorId_3 = 34;
270         String nodeType = "STUB";
271         String ncType = "STUB";
272         int timestamp_1 = 100000;
273         String timestampName_1 = "connectedSince";
274         int actionsValue_1 = 2;
275         int capabilitiesValue_1 = 3;
276         int tablesValue_1 = 1;
277         int buffersValue_1 = 1;
278         int ncState = 1;
279         int ncCapabilities = 1;
280         int ncBandwidth = 1000000000;
281
282         // Test GET all nodes
283         try {
284             String result = getJsonResult(baseURL + "nodes");
285             JSONTokener jt = new JSONTokener(result);
286             JSONObject json = new JSONObject(jt);
287
288             // Test for first node
289             JSONObject node = getJsonInstance(json, "nodeProperties", nodeId_1);
290             Assert.assertNotNull(node);
291             testNodeProperties(node, nodeId_1, nodeType, timestamp_1,
292                     timestampName_1, actionsValue_1, capabilitiesValue_1,
293                     tablesValue_1, buffersValue_1);
294
295             // Test 2nd node, properties of 2nd node same as first node
296             node = getJsonInstance(json, "nodeProperties", nodeId_2);
297             Assert.assertNotNull(node);
298             testNodeProperties(node, nodeId_2, nodeType, timestamp_1,
299                     timestampName_1, actionsValue_1, capabilitiesValue_1,
300                     tablesValue_1, buffersValue_1);
301
302             // Test 3rd node, properties of 3rd node same as first node
303             node = getJsonInstance(json, "nodeProperties", nodeId_3);
304             Assert.assertNotNull(node);
305             testNodeProperties(node, nodeId_3, nodeType, timestamp_1,
306                     timestampName_1, actionsValue_1, capabilitiesValue_1,
307                     tablesValue_1, buffersValue_1);
308
309         } catch (Exception e) {
310             Assert.assertTrue(false);
311         }
312
313         // Test GET nodeConnectors of a node
314         try {
315             //Test first node
316             String result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
317             JSONTokener jt = new JSONTokener(result);
318             JSONObject json = new JSONObject(jt);
319             JSONObject nodeConnectorProperties = json
320                     .getJSONObject("nodeConnectorProperties");
321
322             testNodeConnectorProperties(nodeConnectorProperties,
323                     nodeConnectorId_1, ncType, nodeId_1, nodeType, ncState,
324                     ncCapabilities, ncBandwidth);
325
326             //Test second node
327             result = getJsonResult(baseURL + "node/STUB/" + nodeId_2);
328             jt = new JSONTokener(result);
329             json = new JSONObject(jt);
330             nodeConnectorProperties = json
331                     .getJSONObject("nodeConnectorProperties");
332
333             testNodeConnectorProperties(nodeConnectorProperties,
334                     nodeConnectorId_2, ncType, nodeId_2, nodeType, ncState,
335                     ncCapabilities, ncBandwidth);
336
337             //Test third node
338             result = getJsonResult(baseURL + "node/STUB/" + nodeId_3);
339             jt = new JSONTokener(result);
340             json = new JSONObject(jt);
341
342             nodeConnectorProperties = json
343                     .getJSONObject("nodeConnectorProperties");
344             testNodeConnectorProperties(nodeConnectorProperties,
345                     nodeConnectorId_3, ncType, nodeId_3, nodeType, ncState,
346                     ncCapabilities, ncBandwidth);
347
348         } catch (Exception e) {
349             Assert.assertTrue(false);
350         }
351
352         // Test delete node property
353         try {
354             // Delete timestamp property from node1
355             String result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
356                     + "/property/timeStamp", "DELETE");
357             Assert.assertEquals(200, httpResponseCode.intValue());
358
359             // Check node1
360             result = getJsonResult(baseURL + "nodes");
361             JSONTokener jt = new JSONTokener(result);
362             JSONObject json = new JSONObject(jt);
363             JSONObject node = getJsonInstance(json, "nodeProperties", nodeId_1);
364             Assert.assertNotNull(node);
365             testNodeProperties(node, nodeId_1, nodeType, null, null,
366                     actionsValue_1, capabilitiesValue_1, tablesValue_1,
367                     buffersValue_1);
368
369             // Delete actions property from node2
370             result = getJsonResult(baseURL + "node/STUB/" + nodeId_2
371                     + "/property/actions", "DELETE");
372             Assert.assertEquals(200, httpResponseCode.intValue());
373
374             // Check node2
375             result = getJsonResult(baseURL + "nodes");
376             jt = new JSONTokener(result);
377             json = new JSONObject(jt);
378             node = getJsonInstance(json, "nodeProperties", nodeId_2);
379             Assert.assertNotNull(node);
380             testNodeProperties(node, nodeId_2, nodeType, timestamp_1,
381                     timestampName_1, null, capabilitiesValue_1, tablesValue_1,
382                     buffersValue_1);
383
384         } catch (Exception e) {
385             Assert.assertTrue(false);
386         }
387
388         // Test add property to node
389         try {
390             // Add Tier and Bandwidth property to node1
391             String result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
392                     + "/property/tier/1001", "PUT");
393             Assert.assertEquals(201, httpResponseCode.intValue());
394             result = getJsonResult(baseURL + "node/STUB/" + nodeId_1
395                     + "/property/bandwidth/1002", "PUT");
396             Assert.assertEquals(201, httpResponseCode.intValue());
397
398             // Test for first node
399             result = getJsonResult(baseURL + "nodes");
400             JSONTokener jt = new JSONTokener(result);
401             JSONObject json = new JSONObject(jt);
402             JSONObject node = getJsonInstance(json, "nodeProperties", nodeId_1);
403             Assert.assertNotNull(node);
404             Assert.assertEquals(1001, node.getJSONObject("properties")
405                     .getJSONObject("tier").getInt("tierValue"));
406             Assert.assertEquals(1002, node.getJSONObject("properties")
407                     .getJSONObject("bandwidth").getInt("bandwidthValue"));
408
409         } catch (Exception e) {
410             Assert.assertTrue(false);
411         }
412
413         // Test delete nodeConnector property
414         try {
415             // Delete state property of nodeconnector1
416             String result = getJsonResult(baseURL + "nodeconnector/STUB/"
417                     + nodeId_1 + "/STUB/" + nodeConnectorId_1
418                     + "/property/state", "DELETE");
419             Assert.assertEquals(200, httpResponseCode.intValue());
420
421             result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
422             JSONTokener jt = new JSONTokener(result);
423             JSONObject json = new JSONObject(jt);
424             JSONObject nodeConnectorProperties = json
425                     .getJSONObject("nodeConnectorProperties");
426
427             testNodeConnectorProperties(nodeConnectorProperties,
428                     nodeConnectorId_1, ncType, nodeId_1, nodeType, null,
429                     ncCapabilities, ncBandwidth);
430
431             // Delete capabilities property of nodeconnector2
432             result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_2
433                     + "/STUB/" + nodeConnectorId_2 + "/property/capabilities",
434                     "DELETE");
435             Assert.assertEquals(200, httpResponseCode.intValue());
436
437             result = getJsonResult(baseURL + "node/STUB/" + nodeId_2);
438             jt = new JSONTokener(result);
439             json = new JSONObject(jt);
440             nodeConnectorProperties = json
441                     .getJSONObject("nodeConnectorProperties");
442
443             testNodeConnectorProperties(nodeConnectorProperties,
444                     nodeConnectorId_2, ncType, nodeId_2, nodeType, ncState,
445                     null, ncBandwidth);
446
447         } catch (Exception e) {
448             Assert.assertTrue(false);
449         }
450
451         // Test PUT nodeConnector property
452         try {
453             int newBandwidth = 1001;
454
455             // Add Name/Bandwidth property to nodeConnector1
456             String result = getJsonResult(baseURL + "nodeconnector/STUB/"
457                     + nodeId_1 + "/STUB/" + nodeConnectorId_1
458                     + "/property/bandwidth/" + newBandwidth, "PUT");
459             Assert.assertEquals(201, httpResponseCode.intValue());
460
461             result = getJsonResult(baseURL + "node/STUB/" + nodeId_1);
462             JSONTokener jt = new JSONTokener(result);
463             JSONObject json = new JSONObject(jt);
464             JSONObject nodeConnectorProperties = json
465                     .getJSONObject("nodeConnectorProperties");
466
467             // Check for new bandwidth value, state value removed from previous
468             // test
469             testNodeConnectorProperties(nodeConnectorProperties,
470                     nodeConnectorId_1, ncType, nodeId_1, nodeType, null,
471                     ncCapabilities, newBandwidth);
472
473         } catch (Exception e) {
474             Assert.assertTrue(false);
475         }
476     }
477
478     @Test
479     public void testStatistics() {
480         String actionTypes[] = { "drop", "loopback", "flood", "floodAll",
481                 "controller", "swPath", "hwPath", "output", "setDlSrc",
482                 "setDlDst", "setDlType", "setVlanId", "setVlanPcp",
483                 "setVlanCfi", "popVlan", "pushVlan", "setNwSrc", "setNwDst",
484                 "setNwTos", "setTpSrc", "setTpDst" };
485         System.out.println("Starting Statistics JAXB client.");
486
487         String baseURL = "http://127.0.0.1:8080/controller/nb/v2/statistics/default/";
488         try {
489             String result = getJsonResult(baseURL + "flowstats");
490             JSONTokener jt = new JSONTokener(result);
491             JSONObject json = new JSONObject(jt);
492             JSONObject flowStatistics = getJsonInstance(json, "flowStatistics",
493                     0xCAFE);
494             JSONObject node = flowStatistics.getJSONObject("node");
495             // test that node was returned properly
496             Assert.assertTrue(node.getInt("@id") == 0xCAFE);
497             Assert.assertTrue(node.getString("@type").equals("STUB"));
498
499             // test that flow statistics results are correct
500             JSONArray flowStats = flowStatistics.getJSONArray("flowStat");
501             for (int i = 0; i < flowStats.length(); i++) {
502
503                 JSONObject flowStat = flowStats.getJSONObject(i);
504                 testFlowStat(flowStat, actionTypes[i]);
505
506             }
507
508             // for /controller/nb/v2/statistics/default/portstats
509             result = getJsonResult(baseURL + "portstats");
510             jt = new JSONTokener(result);
511             json = new JSONObject(jt);
512             JSONObject portStatistics = getJsonInstance(json, "portStatistics",
513                     0xCAFE);
514             JSONObject node2 = portStatistics.getJSONObject("node");
515             // test that node was returned properly
516             Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
517             Assert.assertTrue(node2.getString("@type").equals("STUB"));
518
519             // test that port statistic results are correct
520             JSONObject portStat = portStatistics.getJSONObject("portStat");
521             Assert.assertTrue(portStat.getInt("receivePackets") == 250);
522             Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
523             Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
524             Assert.assertTrue(portStat.getInt("transmitBytes") == 5000);
525             Assert.assertTrue(portStat.getInt("receiveDrops") == 2);
526             Assert.assertTrue(portStat.getInt("transmitDrops") == 50);
527             Assert.assertTrue(portStat.getInt("receiveErrors") == 3);
528             Assert.assertTrue(portStat.getInt("transmitErrors") == 10);
529             Assert.assertTrue(portStat.getInt("receiveFrameError") == 5);
530             Assert.assertTrue(portStat.getInt("receiveOverRunError") == 6);
531             Assert.assertTrue(portStat.getInt("receiveCrcError") == 1);
532             Assert.assertTrue(portStat.getInt("collisionCount") == 4);
533
534             // test for getting one specific node's stats
535             result = getJsonResult(baseURL + "flowstats/STUB/51966");
536             jt = new JSONTokener(result);
537             json = new JSONObject(jt);
538             node = json.getJSONObject("node");
539             // test that node was returned properly
540             Assert.assertTrue(node.getInt("@id") == 0xCAFE);
541             Assert.assertTrue(node.getString("@type").equals("STUB"));
542
543             // test that flow statistics results are correct
544             flowStats = json.getJSONArray("flowStat");
545             for (int i = 0; i < flowStats.length(); i++) {
546                 JSONObject flowStat = flowStats.getJSONObject(i);
547                 testFlowStat(flowStat, actionTypes[i]);
548             }
549
550             result = getJsonResult(baseURL + "portstats/STUB/51966");
551             jt = new JSONTokener(result);
552             json = new JSONObject(jt);
553             node2 = json.getJSONObject("node");
554             // test that node was returned properly
555             Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
556             Assert.assertTrue(node2.getString("@type").equals("STUB"));
557
558             // test that port statistic results are correct
559             portStat = json.getJSONObject("portStat");
560             Assert.assertTrue(portStat.getInt("receivePackets") == 250);
561             Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
562             Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
563             Assert.assertTrue(portStat.getInt("transmitBytes") == 5000);
564             Assert.assertTrue(portStat.getInt("receiveDrops") == 2);
565             Assert.assertTrue(portStat.getInt("transmitDrops") == 50);
566             Assert.assertTrue(portStat.getInt("receiveErrors") == 3);
567             Assert.assertTrue(portStat.getInt("transmitErrors") == 10);
568             Assert.assertTrue(portStat.getInt("receiveFrameError") == 5);
569             Assert.assertTrue(portStat.getInt("receiveOverRunError") == 6);
570             Assert.assertTrue(portStat.getInt("receiveCrcError") == 1);
571             Assert.assertTrue(portStat.getInt("collisionCount") == 4);
572
573         } catch (Exception e) {
574             // Got an unexpected exception
575             Assert.assertTrue(false);
576
577         }
578     }
579
580     private void testFlowStat(JSONObject flowStat, String actionType) {
581         try {
582             Assert.assertTrue(flowStat.getInt("tableId") == 1);
583             Assert.assertTrue(flowStat.getInt("durationSeconds") == 40);
584             Assert.assertTrue(flowStat.getInt("durationNanoseconds") == 400);
585             Assert.assertTrue(flowStat.getInt("packetCount") == 200);
586             Assert.assertTrue(flowStat.getInt("byteCount") == 100);
587
588             // test that flow information is correct
589             JSONObject flow = flowStat.getJSONObject("flow");
590             Assert.assertTrue(flow.getInt("priority") == 3500);
591             Assert.assertTrue(flow.getInt("idleTimeout") == 1000);
592             Assert.assertTrue(flow.getInt("hardTimeout") == 2000);
593             Assert.assertTrue(flow.getInt("id") == 12345);
594
595             JSONObject match = (flow.getJSONObject("match")
596                     .getJSONObject("matchField"));
597             Assert.assertTrue(match.getString("type").equals("NW_DST"));
598             Assert.assertTrue(match.getString("value").equals("1.1.1.1"));
599
600             JSONObject act = flow.getJSONObject("actions");
601             Assert.assertTrue(act.getString("@type").equals(actionType));
602
603             if (act.getString("@type").equals("output")) {
604                 JSONObject port = act.getJSONObject("port");
605                 JSONObject port_node = port.getJSONObject("node");
606                 Assert.assertTrue(port.getInt("@id") == 51966);
607                 Assert.assertTrue(port.getString("@type").equals("STUB"));
608                 Assert.assertTrue(port_node.getInt("@id") == 51966);
609                 Assert.assertTrue(port_node.getString("@type").equals("STUB"));
610             }
611
612             if (act.getString("@type").equals("setDlSrc")) {
613                 byte srcMatch[] = { (byte) 5, (byte) 4, (byte) 3, (byte) 2,
614                         (byte) 1 };
615                 String src = act.getString("address");
616                 byte srcBytes[] = new byte[5];
617                 srcBytes[0] = Byte.parseByte(src.substring(0, 2));
618                 srcBytes[1] = Byte.parseByte(src.substring(2, 4));
619                 srcBytes[2] = Byte.parseByte(src.substring(4, 6));
620                 srcBytes[3] = Byte.parseByte(src.substring(6, 8));
621                 srcBytes[4] = Byte.parseByte(src.substring(8, 10));
622                 Assert.assertTrue(Arrays.equals(srcBytes, srcMatch));
623             }
624
625             if (act.getString("@type").equals("setDlDst")) {
626                 byte dstMatch[] = { (byte) 1, (byte) 2, (byte) 3, (byte) 4,
627                         (byte) 5 };
628                 String dst = act.getString("address");
629                 byte dstBytes[] = new byte[5];
630                 dstBytes[0] = Byte.parseByte(dst.substring(0, 2));
631                 dstBytes[1] = Byte.parseByte(dst.substring(2, 4));
632                 dstBytes[2] = Byte.parseByte(dst.substring(4, 6));
633                 dstBytes[3] = Byte.parseByte(dst.substring(6, 8));
634                 dstBytes[4] = Byte.parseByte(dst.substring(8, 10));
635                 Assert.assertTrue(Arrays.equals(dstBytes, dstMatch));
636             }
637             if (act.getString("@type").equals("setDlType"))
638                 Assert.assertTrue(act.getInt("dlType") == 10);
639             if (act.getString("@type").equals("setVlanId"))
640                 Assert.assertTrue(act.getInt("vlanId") == 2);
641             if (act.getString("@type").equals("setVlanPcp"))
642                 Assert.assertTrue(act.getInt("pcp") == 3);
643             if (act.getString("@type").equals("setVlanCfi"))
644                 Assert.assertTrue(act.getInt("cfi") == 1);
645
646             if (act.getString("@type").equals("setNwSrc"))
647                 Assert.assertTrue(act.getString("address").equals("2.2.2.2"));
648             if (act.getString("@type").equals("setNwDst"))
649                 Assert.assertTrue(act.getString("address").equals("1.1.1.1"));
650
651             if (act.getString("@type").equals("pushVlan")) {
652                 int head = act.getInt("VlanHeader");
653                 // parsing vlan header
654                 int id = head & 0xfff;
655                 int cfi = (head >> 12) & 0x1;
656                 int pcp = (head >> 13) & 0x7;
657                 int tag = (head >> 16) & 0xffff;
658                 Assert.assertTrue(id == 1234);
659                 Assert.assertTrue(cfi == 1);
660                 Assert.assertTrue(pcp == 1);
661                 Assert.assertTrue(tag == 0x8100);
662             }
663             if (act.getString("@type").equals("setNwTos"))
664                 Assert.assertTrue(act.getInt("tos") == 16);
665             if (act.getString("@type").equals("setTpSrc"))
666                 Assert.assertTrue(act.getInt("port") == 4201);
667             if (act.getString("@type").equals("setTpDst"))
668                 Assert.assertTrue(act.getInt("port") == 8080);
669         } catch (Exception e) {
670             Assert.assertTrue(false);
671         }
672     }
673
674     @Test
675     public void testFlowProgrammer() {
676         try {
677             String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flow/default/";
678             // Attempt to get a flow that doesn't exit. Should return 404
679             // status.
680             String result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
681             Assert.assertTrue(result.equals("404"));
682
683             // test add flow1
684             String fc = "{\"dynamic\":\"false\", \"name\":\"test1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
685             result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
686             Assert.assertTrue(httpResponseCode == 201);
687
688             // test get returns flow that was added.
689             result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
690             // check that result came out fine.
691             Assert.assertTrue(httpResponseCode == 200);
692             JSONTokener jt = new JSONTokener(result);
693             JSONObject json = new JSONObject(jt);
694             Assert.assertTrue(json.getString("name").equals("test1"));
695             Assert.assertTrue(json.getString("actions").equals("DROP"));
696             Assert.assertTrue(json.getString("installInHw").equals("true"));
697             JSONObject node = json.getJSONObject("node");
698             Assert.assertTrue(node.getString("@type").equals("STUB"));
699             Assert.assertTrue(node.getString("@id").equals("51966"));
700             // test adding same flow again fails due to repeat name..return 409
701             // code
702             result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
703             Assert.assertTrue(result.equals("409"));
704
705             fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
706             result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
707             // test should return 500 for error due to same flow being added.
708             Assert.assertTrue(result.equals("500"));
709
710             // add second flow that's different
711             fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
712             result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
713             Assert.assertTrue(httpResponseCode == 201);
714
715             // check that request returns both flows given node.
716             result = getJsonResult(baseURL + "STUB/51966/", "GET");
717             jt = new JSONTokener(result);
718             json = new JSONObject(jt);
719             Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
720             JSONArray ja = json.getJSONArray("flowConfig");
721             Integer count = ja.length();
722             Assert.assertTrue(count == 2);
723
724             // check that request returns both flows given just container.
725             result = getJsonResult(baseURL);
726             jt = new JSONTokener(result);
727             json = new JSONObject(jt);
728             Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
729             ja = json.getJSONArray("flowConfig");
730             count = ja.length();
731             Assert.assertTrue(count == 2);
732
733             // delete a flow, check that it's no longer in list.
734             result = getJsonResult(baseURL + "STUB/51966/test2", "DELETE");
735             Assert.assertTrue(httpResponseCode == 200);
736
737             result = getJsonResult(baseURL + "STUB/51966/test2", "GET");
738             Assert.assertTrue(result.equals("404"));
739
740         } catch (Exception e) {
741             Assert.assertTrue(false);
742         }
743
744     }
745
746     // method to extract a JSONObject with specified node ID from a JSONObject
747     // that may contain an array of JSONObjects
748     // This is specifically written for statistics manager northbound REST
749     // interface
750     // array_name should be either "flowStatistics" or "portStatistics"
751     private JSONObject getJsonInstance(JSONObject json, String array_name,
752             Integer nodeId) throws JSONException {
753         JSONObject result = null;
754         if (json.get(array_name) instanceof JSONArray) {
755             JSONArray json_array = json.getJSONArray(array_name);
756             for (int i = 0; i < json_array.length(); i++) {
757                 result = json_array.getJSONObject(i);
758                 Integer nid = result.getJSONObject("node").getInt("@id");
759                 if (nid.equals(nodeId))
760                     break;
761             }
762         } else {
763             result = json.getJSONObject(array_name);
764             Integer nid = result.getJSONObject("node").getInt("@id");
765             if (!nid.equals(nodeId))
766                 result = null;
767         }
768         return result;
769     }
770
771     // a class to construct query parameter for HTTP request
772     private class QueryParameter {
773         StringBuilder queryString = null;
774
775         // constructor
776         QueryParameter(String key, String value) {
777             queryString = new StringBuilder();
778             queryString.append("?").append(key).append("=").append(value);
779         }
780
781         // method to add more query parameter
782         QueryParameter add(String key, String value) {
783             this.queryString.append("&").append(key).append("=").append(value);
784             return this;
785         }
786
787         // method to get the query parameter string
788         String getString() {
789             return this.queryString.toString();
790         }
791
792     }
793
794     @Test
795     public void testHostTracker() {
796
797         System.out.println("Starting HostTracker JAXB client.");
798
799         // setup 2 host models for @POST method
800         // 1st host
801         String networkAddress_1 = "192.168.0.8";
802         String dataLayerAddress_1 = "11:22:33:44:55:66";
803         String nodeType_1 = "STUB";
804         Integer nodeId_1 = 3366;
805         String nodeConnectorType_1 = "STUB";
806         Integer nodeConnectorId_1 = 12;
807         String vlan_1 = "4";
808
809         // 2nd host
810         String networkAddress_2 = "10.1.1.1";
811         String dataLayerAddress_2 = "1A:2B:3C:4D:5E:6F";
812         String nodeType_2 = "STUB";
813         Integer nodeId_2 = 4477;
814         String nodeConnectorType_2 = "STUB";
815         Integer nodeConnectorId_2 = 34;
816         String vlan_2 = "0";
817
818         String baseURL = "http://127.0.0.1:8080/controller/nb/v2/host/default";
819
820         // test POST method: addHost()
821         try {
822             String queryParameter = new QueryParameter("dataLayerAddress",
823                     dataLayerAddress_1).add("nodeType", nodeType_1)
824                     .add("nodeId", nodeId_1.toString())
825                     .add("nodeConnectorType", nodeConnectorType_1)
826                     .add("nodeConnectorId", nodeConnectorId_1.toString())
827                     .add("vlan", vlan_1).getString();
828
829             String result = getJsonResult(baseURL + "/" + networkAddress_1
830                     + queryParameter, "POST");
831             Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
832
833             // vlan is not passed through query parameter but should be
834             // defaulted to "0"
835             queryParameter = new QueryParameter("dataLayerAddress",
836                     dataLayerAddress_2).add("nodeType", nodeType_2)
837                     .add("nodeId", nodeId_2.toString())
838                     .add("nodeConnectorType", nodeConnectorType_2)
839                     .add("nodeConnectorId", nodeConnectorId_2.toString())
840                     .getString();
841
842             result = getJsonResult(baseURL + "/" + networkAddress_2
843                     + queryParameter, "POST");
844             Assert.assertTrue(httpResponseCode.intValue() == (Integer) 201);
845         } catch (Exception e) {
846             // Got an unexpected exception
847             Assert.assertTrue(false);
848         }
849
850         // define variables for decoding returned strings
851         String networkAddress;
852         JSONObject host_jo, dl_jo, nc_jo, node_jo;
853
854         // the two hosts should be in inactive host DB
855         // test GET method: getInactiveHosts()
856         try {
857             String result = getJsonResult(baseURL + "/inactive", "GET");
858             Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
859
860             JSONTokener jt = new JSONTokener(result);
861             JSONObject json = new JSONObject(jt);
862             // there should be at least two hosts in the DB
863             Assert.assertTrue(json.get("host") instanceof JSONArray);
864             JSONArray ja = json.getJSONArray("host");
865             Integer count = ja.length();
866             Assert.assertTrue(count == 2);
867
868             for (int i = 0; i < count; i++) {
869                 host_jo = ja.getJSONObject(i);
870                 dl_jo = host_jo.getJSONObject("dataLayerAddress");
871                 nc_jo = host_jo.getJSONObject("nodeConnector");
872                 node_jo = nc_jo.getJSONObject("node");
873
874                 networkAddress = host_jo.getString("networkAddress");
875                 if (networkAddress.equalsIgnoreCase(networkAddress_1)) {
876                     Assert.assertTrue(dl_jo.getString("macAddress")
877                             .equalsIgnoreCase(dataLayerAddress_1));
878                     Assert.assertTrue(nc_jo.getString("@type")
879                             .equalsIgnoreCase(nodeConnectorType_1));
880                     Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
881                     Assert.assertTrue(node_jo.getString("@type")
882                             .equalsIgnoreCase(nodeType_1));
883                     Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
884                     Assert.assertTrue(host_jo.getString("vlan")
885                             .equalsIgnoreCase(vlan_1));
886                 } else if (networkAddress.equalsIgnoreCase(networkAddress_2)) {
887                     Assert.assertTrue(dl_jo.getString("macAddress")
888                             .equalsIgnoreCase(dataLayerAddress_2));
889                     Assert.assertTrue(nc_jo.getString("@type")
890                             .equalsIgnoreCase(nodeConnectorType_2));
891                     Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_2);
892                     Assert.assertTrue(node_jo.getString("@type")
893                             .equalsIgnoreCase(nodeType_2));
894                     Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_2);
895                     Assert.assertTrue(host_jo.getString("vlan")
896                             .equalsIgnoreCase(vlan_2));
897                 } else {
898                     Assert.assertTrue(false);
899                 }
900             }
901         } catch (Exception e) {
902             // Got an unexpected exception
903             Assert.assertTrue(false);
904         }
905
906         // test GET method: getActiveHosts() - no host expected
907         try {
908             String result = getJsonResult(baseURL, "GET");
909             Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
910
911             JSONTokener jt = new JSONTokener(result);
912             JSONObject json = new JSONObject(jt);
913             Assert.assertFalse(hostInJson(json, networkAddress_1));
914             Assert.assertFalse(hostInJson(json, networkAddress_2));
915         } catch (Exception e) {
916             // Got an unexpected exception
917             Assert.assertTrue(false);
918         }
919
920         // put the 1st host into active host DB
921         Node nd;
922         NodeConnector ndc;
923         try {
924             nd = new Node(nodeType_1, nodeId_1);
925             ndc = new NodeConnector(nodeConnectorType_1, nodeConnectorId_1, nd);
926             this.invtoryListener.notifyNodeConnector(ndc, UpdateType.ADDED,
927                     null);
928         } catch (ConstructionException e) {
929             ndc = null;
930             nd = null;
931         }
932
933         // verify the host shows up in active host DB
934         try {
935             String result = getJsonResult(baseURL, "GET");
936             Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
937
938             JSONTokener jt = new JSONTokener(result);
939             JSONObject json = new JSONObject(jt);
940
941             Assert.assertTrue(hostInJson(json, networkAddress_1));
942         } catch (Exception e) {
943             // Got an unexpected exception
944             Assert.assertTrue(false);
945         }
946
947         // test GET method for getHostDetails()
948         try {
949             String result = getJsonResult(baseURL + "/" + networkAddress_1,
950                     "GET");
951             Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
952
953             JSONTokener jt = new JSONTokener(result);
954             JSONObject json = new JSONObject(jt);
955
956             Assert.assertFalse(json.length() == 0);
957
958             dl_jo = json.getJSONObject("dataLayerAddress");
959             nc_jo = json.getJSONObject("nodeConnector");
960             node_jo = nc_jo.getJSONObject("node");
961
962             Assert.assertTrue(json.getString("networkAddress")
963                     .equalsIgnoreCase(networkAddress_1));
964             Assert.assertTrue(dl_jo.getString("macAddress").equalsIgnoreCase(
965                     dataLayerAddress_1));
966             Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(
967                     nodeConnectorType_1));
968             Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
969             Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(
970                     nodeType_1));
971             Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
972             Assert.assertTrue(json.getString("vlan").equalsIgnoreCase(vlan_1));
973         } catch (Exception e) {
974             // Got an unexpected exception
975             Assert.assertTrue(false);
976         }
977
978         // test DELETE method for deleteFlow()
979         try {
980             String result = getJsonResult(baseURL + "/" + networkAddress_1,
981                     "DELETE");
982             Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
983
984         } catch (Exception e) {
985             // Got an unexpected exception
986             Assert.assertTrue(false);
987         }
988
989         // verify host_1 removed from active host DB
990         // test GET method: getActiveHosts() - no host expected
991         try {
992             String result = getJsonResult(baseURL, "GET");
993             Assert.assertTrue(httpResponseCode.intValue() == (Integer) 200);
994
995             JSONTokener jt = new JSONTokener(result);
996             JSONObject json = new JSONObject(jt);
997
998             Assert.assertFalse(hostInJson(json, networkAddress_1));
999         } catch (Exception e) {
1000             // Got an unexpected exception
1001             Assert.assertTrue(false);
1002         }
1003     }
1004
1005     private Boolean hostInJson(JSONObject json, String hostIp)
1006             throws JSONException {
1007         // input JSONObject may be empty
1008         if (json.length() == 0) {
1009             return false;
1010         }
1011         if (json.get("host") instanceof JSONArray) {
1012             JSONArray ja = json.getJSONArray("host");
1013             for (int i = 0; i < ja.length(); i++) {
1014                 String na = ja.getJSONObject(i).getString("networkAddress");
1015                 if (na.equalsIgnoreCase(hostIp))
1016                     return true;
1017             }
1018             return false;
1019         } else {
1020             String na = json.getJSONObject("host").getString("networkAddress");
1021             return (na.equalsIgnoreCase(hostIp)) ? true : false;
1022         }
1023     }
1024
1025     // Configure the OSGi container
1026     @Configuration
1027     public Option[] config() {
1028         return options(
1029                 //
1030                 systemProperty("logback.configurationFile").value(
1031                         "file:" + PathUtils.getBaseDir()
1032                                 + "/src/test/resources/logback.xml"),
1033                 // To start OSGi console for inspection remotely
1034                 systemProperty("osgi.console").value("2401"),
1035                 systemProperty("org.eclipse.gemini.web.tomcat.config.path")
1036                         .value(PathUtils.getBaseDir()
1037                                 + "/src/test/resources/tomcat-server.xml"),
1038
1039                 // setting default level. Jersey bundles will need to be started
1040                 // earlier.
1041                 systemProperty("osgi.bundles.defaultStartLevel").value("4"),
1042
1043                 // Set the systemPackages (used by clustering)
1044                 systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
1045                 mavenBundle("javax.servlet", "servlet-api", "2.5"),
1046
1047                 mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.2"),
1048                 mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),
1049                 mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),
1050                 mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
1051                 mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
1052                 mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
1053                 mavenBundle("org.apache.felix",
1054                         "org.apache.felix.dependencymanager", "3.1.0"),
1055
1056                 // the plugin stub to get data for the tests
1057                 mavenBundle("org.opendaylight.controller",
1058                         "protocol_plugins.stub", "0.4.0-SNAPSHOT"),
1059
1060                 // List all the opendaylight modules
1061                 mavenBundle("org.opendaylight.controller", "security",
1062                         "0.4.0-SNAPSHOT").noStart(),
1063                 mavenBundle("org.opendaylight.controller", "sal",
1064                         "0.5.0-SNAPSHOT"),
1065                 mavenBundle("org.opendaylight.controller",
1066                         "sal.implementation", "0.4.0-SNAPSHOT"),
1067                 mavenBundle("org.opendaylight.controller", "statisticsmanager",
1068                         "0.4.0-SNAPSHOT"),
1069                 mavenBundle("org.opendaylight.controller",
1070                         "statisticsmanager.implementation", "0.4.0-SNAPSHOT"),
1071                 mavenBundle("org.opendaylight.controller", "containermanager",
1072                         "0.4.0-SNAPSHOT"),
1073                 mavenBundle("org.opendaylight.controller",
1074                         "containermanager.implementation", "0.4.0-SNAPSHOT"),
1075                 mavenBundle("org.opendaylight.controller",
1076                         "forwardingrulesmanager", "0.4.0-SNAPSHOT"),
1077                 mavenBundle("org.opendaylight.controller",
1078                         "forwardingrulesmanager.implementation",
1079                         "0.4.0-SNAPSHOT"),
1080                 mavenBundle("org.opendaylight.controller", "arphandler",
1081                         "0.4.0-SNAPSHOT"),
1082                 mavenBundle("org.opendaylight.controller",
1083                         "clustering.services", "0.4.0-SNAPSHOT"),
1084                 mavenBundle("org.opendaylight.controller",
1085                         "clustering.services-implementation", "0.4.0-SNAPSHOT"),
1086                 mavenBundle("org.opendaylight.controller", "switchmanager",
1087                         "0.4.0-SNAPSHOT"),
1088                 mavenBundle("org.opendaylight.controller",
1089                         "switchmanager.implementation", "0.4.0-SNAPSHOT"),
1090                 mavenBundle("org.opendaylight.controller", "configuration",
1091                         "0.4.0-SNAPSHOT"),
1092                 mavenBundle("org.opendaylight.controller",
1093                         "configuration.implementation", "0.4.0-SNAPSHOT"),
1094                 mavenBundle("org.opendaylight.controller", "hosttracker",
1095                         "0.4.0-SNAPSHOT"),
1096                 mavenBundle("org.opendaylight.controller",
1097                         "hosttracker.implementation", "0.4.0-SNAPSHOT"),
1098                 mavenBundle("org.opendaylight.controller", "arphandler",
1099                         "0.4.0-SNAPSHOT"),
1100                 mavenBundle("org.opendaylight.controller",
1101                         "routing.dijkstra_implementation", "0.4.0-SNAPSHOT"),
1102                 mavenBundle("org.opendaylight.controller", "topologymanager",
1103                         "0.4.0-SNAPSHOT"),
1104
1105                 mavenBundle("org.opendaylight.controller", "usermanager",
1106                         "0.4.0-SNAPSHOT"),
1107                 mavenBundle("org.opendaylight.controller",
1108                         "usermanager.implementation", "0.4.0-SNAPSHOT"),
1109                 mavenBundle("org.opendaylight.controller", "logging.bridge",
1110                         "0.4.0-SNAPSHOT"),
1111                 mavenBundle("org.opendaylight.controller", "clustering.test",
1112                         "0.4.0-SNAPSHOT"),
1113
1114                 mavenBundle("org.opendaylight.controller",
1115                         "forwarding.staticrouting", "0.4.0-SNAPSHOT"),
1116
1117                 // Northbound bundles
1118                 mavenBundle("org.opendaylight.controller",
1119                         "commons.northbound", "0.4.0-SNAPSHOT"),
1120                 mavenBundle("org.opendaylight.controller",
1121                         "forwarding.staticrouting.northbound", "0.4.0-SNAPSHOT"),
1122                 mavenBundle("org.opendaylight.controller",
1123                         "statistics.northbound", "0.4.0-SNAPSHOT"),
1124                 mavenBundle("org.opendaylight.controller",
1125                         "topology.northbound", "0.4.0-SNAPSHOT"),
1126                 mavenBundle("org.opendaylight.controller",
1127                         "hosttracker.northbound", "0.4.0-SNAPSHOT"),
1128                 mavenBundle("org.opendaylight.controller",
1129                         "switchmanager.northbound", "0.4.0-SNAPSHOT"),
1130                 mavenBundle("org.opendaylight.controller",
1131                         "flowprogrammer.northbound", "0.4.0-SNAPSHOT"),
1132                 mavenBundle("org.opendaylight.controller",
1133                         "subnets.northbound", "0.4.0-SNAPSHOT"),
1134
1135                 mavenBundle("org.codehaus.jackson", "jackson-mapper-asl",
1136                         "1.9.8"),
1137                 mavenBundle("org.codehaus.jackson", "jackson-core-asl", "1.9.8"),
1138                 mavenBundle("org.codehaus.jackson", "jackson-jaxrs", "1.9.8"),
1139                 mavenBundle("org.codehaus.jettison", "jettison", "1.3.3"),
1140
1141                 mavenBundle("commons-io", "commons-io", "2.3"),
1142
1143                 mavenBundle("commons-fileupload", "commons-fileupload", "1.2.2"),
1144
1145                 mavenBundle("equinoxSDK381", "javax.servlet",
1146                         "3.0.0.v201112011016"),
1147                 mavenBundle("equinoxSDK381", "javax.servlet.jsp",
1148                         "2.2.0.v201112011158"),
1149                 mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",
1150                         "1.4.0.v20120522-1841"),
1151                 mavenBundle("orbit", "javax.xml.rpc", "1.1.0.v201005080400"),
1152                 mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",
1153                         "1.0.400.v20120522-2049"),
1154                 mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",
1155                         "3.3.100.v20120522-1822"),
1156                 mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",
1157                         "0.8.0.v201108120515"),
1158                 mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",
1159                         "0.8.0.v201108120515"),
1160                 mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
1161                         "0.8.0.v201110170705"),
1162                 mavenBundle("equinoxSDK381", "org.eclipse.equinox.cm",
1163                         "1.0.400.v20120522-1841"),
1164                 mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",
1165                         "1.0.0.v20120522-1841"),
1166                 mavenBundle("equinoxSDK381", "org.eclipse.equinox.launcher",
1167                         "1.3.0.v20120522-1813"),
1168
1169                 mavenBundle("geminiweb", "org.eclipse.gemini.web.core",
1170                         "2.2.0.RELEASE"),
1171                 mavenBundle("geminiweb", "org.eclipse.gemini.web.extender",
1172                         "2.2.0.RELEASE"),
1173                 mavenBundle("geminiweb", "org.eclipse.gemini.web.tomcat",
1174                         "2.2.0.RELEASE"),
1175                 mavenBundle("geminiweb",
1176                         "org.eclipse.virgo.kernel.equinox.extensions",
1177                         "3.6.0.RELEASE").noStart(),
1178                 mavenBundle("geminiweb", "org.eclipse.virgo.util.common",
1179                         "3.6.0.RELEASE"),
1180                 mavenBundle("geminiweb", "org.eclipse.virgo.util.io",
1181                         "3.6.0.RELEASE"),
1182                 mavenBundle("geminiweb", "org.eclipse.virgo.util.math",
1183                         "3.6.0.RELEASE"),
1184                 mavenBundle("geminiweb", "org.eclipse.virgo.util.osgi",
1185                         "3.6.0.RELEASE"),
1186                 mavenBundle("geminiweb",
1187                         "org.eclipse.virgo.util.osgi.manifest", "3.6.0.RELEASE"),
1188                 mavenBundle("geminiweb",
1189                         "org.eclipse.virgo.util.parser.manifest",
1190                         "3.6.0.RELEASE"),
1191
1192                 mavenBundle("org.apache.felix",
1193                         "org.apache.felix.dependencymanager", "3.1.0"),
1194                 mavenBundle("org.apache.felix",
1195                         "org.apache.felix.dependencymanager.shell", "3.0.1"),
1196
1197                 mavenBundle("com.google.code.gson", "gson", "2.1"),
1198                 mavenBundle("org.jboss.spec.javax.transaction",
1199                         "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
1200                 mavenBundle("org.apache.felix", "org.apache.felix.fileinstall",
1201                         "3.1.6"),
1202                 mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
1203                 mavenBundle("commons-codec", "commons-codec"),
1204                 mavenBundle("virgomirror",
1205                         "org.eclipse.jdt.core.compiler.batch",
1206                         "3.8.0.I20120518-2145"),
1207                 mavenBundle("eclipselink", "javax.persistence",
1208                         "2.0.4.v201112161009"),
1209
1210                 mavenBundle("orbit", "javax.activation", "1.1.0.v201211130549"),
1211                 mavenBundle("orbit", "javax.annotation", "1.1.0.v201209060031"),
1212                 mavenBundle("orbit", "javax.ejb", "3.1.1.v201204261316"),
1213                 mavenBundle("orbit", "javax.el", "2.2.0.v201108011116"),
1214                 mavenBundle("orbit", "javax.mail.glassfish",
1215                         "1.4.1.v201108011116"),
1216                 mavenBundle("orbit", "javax.xml.rpc", "1.1.0.v201005080400"),
1217                 mavenBundle("orbit", "org.apache.catalina",
1218                         "7.0.32.v201211201336"),
1219                 // these are bundle fragments that can't be started on its own
1220                 mavenBundle("orbit", "org.apache.catalina.ha",
1221                         "7.0.32.v201211201952").noStart(),
1222                 mavenBundle("orbit", "org.apache.catalina.tribes",
1223                         "7.0.32.v201211201952").noStart(),
1224                 mavenBundle("orbit", "org.apache.coyote",
1225                         "7.0.32.v201211201952").noStart(),
1226                 mavenBundle("orbit", "org.apache.jasper",
1227                         "7.0.32.v201211201952").noStart(),
1228
1229                 mavenBundle("orbit", "org.apache.el", "7.0.32.v201211081135"),
1230                 mavenBundle("orbit", "org.apache.juli.extras",
1231                         "7.0.32.v201211081135"),
1232                 mavenBundle("orbit", "org.apache.tomcat.api",
1233                         "7.0.32.v201211081135"),
1234                 mavenBundle("orbit", "org.apache.tomcat.util",
1235                         "7.0.32.v201211201952").noStart(),
1236                 mavenBundle("orbit", "javax.servlet.jsp.jstl",
1237                         "1.2.0.v201105211821"),
1238                 mavenBundle("orbit", "javax.servlet.jsp.jstl.impl",
1239                         "1.2.0.v201210211230"),
1240
1241                 mavenBundle("org.ops4j.pax.exam", "pax-exam-container-native"),
1242                 mavenBundle("org.ops4j.pax.exam", "pax-exam-junit4"),
1243                 mavenBundle("org.ops4j.pax.exam", "pax-exam-link-mvn"),
1244                 mavenBundle("org.ops4j.pax.url", "pax-url-aether"),
1245
1246                 mavenBundle("org.springframework", "org.springframework.asm",
1247                         "3.1.3.RELEASE"),
1248                 mavenBundle("org.springframework", "org.springframework.aop",
1249                         "3.1.3.RELEASE"),
1250                 mavenBundle("org.springframework",
1251                         "org.springframework.context", "3.1.3.RELEASE"),
1252                 mavenBundle("org.springframework",
1253                         "org.springframework.context.support", "3.1.3.RELEASE"),
1254                 mavenBundle("org.springframework", "org.springframework.core",
1255                         "3.1.3.RELEASE"),
1256                 mavenBundle("org.springframework", "org.springframework.beans",
1257                         "3.1.3.RELEASE"),
1258                 mavenBundle("org.springframework",
1259                         "org.springframework.expression", "3.1.3.RELEASE"),
1260                 mavenBundle("org.springframework", "org.springframework.web",
1261                         "3.1.3.RELEASE"),
1262
1263                 mavenBundle("org.aopalliance",
1264                         "com.springsource.org.aopalliance", "1.0.0"),
1265                 mavenBundle("org.springframework",
1266                         "org.springframework.web.servlet", "3.1.3.RELEASE"),
1267                 mavenBundle("org.springframework.security",
1268                         "spring-security-config", "3.1.3.RELEASE"),
1269                 mavenBundle("org.springframework.security",
1270                         "spring-security-core", "3.1.3.RELEASE"),
1271                 mavenBundle("org.springframework.security",
1272                         "spring-security-web", "3.1.3.RELEASE"),
1273                 mavenBundle("org.springframework.security",
1274                         "spring-security-taglibs", "3.1.3.RELEASE"),
1275                 mavenBundle("org.springframework",
1276                         "org.springframework.transaction", "3.1.3.RELEASE"),
1277
1278                 mavenBundle("org.ow2.chameleon.management", "chameleon-mbeans",
1279                         "1.0.0"),
1280                 mavenBundle("org.opendaylight.controller.thirdparty",
1281                         "net.sf.jung2", "2.0.1-SNAPSHOT"),
1282                 mavenBundle("org.opendaylight.controller.thirdparty",
1283                         "com.sun.jersey.jersey-servlet", "1.17-SNAPSHOT"),
1284
1285                 // Jersey needs to be started before the northbound application
1286                 // bundles, using a lower start level
1287                 mavenBundle("com.sun.jersey", "jersey-client", "1.17"),
1288                 mavenBundle("com.sun.jersey", "jersey-server", "1.17")
1289                         .startLevel(2),
1290                 mavenBundle("com.sun.jersey", "jersey-core", "1.17")
1291                         .startLevel(2),
1292                 mavenBundle("com.sun.jersey", "jersey-json", "1.17")
1293                         .startLevel(2), junitBundles());
1294     }
1295 }