1 package jtest.org.onap.ccsdk.sli.plugins.prop;
3 import java.util.HashMap;
4 import java.util.HashSet;
10 import org.junit.contrib.java.lang.system.EnvironmentVariables;
11 import static org.junit.Assert.assertEquals;
12 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
13 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
14 import org.onap.ccsdk.sli.plugins.prop.PropertiesNode;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 public class TestPropertiesNode {
20 private static final Logger log = LoggerFactory.getLogger(TestPropertiesNode.class);
22 public EnvironmentVariables environmentVariables = new EnvironmentVariables();
25 public void testJSONFileParsing() throws SvcLogicException {
26 SvcLogicContext ctx = new SvcLogicContext();
28 Map<String, String> p = new HashMap<String, String>();
29 p.put("fileName", "src/test/resources/test.json");
30 p.put("contextPrefix", "test-json");
31 p.put("fileBasedParsing","true");
33 PropertiesNode rcn = new PropertiesNode();
34 rcn.readProperties(p, ctx);
36 assertEquals(ctx.getAttribute("test-json.message"),"The provisioned access " +
37 "bandwidth is at or exceeds 50% of the total server capacity.");
41 public void testJSONFileArrayParsing() throws SvcLogicException {
42 SvcLogicContext ctx = new SvcLogicContext();
44 Map<String, String> p = new HashMap<String, String>();
45 p.put("fileName", "src/test/resources/test.json");
46 p.put("contextPrefix", "test-json");
47 p.put("fileBasedParsing","true");
49 PropertiesNode rcn = new PropertiesNode();
50 rcn.readProperties(p, ctx);
52 assertEquals(ctx.getAttribute("test-json.equipment-data[0].max-server-speed"),"1600000");
53 assertEquals(ctx.getAttribute("test-json.resource-state.used"),"1605000");
54 assertEquals(ctx.getAttribute("test-json.resource-rule.service-model"),"DUMMY");
55 assertEquals(ctx.getAttribute("test-json.resource-rule.endpoint-position"),"VCE-Cust");
59 public void testJSONFileParsingPrefixCheck() throws SvcLogicException {
60 SvcLogicContext ctx = new SvcLogicContext();
62 Map<String, String> p = new HashMap<String, String>();
63 p.put("fileName", "src/test/resources/test.json");
64 p.put("contextPrefix", "");
65 p.put("fileBasedParsing","true");
67 PropertiesNode rcn = new PropertiesNode();
68 rcn.readProperties(p, ctx);
70 assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000");
71 assertEquals(ctx.getAttribute("resource-state.used"),"1605000");
72 assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY");
73 assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust");
74 assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" +
75 "speed * number-primary-servers");
79 public void testJSONFileParsingNoPrefix() throws SvcLogicException {
80 SvcLogicContext ctx = new SvcLogicContext();
82 Map<String, String> p = new HashMap<String, String>();
83 p.put("fileName", "src/test/resources/test.json");
84 p.put("fileBasedParsing","true");
86 PropertiesNode rcn = new PropertiesNode();
87 rcn.readProperties(p, ctx);
89 assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000");
90 assertEquals(ctx.getAttribute("resource-state.used"),"1605000");
91 assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY");
92 assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust");
93 assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" +
94 "speed * number-primary-servers");
98 public void testJSONFileParsingCtxCheck() throws SvcLogicException {
99 SvcLogicContext ctx = new SvcLogicContext();
100 ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
102 Map<String, String> p = new HashMap<String, String>();
103 p.put("fileName", "src/test/resources/test.json");
104 p.put("fileBasedParsing","true");
106 PropertiesNode rcn = new PropertiesNode();
107 rcn.readProperties(p, ctx);
109 assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000");
110 assertEquals(ctx.getAttribute("resource-state.used"),"1605000");
111 assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY");
112 assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust");
113 assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" +
114 "speed * number-primary-servers");
115 assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
118 @Test(expected = SvcLogicException.class)
119 public void testToPropertiesInvalidJson() throws SvcLogicException {
120 SvcLogicContext ctx = new SvcLogicContext();
121 ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
123 Map<String, String> p = new HashMap<String, String>();
124 p.put("fileName", "src/test/resources/test-invalid.json");
125 p.put("contextPrefix", "invalid");
126 p.put("fileBasedParsing","true");
128 PropertiesNode rcn = new PropertiesNode();
129 rcn.readProperties(p, ctx);
131 assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
135 public void testTXTFileParsing() throws SvcLogicException {
137 environmentVariables.set("deployer_pass", "sdncp-123");
138 assertEquals("sdncp-123", System.getenv("deployer_pass"));
140 SvcLogicContext ctx = new SvcLogicContext();
142 Map<String, String> p = new HashMap<String, String>();
143 p.put("fileName", "src/test/resources/test.txt");
144 p.put("contextPrefix", "test-txt");
145 p.put("fileBasedParsing","true");
147 PropertiesNode rcn = new PropertiesNode();
148 rcn.readProperties(p, ctx);
150 assertEquals(ctx.getAttribute("test-txt.service-data.service-information.service-type"),"AVPN");
151 assertEquals(ctx.getAttribute("test-txt.service-configuration-notification-input.response-code"),"0");
152 assertEquals(ctx.getAttribute("test-txt.operational-data.avpn-ip-port-information.port-" +
153 "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
154 assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
155 "access-information.l1-customer-handoff"),"_1000BASELX");
156 assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
157 "access-information.vlan-tag-control"),"_1Q");
158 assertEquals(ctx.getAttribute("test-txt.obfuscated-var"), "sdncp-123");
162 public void testTXTFileParsingPrefixCheck() throws SvcLogicException {
163 SvcLogicContext ctx = new SvcLogicContext();
165 Map<String, String> p = new HashMap<String, String>();
166 p.put("fileName", "src/test/resources/test.txt");
167 p.put("contextPrefix", "");
168 p.put("fileBasedParsing","true");
170 PropertiesNode rcn = new PropertiesNode();
171 rcn.readProperties(p, ctx);
173 assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
174 assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
175 assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
176 "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
177 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
178 "access-information.l1-customer-handoff"),"_1000BASELX");
179 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
180 "access-information.vlan-tag-control"),"_1Q");
184 public void testTXTFileParsingNoPrefix() throws SvcLogicException {
185 SvcLogicContext ctx = new SvcLogicContext();
187 Map<String, String> p = new HashMap<String, String>();
188 p.put("fileName", "src/test/resources/test.txt");
189 p.put("fileBasedParsing","true");
191 PropertiesNode rcn = new PropertiesNode();
192 rcn.readProperties(p, ctx);
194 assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
195 assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
196 assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
197 "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
198 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
199 "access-information.l1-customer-handoff"),"_1000BASELX");
200 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
201 "access-information.vlan-tag-control"),"_1Q");
205 public void testTXTFileParsingCtxCheck() throws SvcLogicException {
206 SvcLogicContext ctx = new SvcLogicContext();
207 ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
209 Map<String, String> p = new HashMap<String, String>();
210 p.put("fileName", "src/test/resources/test.txt");
211 p.put("fileBasedParsing","true");
213 PropertiesNode rcn = new PropertiesNode();
214 rcn.readProperties(p, ctx);
216 assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
217 assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
218 assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
219 "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
220 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
221 "access-information.l1-customer-handoff"),"_1000BASELX");
222 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
223 "access-information.vlan-tag-control"),"_1Q");
224 assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
227 @Test(expected = SvcLogicException.class)
228 public void testToPropertiesInvalidParam() throws SvcLogicException {
229 SvcLogicContext ctx = new SvcLogicContext();
230 ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
232 Map<String, String> p = new HashMap<String, String>();
233 p.put("responsePrefix", "response");
234 p.put("skipSending", "true");
235 p.put("fileBasedParsing","true");
237 PropertiesNode rcn = new PropertiesNode();
238 rcn.readProperties(p, ctx);
240 assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
243 @Test(expected = SvcLogicException.class)
244 public void testToPropertiesNoParam() throws SvcLogicException {
245 SvcLogicContext ctx = new SvcLogicContext();
246 ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
248 Map<String, String> p = new HashMap<String, String>();
249 p.put("fileBasedParsing","true");
251 PropertiesNode rcn = new PropertiesNode();
252 rcn.readProperties(p, ctx);
254 assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
257 @Test(expected = SvcLogicException.class)
258 public void testToPropertiesFilePathError() throws SvcLogicException {
259 SvcLogicContext ctx = new SvcLogicContext();
260 ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
262 Map<String, String> p = new HashMap<String, String>();
263 p.put("fileName", "src/tests/resources/test.txt");
264 p.put("fileBasedParsing","true");
266 PropertiesNode rcn = new PropertiesNode();
267 rcn.readProperties(p, ctx);
269 assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
273 public void testXMLFileParsing() throws SvcLogicException {
274 SvcLogicContext ctx = new SvcLogicContext();
276 Map<String, String> p = new HashMap<String, String>();
277 p.put("fileName", "src/test/resources/test.xml");
278 p.put("contextPrefix", "test-xml");
279 p.put("listName", "project.build");
280 p.put("fileBasedParsing","true");
282 PropertiesNode rcn = new PropertiesNode();
283 rcn.readProperties(p, ctx);
285 assertEquals(ctx.getAttribute("test-xml.project.modelVersion"),"4.0.0");
289 public void testXMLFileInnerParsing() throws SvcLogicException {
290 SvcLogicContext ctx = new SvcLogicContext();
292 Map<String, String> p = new HashMap<String, String>();
293 p.put("fileName", "src/test/resources/test.xml");
294 p.put("contextPrefix", "test-xml");
295 p.put("listName", "project.modelVersion");
296 p.put("fileBasedParsing","true");
298 PropertiesNode rcn = new PropertiesNode();
299 rcn.readProperties(p, ctx);
301 assertEquals(ctx.getAttribute("test-xml.project.properties.project.build.sourceEncoding"),"UTF-8");
302 assertEquals(ctx.getAttribute("test-xml.project.dependencies.dependency.scope"),"provided");
303 assertEquals(ctx.getAttribute("test-xml.project.build.pluginManagement.plugins.plugin.configuration" +
304 ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
305 "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
306 assertEquals(ctx.getAttribute("test-xml.project.build.plugins.plugin.configuration." +
307 "instructions.Import-Package"),"*");
311 public void testXMLFileParsingPrefixCheck() throws SvcLogicException {
312 SvcLogicContext ctx = new SvcLogicContext();
314 Map<String, String> p = new HashMap<String, String>();
315 p.put("fileName", "src/test/resources/test.xml");
316 p.put("contextPrefix", "");
317 p.put("fileBasedParsing","true");
319 PropertiesNode rcn = new PropertiesNode();
320 rcn.readProperties(p, ctx);
322 assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8");
323 assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided");
324 assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" +
325 ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
326 "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
327 assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." +
328 "instructions.Import-Package"),"*");
332 public void testXMLFileParsingNoPrefix() throws SvcLogicException {
333 SvcLogicContext ctx = new SvcLogicContext();
335 Map<String, String> p = new HashMap<String, String>();
336 p.put("fileName", "src/test/resources/test.xml");
337 p.put("fileBasedParsing","true");
339 PropertiesNode rcn = new PropertiesNode();
340 rcn.readProperties(p, ctx);
342 assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8");
343 assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided");
344 assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" +
345 ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
346 "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
347 assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." +
348 "instructions.Import-Package"),"*");
352 public void testXMLFileParsingCtxCheck() throws SvcLogicException {
353 SvcLogicContext ctx = new SvcLogicContext();
354 ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
356 Map<String, String> p = new HashMap<String, String>();
357 p.put("fileName", "src/test/resources/test.xml");
358 p.put("fileBasedParsing","true");
360 PropertiesNode rcn = new PropertiesNode();
361 rcn.readProperties(p, ctx);
363 assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8");
364 assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided");
365 assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" +
366 ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
367 "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
368 assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." +
369 "instructions.Import-Package"),"*");
370 assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
373 @Test(expected = SvcLogicException.class)
374 public void testToPropertiesInvalidXML() throws SvcLogicException {
375 SvcLogicContext ctx = new SvcLogicContext();
376 ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
378 Map<String, String> p = new HashMap<String, String>();
379 p.put("fileName", "src/test/resources/test-invalid.xml");
380 p.put("contextPrefix", "invalid");
381 p.put("fileBasedParsing","true");
383 PropertiesNode rcn = new PropertiesNode();
384 rcn.readProperties(p, ctx);
386 assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
390 public void testXMLFileParsingListName() throws SvcLogicException {
391 SvcLogicContext ctx = new SvcLogicContext();
393 Map<String, String> p = new HashMap<String, String>();
394 p.put("fileName", "src/test/resources/test.xml");
395 p.put("contextPrefix", "test-xml-listName");
396 p.put("fileBasedParsing","true");
397 p.put("listName", "project.build.pluginManagement");
399 PropertiesNode rcn = new PropertiesNode();
400 rcn.readProperties(p, ctx);
402 assertEquals(ctx.getAttribute("test-xml-listName.project.build." +
403 "pluginManagement.plugins.plugin.version"),null);
404 assertEquals(ctx.getAttribute("test-xml-listName.project.build." +
405 "plugins.plugin.groupId"),"org.apache.felix");
409 public void testXMLFileParsingListNameAnother() throws SvcLogicException {
410 SvcLogicContext ctx = new SvcLogicContext();
412 Map<String, String> p = new HashMap<String, String>();
413 p.put("fileName", "src/test/resources/test.xml");
414 p.put("contextPrefix", "test-xml-listName");
415 p.put("fileBasedParsing","true");
416 p.put("listName", "project.modelVersion");
418 PropertiesNode rcn = new PropertiesNode();
419 rcn.readProperties(p, ctx);
421 assertEquals(ctx.getAttribute("test-xml-listName.project.modelVersion"),null);
422 assertEquals(ctx.getAttribute("test-xml-listName.project.build." +
423 "plugins.plugin.groupId"),"org.apache.felix");
427 public void testTXTFileParsingNotFileBased() throws SvcLogicException {
428 SvcLogicContext ctx = new SvcLogicContext();
430 Map<String, String> p = new HashMap<String, String>();
431 p.put("fileName", "src/test/resources/test.txt");
432 p.put("contextPrefix", "test-txt");
434 PropertiesNode rcn = new PropertiesNode();
435 rcn.readProperties(p, ctx);
437 assertEquals(ctx.getAttribute("test-txt.service-data.service-information.service-type"),"AVPN");
438 assertEquals(ctx.getAttribute("test-txt.service-configuration-notification-input.response-code"),"0");
439 assertEquals(ctx.getAttribute("test-txt.operational-data.avpn-ip-port-information.port-" +
440 "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
441 assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
442 "access-information.l1-customer-handoff"),"_1000BASELX");
443 assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
444 "access-information.vlan-tag-control"),"_1Q");
448 public void testTXTFileParsingPrefixCheckNotFileBased() throws SvcLogicException {
449 SvcLogicContext ctx = new SvcLogicContext();
451 Map<String, String> p = new HashMap<String, String>();
452 p.put("fileName", "src/test/resources/test.txt");
453 p.put("contextPrefix", "");
455 PropertiesNode rcn = new PropertiesNode();
456 rcn.readProperties(p, ctx);
458 assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
459 assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
460 assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
461 "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
462 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
463 "access-information.l1-customer-handoff"),"_1000BASELX");
464 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
465 "access-information.vlan-tag-control"),"_1Q");
469 public void testTXTFileParsingNoPrefixNotFileBased() throws SvcLogicException {
470 SvcLogicContext ctx = new SvcLogicContext();
472 Map<String, String> p = new HashMap<String, String>();
473 p.put("fileName", "src/test/resources/test.txt");
475 PropertiesNode rcn = new PropertiesNode();
476 rcn.readProperties(p, ctx);
478 assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
479 assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
480 assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
481 "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
482 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
483 "access-information.l1-customer-handoff"),"_1000BASELX");
484 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
485 "access-information.vlan-tag-control"),"_1Q");
489 public void testTXTFileParsingCtxCheckNotFileBased() throws SvcLogicException {
490 SvcLogicContext ctx = new SvcLogicContext();
491 ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
493 Map<String, String> p = new HashMap<String, String>();
494 p.put("fileName", "src/test/resources/test.txt");
496 PropertiesNode rcn = new PropertiesNode();
497 rcn.readProperties(p, ctx);
499 assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
500 assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
501 assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
502 "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
503 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
504 "access-information.l1-customer-handoff"),"_1000BASELX");
505 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
506 "access-information.vlan-tag-control"),"_1Q");
507 assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
511 public void testJSONFileArrayParsingNotFileBased() throws SvcLogicException {
512 SvcLogicContext ctx = new SvcLogicContext();
514 Map<String, String> p = new HashMap<String, String>();
515 p.put("fileName", "src/test/resources/test.json");
516 p.put("contextPrefix", "NotFileBased");
518 PropertiesNode rcn = new PropertiesNode();
519 rcn.readProperties(p, ctx);
521 assertEquals(ctx.getAttribute("NotFileBased.\"limit-value\""),"\"1920000\"");
522 assertEquals(ctx.getAttribute("NotFileBased.\"hard-limit-expression\""),"\"max-server-speed * number-primary-servers\",");
523 assertEquals(ctx.getAttribute("NotFileBased.\"test-inner-node\""),"\"Test-Value\"");
527 public void testXMLFileInnerParsingNotFileBased() throws SvcLogicException {
528 SvcLogicContext ctx = new SvcLogicContext();
530 Map<String, String> p = new HashMap<String, String>();
531 p.put("fileName", "src/test/resources/test.xml");
532 p.put("contextPrefix", "NotFileBased");
533 p.put("listName", "project.modelVersion");
535 PropertiesNode rcn = new PropertiesNode();
536 rcn.readProperties(p, ctx);
538 assertEquals(ctx.getAttribute("NotFileBased.<name>RESTAPI"),"Call Node - Provider</name>");
539 assertEquals(ctx.getAttribute("NotFileBased.<project"),
540 "xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
541 " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">");
542 assertEquals(ctx.getAttribute("NotFileBased.openECOMP"),"SDN-C");
543 assertEquals(ctx.getAttribute("NotFileBased.<ignore"),"/>");
547 public void testNoFileTypeNoPrefixNotFileBased() throws SvcLogicException {
548 SvcLogicContext ctx = new SvcLogicContext();
550 Map<String, String> p = new HashMap<String, String>();
551 p.put("fileName", "src/test/resources/test");
552 p.put("fileBasedParsing","true");
554 PropertiesNode rcn = new PropertiesNode();
555 rcn.readProperties(p, ctx);
557 assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
558 assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
559 assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
560 "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
561 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
562 "access-information.l1-customer-handoff"),"_1000BASELX");
563 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
564 "access-information.vlan-tag-control"),"_1Q");
567 @Test(expected = SvcLogicException.class)
568 public void testNoFileTypeParseReqError() throws SvcLogicException {
569 SvcLogicContext ctx = new SvcLogicContext();
571 Map<String, String> p = new HashMap<String, String>();
572 p.put("file Name", "src/test/resources/test");
573 p.put("fileBasedParsing","true");
575 PropertiesNode rcn = new PropertiesNode();
576 rcn.readProperties(p, ctx);
578 assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
579 assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
580 assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
581 "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
582 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
583 "access-information.l1-customer-handoff"),"_1000BASELX");
584 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
585 "access-information.vlan-tag-control"),"_1Q");
589 public void testNoFileTypeParseError() throws SvcLogicException {
590 SvcLogicContext ctx = new SvcLogicContext();
592 Map<String, String> p = new HashMap<String, String>();
593 p.put("fileName", "src/test/resources/test");
594 p.put("file Based % Parsing","true");
596 PropertiesNode rcn = new PropertiesNode();
597 rcn.readProperties(p, ctx);
599 assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
600 assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
601 assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
602 "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
603 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
604 "access-information.l1-customer-handoff"),"_1000BASELX");
605 assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
606 "access-information.vlan-tag-control"),"_1Q");