2 * Copyright 2017 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient;
19 import static org.junit.Assert.assertEquals;
21 import java.io.Reader;
22 import java.io.StringReader;
24 import org.junit.After;
25 import org.junit.AfterClass;
26 import org.junit.Before;
27 import org.junit.BeforeClass;
28 import org.junit.Test;
38 public class ReaderHelperTest {
43 * @throws java.lang.Exception
47 public static void setUpBeforeClass() throws Exception {
53 * @throws java.lang.Exception
57 public static void tearDownAfterClass() throws Exception {
63 * @throws java.lang.Exception
67 public void setUp() throws Exception {
73 * @throws java.lang.Exception
77 public void tearDown() throws Exception {
81 * Test method for {@link org.openo.baseservice.util.inf.ReaderHelper#getLine()}.
84 public void testGetLine() {
85 final String message = "hello.. how are you?";
86 final Reader reader = new StringReader(message);
87 final ReaderHelper helper = new ReaderHelper(reader);
88 final String actual = helper.getLine();
89 assertEquals(message, actual);
93 * Test method for {@link org.openo.baseservice.util.inf.ReaderHelper#getLine()}.
96 public void testGetLineMultiLine() {
97 final String line1 = "hello.. how are you?";
98 final String line2 = "I am fine.";
99 final Reader reader = new StringReader(line1 + System.lineSeparator() + line2);
100 final ReaderHelper helper = new ReaderHelper(reader);
101 String actual = helper.getLine();
102 assertEquals(line1, actual);
103 actual = helper.getLine();
104 assertEquals(line2, actual);
105 actual = helper.getLine();
106 assertEquals(null, actual);
110 public void testGetLineNull() {
111 final ReaderHelper helper = new ReaderHelper(null);
112 final String actual = helper.getLine();
113 assertEquals(null, actual);