blob: 89d5ab96bfb9cf52c2cd2e6b4064a1adf1eb7d69 [file] [log] [blame]
xueliang37a396a2016-09-09 14:43:49 +09001/*
2 * Copyright 2016-present Open Networking Laboratory
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
17package org.onosproject.drivers.fujitsu;
18
19/**
20 * Mock FujitsuVoltXmlUtility.
21 * This is to avoid using the same names/definitions
22 * in FujitsuVoltXmlUtility in test codes - not tied to actual codes.
23 */
24final class FujitsuVoltXmlUtilityMock {
25
26 public static final String TEST_COLON = ":";
27 public static final String TEST_DOT = ".";
28 public static final String TEST_HYPHEN = "-";
29 public static final String TEST_SLASH = "/";
30 public static final String TEST_SPACE = " ";
31 public static final String TEST_NEW_LINE = "\n";
32 public static final String TEST_ANGLE_LEFT = "<";
33 public static final String TEST_ANGLE_RIGHT = ">";
34
35 public static final String TEST_REPORT_ALL = "report-all";
36 public static final String TEST_RUNNING = "running";
37
38 public static final String TEST_VOLT_NE_NAMESPACE =
39 "xmlns=\"http://fujitsu.com/ns/volt/1.1\"";
40 public static final String TEST_VOLT_NE = "volt-ne";
41 public static final String TEST_PONLINK_ID = "ponlink-id";
42 public static final String TEST_ONU_ID = "onu-id";
43 public static final String TEST_ROOT = "fakeroot";
44
45 public static final String TEST_VOLT_NE_OPEN = TEST_ANGLE_LEFT + TEST_VOLT_NE + TEST_SPACE;
46 public static final String TEST_VOLT_NE_CLOSE = TEST_ANGLE_LEFT + TEST_SLASH + TEST_VOLT_NE + TEST_ANGLE_RIGHT;
47
48 public static final String TEST_BASE_NAMESPACE =
49 " xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n";
50
51 public static final String TEST_DUPLICATE_SPACES_REGEX = " +";
52 public static final String TEST_WHITESPACES_REGEX = "\\s+";
53 public static final String TEST_EMPTY_STRING = "";
54
55 public static final String TEST_VOLT_NAMESPACE = TEST_VOLT_NE_OPEN +
56 TEST_VOLT_NE_NAMESPACE;
57
58
59 private FujitsuVoltXmlUtilityMock() {
60 }
61
62 /**
63 * Builds XML start tag with name provided.
64 *
65 * @param name tag name
66 * @return string
67 */
68 public static String startTag(String name) {
69 return startTag(name, true);
70 }
71
72 /**
73 * Builds XML end tag with name provided.
74 *
75 * @param name tag name
76 * @return string
77 */
78 public static String endTag(String name) {
79 return endTag(name, true);
80 }
81
82 /**
83 * Builds XML empty tag with name provided.
84 *
85 * @param name tag name
86 * @return string
87 */
88 public static String emptyTag(String name) {
89 return emptyTag(name, true);
90 }
91
92 /**
93 * Builds XML start tag with name provided.
94 *
95 * @param name tag name
96 * @param addNewLine option to add new line character after tag
97 * @return string
98 */
99 public static String startTag(String name, boolean addNewLine) {
100 if (addNewLine) {
101 return (TEST_ANGLE_LEFT + name + TEST_ANGLE_RIGHT + TEST_NEW_LINE);
102 } else {
103 return (TEST_ANGLE_LEFT + name + TEST_ANGLE_RIGHT);
104 }
105 }
106
107 /**
108 * Builds XML end tag with name provided.
109 *
110 * @param name tag name
111 * @param addNewLine option to add new line character after tag
112 * @return string
113 */
114 public static String endTag(String name, boolean addNewLine) {
115 if (addNewLine) {
116 return (TEST_ANGLE_LEFT + TEST_SLASH + name + TEST_ANGLE_RIGHT + TEST_NEW_LINE);
117 } else {
118 return (TEST_ANGLE_LEFT + TEST_SLASH + name + TEST_ANGLE_RIGHT);
119 }
120 }
121
122 /**
123 * Builds XML empty element tag with name provided.
124 *
125 * @param name tag name
126 * @param addNewLine option to add new line character after tag
127 * @return string
128 */
129 public static String emptyTag(String name, boolean addNewLine) {
130 if (addNewLine) {
131 return (TEST_ANGLE_LEFT + name + TEST_SLASH + TEST_ANGLE_RIGHT + TEST_NEW_LINE);
132 } else {
133 return (TEST_ANGLE_LEFT + name + TEST_SLASH + TEST_ANGLE_RIGHT);
134 }
135 }
136
137}