Unit test cases for iaas impl package
[appc.git] / appc-adapters / appc-iaas-adapter / appc-iaas-adapter-bundle / src / test / java / org / onap / appc / adapter / iaas / impl / TestServiceCatalogFactory.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP : APPC\r
4  * ================================================================================\r
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Copyright (C) 2017 Amdocs\r
8  * =============================================================================\r
9  * Licensed under the Apache License, Version 2.0 (the "License");\r
10  * you may not use this file except in compliance with the License.\r
11  * You may obtain a copy of the License at\r
12  * \r
13  *      http://www.apache.org/licenses/LICENSE-2.0\r
14  * \r
15  * Unless required by applicable law or agreed to in writing, software\r
16  * distributed under the License is distributed on an "AS IS" BASIS,\r
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
18  * See the License for the specific language governing permissions and\r
19  * limitations under the License.\r
20  * \r
21  * ============LICENSE_END=========================================================\r
22  */\r
23 \r
24 package org.onap.appc.adapter.iaas.impl;\r
25 \r
26 import java.util.Properties;\r
27 import org.junit.Assert;\r
28 import org.junit.Test;\r
29 \r
30 /**\r
31  * This class tests the service catalog factory against a known provider.\r
32  */\r
33 public class TestServiceCatalogFactory {\r
34 \r
35     @Test\r
36     public void testGetServiceCatalogV2() {\r
37         String tenantIdentifier = null;\r
38         String principal = null;\r
39         String credential = null;\r
40         String domain = null;\r
41         Properties properties = null;\r
42 \r
43         String url = "http://192.168.1.1:5000/v2.0/";\r
44         ServiceCatalog catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential,\r
45                 domain, properties);\r
46         Assert.assertNotNull(catalog);\r
47         Assert.assertEquals(catalog.getClass(), ServiceCatalogV2.class);\r
48 \r
49         url = "http://192.168.1.1:5000/v2/";\r
50         catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential, domain,\r
51                 properties);\r
52         Assert.assertNotNull(catalog);\r
53         Assert.assertEquals(catalog.getClass(), ServiceCatalogV2.class);\r
54 \r
55         url = "http://192.168.1.1:5000/v2.1/";\r
56         catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential, domain,\r
57                 properties);\r
58         Assert.assertNotNull(catalog);\r
59         Assert.assertEquals(catalog.getClass(), ServiceCatalogV2.class);\r
60 \r
61     }\r
62 \r
63     @Test\r
64     public void testGetServiceCatalogV3() {\r
65         String url = "http://192.168.1.1:5000/v3.0/";\r
66         String tenantIdentifier = null;\r
67         String principal = null;\r
68         String credential = null;\r
69         String domain = null;\r
70         Properties properties = null;\r
71         ServiceCatalog catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential,\r
72                 domain, properties);\r
73 \r
74         Assert.assertNotNull(catalog);\r
75         Assert.assertEquals(catalog.getClass(), ServiceCatalogV3.class);\r
76     }\r
77 \r
78     @Test\r
79     public void testGetServiceCatalogOther() {\r
80         String url = "http://192.168.1.1:5000/v4.0/";\r
81         String tenantIdentifier = null;\r
82         String principal = null;\r
83         String credential = null;\r
84         String domain = null;\r
85         Properties properties = null;\r
86         ServiceCatalog catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential,\r
87                 domain, properties);\r
88 \r
89         Assert.assertNull(catalog);\r
90     }\r
91 \r
92     @Test\r
93     public void testGetServiceCatalogEmptyURL() {\r
94         String url = null;\r
95         String tenantIdentifier = null;\r
96         String principal = null;\r
97         String credential = null;\r
98         String domain = null;\r
99         Properties properties = null;\r
100         ServiceCatalog catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential,\r
101                 domain, properties);\r
102 \r
103         Assert.assertNull(catalog);\r
104     }\r
105 \r
106     @Test\r
107     public void testGetServiceCatalogWithoutVersion() {\r
108         String url = "http://192.168.1.1:5000/";\r
109         String tenantIdentifier = null;\r
110         String principal = null;\r
111         String credential = null;\r
112         String domain = null;\r
113         Properties properties = null;\r
114         ServiceCatalog catalog = ServiceCatalogFactory.getServiceCatalog(url, tenantIdentifier, principal, credential,\r
115                 domain, properties);\r
116 \r
117         Assert.assertNull(catalog);\r
118     }\r
119 \r
120 }\r