Yuta HIGUCHI | b34078e | 2017-08-17 12:06:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 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.onlab.util; |
| 17 | |
| 18 | import static org.junit.Assert.*; |
| 19 | |
| 20 | import org.junit.Test; |
| 21 | |
| 22 | public class XmlStringTest { |
| 23 | |
| 24 | @Test |
| 25 | public void testToString() { |
| 26 | String input = "<root> <a some='foo '/><b attr='4' ><c>42</c></b></root>"; |
| 27 | CharSequence xml = XmlString.prettifyXml(input); |
| 28 | String expected = "<root>\n" |
| 29 | + " <a some=\"foo \"/>\n" |
| 30 | + " <b attr=\"4\">\n" |
| 31 | + " <c>42</c>\n" |
| 32 | + " </b>\n" |
| 33 | + "</root>\n"; |
| 34 | assertEquals(expected, xml.toString()); |
| 35 | } |
| 36 | |
| 37 | @Test |
| 38 | public void illFormed() { |
| 39 | String input = "<root> <a some='foo '/>"; |
| 40 | |
| 41 | assertEquals(input, XmlString.prettifyXml(input).toString()); |
| 42 | } |
| 43 | |
| 44 | } |