2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.openecomp.appc.design.validator;
27 import java.io.InputStream;
28 import java.util.Enumeration;
29 import java.util.HashMap;
30 import java.util.Properties;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.openecomp.appc.design.services.util.DesignServiceConstants;
35 import org.openecomp.sdnc.sli.SvcLogicContext;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
39 import junit.framework.Assert;
41 public class TestValidatorService {
45 private final Logger logger = LoggerFactory.getLogger(TestValidatorService.class);
47 public void testvalidXMLValidation() throws Exception {
48 String response = null;
49 String xmlString = "<xml><configure>"
50 + "<operation>create</operation>"
52 + "<request-information>"
53 + "<source>SDN-GP</source>"
54 + "</request-information>"
59 ValidatorService vs = new ValidatorService();
61 response = vs.execute("", xmlString, "XML");
64 System.out.println(e.getMessage());
67 Assert.assertEquals("success", response);
71 public void testInvalidXMLValidation() throws Exception {
72 String response = null;
73 String xmlString = "<xml><configure>"
74 + "<operation>create</operation>"
76 + "<request-information>"
77 + "<source>SDN-GP</source>"
78 + "</request-information>"
82 ValidatorService vs = new ValidatorService();
84 response = vs.execute("", xmlString, "XML");
87 System.out.println(e.getMessage());
90 Assert.assertEquals(null, response);
94 public void testYAMLValidation() throws Exception {
95 String response = null;
96 String YAMLString = "en:";
99 ValidatorService vs = new ValidatorService();
101 response = vs.execute("", YAMLString, "YAML");
104 System.out.println(e.getMessage());
108 Assert.assertEquals("success", response);
112 public void testInvalidYAMLValidation() throws Exception {
113 String response = null;
114 String YAMLString = "Test \n A:";
117 ValidatorService vs = new ValidatorService();
119 response = vs.execute("", YAMLString,"YAML");
122 System.out.println(e.getMessage());
125 Assert.assertEquals(null, response);
130 public void testJSONValidation() throws Exception {
131 String response = null;
132 String YAMLString = "{\"Test\": \"Test1\" }";
135 ValidatorService vs = new ValidatorService();
137 response = vs.execute("", YAMLString, "JSON");
140 System.out.println(e.getMessage());
143 Assert.assertEquals("success", response);
147 public void testInvalidJSONValidation() throws Exception {
148 String response = null;
149 String YAMLString = "{\"Test\" \"Test1\" }";
152 ValidatorService vs = new ValidatorService();
154 response = vs.execute("", YAMLString, "JSON");
157 System.out.println(e.getMessage());
160 Assert.assertEquals(null, response);
165 public void testainvalidvalidateVelocity() throws Exception {
166 String response = null;
167 String validateVelocity = "{\"Test\" \"Test1\" }";
170 ValidatorService vs = new ValidatorService();
172 response = vs.execute("", validateVelocity, "Velocity");
175 System.out.println(e.getMessage());
178 Assert.assertEquals(null, response);