summaryrefslogtreecommitdiffstats
path: root/holmes-actions/src/test/java
diff options
context:
space:
mode:
authorYiLi <li.yi101@zte.com.cn>2018-03-15 10:59:09 +0800
committerYiLi <li.yi101@zte.com.cn>2018-03-16 09:19:10 +0800
commitc93746f09c38562d25e51b8274d6385eaaf07a00 (patch)
tree8225026e1ca212b18da80fcbd9f4578fc296aacb /holmes-actions/src/test/java
parent1a1dd97a485df783e654231bed8c562d8dd52955 (diff)
Add log filter
Change-Id: I07a51e3675f7ff99936c5788d56243934a083791 Issue-ID: HOLMES-112 Signed-off-by: YiLi <li.yi101@zte.com.cn>
Diffstat (limited to 'holmes-actions/src/test/java')
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/utils/transactionid/TransactionIdFilterTest.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/utils/transactionid/TransactionIdFilterTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/utils/transactionid/TransactionIdFilterTest.java
new file mode 100644
index 0000000..3ef092e
--- /dev/null
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/utils/transactionid/TransactionIdFilterTest.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2018 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.utils.transactionid;
+
+import javax.servlet.FilterChain;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class TransactionIdFilterTest {
+ TransactionIdFilter filter = new TransactionIdFilter();
+
+ private HttpServletRequest requestMock;
+ private HttpServletResponse responseMock;
+ private FilterChain chainMock;
+
+ @Before
+ public void setUp() throws Exception{
+ requestMock = EasyMock.createMock(HttpServletRequest.class);
+ responseMock = EasyMock.createMock(HttpServletResponse.class);
+ chainMock = EasyMock.createMock(FilterChain.class);
+ }
+ @Test
+ public void callsChainDoFilter() throws Exception {
+ filter.doFilter(requestMock, responseMock, chainMock);
+ EasyMock.verify();
+ }
+ @Test
+ public void requestIdExistTest() throws Exception{
+ String requestID = TransactionIdUtils.getUUID();
+ EasyMock.expect(requestMock.getHeader(TransactionIdUtils.REQUEST_ID_HEADER)).andReturn(requestID);
+
+ EasyMock.replay(requestMock);
+ filter.doFilter(requestMock, responseMock, chainMock);
+ EasyMock.verify();
+
+ }
+
+
+} \ No newline at end of file