init code
[vfc/nfvo/wfengine.git] / wso2 / rest-client / src / test / java / org / openo / baseservice / roa / util / ReaderHelperTest.java
1 /*
2  * Copyright 2016 Huawei Technologies Co., Ltd.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.openo.baseservice.roa.util;
17
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;
23
24 import java.io.Reader;
25 import java.io.StringReader;
26
27 import junit.framework.Assert;
28
29 /**
30  * <br/>
31  * <p>
32  * </p>
33  * 
34  * @author
35  * @version   12-Jun-2016
36  */
37 public class ReaderHelperTest {
38
39     /**
40      * <br/>
41      * 
42      * @throws java.lang.Exception
43      * @since  
44      */
45     @BeforeClass
46     public static void setUpBeforeClass() throws Exception {
47     }
48
49     /**
50      * <br/>
51      * 
52      * @throws java.lang.Exception
53      * @since  
54      */
55     @AfterClass
56     public static void tearDownAfterClass() throws Exception {
57     }
58
59     /**
60      * <br/>
61      * 
62      * @throws java.lang.Exception
63      * @since  
64      */
65     @Before
66     public void setUp() throws Exception {
67     }
68
69     /**
70      * <br/>
71      * 
72      * @throws java.lang.Exception
73      * @since  
74      */
75     @After
76     public void tearDown() throws Exception {
77     }
78
79     /**
80      * Test method for {@link org.openo.baseservice.util.inf.ReaderHelper#getLine()}.
81      */
82     @Test
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);
89     }
90
91     /**
92      * Test method for {@link org.openo.baseservice.util.inf.ReaderHelper#getLine()}.
93      */
94     @Test
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);
106     }
107
108     @Test
109     public void testGetLineNull() {
110         final ReaderHelper helper = new ReaderHelper(null);
111         final String actual = helper.getLine();
112         Assert.assertEquals(null, actual);
113
114     }
115
116 }