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