2 * Copyright (C) 2015 IBM, Inc.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.neutron.e2etest;
11 import java.io.OutputStreamWriter;
13 import java.lang.Thread;
15 import java.net.HttpURLConnection;
18 import org.junit.Assert;
20 public class NeutronSubnetTests {
23 public NeutronSubnetTests(String base) {
27 public void subnet_collection_get_test() {
28 String url_s = base + "/subnets";
30 URL url = new URL(url_s);
31 HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
32 httpConn.setRequestMethod("GET");
33 httpConn.setRequestProperty("Content-Type", "application/json");
34 httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
35 Assert.assertEquals("Subnet Collection GET failed",
36 200, httpConn.getResponseCode());
37 } catch (Exception e) {
38 Assert.assertFalse("E2E Tests Failed", true);
42 //TODO handle SB check
43 public void singleton_subnet_create_test() {
44 String url_s = base + "/subnets";
45 String content = " { \"subnet\": { "+
47 "\"enable_dhcp\": true, "+
48 "\"network_id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\", "+
49 "\"tenant_id\": \"9bacb3c5d39d41a79512987f338cf177\", "+
50 "\"dns_nameservers\": [], "+
51 "\"allocation_pools\": [ { "+
52 "\"start\": \"10.0.0.2\", "+
53 "\"end\": \"10.0.0.254\" } ], "+
54 "\"host_routes\": [], "+
55 "\"ip_version\": 4, "+
56 "\"gateway_ip\": \"10.0.0.1\", "+
57 "\"cidr\": \"10.0.0.0/24\", "+
58 "\"id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\" } } ";
61 URL url = new URL(url_s);
62 HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
63 httpConn.setRequestMethod("POST");
64 httpConn.setRequestProperty("Content-Type", "application/json");
65 httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
66 httpConn.setDoOutput(true);
67 OutputStreamWriter out = new OutputStreamWriter(
68 httpConn.getOutputStream());
71 Assert.assertEquals("Singleton Subnet Post Failed NB",
72 201, httpConn.getResponseCode());
73 } catch (Exception e) {
74 Assert.assertFalse("E2E Tests Failed", true);
78 //TODO handle SB check
79 public void external_subnet_create_test() {
80 String url_s = base + "/subnets";
81 String content = " { \"subnet\": { "+
83 "\"enable_dhcp\": true, "+
84 "\"network_id\": \"8ca37218-28ff-41cb-9b10-039601ea7e6b\", "+
85 "\"tenant_id\": \"9bacb3c5d39d41a79512987f338cf177\", "+
86 "\"dns_nameservers\": [], "+
87 "\"allocation_pools\": [ { "+
88 "\"start\": \"10.1.0.2\", "+
89 "\"end\": \"10.1.0.254\" } ], "+
90 "\"host_routes\": [], "+
91 "\"ip_version\": 4, "+
92 "\"gateway_ip\": \"10.1.0.1\", "+
93 "\"cidr\": \"10.1.0.0/24\", "+
94 "\"id\": \"f13b537f-1268-455f-b5fa-1e6817a9c204\" } } ";
97 URL url = new URL(url_s);
98 HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
99 httpConn.setRequestMethod("POST");
100 httpConn.setRequestProperty("Content-Type", "application/json");
101 httpConn.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4=");
102 httpConn.setDoOutput(true);
103 OutputStreamWriter out = new OutputStreamWriter(
104 httpConn.getOutputStream());
107 Assert.assertEquals("External Subnet Post Failed NB",
108 201, httpConn.getResponseCode());
109 } catch (Exception e) {
110 Assert.assertFalse("E2E Tests Failed", true);