2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.aai.sparky.util;
23 import org.junit.Test;
25 import java.util.Arrays;
27 import static org.junit.Assert.assertEquals;
29 * The Class EncryptConvertor.
31 public class EncryptConvertorTest {
34 public void toHexStringTestString() {
35 assertEquals(EncryptConvertor.toHexString("abcd"),"61626364");
39 public void toHexStringTestByteArray() {
40 assertEquals(EncryptConvertor.toHexString("abcd".getBytes()),"61626364");
44 public void stringFromHexTestString() throws Exception {
45 assertEquals(EncryptConvertor.stringFromHex("61626364"),"abcd");
49 public void stringFromHexTestCharArray() throws Exception {
50 assertEquals(EncryptConvertor.stringFromHex("61626364".toCharArray()),"abcd");
54 public void bytesFromHexTestCharArray() throws Exception {
55 byte[] buf = {97, 98, 99, 100};
56 assertEquals(Arrays.toString(EncryptConvertor.bytesFromHex("61626364")), Arrays.toString(buf));
60 public void bytesFromHex() throws Exception {
61 byte[] buf = {97, 98, 99, 100};
62 assertEquals(Arrays.toString(EncryptConvertor.bytesFromHex("61626364".toCharArray())), Arrays.toString(buf));
66 public void fromHexDigit() throws Exception {
67 assertEquals(EncryptConvertor.fromHexDigit('a',2), 10);