2 * Copyright (c) 2013, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.config.yangjmxgenerator.plugin.util;
11 import static java.util.Arrays.asList;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertTrue;
15 import java.io.IOException;
16 import org.junit.Ignore;
17 import org.junit.Test;
18 import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.FullyQualifiedName;
20 public class StringUtilTest {
22 public void testPrefixAndJoin() {
23 assertEquals(" extends p1.Foo,Bar", StringUtil.prefixAndJoin(asList(
24 new FullyQualifiedName("p1", "Foo"), new FullyQualifiedName("", "Bar")), "extends"));
28 public void testAddAsterixAtEachLineStart() {
29 String input = "foo \nbar";
30 String expectedOutput = "* foo\n* bar\n";
31 assertEquals(expectedOutput, StringUtil.addAsterixAtEachLineStart(input));
36 public void testCopyright() throws IOException {
37 assertTrue(StringUtil.loadCopyright().isPresent());
41 public void testFormatting() {
43 String input = " \tpack;\n" +
49 String expected = "pack;\n" +
55 assertEquals(expected, StringUtil.formatJavaSource(input));
58 String input = "{\n" +
62 String expected = "{\n" +
66 assertEquals(expected, StringUtil.formatJavaSource(input));