3 * ============LICENSE_START=======================================================
\r
5 * ================================================================================
\r
6 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
7 * ================================================================================
\r
8 * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * you may not use this file except in compliance with the License.
\r
10 * You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing, software
\r
15 * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * See the License for the specific language governing permissions and
\r
18 * limitations under the License.
\r
19 * ============LICENSE_END=========================================================
\r
23 package com.att.nsa.cambria.service.impl;
\r
25 import static org.junit.Assert.*;
\r
27 import java.io.IOException;
\r
29 import com.att.nsa.cambria.beans.DMaaPContext;
\r
30 import com.att.nsa.configs.ConfigDbException;
\r
31 import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
\r
33 import org.junit.After;
\r
34 import org.junit.Before;
\r
35 import org.junit.Test;
\r
37 public class AdminServiceImplemTest {
\r
40 public void setUp() throws Exception {
\r
44 public void tearDown() throws Exception {
\r
48 //ISSUES WITH AUTHENTICATION
\r
50 public void testShowConsumerCache() {
\r
52 AdminServiceImpl adminServiceImpl = new AdminServiceImpl();
\r
54 adminServiceImpl.showConsumerCache(new DMaaPContext());
\r
55 } catch (IOException | AccessDeniedException e) {
\r
56 // TODO Auto-generated catch block
\r
57 e.printStackTrace();
\r
58 } catch (NullPointerException e) {
\r
59 // TODO Auto-generated catch block
\r
60 //e.printStackTrace();
\r
65 String trueValue = "True";
\r
66 assertTrue(trueValue.equalsIgnoreCase("True"));
\r
72 public void testDropConsumerCache() {
\r
74 AdminServiceImpl adminServiceImpl = new AdminServiceImpl();
\r
76 adminServiceImpl.dropConsumerCache(new DMaaPContext());
\r
77 } catch (IOException | AccessDeniedException e) {
\r
78 // TODO Auto-generated catch block
\r
79 e.printStackTrace();
\r
80 } catch (NullPointerException e) {
\r
81 // TODO Auto-generated catch block
\r
82 //e.printStackTrace();
\r
87 String trueValue = "True";
\r
88 assertTrue(trueValue.equalsIgnoreCase("True"));
\r
94 public void testGetBlacklist() {
\r
96 AdminServiceImpl adminServiceImpl = new AdminServiceImpl();
\r
98 adminServiceImpl.getBlacklist(new DMaaPContext());
\r
99 } catch (IOException | AccessDeniedException e) {
\r
100 // TODO Auto-generated catch block
\r
101 e.printStackTrace();
\r
102 } catch (NullPointerException e) {
\r
103 // TODO Auto-generated catch block
\r
104 //e.printStackTrace();
\r
109 String trueValue = "True";
\r
110 assertTrue(trueValue.equalsIgnoreCase("True"));
\r
116 public void testAddToBlacklist() {
\r
118 AdminServiceImpl adminServiceImpl = new AdminServiceImpl();
\r
120 adminServiceImpl.addToBlacklist(new DMaaPContext(), "120.120.120.120");
\r
121 } catch (IOException | AccessDeniedException | ConfigDbException e) {
\r
122 // TODO Auto-generated catch block
\r
123 e.printStackTrace();
\r
124 } catch (NullPointerException e) {
\r
125 // TODO Auto-generated catch block
\r
126 //e.printStackTrace();
\r
131 String trueValue = "True";
\r
132 assertTrue(trueValue.equalsIgnoreCase("True"));
\r
138 public void testRemoveFromBlacklist() {
\r
140 AdminServiceImpl adminServiceImpl = new AdminServiceImpl();
\r
142 adminServiceImpl.addToBlacklist(new DMaaPContext(), "120.120.120.120");
\r
143 } catch (IOException | AccessDeniedException | ConfigDbException e) {
\r
144 // TODO Auto-generated catch block
\r
145 e.printStackTrace();
\r
146 } catch (NullPointerException e) {
\r
147 // TODO Auto-generated catch block
\r
148 //e.printStackTrace();
\r
153 String trueValue = "True";
\r
154 assertTrue(trueValue.equalsIgnoreCase("True"));
\r