1 /*******************************************************************************
2 * ============LICENSE_START==================================================
4 * * ===========================================================================
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * * ===========================================================================
7 * * Licensed under the Apache License, Version 2.0 (the "License");
8 * * you may not use this file except in compliance with the License.
9 * * You may obtain a copy of the License at
11 * * http://www.apache.org/licenses/LICENSE-2.0
13 * * Unless required by applicable law or agreed to in writing, software
14 * * distributed under the License is distributed on an "AS IS" BASIS,
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * * See the License for the specific language governing permissions and
17 * * limitations under the License.
18 * * ============LICENSE_END====================================================
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 ******************************************************************************/
23 package org.onap.dmaap.datarouter.node;
25 import org.junit.Assert;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
29 import org.powermock.modules.junit4.PowerMockRunner;
31 @RunWith(PowerMockRunner.class)
32 @SuppressStaticInitializationFor("org.onap.dmaap.datarouter.node.NodeUtils")
33 public class NodeUtilsTest {
36 public void Given_Uri_With_Params_Then_Get_Feed_And_File_Id_Returns_Correct_Values() {
37 String uri = "prov.datarouternew.com:8443/feed/12/fileName";
38 String[] uriParams = NodeUtils.getFeedAndFileID(uri);
39 Assert.assertEquals("12", uriParams[0]);
40 Assert.assertEquals("fileName", uriParams[1]);
44 public void Given_Uri_With_Illegal_Params_Then_Get_Feed_And_File_Id_Returns_Null() {
45 String uri = "prov.datarouternew.com:8443/feed";
46 String[] uriParams = NodeUtils.getFeedAndFileID(uri);
47 Assert.assertNull(uriParams);
51 public void Given_String_With_Escape_Fields_Then_Loge_Returns_Special_Chars() {
52 String s = NodeUtils.loge("\\search|pub|12\n");
53 Assert.assertEquals("\\esearch\\ppub\\p12\\n", s);
57 public void Given_String_With_Special_Chars_Then_Loge_Returns_String_With_Escape_Fields() {
58 String s = NodeUtils.unloge("\\esearch\\ppub\\p12\\n");
59 Assert.assertEquals("\\search|pub|12\n", s);