2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package com.att.nsa.dmaap.service;
\r
23 import static org.junit.Assert.*;
\r
25 import java.lang.reflect.InvocationTargetException;
\r
26 import java.lang.reflect.Method;
\r
28 import org.junit.After;
\r
29 import org.junit.Before;
\r
30 import org.junit.Test;
\r
32 import com.att.nsa.cambria.CambriaApiException;
\r
33 import com.att.nsa.cambria.beans.ApiKeyBean;
\r
34 import com.att.nsa.configs.ConfigDbException;
\r
35 import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
\r
37 public class ApiKeysRestServiceTest {
\r
39 private ApiKeysRestService service = null;
\r
42 public void setUp() throws Exception {
\r
43 service = new ApiKeysRestService();
\r
47 public void tearDown() throws Exception {
\r
51 public void testGetAllApiKeys() {
\r
54 service.getAllApiKeys();
\r
55 } catch (CambriaApiException e) {
\r
56 // TODO Auto-generated catch block
\r
57 e.printStackTrace();
\r
58 } catch (NullPointerException e) {
\r
65 public void testGetApiKey() {
\r
68 service.getApiKey("apikeyName");
\r
69 } catch (CambriaApiException e) {
\r
70 // TODO Auto-generated catch block
\r
71 e.printStackTrace();
\r
72 } catch (NullPointerException e) {
\r
79 public void testCreateApiKey() {
\r
82 service.createApiKey(new ApiKeyBean("hs647a@att.com", "test apikey"));
\r
83 } catch (CambriaApiException e) {
\r
84 // TODO Auto-generated catch block
\r
85 e.printStackTrace();
\r
86 } catch (NullPointerException e) {
\r
94 public void testUpdateApiKey() {
\r
97 service.updateApiKey("apikeyName", new ApiKeyBean("hs647a@att.com", "test apikey"));
\r
98 } catch (CambriaApiException e) {
\r
99 // TODO Auto-generated catch block
\r
100 e.printStackTrace();
\r
101 } catch (NullPointerException e) {
\r
108 public void testDeleteApiKey() {
\r
111 service.deleteApiKey("apikeyName");
\r
112 } catch (CambriaApiException e) {
\r
113 // TODO Auto-generated catch block
\r
114 e.printStackTrace();
\r
115 } catch (NullPointerException e) {
\r
122 public void testGetDmaapContext() {
\r
123 Class clazz = null;
\r
124 Method method = null;
\r
126 clazz = Class.forName("ApiKeysRestService");
\r
127 Object obj = clazz.newInstance();
\r
128 method = clazz.getDeclaredMethod("getDmaapContext", null);
\r
129 method.setAccessible(true);
\r
130 method.invoke(obj, null);
\r
131 } catch (ClassNotFoundException e) {
\r
132 // TODO Auto-generated catch block
\r
133 e.printStackTrace();
\r
134 } catch (NoSuchMethodException e) {
\r
135 // TODO Auto-generated catch block
\r
136 e.printStackTrace();
\r
137 } catch (SecurityException e) {
\r
138 // TODO Auto-generated catch block
\r
139 e.printStackTrace();
\r
140 } catch (InstantiationException e) {
\r
141 // TODO Auto-generated catch block
\r
142 e.printStackTrace();
\r
143 } catch (IllegalAccessException e) {
\r
144 // TODO Auto-generated catch block
\r
145 e.printStackTrace();
\r
146 } catch (IllegalArgumentException e) {
\r
147 // TODO Auto-generated catch block
\r
148 e.printStackTrace();
\r
149 } catch (InvocationTargetException e) {
\r
150 // TODO Auto-generated catch block
\r
151 e.printStackTrace();
\r