commiting code for test coverage
[dmaap/messagerouter/messageservice.git] / src / test / java / com / att / nsa / dmaap / util / DMaaPAuthFilterTest.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP Policy Engine\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
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \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
19  */\r
20 \r
21 package com.att.nsa.dmaap.util;\r
22 \r
23 \r
24 import org.junit.After;\r
25 import org.junit.Before;\r
26 import org.junit.Test;\r
27 \r
28 import org.junit.runner.RunWith;\r
29 /*import org.mockito.InjectMocks;\r
30 import org.mockito.Mock;\r
31 import org.mockito.MockitoAnnotations;\r
32 import org.powermock.core.classloader.annotations.PrepareForTest;\r
33 import org.powermock.modules.junit4.PowerMockRunner;\r
34 \r
35 import com.att.ajsc.beans.PropertiesMapBean;\r
36 import static org.mockito.Mockito.when;\r
37 */\r
38 import java.io.IOException;\r
39 import javax.servlet.FilterChain;\r
40 import javax.servlet.ServletException;\r
41 import javax.servlet.ServletResponse;\r
42 import javax.servlet.http.HttpServletRequest;\r
43 \r
44 import com.att.nsa.cambria.beans.DMaaPContext;\r
45 import com.att.nsa.cambria.exception.DMaaPResponseCode;\r
46 \r
47 /*@RunWith(PowerMockRunner.class)\r
48 @PrepareForTest({ PropertiesMapBean.class, DMaaPResponseCode.class })*/\r
49 public class DMaaPAuthFilterTest {/*\r
50         \r
51         @InjectMocks\r
52         DMaaPAuthFilter filter;\r
53         \r
54         @Mock\r
55         HttpServletRequest req; \r
56         \r
57         @Mock\r
58         ServletResponse res;\r
59         \r
60         \r
61         @Mock\r
62         FilterChain chain;\r
63         \r
64         @Mock\r
65         DMaaPContext dmaapContext;\r
66         \r
67         @Before\r
68         public void setUp() throws Exception {\r
69                 MockitoAnnotations.initMocks(this);\r
70         }\r
71 \r
72         @After\r
73         public void tearDown() throws Exception {\r
74         }\r
75 \r
76         @Test\r
77         public void testDoFilter() throws IOException, ServletException {\r
78                 \r
79                 when(dmaapContext.getRequest()).thenReturn(req);\r
80                 when(req.getHeader("Authorization")).thenReturn("Authorization");\r
81         \r
82                 //when(dmaapContext.getResponse()).thenReturn(res);\r
83                 filter.doFilter(req, res, chain);\r
84 \r
85 \r
86         }\r
87         \r
88         @Test\r
89         public void testDoFilter_nullAuth() throws IOException, ServletException {\r
90                 \r
91                 when(dmaapContext.getRequest()).thenReturn(req);\r
92                 //when(req.getHeader("Authorization")).thenReturn("Authorization");\r
93         \r
94                 //when(dmaapContext.getResponse()).thenReturn(res);\r
95                 filter.doFilter(req, res, chain);\r
96 \r
97 \r
98         }\r
99 \r
100         \r
101         \r
102 */}