Change nexus values to properties
[appc.git] / app-c / appc / appc-common / src / test / java / org / openecomp / appc / util / TestStreamHelper.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
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
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
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=========================================================
20  */
21
22 package org.openecomp.appc.util;
23
24 import static org.junit.Assert.*;
25
26 import java.io.ByteArrayInputStream;
27
28 import org.junit.Test;
29 import org.openecomp.appc.util.StreamHelper;
30
31 public class TestStreamHelper {
32
33     private static final String text = "Filler text (also placeholder text or dummy text) is text that shares "
34         + "some characteristics of a real written text, but is random or otherwise generated. It may be used "
35         + "to display a sample of fonts, generate text for testing, or to spoof an e-mail spam filter. The "
36         + "process of using filler text is sometimes called greeking, although the text itself may be nonsense, "
37         + "or largely Latin, as in Lorem ipsum.\nASDF is the sequence of letters that appear on the first four "
38         + "keys on the home row of a QWERTY or QWERTZ keyboard. They are often used as a sample or test case "
39         + "or as random, meaningless nonsense. It is also a common learning tool for keyboard classes, since "
40         + "all four keys are located on Home row.\nETAOIN SHRDLU is the approximate order of frequency of the "
41         + "twelve most commonly used letters in the English language, best known as a nonsense phrase that "
42         + "sometimes appeared in print in the days of \"hot type\" publishing due to a custom of Linotype "
43         + "machine operators.\nLorem ipsum... is one of the most common filler texts, popular with "
44         + "typesetters and graphic designers. \"Li Europan lingues...\" is another similar example.\n"
45         + "Now is the time for all good men to come to the aid of the party\" is a phrase first proposed "
46         + "as a typing drill by instructor Charles E. Weller; its use is recounted in his book The Early "
47         + "History of the Typewriter, p. 21 (1918).[1] Frank E. McGurrin, an expert on the early Remington "
48         + "typewriter, used it in demonstrating his touch typing abilities in January 1889.[2] It has "
49         + "appeared in a number of typing books, often in the form \"Now is the time for all good men to "
50         + "come to the aid of their country.\"\nThe quick brown fox jumps over the lazy dog - A coherent, "
51         + "short phrase that uses every letter of the alphabet. See pangram for more examples.\nNew Petitions"
52         + " and Building Code - Many B movies of the 1940s, 50s, and 60s utilized the \"spinning newspaper\" "
53         + "effect to narrate important plot points that occurred offscreen. The effect necessitated the "
54         + "appearance of a realistic front page, which consisted of a main headline relevant to the plot, "
55         + "and several smaller headlines used as filler. A large number of these spinning newspapers "
56         + "included stories titled \"New Petitions Against Tax\" and \"Building Code Under Fire.\" These "
57         + "phrases have become running jokes among B movie fans, and particularly fans of Mystery "
58         + "Science Theater 3000. \nCharacter Generator Protocol - The Character Generator Protocol "
59         + "(CHARGEN) service is an Internet protocol intended for testing, debugging, and measurement "
60         + "purposes.\n!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefgh\n\""
61         + "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghi\n"
62         + "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghij\n"
63         + "$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijk\n";
64
65     @Test
66     public void testStreamHelperNullStream() {
67         assertNotNull(StreamHelper.getStringFromInputStream(null));
68         assertEquals("", StreamHelper.getStringFromInputStream(null));
69     }
70
71     @Test
72     public void testStreamHelperByteArrayStream() {
73         ByteArrayInputStream in = new ByteArrayInputStream(text.getBytes());
74
75         assertEquals(text, StreamHelper.getStringFromInputStream(in));
76     }
77
78 }