2 * Copyright (c) 2016, 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.
16 package org.openo.baseservice.roa.util;
18 import org.junit.After;
19 import org.junit.AfterClass;
20 import org.junit.Before;
21 import org.junit.BeforeClass;
22 import org.junit.Test;
24 import java.io.Reader;
25 import java.io.StringReader;
27 import junit.framework.Assert;
35 * @version SDNO 0.5 12-Jun-2016
37 public class ReaderHelperTest {
42 * @throws java.lang.Exception
46 public static void setUpBeforeClass() throws Exception {
52 * @throws java.lang.Exception
56 public static void tearDownAfterClass() throws Exception {
62 * @throws java.lang.Exception
66 public void setUp() throws Exception {
72 * @throws java.lang.Exception
76 public void tearDown() throws Exception {
80 * Test method for {@link org.openo.baseservice.util.inf.ReaderHelper#getLine()}.
83 public void testGetLine() {
84 final String message = "hello.. how are you?";
85 final Reader reader = new StringReader(message);
86 final ReaderHelper helper = new ReaderHelper(reader);
87 final String actual = helper.getLine();
88 Assert.assertEquals(message, actual);
92 * Test method for {@link org.openo.baseservice.util.inf.ReaderHelper#getLine()}.
95 public void testGetLineMultiLine() {
96 final String line1 = "hello.. how are you?";
97 final String line2 = "I am fine.";
98 final Reader reader = new StringReader(line1 + System.lineSeparator() + line2);
99 final ReaderHelper helper = new ReaderHelper(reader);
100 String actual = helper.getLine();
101 Assert.assertEquals(line1, actual);
102 actual = helper.getLine();
103 Assert.assertEquals(line2, actual);
104 actual = helper.getLine();
105 Assert.assertEquals(null, actual);
109 public void testGetLineNull() {
110 final ReaderHelper helper = new ReaderHelper(null);
111 final String actual = helper.getLine();
112 Assert.assertEquals(null, actual);