From 025301d08b061482c1f046d562bf017c8cbcfe8d Mon Sep 17 00:00:00 2001 From: ChrisC Date: Tue, 31 Jan 2017 11:40:03 +0100 Subject: Initial OpenECOMP MSO commit Change-Id: Ia6a7574859480717402cc2f22534d9973a78fa6d Signed-off-by: ChrisC --- bpmn/MSOCoreBPMN/pom.xml | 181 +++++++ .../org/openecomp/mso/bpmn/core/BPMNLogger.java | 33 ++ .../mso/bpmn/core/BadInjectedFieldException.java | 52 ++ .../java/org/openecomp/mso/bpmn/core/BaseTask.java | 529 ++++++++++++++++++++ .../mso/bpmn/core/HealthCheckHandler.java | 203 ++++++++ .../java/org/openecomp/mso/bpmn/core/LogTask.java | 98 ++++ .../bpmn/core/MissingInjectedFieldException.java | 39 ++ .../mso/bpmn/core/PropertyConfiguration.java | 440 +++++++++++++++++ .../openecomp/mso/bpmn/core/ReadConfigTask.java | 111 +++++ .../org/openecomp/mso/bpmn/core/ReadFileTask.java | 117 +++++ .../openecomp/mso/bpmn/core/ResponseBuilder.java | 297 ++++++++++++ .../org/openecomp/mso/bpmn/core/RollbackData.java | 108 +++++ .../openecomp/mso/bpmn/core/URNMappingsTask.java | 32 ++ .../openecomp/mso/bpmn/core/WorkflowException.java | 84 ++++ .../openecomp/mso/bpmn/core/XQueryScriptTask.java | 243 ++++++++++ .../openecomp/mso/bpmn/core/json/JsonUtils.java | 443 +++++++++++++++++ .../core/mybatis/CustomMyBatisSessionFactory.java | 102 ++++ .../mso/bpmn/core/mybatis/URNMapping.java | 122 +++++ .../core/plugins/LoggingAndURNMappingPlugin.java | 424 ++++++++++++++++ .../bpmn/core/plugins/WorkflowExceptionPlugin.java | 170 +++++++ .../org/openecomp/mso/bpmn/core/xml/XmlTool.java | 340 +++++++++++++ .../openecomp/mso/bpmn/test/CamundaDBSetup.java | 108 +++++ .../mso/bpmn/test/PropertyConfigurationSetup.java | 315 ++++++++++++ .../main/resources/customMyBatisConfiguration.xml | 32 ++ .../src/main/resources/normalize-namespaces.xsl | 185 +++++++ bpmn/MSOCoreBPMN/src/main/resources/urnMapping.xml | 44 ++ .../openecomp/mso/bpmn/core/BPMNLoggerESTest.java | 30 ++ .../mso/bpmn/core/BPMNLoggerESTestscaffolding.java | 106 ++++ .../bpmn/core/BadInjectedFieldExceptionESTest.java | 24 + ...BadInjectedFieldExceptionESTestscaffolding.java | 83 ++++ .../org/openecomp/mso/bpmn/core/JsonUtilsTest.java | 255 ++++++++++ .../org/openecomp/mso/bpmn/core/LogTaskESTest.java | 41 ++ .../mso/bpmn/core/LogTaskESTestscaffolding.java | 342 +++++++++++++ .../core/MissingInjectedFieldExceptionESTest.java | 20 + ...ingInjectedFieldExceptionESTestscaffolding.java | 85 ++++ .../mso/bpmn/core/PropertyConfigurationTest.java | 115 +++++ .../mso/bpmn/core/ReadConfigTaskESTest.java | 58 +++ .../bpmn/core/ReadConfigTaskESTestscaffolding.java | 331 +++++++++++++ .../mso/bpmn/core/ReadFileTaskESTest.java | 58 +++ .../bpmn/core/ReadFileTaskESTestscaffolding.java | 339 +++++++++++++ .../mso/bpmn/core/RollbackDataESTest.java | 117 +++++ .../bpmn/core/RollbackDataESTestscaffolding.java | 83 ++++ .../org/openecomp/mso/bpmn/core/TestBaseTask.java | 262 ++++++++++ .../mso/bpmn/core/URNMappingsTaskESTest.java | 27 ++ .../core/URNMappingsTaskESTestscaffolding.java | 103 ++++ .../mso/bpmn/core/WorkflowExceptionESTest.java | 88 ++++ .../core/WorkflowExceptionESTestscaffolding.java | 83 ++++ .../mso/bpmn/core/XQueryScriptTaskESTest.java | 81 ++++ .../core/XQueryScriptTaskESTestscaffolding.java | 533 +++++++++++++++++++++ .../mso/bpmn/core/json/JsonUtilsESTest.java | 165 +++++++ .../bpmn/core/json/JsonUtilsESTestscaffolding.java | 120 +++++ .../mso/bpmn/core/mybatis/URNMappingESTest.java | 114 +++++ .../core/mybatis/URNMappingESTestscaffolding.java | 78 +++ .../src/test/resources/BaseTaskTest.bpmn | 79 +++ .../MSOCoreBPMN/src/test/resources/camunda.cfg.xml | 77 +++ .../src/test/resources/logback-test.xml | 48 ++ .../src/test/resources/mso.bpmn.properties | 22 + .../src/test/resources/mso.bpmn.urn.properties | 21 + bpmn/MSOCoreBPMN/src/test/resources/request.json | 28 ++ 59 files changed, 8868 insertions(+) create mode 100644 bpmn/MSOCoreBPMN/pom.xml create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BPMNLogger.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BadInjectedFieldException.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/LogTask.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldException.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ResponseBuilder.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/URNMappingsTask.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/WorkflowException.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/test/CamundaDBSetup.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/test/PropertyConfigurationSetup.java create mode 100644 bpmn/MSOCoreBPMN/src/main/resources/customMyBatisConfiguration.xml create mode 100644 bpmn/MSOCoreBPMN/src/main/resources/normalize-namespaces.xsl create mode 100644 bpmn/MSOCoreBPMN/src/main/resources/urnMapping.xml create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BPMNLoggerESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BPMNLoggerESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BadInjectedFieldExceptionESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BadInjectedFieldExceptionESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/LogTaskESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/LogTaskESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldExceptionESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldExceptionESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadConfigTaskESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadConfigTaskESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadFileTaskESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadFileTaskESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/URNMappingsTaskESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/URNMappingsTaskESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/WorkflowExceptionESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/WorkflowExceptionESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/XQueryScriptTaskESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/XQueryScriptTaskESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/mybatis/URNMappingESTest.java create mode 100644 bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/mybatis/URNMappingESTestscaffolding.java create mode 100644 bpmn/MSOCoreBPMN/src/test/resources/BaseTaskTest.bpmn create mode 100644 bpmn/MSOCoreBPMN/src/test/resources/camunda.cfg.xml create mode 100644 bpmn/MSOCoreBPMN/src/test/resources/logback-test.xml create mode 100644 bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.properties create mode 100644 bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.urn.properties create mode 100644 bpmn/MSOCoreBPMN/src/test/resources/request.json (limited to 'bpmn/MSOCoreBPMN') diff --git a/bpmn/MSOCoreBPMN/pom.xml b/bpmn/MSOCoreBPMN/pom.xml new file mode 100644 index 0000000000..db0f7cf30a --- /dev/null +++ b/bpmn/MSOCoreBPMN/pom.xml @@ -0,0 +1,181 @@ + + + + org.openecomp.mso + bpmn + 0.0.4-SNAPSHOT + + 4.0.0 + org.openecomp.mso + MSOCoreBPMN + jar + + + + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.6 + + + + + default-jar + package + + jar + + + + org/openecomp/mso/bpmn/test/** + + + + + + + test-utilities + package + + jar + + + test + + org/openecomp/mso/bpmn/test/** + + + + + + + + + + + + org.camunda.bpm + camunda-engine + provided + + + org.camunda.bpm + camunda-engine-rest + classes + + + + commons-fileupload + commons-fileupload + + + + + + commons-fileupload + commons-fileupload + 1.3.2 + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + junit + junit + test + + + org.mockito + mockito-all + 1.10.19 + test + + + + org.camunda.connect + camunda-connect-connectors-all + compile + + + org.camunda.template-engines + camunda-template-engines-freemarker + + + org.camunda.bpm + camunda-engine-plugin-spin + + + + org.camunda.spin + camunda-spin-dataformat-json-jackson + + + org.camunda.spin + camunda-spin-dataformat-xml-dom + + + org.camunda.bpm + camunda-engine-plugin-connect + + + org.codehaus.groovy + groovy-all + compile + + + com.h2database + h2 + provided + + + net.sf.saxon + Saxon-HE + + + org.openecomp.mso + common + ${project.version} + + + org.jboss.resteasy + resteasy-jaxrs + 3.0.19.Final + provided + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + + + org.apache.httpcomponents + httpclient + + + + + org.json + json + 20160212 + + + xmlunit + xmlunit + 1.6 + + + diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BPMNLogger.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BPMNLogger.java new file mode 100644 index 0000000000..821380f562 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BPMNLogger.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import org.openecomp.mso.logger.MsoLogger; + +public class BPMNLogger { + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + public static void debug (String isDebugLogEnabled, String LogText) { + if (("true").equalsIgnoreCase(isDebugLogEnabled)) + msoLogger.debug(LogText); + } +} + diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BadInjectedFieldException.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BadInjectedFieldException.java new file mode 100644 index 0000000000..84c0954386 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BadInjectedFieldException.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +public class BadInjectedFieldException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + * @param fieldName the field name + * @param taskName the task name + * @param info additional information, e.g. the field value + */ + public BadInjectedFieldException(String fieldName, String taskName, + Object info) { + super(taskName + " injected field '" + fieldName + "' is bad: " + info); + } + + /** + * Constructor. + * + * @param fieldName the field name + * @param taskName the task name + * @param info additional information, e.g. the field value + * @param cause the cause + */ + public BadInjectedFieldException(String fieldName, + String taskName, Object info, Throwable cause) { + super(taskName + " injected field '" + fieldName + "' is bad: " + + info, cause); + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java new file mode 100644 index 0000000000..849c8ba4f8 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java @@ -0,0 +1,529 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.delegate.JavaDelegate; + +/** + * Base class for service tasks. + */ +public abstract class BaseTask implements JavaDelegate { + + /** + * Get the value of a required field. This method throws + * MissingInjectedFieldException if the expression is null, and + * BadInjectedFieldException if the expression evaluates to a null + * value. + * + * @param expression the expression + * @param execution the execution + * @param fieldName the field name (for logging and exceptions) + * @return the field value + */ + protected Object getField(Expression expression, + DelegateExecution execution, String fieldName) { + return getFieldImpl(expression, execution, fieldName, false); + } + + /** + * Gets the value of an optional field. There are three conditions + * in which this method returns null: + *

+ *

    + *
  1. The expression itself is null (i.e. the field is missing + * altogether.
  2. + *
  3. The expression evaluates to a null value.
  4. + *
  5. The expression references a single variable which has not + * been set.
  6. + *
+ *

+ * Examples:
+ * Expression ${x} when x is null: return null
+ * Expression ${x} when x is unset: return null
+ * Expression ${x+y} when x and/or y are unset: exception
+ * + * @param expression the expression + * @param execution the execution + * @param fieldName the field name (for logging and exceptions) + * @return the field value, possibly null + */ + protected Object getOptionalField(Expression expression, + DelegateExecution execution, String fieldName) { + return getFieldImpl(expression, execution, fieldName, true); + } + + /** + * Get the value of a required output variable field. This method + * throws MissingInjectedFieldException if the expression is null, and + * BadInjectedFieldException if the expression produces a null or + * illegal variable name. Legal variable names contain only letters, + * numbers, and the underscore character ('_'). + * + * @param expression the expression + * @param execution the execution + * @param fieldName the field name (for logging and exceptions) + * @return the output variable name + */ + protected String getOutputField(Expression expression, + DelegateExecution execution, String fieldName) { + Object o = getFieldImpl(expression, execution, fieldName, false); + if (o instanceof String) { + String variable = (String) o; + if (!isLegalVariable(variable)) { + throw new BadInjectedFieldException( + fieldName, getTaskName(), "'" + variable + + "' is not a legal variable name"); + } + return variable; + } else { + throw new BadInjectedFieldException( + fieldName, getTaskName(), "expected a variable name string" + + ", got object of type " + o.getClass().getName()); + } + } + + /** + * Get the value of an optional output variable field. This method + * throws BadInjectedFieldException if the expression produces an illegal + * variable name. Legal variable names contain only letters, numbers, + * and the underscore character ('_'). + * + * @param expression the expression + * @param execution the execution + * @param fieldName the field name (for logging and exceptions) + * @return the output variable name, possibly null + */ + protected String getOptionalOutputField(Expression expression, + DelegateExecution execution, String fieldName) { + Object o = getFieldImpl(expression, execution, fieldName, true); + if (o instanceof String) { + String variable = (String) o; + if (!isLegalVariable(variable)) { + throw new BadInjectedFieldException( + fieldName, getTaskName(), "'" + variable + + "' is not a legal variable name"); + } + return variable; + } else if (o == null) { + return null; + } else { + throw new BadInjectedFieldException( + fieldName, getTaskName(), "expected a variable name string" + + ", got object of type " + o.getClass().getName()); + } + } + + /** + * Get the value of a required string field. This method throws + * MissingInjectedFieldException if the expression is null, and + * BadInjectedFieldException if the expression evaluates to a null + * value. + *

+ * Note: the result is coerced to a string value, if necessary. + * + * @param expression the expression + * @param execution the execution + * @param fieldName the field name (for logging and exceptions) + * @return the field value + */ + protected String getStringField(Expression expression, + DelegateExecution execution, String fieldName) { + Object o = getFieldImpl(expression, execution, fieldName, false); + if (o instanceof String) { + return (String) o; + } else { + throw new BadInjectedFieldException( + fieldName, getTaskName(), "cannot convert '" + o.toString() + + "' to Integer"); + } + } + + /** + * Gets the value of an optional string field. There are three conditions + * in which this method returns null: + *

+ *

    + *
  1. The expression itself is null (i.e. the field is missing + * altogether.
  2. + *
  3. The expression evaluates to a null value.
  4. + *
  5. The expression references a single variable which has not + * been set.
  6. + *
+ *

+ * Examples:
+ * Expression ${x} when x is null: return null
+ * Expression ${x} when x is unset: return null
+ * Expression ${x+y} when x and/or y are unset: exception
+ *

+ * Note: the result is coerced to a string value, if necessary. + * + * @param expression the expression + * @param execution the execution + * @param fieldName the field name (for logging and exceptions) + * @return the field value, possibly null + */ + protected String getOptionalStringField(Expression expression, + DelegateExecution execution, String fieldName) { + Object o = getFieldImpl(expression, execution, fieldName, true); + if (o instanceof String) { + return (String) o; + } else if (o == null) { + return null; + } else { + return o.toString(); + } + } + + /** + * Get the value of a required integer field. This method throws + * MissingInjectedFieldException if the expression is null, and + * BadInjectedFieldException if the expression evaluates to a null + * value or a value that cannot be coerced to an integer. + * + * @param expression the expression + * @param execution the execution + * @param fieldName the field name (for logging and exceptions) + * @return the field value + */ + protected Integer getIntegerField(Expression expression, + DelegateExecution execution, String fieldName) { + Object o = getFieldImpl(expression, execution, fieldName, false); + if (o instanceof Integer) { + return (Integer) o; + } else { + try { + return Integer.parseInt(o.toString()); + } catch (NumberFormatException e) { + throw new BadInjectedFieldException( + fieldName, getTaskName(), "cannot convert '" + o.toString() + + "' to Integer"); + } + } + } + + /** + * Gets the value of an optional integer field. There are three conditions + * in which this method returns null: + *

+ *

    + *
  1. The expression itself is null (i.e. the field is missing + * altogether.
  2. + *
  3. The expression evaluates to a null value.
  4. + *
  5. The expression references a single variable which has not + * been set.
  6. + *
+ *

+ * Examples:
+ * Expression ${x} when x is null: return null
+ * Expression ${x} when x is unset: return null
+ * Expression ${x+y} when x and/or y are unset: exception
+ *

+ * Note: the result is coerced to an integer value, if necessary. This + * method throws BadInjectedFieldException if the result cannot be coerced + * to an integer. + * + * @param expression the expression + * @param execution the execution + * @param fieldName the field name (for logging and exceptions) + * @return the field value, possibly null + */ + protected Integer getOptionalIntegerField(Expression expression, + DelegateExecution execution, String fieldName) { + Object o = getFieldImpl(expression, execution, fieldName, true); + if (o instanceof Integer) { + return (Integer) o; + } else if (o == null) { + return null; + } else { + try { + return Integer.parseInt(o.toString()); + } catch (NumberFormatException e) { + throw new BadInjectedFieldException( + fieldName, getTaskName(), "cannot convert '" + o.toString() + + "' to Integer"); + } + } + } + + /** + * Gets the value of an optional long field. There are three conditions + * in which this method returns null: + *

+ *

    + *
  1. The expression itself is null (i.e. the field is missing + * altogether.
  2. + *
  3. The expression evaluates to a null value.
  4. + *
  5. The expression references a single variable which has not + * been set.
  6. + *
+ *

+ * Examples:
+ * Expression ${x} when x is null: return null
+ * Expression ${x} when x is unset: return null
+ * Expression ${x+y} when x and/or y are unset: exception
+ *

+ * Note: the result is coerced to a long value, if necessary. This + * method throws BadInjectedFieldException if the result cannot be coerced + * to a long. + * + * @param expression the expression + * @param execution the execution + * @param fieldName the field name (for logging and exceptions) + * @return the field value, possibly null + */ + protected Long getOptionalLongField(Expression expression, + DelegateExecution execution, String fieldName) { + Object o = getFieldImpl(expression, execution, fieldName, true); + if (o instanceof Long) { + return (Long) o; + } else if (o == null) { + return null; + } else { + try { + return Long.parseLong(o.toString()); + } catch (NumberFormatException e) { + throw new BadInjectedFieldException( + fieldName, getTaskName(), "cannot convert '" + o.toString() + + "' to Long"); + } + } + } + + /** + * Get the value of a required long field. This method throws + * MissingInjectedFieldException if the expression is null, and + * BadInjectedFieldException if the expression evaluates to a null + * value or a value that cannot be coerced to a long. + * + * @param expression the expression + * @param execution the execution + * @param fieldName the field name (for logging and exceptions) + * @return the field value + */ + protected Long getLongField(Expression expression, + DelegateExecution execution, String fieldName) { + Object o = getFieldImpl(expression, execution, fieldName, false); + if (o instanceof Long) { + return (Long) o; + } else { + try { + return Long.parseLong(o.toString()); + } catch (NumberFormatException e) { + throw new BadInjectedFieldException( + fieldName, getTaskName(), "cannot convert '" + o.toString() + + "' to Long"); + } + } + } + + /** + * Common implementation for field "getter" methods. + * @param expression the expression + * @param execution the execution + * @param fieldName the field name (for logging and exceptions) + * @param optional true if the field is optional + * @return the field value, possibly null + */ + private Object getFieldImpl(Expression expression, + DelegateExecution execution, String fieldName, boolean optional) { + if (expression == null) { + if (!optional) { + throw new MissingInjectedFieldException( + fieldName, getTaskName()); + } + return null; + } + + Object value; + + try { + value = expression.getValue(execution); + } catch (Exception e) { + if (!optional) { + throw new BadInjectedFieldException( + fieldName, getTaskName(), e.getClass().getSimpleName(), e); + } + + // At this point, we have an exception that occurred while + // evaluating an expression for an optional field. A common + // problem is that the expression is a simple reference to a + // variable which has never been set, e.g. the expression is + // ${x}. The normal activiti behavior is to throw an exception, + // but we don't like that, so we have the following workaround, + // which parses the expression text to see if it is a "simple" + // variable reference, and if so, returns null. If the + // expression is anything other than a single variable + // reference, then an exception is thrown, as it would have + // been without this workaround. + + // Get the expression text so we can parse it + String s = expression.getExpressionText(); + +// if (isDebugEnabled(execution)) { +// logDebug(execution, getTaskName() + " field '" + fieldName +// + "' expression evaluation failed: " + s); +// } + + int len = s.length(); + int i = 0; + + // Skip whitespace + while (i < len && Character.isWhitespace(s.charAt(i))) { + i++; + } + + // Next character must be '$' + if (i == len || s.charAt(i++) != '$') { + throw new BadInjectedFieldException( + fieldName, getTaskName(), e.getClass().getSimpleName(), e); + } + + // Skip whitespace + while (i < len && Character.isWhitespace(s.charAt(i))) { + i++; + } + + // Next character must be '{' + if (i == len || s.charAt(i++) != '{') { + throw new BadInjectedFieldException( + fieldName, getTaskName(), e.getClass().getSimpleName(), e); + } + + // Skip whitespace + while (i < len && Character.isWhitespace(s.charAt(i))) { + i++; + } + + // Collect the variable name + StringBuilder variable = new StringBuilder(); + while (i < len && isWordCharacter(s.charAt(i))) { + variable.append(s.charAt(i)); + i++; + } + + if (variable.length() == 0) { + throw new BadInjectedFieldException( + fieldName, getTaskName(), e.getClass().getSimpleName(), e); + } + + // Skip whitespace + while (i < len && Character.isWhitespace(s.charAt(i))) { + i++; + } + + // Next character must be '}' + if (i == len || s.charAt(i++) != '}') { + throw new BadInjectedFieldException( + fieldName, getTaskName(), e.getClass().getSimpleName(), e); + } + + // Skip whitespace + while (i < len && Character.isWhitespace(s.charAt(i))) { + i++; + } + + // Must be at end of string + if (i != len) { + throw new BadInjectedFieldException( + fieldName, getTaskName(), e.getClass().getSimpleName(), e); + } + +// if (isDebugEnabled(execution)) { +// logDebug(execution, "Checking if variable '" +// + variable.toString() + "' exists"); +// } + + // If the variable exists then the problem was + // something else... + if (execution.hasVariable(variable.toString())) { + throw new BadInjectedFieldException( + fieldName, getTaskName(), e.getClass().getSimpleName(), e); + } + + // The variable doesn't exist. + +// if (isDebugEnabled(execution)) { +// logDebug(execution, "Variable '" + variable.toString() +// + "' does not exist [ok]"); +// } + + value = null; + } + + if (value == null && !optional) { + throw new BadInjectedFieldException( + fieldName, getTaskName(), "required field has null value"); + } + + return value; + } + + /** + * Tests if a character is a "word" character. + * @param c the character + * @return true if the character is a "word" character. + */ + private boolean isWordCharacter(char c) { + return (Character.isLetterOrDigit(c) || c == '_'); + } + + /** + * Tests if the specified string is a legal flow variable name. + * @param name the string + * @return true if the string is a legal flow variable name + */ + private boolean isLegalVariable(String name) { + if (name == null) { + return false; + } + + int len = name.length(); + + if (len == 0) { + return false; + } + + char c = name.charAt(0); + + if (!Character.isLetter(c) && c != '_') { + return false; + } + + for (int i = 1; i < len; i++) { + c = name.charAt(i); + if (!Character.isLetterOrDigit(c) && c != '_') { + return false; + } + } + + return true; + } + + /** + * Returns the name of the task (normally the java class name). + * @return the name of the task + */ + public String getTaskName() { + return getClass().getSimpleName(); + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java new file mode 100644 index 0000000000..df6213284c --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/HealthCheckHandler.java @@ -0,0 +1,203 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import org.apache.http.client.config.RequestConfig; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Map; +import java.util.UUID; + +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +import org.camunda.bpm.engine.ProcessEngines; + +@Path("/") +public class HealthCheckHandler { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + private static final String SITENAME = "mso.sitename"; + private static final String ADPTER_ENDPOINT = "mso.adapters.db.endpoint"; + private static final String CONFIG = "mso.bpmn.urn.properties"; + + private static final String CHECK_HTML = "Health CheckApplication ready"; + private static final String NOT_FOUND = "Application Not StartedApplication not started. Properties file missing or invalid or database Connection failed"; + private static final String NOT_HEALTHY = "Application Not StartedApplication not available or at least one of the sub-modules is not available."; + public static final Response HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_OK) + .entity (CHECK_HTML) + .build (); + public static final Response HEALTH_CHECK_NOK_RESPONSE = Response.status (HttpStatus.SC_SERVICE_UNAVAILABLE) + .entity (NOT_HEALTHY) + . build (); + public static final Response NOT_STARTED_RESPONSE = Response.status (HttpStatus.SC_SERVICE_UNAVAILABLE) + .entity (NOT_FOUND) + .build (); + + @HEAD + @GET + @Path("/healthcheck") + @Produces("text/html") + public Response healthcheck (@QueryParam("requestId") String requestId) { + MsoLogger.setServiceName ("Healthcheck"); + verifyOldUUID(requestId); + + PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); + Map props = propertyConfiguration.getProperties(CONFIG); + + if (props == null) { + + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.AvailabilityError, "Unable to load " + CONFIG); + + return NOT_STARTED_RESPONSE; + } + + String siteName = props.get(SITENAME); + String endpoint = props.get(ADPTER_ENDPOINT); + + if (null == siteName || siteName.length () == 0 || null == endpoint || endpoint.length () == 0) { + + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.DataError, "Unable to load key attributes (" + SITENAME + " or " + ADPTER_ENDPOINT + ") from the config file:" + CONFIG); + + return NOT_STARTED_RESPONSE; + } + + try { + if (!this.getSiteStatus (endpoint, siteName)) { + msoLogger.debug("This site is currently disabled for maintenance."); + return HEALTH_CHECK_NOK_RESPONSE; + } + } catch (Exception e) { + + msoLogger.error(MessageEnum.GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception while getting SiteStatus", e); + + msoLogger.debug("Exception while getting SiteStatus"); + return NOT_STARTED_RESPONSE; + } + + try { + ProcessEngines.getDefaultProcessEngine().getIdentityService().createGroupQuery().list(); + } catch (final Exception e) { + + msoLogger.error(MessageEnum.GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception while verifying Camunda engine", e); + + msoLogger.debug("Exception while verifying Camunda engine"); + return NOT_STARTED_RESPONSE; + } + + return HEALTH_CHECK_RESPONSE; + } + + + private String verifyOldUUID (String oldId) { + if (!isValidUUID(oldId)) { + String newId = UUID.randomUUID().toString(); + MsoLogger.setLogContext(newId, null); + return newId; + } + MsoLogger.setLogContext(oldId, null); + return oldId; + } + + + private boolean isValidUUID (String id) { + try { + if (null == id) { + return false; + } + UUID uuid = UUID.fromString(id); + return uuid.toString().equalsIgnoreCase(id); + } catch (IllegalArgumentException iae) { + return false; + } + } + + private boolean getSiteStatus (String url, String site) throws Exception { + HttpResponse response; + // set the connection timeout value to 30 seconds (30000 milliseconds) + RequestConfig.Builder requestBuilder = RequestConfig.custom(); + requestBuilder = requestBuilder.setConnectTimeout(30000); + requestBuilder = requestBuilder.setConnectionRequestTimeout(30000); + HttpClientBuilder builder = HttpClientBuilder.create (); + builder.setDefaultRequestConfig (requestBuilder.build ()); + + HttpPost post = new HttpPost(url); + msoLogger.debug("Post url is: " + url); + + //now create a soap request message as follows: + final StringBuffer payload = new StringBuffer(); + payload.append("\n"); + payload.append("\n"); + payload.append("\n"); + payload.append("\n"); + payload.append("\n"); + payload.append("" + site + "\n"); + payload.append("\n"); + payload.append("\n"); + payload.append("\n"); + + msoLogger.debug ("Initialize SOAP request to url:" + url); + msoLogger.debug ("The payload of the request is:" + payload); + HttpEntity entity = new StringEntity(payload.toString(),"UTF-8"); + post.setEntity(entity); + + try (CloseableHttpClient client = builder.build()) { + response = client.execute(post); + msoLogger.debug("Response received is:" + response); + + int statusCode = response.getStatusLine().getStatusCode(); + if (statusCode != 200) { + + msoLogger.error(MessageEnum.GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.DataError, + "Communication with DB Adapter failed, The response received from DB Adapter is with failed status code:" + statusCode); + + Exception e = new Exception("Communication with DB Adapter failed"); + throw e; + } + BufferedReader rd = new BufferedReader( + new InputStreamReader(response.getEntity().getContent())); + + StringBuffer result = new StringBuffer(); + String line = ""; + while ((line = rd.readLine()) != null) { + result.append(line); + } + msoLogger.debug("Content of the response is:" + result); + String status = result.substring(result.indexOf("") + 8, result.indexOf("")); + + return Boolean.valueOf(status); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/LogTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/LogTask.java new file mode 100644 index 0000000000..41033d9e12 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/LogTask.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.Expression; + +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Logs a text message. The text may contain variable references. + * For example:

+ *     name=$name, address=$address + *

+ * Required fields:

+ *     text: The text to log
+ * Optional fields:

+ *     level: The log level (TRACE, DEBUG, INFO, WARN, ERROR)
+ */ +public class LogTask extends BaseTask { + + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + + private Expression text; + private Expression level; + + public void execute(DelegateExecution execution) throws Exception { + String theText = getStringField(text, execution, "text"); + + + + StringBuilder out = new StringBuilder(); + StringBuilder var = new StringBuilder(); + boolean inVar = false; + + int pos = 0; + int len = theText.length(); + + while (pos < len) { + char c = theText.charAt(pos++); + + if (inVar && !Character.isLetterOrDigit(c) && c != '_') { + if (var.length() > 0) { + Object value = execution.getVariable(var.toString()); + + if (value != null) { + out.append(value.toString()); + } + + var.setLength(0); + } + + inVar = false; + } + + if (c == '$') { + inVar = true; + } else { + if (inVar) { + var.append(c); + } else { + out.append(c); + } + } + } + + if (inVar && var.length() > 0) { + Object value = execution.getVariable(var.toString()); + if (value != null) { + out.append(value.toString()); + } + } + + + + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldException.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldException.java new file mode 100644 index 0000000000..589a111b3b --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldException.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +/** + * A BadInjectedFieldException that indicates a required field is missing. + */ +public class MissingInjectedFieldException extends BadInjectedFieldException { + + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + * @param fieldName the field name + * @param taskName the task name + */ + public MissingInjectedFieldException(String fieldName, String taskName) { + super(fieldName, taskName, "missing required field"); + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java new file mode 100644 index 0000000000..90df1da7e5 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java @@ -0,0 +1,440 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.ClosedWatchServiceException; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; +import java.nio.file.WatchService; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ConcurrentHashMap; + +import org.slf4j.MDC; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Loads the property configuration from file system and refreshes the + * properties when the property gets changed. + * + * WARNING: automatic refreshes might not work on network filesystems. + */ +public class PropertyConfiguration { + + /** + * The base name of the MSO BPMN properties file (mso.bpmn.properties). + */ + public static final String MSO_BPMN_PROPERTIES = "mso.bpmn.properties"; + + /** + * The base name of the MSO BPMN URN-Mappings properties file (mso.bpmn.urn.properties). + */ + public static final String MSO_BPMN_URN_PROPERTIES = "mso.bpmn.urn.properties"; + + /** + * The name of the meta-property holding the time the properties were loaded + * from the file. + */ + public static final String TIMESTAMP_PROPERTY = "mso.properties.timestamp"; + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + private static final List SUPPORTED_FILES = + Arrays.asList(MSO_BPMN_PROPERTIES, MSO_BPMN_URN_PROPERTIES); + + private volatile String msoConfigPath = null; + + private final ConcurrentHashMap> propFileCache = + new ConcurrentHashMap>(); + + private final Object CACHELOCK = new Object(); + private FileWatcherThread fileWatcherThread = null; + + // The key is the file name + private Map timerTaskMap = new HashMap(); + + /** + * Singleton holder pattern eliminates locking when accessing the instance + * and still provides for lazy initialization. + */ + private static class PropertyConfigurationInstanceHolder { + private static PropertyConfiguration instance = new PropertyConfiguration(); + } + + /** + * Gets the one and only instance of this class. + */ + public static PropertyConfiguration getInstance() { + return PropertyConfigurationInstanceHolder.instance; + } + + /** + * Returns the list of supported files. + */ + public static List supportedFiles() { + return new ArrayList(SUPPORTED_FILES); + } + + /** + * Private Constructor. + */ + private PropertyConfiguration() { + startUp(); + } + + /** + * May be called to restart the PropertyConfiguration if it was previously shut down. + */ + public synchronized void startUp() { + msoConfigPath = System.getProperty("mso.config.path"); + + if (msoConfigPath == null) { + LOGGER.debug("mso.config.path JVM system property is not set"); + return; + } + + try { + Path directory = FileSystems.getDefault().getPath(msoConfigPath); + WatchService watchService = FileSystems.getDefault().newWatchService(); + directory.register(watchService, ENTRY_MODIFY); + + LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN", "Starting FileWatcherThread"); + LOGGER.debug("Starting FileWatcherThread"); + fileWatcherThread = new FileWatcherThread(watchService); + fileWatcherThread.start(); + } catch (Exception e) { + LOGGER.debug("Error occurred while starting FileWatcherThread:", e); + LOGGER.error( + MessageEnum.BPMN_GENERAL_EXCEPTION, + "BPMN", + "Property Configuration", + MsoLogger.ErrorCode.UnknownError, + "Error occurred while starting FileWatcherThread:" + e); + } + } + + /** + * May be called to shut down the PropertyConfiguration. A shutDown followed + * by a startUp will reset the PropertyConfiguration to its initial state. + */ + public synchronized void shutDown() { + if (fileWatcherThread != null) { + LOGGER.debug("Shutting down FileWatcherThread " + System.identityHashCode(fileWatcherThread)); + fileWatcherThread.shutdown(); + + long waitInSeconds = 10; + + try { + fileWatcherThread.join(waitInSeconds * 1000); + } catch (InterruptedException e) { + LOGGER.debug("FileWatcherThread " + System.identityHashCode(fileWatcherThread) + + " shutdown did not occur within " + waitInSeconds + " seconds"); + } + + LOGGER.debug("Finished shutting down FileWatcherThread " + System.identityHashCode(fileWatcherThread)); + fileWatcherThread = null; + } + + clearCache(); + msoConfigPath = null; + } + + public synchronized boolean isFileWatcherRunning() { + return fileWatcherThread != null; + } + + public void clearCache() { + synchronized(CACHELOCK) { + propFileCache.clear(); + } + } + + public int cacheSize() { + return propFileCache.size(); + } + + // TODO: throw IOException? + public Map getProperties(String fileName) { + Map properties = propFileCache.get(fileName); + + if (properties == null) { + if (!SUPPORTED_FILES.contains(fileName)) { + throw new IllegalArgumentException("Not a supported property file: " + fileName); + } + + if (msoConfigPath == null) { + LOGGER.debug("mso.config.path JVM system property must be set to load " + fileName); + + LOGGER.error( + MessageEnum.BPMN_GENERAL_EXCEPTION, + "BPMN", + MDC.get(fileName), + MsoLogger.ErrorCode.UnknownError, + "mso.config.path JVM system property must be set to load " + fileName); + + return null; + } + + try { + properties = readProperties(new File(msoConfigPath, fileName)); + } catch (Exception e) { + LOGGER.debug("Error loading " + fileName); + + LOGGER.error( + MessageEnum.BPMN_GENERAL_EXCEPTION, + "BPMN", + MDC.get(fileName), + MsoLogger.ErrorCode.UnknownError, + "Error loading " + fileName, e); + + return null; + } + } + + return Collections.unmodifiableMap(properties); + } + + /** + * Reads properties from the specified file, updates the property file cache, and + * returns the properties in a map. + * @param file the file to read + * @param reload true if this is a reload event + * @return a map of properties + */ + private Map readProperties(File file) throws IOException { + String fileName = file.getName(); + LOGGER.debug("Reading " + fileName); + + Map properties = new HashMap(); + Properties newProperties = new Properties(); + + FileReader reader = null; + try { + reader = new FileReader(file); + newProperties.load(reader); + } finally { + if (reader != null) { + try { + reader.close(); + LOGGER.debug("Closed " + fileName); + } catch (Exception e) { + // Ignore + } + } + } + + for (Entry entry : newProperties.entrySet()) { + properties.put(entry.getKey().toString(), entry.getValue().toString()); + } + + properties.put(TIMESTAMP_PROPERTY, String.valueOf(System.currentTimeMillis())); + + synchronized(CACHELOCK) { + propFileCache.put(fileName, properties); + } + + return properties; + } + + /** + * File watcher thread which monitors a directory for file modification. + */ + private class FileWatcherThread extends Thread { + private final WatchService watchService; + private final Timer timer = new Timer("FileWatcherTimer"); + + public FileWatcherThread(WatchService service) { + this.watchService = service; + } + + public void shutdown() { + interrupt(); + } + + public void run() { + LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN", + "FileWatcherThread started"); + + LOGGER.debug("Started FileWatcherThread " + System.identityHashCode(fileWatcherThread)); + + try { + WatchKey watchKey = null; + + while (!isInterrupted()) { + try { + if (watchKey != null) { + watchKey.reset(); + } + + watchKey = watchService.take(); + + for (WatchEvent event : watchKey.pollEvents()) { + @SuppressWarnings("unchecked") + WatchEvent pathEvent = (WatchEvent) event; + + if ("EVENT_OVERFLOW".equals(pathEvent.kind())) { + LOGGER.debug("Ignored overflow event for " + msoConfigPath); + continue; + } + + String fileName = pathEvent.context().getFileName().toString(); + + if (!SUPPORTED_FILES.contains(fileName)) { + LOGGER.debug("Ignored modify event for " + fileName); + continue; + } + + LOGGER.debug("Configuration file has changed: " + fileName); + + LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN", + "Configuation file has changed: " + fileName); + + // There's a potential problem here. The MODIFY event is + // triggered as soon as somebody starts writing the file but + // there's no obvious way to know when the write is done. If we + // read the file while the write is still in progress, then the + // cache can really be messed up. As a workaround, we use a timer + // to sleep for at least one second, and then we sleep for as long + // as it takes for the file's lastModified time to stop changing. + // The timer has another benefit: it consolidates multiple events + // that we seem to receive when a file is modified. + + synchronized(timerTaskMap) { + TimerTask task = timerTaskMap.get(fileName); + + if (task != null) { + task.cancel(); + } + + File file = new File(msoConfigPath, fileName); + task = new DelayTimerTask(timer, file, 1000); + timerTaskMap.put(fileName, task); + } + } + } catch (InterruptedException e) { + break; + } catch (ClosedWatchServiceException e) { + LOGGER.info( + MessageEnum.BPMN_GENERAL_INFO, + "BPMN", + "FileWatcherThread shut down because the watch service was closed"); + break; + } catch (Exception e) { + LOGGER.error( + MessageEnum.BPMN_GENERAL_EXCEPTION, + "BPMN", + "Property Configuration", + MsoLogger.ErrorCode.UnknownError, + "FileWatcherThread caught unexpected " + e.getClass().getSimpleName(), e); + } + + } + } finally { + timer.cancel(); + + synchronized(timerTaskMap) { + timerTaskMap.clear(); + } + + try { + watchService.close(); + } catch (IOException e) { + LOGGER.debug("FileWatcherThread caught " + e.getClass().getSimpleName() + + " while closing the watch service"); + } + + LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN", + "FileWatcherThread stopped"); + } + } + } + + private class DelayTimerTask extends TimerTask { + private final File file; + private final long lastModifiedTime; + private final Timer timer; + + public DelayTimerTask(Timer timer, File file, long delay) { + this.timer = timer; + this.file = file; + this.lastModifiedTime = file.lastModified(); + timer.schedule(this, delay); + } + + @Override + public void run() { + try { + long newLastModifiedTime = file.lastModified(); + + if (newLastModifiedTime == lastModifiedTime) { + try { + readProperties(file); + } catch (Exception e) { + LOGGER.error( + MessageEnum.BPMN_GENERAL_EXCEPTION, + "BPMN", + "Property Configuration", + MsoLogger.ErrorCode.UnknownError, + "Unable to reload " + file, e); + } + } else { + LOGGER.debug("Delaying reload of " + file + " by 1 second"); + + synchronized(timerTaskMap) { + TimerTask task = timerTaskMap.get(file.getName()); + + if (task != null && task != this) { + task.cancel(); + } + + task = new DelayTimerTask(timer, file, 1000); + timerTaskMap.put(file.getName(), task); + } + } + } finally { + synchronized(timerTaskMap) { + TimerTask task = timerTaskMap.get(file.getName()); + + if (task == this) { + timerTaskMap.remove(file.getName()); + } + } + } + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java new file mode 100644 index 0000000000..b46ffcd7f7 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.Expression; + +import org.openecomp.mso.logger.MsoLogger; + +/** + * Reads the contents of a resource file as a string and stores it in an + * execution variable. + *

+ * Required fields:

+ *     file: the resource file path
+ *     outputVariable: the output variable name
+ */ +public class ReadConfigTask extends BaseTask { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + private static Properties properties = null; + + private Expression propertiesFile; + + public void execute(DelegateExecution execution) throws Exception { + if (msoLogger.isDebugEnabled()) { + msoLogger.debug("Started Executing " + getTaskName()); + } + + String thePropertiesFile = + getStringField(propertiesFile, execution, "propertiesFile"); + + if (msoLogger.isDebugEnabled()) { + msoLogger.debug("propertiesFile = " + thePropertiesFile); + } + + Boolean shouldFail = (Boolean) execution.getVariable("shouldFail"); + + if (shouldFail != null && shouldFail) { + throw new ProcessEngineException(getClass().getSimpleName() + " Failed"); + } + + synchronized (ReadConfigTask.class) { + if (properties == null) { + properties = new Properties(); + + InputStream stream = null; + + try { + stream = getClass().getResourceAsStream(thePropertiesFile); + + if (stream == null) { + throw new IOException("Resource not found: " + thePropertiesFile); + } + + properties.load(stream); + + stream.close(); + stream = null; + + } finally { + if (stream != null) { + try { + stream.close(); + } catch (Exception e) { + // Do nothing + } + } + } + } + } + + for (Object objectKey : properties.keySet()) { + String key = (String) objectKey; + String value = properties.getProperty(key); + + if (msoLogger.isDebugEnabled()) { + msoLogger.debug("Setting variable '" + key + "' to '" + value + "'"); + } + + execution.setVariable(key, value); + } + + if (msoLogger.isDebugEnabled()) { + msoLogger.debug("Done Executing " + getTaskName()); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java new file mode 100644 index 0000000000..389fdc0518 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.Expression; + +import org.openecomp.mso.logger.MsoLogger; + +/** + * Conditionally reads the contents of a resource file as a string and stores it + * in an execution variable. The file is read only if the value of the input + * variable is null. + *

+ * Required fields:

+ *     file: the resource file path
+ *     inputVariable: the input variable name
+ *     outputVariable: the output variable name
+ */ +public class ReadFileTask extends BaseTask { + + private Expression file; + private Expression inputVariable; + private Expression outputVariable; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + public void execute(DelegateExecution execution) throws Exception { + if (msoLogger.isDebugEnabled()) { + msoLogger.debug("Started Executing " + getTaskName()); + } + + String theInputVariable = + getStringField(inputVariable, execution, "inputVariable"); + String theOutputVariable = + getOutputField(outputVariable, execution, "outputVariable"); + String theFile =getStringField(file, execution, "file"); + + if (msoLogger.isDebugEnabled()) { + msoLogger.debug("inputVariable = " + theInputVariable + + " outputVariable = " + theOutputVariable + + "file = " + theFile); + } + + Boolean shouldFail = (Boolean) execution.getVariable("shouldFail"); + + if (shouldFail != null && shouldFail) { + throw new ProcessEngineException(getClass().getSimpleName() + " Failed"); + } + + Object value = execution.getVariable(theInputVariable); + + if (value == null) { + InputStream xmlStream = null; + + try { + xmlStream = getClass().getResourceAsStream(theFile); + + if (xmlStream == null) { + throw new IOException("Resource not found: " + theFile); + } + + BufferedReader reader = new BufferedReader(new InputStreamReader(xmlStream)); + StringBuilder output = new StringBuilder(); + String line; + + while ((line = reader.readLine()) != null) { + output.append(line); + } + + xmlStream.close(); + xmlStream = null; + + value = output.toString(); + + } finally { + if (xmlStream != null) { + try { + xmlStream.close(); + } catch (Exception e) { + // Do nothing + } + } + } + } + execution.setVariable(theInputVariable, value); + execution.setVariable(theOutputVariable, value); + System.out.println("ServiceInput - " + execution.getVariable("gServiceInput")); + if (msoLogger.isDebugEnabled()) { + msoLogger.debug("Done Executing " + getTaskName()); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ResponseBuilder.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ResponseBuilder.java new file mode 100644 index 0000000000..632933d3a3 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ResponseBuilder.java @@ -0,0 +1,297 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import org.camunda.bpm.engine.delegate.DelegateExecution; + +/** + * Used in the output variable mapping configuration of subflow call activity + * tasks to normalize subflow responses. The output mapping is normally set up + * as follows. Note that the order of these mappings is important! + *

+ * OUTPUT MAPPING + *

+ *   SOURCE EXPRESSION                                      TARGET
+ *   ${ResponseBuilder.buildWorkflowException(execution)}   WorkflowException
+ *   ${ResponseBuilder.buildWorkflowResponse(execution)}    SomeResponseVariable
+ * 
+ */ +public class ResponseBuilder implements java.io.Serializable { + private static final long serialVersionUID = 1L; + + /** + * Creates a WorkflowException using data from the execution variables. + * If the variables do not indicate that there was an error, null + * is returned. + * @param execution the execution + */ + public WorkflowException buildWorkflowException(DelegateExecution execution) { + + String method = getClass().getSimpleName() + ".buildWorkflowException(" + + "execution=" + execution.getId() + + ")"; + String isDebugLogEnabled = (String) execution.getVariable("isDebugLogEnabled"); + logDebug("Entered " + method, isDebugLogEnabled); + + String prefix = (String) execution.getVariable("prefix"); + String processKey = getProcessKey(execution); + + logDebug("processKey=" + processKey, isDebugLogEnabled); + + // See if there"s already a WorkflowException object in the execution. + WorkflowException theException = (WorkflowException) execution.getVariable("WorkflowException"); + + if (theException != null) { + logDebug("Exited " + method + " - propagated " + theException, isDebugLogEnabled); + return theException; + } + + // Look in the legacy variables: ErrorResponse and ResponseCode + + String errorResponse = trimString(execution.getVariable(prefix + "ErrorResponse"), null); + String responseCode = trimString(execution.getVariable(prefix + "ResponseCode"), null); + logDebug("errorResponse=" + errorResponse, isDebugLogEnabled); + logDebug("responseCode=" + responseCode, isDebugLogEnabled); + if (errorResponse != null || !isOneOf(responseCode, null, "0", "200", "201", "202", "204")) { + // This is an error condition. We need to return a WorkflowExcpetion + + if (errorResponse == null) { + // No errorResponse string. See if there"s something in the Response variable + String response = trimString(execution.getVariable(processKey + "Response"), null); + if (response == null) { + errorResponse = "Received response code " + responseCode + " from " + processKey; + } else { + errorResponse = response; + } + } + + // Some subflows may try to return a WorkflowException as XML in the + // errorResponse. If provided, use the errorCode and errorMessage + // from the XML + + String maybeXML = removeXMLNamespaces(errorResponse); + + String xmlErrorMessage = trimString(getXMLTextElement(maybeXML, "ErrorMessage"), null); + String xmlErrorCode = trimString(getXMLTextElement(maybeXML, "ErrorCode"), null); + + if (xmlErrorMessage != null || xmlErrorCode != null) { + logDebug("xmlErrorMessage=" + xmlErrorMessage, isDebugLogEnabled); + logDebug("xmlErrorCode=" + xmlErrorCode, isDebugLogEnabled); + + if (xmlErrorMessage == null) { + errorResponse = "Received error code " + xmlErrorCode + " from " + processKey; + } else { + errorResponse = xmlErrorMessage; + } + + if (xmlErrorCode != null) { + responseCode = xmlErrorCode; + } + } + + // Convert the responseCode to an integer + + int intResponseCode; + + try { + intResponseCode = Integer.valueOf(responseCode); + } catch (NumberFormatException e) { + // Internal Error + intResponseCode = 2000; + } + + // Convert 3-digit HTTP response codes (we should not be using them here) + // to appropriate 4-digit response codes + + if (intResponseCode < 1000) { + if (intResponseCode >= 400 && intResponseCode <= 499) { + // Invalid Message + intResponseCode = 1002; + } else { + // Internal Error + intResponseCode = 2000; + } + } + + // Create a new WorkflowException object + + theException = new WorkflowException(processKey, intResponseCode, errorResponse); + execution.setVariable("WorkflowException", theException); + logDebug("Exited " + method + " - created " + theException, isDebugLogEnabled); + return theException; + } + + logDebug("Exited " + method + " - no WorkflowException", isDebugLogEnabled); + return null; + } + + /** + * Returns the "Response" variable, unless the execution variables + * indicate there was an error. In that case, null is returned. + * @param execution the execution + */ + public Object buildWorkflowResponse(DelegateExecution execution) { + + String method = getClass().getSimpleName() + ".buildWorkflowResponse(" + + "execution=" + execution.getId() + + ")"; + String isDebugLogEnabled = (String) execution.getVariable("isDebugLogEnabled"); + logDebug("Entered " + method, isDebugLogEnabled); + + String prefix = (String) execution.getVariable("prefix"); + String processKey = getProcessKey(execution); + + Object theResponse = null; + + WorkflowException theException = (WorkflowException) execution.getVariable("WorkflowException"); + String errorResponse = trimString(execution.getVariable(prefix + "ErrorResponse"), null); + String responseCode = trimString(execution.getVariable(prefix + "ResponseCode"), null); + + if (theException == null && errorResponse == null && + isOneOf(responseCode, null, "0", "200", "201", "202", "204")) { + + theResponse = execution.getVariable("WorkflowResponse"); + + if (theResponse == null) { + theResponse = execution.getVariable(processKey + "Response"); + } + } + + logDebug("Exited " + method, isDebugLogEnabled); + return theResponse; + } + + /** + * Checks if the specified item is one of the specified values. + * @param item the item + * @param values the list of values + * @return true if the item is in the list of values + */ + private boolean isOneOf(Object item, Object ... values) { + if (values == null) { + return item == null; + } + + for (Object value : values) { + if (value == null) { + if (item == null) { + return true; + } + } else { + if (value.equals(item)) { + return true; + } + } + } + + return false; + } + + /** + * Creates a string value of the specified object, trimming whitespace in + * the process. If the result is null or empty, the specified empty string + * value is returned. Otherwise the trimmed value is returned. This method + * helps ensure consistent treatment of empty and null strings. + * @param object the object to convert (possibly null) + * @param emptyStringValue the desired value for empty results + */ + private String trimString(Object object, String emptyStringValue) { + if (object == null) { + return emptyStringValue; + } + + String s = String.valueOf(object).trim(); + return s.equals("") ? emptyStringValue : s; + } + + /** + * Returns the process definition key (i.e. the process name) from the + * execution. + * @param execution the execution + */ + private String getProcessKey(DelegateExecution execution) { + Object testKey = execution.getVariable("testProcessKey"); + + if (testKey instanceof String) { + return (String) testKey; + } + + return execution.getProcessEngineServices().getRepositoryService() + .getProcessDefinition(execution.getProcessDefinitionId()).getKey(); + } + + /** + * Logs a message at the DEBUG level. + * @param message the message + * @param isDebugLogEnabled a flag indicating if DEBUG level is enabled + */ + private void logDebug(String message, String isDebugLogEnabled) { + BPMNLogger.debug(isDebugLogEnabled, message); + } + + /** + * Removes namespace definitions and prefixes from XML, if any. + */ + private String removeXMLNamespaces(String xml) { + // remove xmlns declaration + xml = xml.replaceAll("xmlns.*?(\"|\').*?(\"|\')", ""); + + // remove opening tag prefix + xml = xml.replaceAll("(<)(\\w+:)(.*?>)", "$1$3"); + + // remove closing tags prefix + xml = xml.replaceAll("()", "$1$3"); + + // remove extra spaces left when xmlns declarations are removed + xml = xml.replaceAll("\\s+>", ">"); + + return xml; + } + + /** + * Extracts text from an XML element. This method is not namespace aware + * (namespaces are ignored). The first matching element is selected. + * @param xml the XML document or fragment + * @param tag the desired element, e.g. "" + * @return the element text, or null if the element was not found + */ + private String getXMLTextElement(String xml, String tag) { + xml = removeXMLNamespaces(xml); + + if (!tag.startsWith("<")) { + tag = "<" + tag + ">"; + } + + int start = xml.indexOf(tag); + + if (start == -1) { + return null; + } + + int end = xml.indexOf('<', start + tag.length()); + + if (end == -1) { + return null; + } + + return xml.substring(start + tag.length(), end); + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java new file mode 100644 index 0000000000..1b2bb8752c --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +/** + * An object that stores data for rollbacks. Data is organized by type. A + * type is simply a string identifier. Multiple types of data may be stored + * in the same object for separate rollback operations. + */ +public class RollbackData implements Serializable { + private static final long serialVersionUID = 1L; + + private Map> dictionary = + new HashMap>(); + + /** + * Returns true if the specified type is stored in this object. + * @param type the data type + */ + public boolean hasType(String type) { + return dictionary.containsKey(type); + } + + /** + * Stores a single item. + * @param type the data type + * @param key the key + * @param value the value + */ + public void put(String type, String key, String value) { + Map mapForType = dictionary.get(type); + + if (mapForType == null) { + mapForType = new HashMap(); + dictionary.put(type, mapForType); + } + + mapForType.put(key, value); + } + + /** + * Gets a single item. + * @param type the data type + * @param key the key + * @return the item or null if there is no item for the specified type and key + */ + public Serializable get(String type, String key) { + Map mapForType = dictionary.get(type); + + if (mapForType == null) { + return null; + } + + return mapForType.get(key); + } + + /** + * Gets a map containing all items associated with the specified data type. + * @param type the data type + * @return a map, or null if there are no items associated with the specified + * data type + */ + public Map get(String type) { + return dictionary.get(type); + } + + /** + * Returns a string representation of this object. + */ + public String toString() { + StringBuilder out = new StringBuilder(); + out.append(getClass().getSimpleName()); + out.append('['); + boolean hasOne = false; + for (String type : dictionary.keySet()) { + if (hasOne) { + out.append(','); + } + out.append(type); + out.append(dictionary.get(type)); + hasOne = true; + } + out.append(']'); + return out.toString(); + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/URNMappingsTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/URNMappingsTask.java new file mode 100644 index 0000000000..6c6d96ad2c --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/URNMappingsTask.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import org.camunda.bpm.engine.delegate.DelegateExecution; + +/** + * DEPRECATION WARNING: setting of URN mappings is now done by a plugin. + */ +@Deprecated +public class URNMappingsTask extends BaseTask { + public void execute(DelegateExecution execution) throws Exception { + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/WorkflowException.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/WorkflowException.java new file mode 100644 index 0000000000..559ec6df00 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/WorkflowException.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import java.io.Serializable; + +/** + * An object that represents a workflow exception. + */ +public class WorkflowException implements Serializable { + private static final long serialVersionUID = 1L; + + private final String processKey; + private final int errorCode; + private final String errorMessage; + + /** + * Constructor + * @param processKey the process key for the process that generated the exception + * @param errorCode the numeric error code (normally 1xxx or greater) + * @param errorMessage a short error message + */ + public WorkflowException(String processKey, int errorCode, + String errorMessage) { + this.processKey = processKey; + this.errorCode = errorCode; + this.errorMessage = errorMessage; + } + + /** + * Returns the process key. + */ + public String getProcessKey() { + return processKey; + } + + /** + * Returns the error code. + */ + public int getErrorCode() { + return errorCode; + } + + /** + * Returns the error message. + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Returns a string representation of this object. + */ + public String toString() { + StringBuilder out = new StringBuilder(); + out.append(getClass().getSimpleName()); + out.append("[processKey="); + out.append(getProcessKey()); + out.append(",errorCode="); + out.append(getErrorCode()); + out.append(",errorMessage="); + out.append(getErrorMessage()); + out.append("]"); + return out.toString(); + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java new file mode 100644 index 0000000000..8a7b20016b --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java @@ -0,0 +1,243 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URI; +import java.util.Iterator; + +import javax.xml.transform.stream.StreamSource; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.delegate.DelegateExecution; +//import java.util.logging.Logger; +import org.camunda.bpm.engine.delegate.Expression; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +import net.sf.saxon.Configuration; +import net.sf.saxon.s9api.DocumentBuilder; +import net.sf.saxon.s9api.Processor; +import net.sf.saxon.s9api.QName; +import net.sf.saxon.s9api.XQueryCompiler; +import net.sf.saxon.s9api.XQueryEvaluator; +import net.sf.saxon.s9api.XQueryExecutable; +import net.sf.saxon.s9api.XdmAtomicValue; +import net.sf.saxon.s9api.XdmItem; +import net.sf.saxon.s9api.XdmNode; + +/** + * Executes an XQuery script. + *

+ * Required fields:

+ *     scriptFile: the XQuery script file path
+ *     outputVariable: the output variable name
+ *

+ * Optional fields:

+ *     xmlInputVariables: CSV list of variables containing + * XML data to be injected into the script
+ *     atomicInputVariables: CSV list of variables containing + * atomic data to be injected into the script
+ */ +public class XQueryScriptTask extends BaseTask { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + private Expression scriptFile; + private Expression xmlInputVariables; + private Expression atomicInputVariables; + private Expression outputVariable; + + public void execute(DelegateExecution execution) throws Exception { + if (msoLogger.isDebugEnabled()) { + msoLogger.debug("Started Executing " + getTaskName()); + } + + String theScriptFile = + getStringField(scriptFile, execution, "scriptFile"); + String theXmlInputVariables = + getOptionalStringField(xmlInputVariables, execution, "xmlInputVariables"); + String theAtomicInputVariables = + getOptionalStringField(atomicInputVariables, execution, "atomicInputVariables"); + String theOutputVariable = + getStringField(outputVariable, execution, "outputVariable"); + + if (msoLogger.isDebugEnabled()) { + System.out.println("scriptFile = " + theScriptFile + + " xmlInputVariables = " + theXmlInputVariables + + " atomicInputVariables = " + theAtomicInputVariables + + "outputVariable = " + theOutputVariable); + } + + String[] xmlInputVariableArray = (theXmlInputVariables == null) + ? new String[0] : theXmlInputVariables.split(",[ ]*"); + + String[] atomicInputVariableArray = (theAtomicInputVariables == null) + ? new String[0] : theAtomicInputVariables.split(",[ ]*"); + + Boolean shouldFail = (Boolean) execution.getVariable("shouldFail"); + + if (shouldFail != null && shouldFail) { + throw new ProcessEngineException(getClass().getSimpleName() + " Failed"); + } + + // The script could be compiled once and reused, but we are reading it + // and compiling it every time. + Configuration configuration = new Configuration(); + Processor processor = new Processor(configuration); + XQueryCompiler compiler = processor.newXQueryCompiler(); + XQueryExecutable executable = compile(compiler, theScriptFile); + + // The evaluator must not be shared by multiple threads. Here is where + // the initial context may be set, as well as values of external variables. + XQueryEvaluator evaluator = executable.load(); + + // Convert XML string variable content to document-node objects and inject + // these into the evaluator. Note: the script must accept the document-node + // type. Most MSO scripts today expect element() input, not document-node + // input. TODO: figure out how to pass the variable data as element() types. + + for (String xmlInputVariable : xmlInputVariableArray) { + if (msoLogger.isDebugEnabled()) { + msoLogger.debug("Injecting XML variable '" + xmlInputVariable + "'"); + msoLogger.debug("printing the variable content>>'" + execution.getVariable(xmlInputVariable) +"'"); + } + + String xml = (String) execution.getVariable(xmlInputVariable); + DocumentBuilder documentBuilder = processor.newDocumentBuilder(); + StreamSource source = new StreamSource(new ByteArrayInputStream(xml.getBytes("UTF-8"))); + XdmNode xdmNode = documentBuilder.build(source); + + // Inject the document-node object into the XQueryEvaluator. + // TODO: transform it to an element() + QName variable = new QName(xmlInputVariable); + evaluator.setExternalVariable(variable, xdmNode); + } + + // Inject atomic variables into the evaluator. + + for (String atomicInputVariable : atomicInputVariableArray) { + + if (msoLogger.isDebugEnabled()) { + System.out.println("Injecting object variable '" + + atomicInputVariable + "'"); + } + + QName variable = new QName(atomicInputVariable); + Object value = execution.getVariable(atomicInputVariable); + + if (value == null) { + // The variable value is null, so we have no way to know what + // type it is. I don't know how to deal with this, so for + // now, just skip it. + + msoLogger.warn (MessageEnum.BPMN_VARIABLE_NULL, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.DataError, atomicInputVariable); + + continue; + } + + // There might be a better way to do this... + if (value instanceof BigDecimal) { + evaluator.setExternalVariable(variable, + new XdmAtomicValue((BigDecimal) value)); + } else if (value instanceof Boolean) { + evaluator.setExternalVariable(variable, + new XdmAtomicValue((Boolean) value)); + } else if (value instanceof Double) { + evaluator.setExternalVariable(variable, + new XdmAtomicValue((Double) value)); + } else if (value instanceof Float) { + evaluator.setExternalVariable(variable, + new XdmAtomicValue((Float) value)); + } else if (value instanceof Long) { + evaluator.setExternalVariable(variable, + new XdmAtomicValue((Long) value)); + } else if (value instanceof String) { + evaluator.setExternalVariable(variable, + new XdmAtomicValue((String) value)); + } else if (value instanceof URI) { + evaluator.setExternalVariable(variable, + new XdmAtomicValue((URI) value)); + } else { + throw new BadInjectedFieldException( + "atomicInputVariables", getTaskName(), + "'" + atomicInputVariable + "' type is not supported: " + + value.getClass()); + } + } + + // Evaluate the query and collect the output. + StringBuilder output = new StringBuilder(); + Iterator xdmItems = evaluator.iterator(); + while (xdmItems.hasNext()) { + XdmItem item = xdmItems.next(); + + if (msoLogger.isDebugEnabled()) { + msoLogger.debug("XQuery result item = " + item); + } + + output.append(item.toString()); + } + + // Set the output variable. + execution.setVariable(theOutputVariable, output.toString()); + + if (msoLogger.isDebugEnabled()) { + msoLogger.debug("Done Executing " + getTaskName()); + } + } + + /** + * Compiles an XQuery script contained in a resource (file). + * @param compiler the XQueryCompiler + * @param resource the resource path + * @return an XQueryExecutable + * @throws Exception on error + */ + private XQueryExecutable compile(XQueryCompiler compiler, String resource) + throws Exception { + InputStream xqStream = null; + try { + xqStream = getClass().getResourceAsStream(resource); + + if (xqStream == null) { + throw new IOException("Resource not found: " + resource); + } + + XQueryExecutable executable = compiler.compile(xqStream); + xqStream.close(); + xqStream = null; + return executable; + } finally { + if (xqStream != null) { + try { + xqStream.close(); + } catch (Exception e) { + // Do nothing + } + } + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java new file mode 100644 index 0000000000..8329746347 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java @@ -0,0 +1,443 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core.json; + +import java.util.Iterator; +import java.util.StringTokenizer; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.XML; + +//import org.openecomp.mso.bpmn.core.BPMNLogger; +import org.openecomp.mso.bpmn.core.xml.XmlTool; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Utility class for JSON processing + * + * @version 1.0 + */ + +public class JsonUtils { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + private static int MSOJsonIndentFactor = 3; + + /** + * Uses the JSONObject static method to convert a XML doc to JSON. + * + * @param xml String containing the XML doc + * @param pretty flag to determine if the output should be formatted + * @return String containing the JSON translation + */ + public static String xml2json(String xml, Boolean pretty) { +// String isDebugLogEnabled = "true"; + try { + // name spaces cause problems, so just remove them + JSONObject jsonObj = XML.toJSONObject(XmlTool.removeNamespaces(xml)); + if (!pretty) { + return jsonObj.toString(); + } else { + // add an indent to make it 'pretty' + return jsonObj.toString(MSOJsonIndentFactor); + } + } catch (Exception e){ + msoLogger.debug("xml2json(): unable to parse xml and convert to json. Exception was: " + e.toString()); + return null; + } + } + + /** + * Invokes xml2json(String, Boolean) defaulting to 'pretty' output. + * + * @param xml String containing the XML doc + * @return String containing the JSON translation + */ + public static String xml2json(String xml) { + return xml2json(xml, true); + } + + /** + * Uses the JSONObject static method to convert a JSON doc to XML. + * Note: this method will not generate valid XML if the JSONObject + * contains JSONArrays which are used to represent XML attributes + * in the JSON doc. + * + * @param jsonStr String containing the JSON doc + * @param pretty flag to determine if the output should be formatted + * @return String containing the XML translation + */ + public static String json2xml(String jsonStr, Boolean pretty) { +// String isDebugLogEnabled = "true"; + try { + JSONObject jsonObj = new JSONObject(jsonStr); + if (pretty) { + return XmlTool.normalize(XML.toString(jsonObj)); + } else { + return XML.toString(jsonObj); + } + } catch (Exception e){ + msoLogger.debug("json2xml(): unable to parse json and convert to xml. Exception was: " + e.toString()); + return null; + } + } + + /** + * Invokes json2xml(String, Boolean) defaulting to 'pretty' output. + * + * @param jsonStr String containing the XML doc + * @return String containing the JSON translation + */ + public static String json2xml(String jsonStr) { + return json2xml(jsonStr, true); + } + + /** + * Uses the JSONObject static method to convert a JSON doc to XML. + * + * @param jsonStr String containing the JSON doc + * @return Iterator over the JSON keys + */ + public static Iterator getJsonIterator(String jsonStr) { +// String isDebugLogEnabled = "true"; + try { + JSONObject json = new JSONObject(jsonStr); + return json.keys(); + + } catch (Exception e){ + msoLogger.debug("getJsonIterator(): unable to parse json to retrieve the keys iterator. Exception was: " + e.toString()); + return null; + } + } + + /** + * Invokes the getJsonRawValue() method and returns the String equivalent of + * the object returned. + * + * TBD: May need separate methods for boolean, float, and integer fields if the + * String representation is not sufficient to meet client needs. + * + * @param jsonStr String containing the JSON doc + * @param keys full key path to the target value in the format of "key1.key2.key3..." + * @return String field value associated with keys + */ + public static String getJsonValue(String jsonStr, String keys) { +// String isDebugLogEnabled = "true"; + try { + Object rawValue = getJsonRawValue(jsonStr, keys); + if (rawValue == null) { + return null; + } else { + if (rawValue instanceof String) { + msoLogger.debug("getJsonValue(): the raw value is a String Object=" + ((String) rawValue).toString()); + return (String) rawValue; + } else { + msoLogger.debug("getJsonValue(): the raw value is NOT a String Object=" + rawValue.toString()); + return rawValue.toString(); + } + } + } catch (Exception e) { + msoLogger.debug("getJsonValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString()); + } + return null; + } + + /** + * Invokes the getJsonRawValue() method to obtain the JSONArray associated with + * the specified keys. The JSONArray is then walked to retrieve the content value of + * the specified field name. + * + * @param jsonStr String containing the JSON doc + * @param keys full key path to the target value in the format of "key1.key2.key3..." + * @param name field name for the param to be retrieved + * @return String param value associated with field name + */ + public static String getJsonParamValue(String jsonStr, String keys, String name) { +// String isDebugLogEnabled = "true"; + try { + Object rawValue = getJsonRawValue(jsonStr, keys); + if (rawValue == null) { + return null; + } else { + if (rawValue instanceof JSONArray) { + msoLogger.debug("getJsonParamValue(): keys=" + keys + " points to JSONArray: " + ((JSONArray) rawValue).toString()); + for (int i = 0; i < ((JSONArray) rawValue).length(); i++) { + msoLogger.debug("getJsonParamValue(): index: " + i + ", value: " + ((JSONArray) rawValue).get(i).toString()); + if (((JSONArray) rawValue).get(i) instanceof JSONObject) { + msoLogger.debug("getJsonParamValue(): index: " + i + " is a JSONObject"); + JSONObject jsonObj = (JSONObject)((JSONArray) rawValue).get(i); + if (jsonObj.get("name").equals(name)) { + msoLogger.debug("getJsonParamValue(): found value: " + (String) jsonObj.get("content") + " for name: " + name); + return (String) jsonObj.get("content"); + } + } else { + msoLogger.debug("getJsonParamValue(): the JSONArray element is NOT a JSONObject=" + rawValue.toString()); + return null; + } + } + msoLogger.debug("getJsonParamValue(): content value NOT found for name: " + name); + return null; + } else { + msoLogger.debug("getJsonParamValue(): the raw value is NOT a JSONArray Object=" + rawValue.toString()); + return null; + } + } + } catch (JSONException je) { + // JSONObject::get() throws this exception if one of the specified keys is not found + msoLogger.debug("getJsonParamValue(): caught JSONException attempting to retrieve param value for keys:" + keys + ", name=" + name); + } catch (Exception e) { + msoLogger.debug("getJsonParamValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString()); + } + return null; + } + + /** + * Wrapper to generate the JSONObject to pass to the getJsonValueForKey(JSONObject, String) + * method so that recursion over the subobjects can be supported there + * + * @param jsonStr String containing the JSON doc + * @param key key to the target value + * @return String field value associated with key + */ + public static String getJsonValueForKey(String jsonStr, String key) { +// String isDebugLogEnabled = "true"; + try { + JSONObject jsonObj = new JSONObject(jsonStr); + if (jsonObj != null) { + return getJsonValueForKey(jsonObj, key); + } + } catch (Exception e) { + msoLogger.debug("getJsonValueForKey(): unable to parse json to retrieve value for field=" + key + ". Exception was: " + e.toString()); + } + return null; + } + + /** + * Walks the JSONObject (and sub-objects recursively), searching for the first value associated with the + * single key/field name specified. Returns the associated value if found or null if the key is not found + * + * @param jsonObj JSONObject representation of the the JSON doc + * @param key key to the target value + * @return String field value associated with key + */ + public static String getJsonValueForKey(JSONObject jsonObj, String key) { +// String isDebugLogEnabled = "true"; + String keyValue = null; + try { + if (jsonObj.has(key)) { + msoLogger.debug("getJsonValueForKey(): found value for key=" + key); + return ((String) jsonObj.get(key)); + } else { + msoLogger.debug("getJsonValueForKey(): iterating over the keys"); + Iterator itr = jsonObj.keys(); + while (itr.hasNext()) { + String nextKey = (String) itr.next(); + Object obj = jsonObj.get(nextKey); + if (obj instanceof JSONObject) { + msoLogger.debug("getJsonValueForKey(): key=" + nextKey + ", points to JSONObject, recursive call"); + keyValue = getJsonValueForKey((JSONObject) obj, key); + if (keyValue != null) { + msoLogger.debug("getJsonValueForKey(): found value=" + keyValue + ", for key=" + key); + break; + } + } else { + msoLogger.debug("getJsonValueForKey(): key=" + nextKey + ", does not point to a JSONObject, next key"); + } + } + } + } catch (JSONException je) { + // JSONObject::get() throws this exception if one of the specified keys is not found + msoLogger.debug("getJsonValueForKey(): caught JSONException attempting to retrieve value for key=" + key); + keyValue = null; + } catch (Exception e) { + msoLogger.debug("getJsonValueForKey(): unable to parse json to retrieve value for field=" + key + ". Exception was: " + e.toString()); + } + return keyValue; + } + + /** + * Boolean method to determine if a key path is valid for the JSON doc. Invokes + * getJsonValue(). + * + * @param jsonStr String containing the JSON doc + * @param keys full key path to the target value in the format of "key1.key2.key3..." + * @return Boolean true if keys points to value in the JSON doc + */ + public static Boolean jsonValueExists(String jsonStr, String keys) { + if (getJsonRawValue(jsonStr, keys) == null) { + return false; + } else { + return true; + } + } + + /** + * Inserts the new key/value pair at the appropriate location in the JSON + * document after first determining if keyed field already exists. If + * it does exist, return the JSON unmodified, otherwise return the new JSON + * Note: this method currently only supports String value inserts. + * + * @param jsonStr String containing the JSON doc + * @param keys full key path to the value to be added in the format of "key1.key2.key3..." + * @return String containing the updated JSON doc + */ + public static String addJsonValue(String jsonStr, String keys, String value) { +// String isDebugLogEnabled = "true"; + // only attempt to insert the key/value pair if it does not exist + if (!jsonValueExists(jsonStr, keys)) { + return putJsonValue(jsonStr, keys, value); + } else { + msoLogger.debug("addJsonValue(): JSON add failed, key=" + keys + "/value=" + (String) value + " already exists"); + return jsonStr; + } + } + + /** + * Updates the value for the specified key in the JSON document + * after first determining if keyed field exists. If it does + * not exist, return the JSON unmodified, otherwise return the updated JSON. + * Note: this method currently only supports String value updates. + * + * @param jsonStr String containing the JSON doc + * @param keys full key path to the value to be updated in the format of "key1.key2.key3..." + * @return String containing the updated JSON doc + */ + public static String updJsonValue(String jsonStr, String keys, String newValue) { +// String isDebugLogEnabled = "true"; + // only attempt to modify the key/value pair if it exists + if (jsonValueExists(jsonStr, keys)) { + return putJsonValue(jsonStr, keys, newValue); + } else { + msoLogger.debug("updJsonValue(): JSON update failed, no value exists for key=" + keys); + return jsonStr; + } + } + + /** + * Deletes the value for the specified key in the JSON document + * after first determining if keyed field exists. If it does + * not exist, return the JSON unmodified, otherwise return the updated JSON + * + * @param jsonStr String containing the JSON doc + * @param keys full key path to the value to be deleted in the format of "key1.key2.key3..." + * @return String containing the updated JSON doc + */ + public static String delJsonValue(String jsonStr, String keys) { +// String isDebugLogEnabled = "true"; + // only attempt to remove the key/value pair if it exists + if (jsonValueExists(jsonStr, keys)) { + // passing a null value results in a delete + return putJsonValue(jsonStr, keys, null); + } else { + msoLogger.debug("delJsonValue(): JSON delete failed, no value exists for key=" + keys); + return jsonStr; + } + } + + /** + * Walks the JSON doc using the full key path to retrieve the associated + * value. All but the last key points to the 'parent' object name(s) in order + * in the JSON hierarchy with the last key pointing to the target value. + * The value returned is a Java object. + * + * @param jsonStr String containing the JSON doc + * @param keys full key path to the target value in the format of "key1.key2.key3..." + * @return Object field value associated with keys + */ + private static Object getJsonRawValue(String jsonStr, String keys) { +// String isDebugLogEnabled = "true"; + String keyStr = ""; + try { + JSONObject jsonObj = new JSONObject(jsonStr); + StringTokenizer keyTokens = new StringTokenizer(keys, "."); + while (keyTokens.hasMoreElements()) { + keyStr = keyTokens.nextToken(); + Object keyValue = jsonObj.get(keyStr); + if (keyValue instanceof JSONObject) { + msoLogger.debug("getJsonRawValue(): key=" + keyStr + " points to json object"); + jsonObj = (JSONObject) keyValue; + } else { + if (keyTokens.hasMoreElements()) { + msoLogger.debug("getJsonRawValue(): value found prior to last key for key=" + keyStr); + } + return keyValue; + } + } + // we should not hit this point: either the key points to a valid value and + // we return it above or the key is invalid and we handle the JSONException + // below and return null + return null; + + } catch (JSONException je) { + // JSONObject::get() throws this exception if one of the specified keys is not found + msoLogger.debug("getJsonRawValue(): caught JSONException attempting to retrieve raw value for key=" + keyStr); + } catch (Exception e) { + msoLogger.debug("getJsonRawValue(): unable to parse json to retrieve value for field=" + keys + ". Exception was: " + e.toString()); + } + return null; + } + + /** + * Private method invoked by the public add, update, and delete methods. + * + * @param jsonStr String containing the JSON doc + * @param keys full key path to the value to be deleted in the format of "key1.key2.key3..." + * @return String containing the updated JSON doc + */ + private static String putJsonValue(String jsonStr, String keys, String value) { +// String isDebugLogEnabled = "true"; + String keyStr = ""; + try { + JSONObject jsonObj = new JSONObject(jsonStr); + JSONObject jsonObjOut = jsonObj; + StringTokenizer keyTokens = new StringTokenizer(keys, "."); + while (keyTokens.hasMoreElements()) { + keyStr = keyTokens.nextToken(); + if (keyTokens.hasMoreElements()) { + Object keyValue = jsonObj.get(keyStr); + if (keyValue instanceof JSONObject) { + msoLogger.debug("putJsonValue(): key=" + keyStr + " points to json object"); + jsonObj = (JSONObject) keyValue; + } else { + msoLogger.debug("putJsonValue(): key=" + keyStr + " not the last key but points to non-json object: " + (String) keyValue); + return null; + } + } else { // at the last/new key value + jsonObj.put(keyStr, value); + return jsonObjOut.toString(3); + } + } + // should not hit this point if the key points to a valid key value + return null; + + } catch (JSONException je) { + // JSONObject::get() throws this exception if one of the specified keys is not found + msoLogger.debug("putJsonValue(): caught JSONException attempting to retrieve value for key=" + keyStr); + return null; + } catch (Exception e) { + msoLogger.debug("putJsonValue(): unable to parse json to put value for key=" + keys + ". Exception was: " + e.toString()); + } + return null; + } +} + diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java new file mode 100644 index 0000000000..3a731558a4 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/CustomMyBatisSessionFactory.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core.mybatis; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration; +import org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor; +import org.camunda.bpm.engine.impl.interceptor.CommandInterceptor; +import org.camunda.bpm.engine.impl.interceptor.LogInterceptor; +import org.camunda.bpm.engine.impl.util.ReflectUtil; + + +/** + * A special process engine that provides access to MyBatis mappings. + * @version 1.0 + */ +public class CustomMyBatisSessionFactory extends + StandaloneProcessEngineConfiguration { + + private String resourceName; + + /** + * Overridden to ensure nobody ever tries to initialize this process engine + * in the normal way. We are using this process engine only for MyBatis + * access. + */ + @Override + protected void init() { + throw new UnsupportedOperationException("init"); + } + + /** + * Initialize the ProcessEngineConfiguration from an existing one, just + * using the database settings to initialize the database / MyBatis stuff. + */ + public void initFromProcessEngineConfiguration( + ProcessEngineConfigurationImpl processEngineConfiguration, + String resourceName) { + this.resourceName = resourceName; + + setDatabaseType(processEngineConfiguration.getDatabaseType()); + setDataSource(processEngineConfiguration.getDataSource()); + setDatabaseTablePrefix(processEngineConfiguration + .getDatabaseTablePrefix()); + + initDataSource(); + // initVariableTypes(); + initCommandContextFactory(); + initTransactionFactory(); + initTransactionContextFactory(); + initCommandExecutors(); + initSqlSessionFactory(); + initIncidentHandlers(); + initIdentityProviderSessionFactory(); + initSessionFactories(); + } + + /** + * In order to always open a new command context set the property + * "alwaysOpenNew" to true inside the CommandContextInterceptor. + * + * If you execute the custom queries inside the process engine (for example + * in a service task), you have to do this. + */ + @Override + protected Collection getDefaultCommandInterceptorsTxRequired() { + List defaultCommandInterceptorsTxRequired = + new ArrayList(); + defaultCommandInterceptorsTxRequired.add(new LogInterceptor()); + defaultCommandInterceptorsTxRequired.add(new CommandContextInterceptor( + commandContextFactory, this, true)); + return defaultCommandInterceptorsTxRequired; + } + + @Override + protected InputStream getMyBatisXmlConfigurationSteam() { + return ReflectUtil.getResourceAsStream(resourceName); + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java new file mode 100644 index 0000000000..07959cb016 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/mybatis/URNMapping.java @@ -0,0 +1,122 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core.mybatis; + +/** + * A bean that represents a single URN mapping. + */ +public class URNMapping { + private String name; + private String value; + private String rev; + + /** + * Get the name. + * @return the name + */ + public String getName() { + return name; + } + + /** + * Set the name. + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the value mapped to the name. + * @return the value mapped to the name + */ + public String getValue() { + return value; + } + + /** + * Set the value mapped to the name. + * @param value the value mapped to the name + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Get the revision attribute (currently unused). + * @return the revision attribute + */ + public String getRev() { + return rev; + } + + /** + * Set the revision attribute (currently unused). + * @param rev the revision attribute + */ + public void setRev(String rev) { + this.rev = rev; + } + + /** + * Converts a URN to "normal" form so it can used as a java or groovy + * variable identifier. This is done in a way that makes the identifier + * as readable as possible, but note that it might result in a loss of + * uniqueness. + *

    + *
  1. URN_ is prepended
  2. + *
  3. All characters that are not letters or digits are converted to + * underscore characters
  4. + *
  5. Sequences of multiple underscores are collapsed to a single + * underscore character
  6. + *
+ * Examples: + *

+ * aai:endpoint becomes URN_aai_endpoint
+ * ae:internal-reporting becomes URN_ae_internal_reporting
+ * + * @param name the URN + * @return a normalized identifier + */ + public static String createIdentifierFromURN(String urn) { + StringBuilder builder = new StringBuilder(); + builder.append("URN_"); + char last = builder.charAt(builder.length() - 1); + + int len = urn.length(); + + for (int i = 0; i < len; i++) { + char c = urn.charAt(i); + + if (!Character.isLetterOrDigit(c) && c != '_') { + c = '_'; + } + + if (!(c == '_' && last == '_')) { + builder.append(c); + } + + last = c; + } + + return builder.toString(); + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java new file mode 100644 index 0000000000..8e3f254def --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -0,0 +1,424 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core.plugins; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.ExecutionListener; +import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener; +import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener; +import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl; +import org.camunda.bpm.engine.impl.pvm.process.TransitionImpl; +import org.camunda.bpm.engine.impl.util.xml.Element; +import org.camunda.bpm.engine.impl.variable.VariableDeclaration; + +import org.openecomp.mso.bpmn.core.BPMNLogger; +import org.openecomp.mso.bpmn.core.PropertyConfiguration; +import org.openecomp.mso.bpmn.core.mybatis.CustomMyBatisSessionFactory; +import org.openecomp.mso.bpmn.core.mybatis.URNMapping; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Plugin for MSO logging and URN mapping. + */ +public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + private static final String FSPROPKEY = "URNMapping.FileSystemLoading.Enabled"; + + @Override + public void preInit( + ProcessEngineConfigurationImpl processEngineConfiguration) { + List preParseListeners = processEngineConfiguration + .getCustomPreBPMNParseListeners(); + if (preParseListeners == null) { + preParseListeners = new ArrayList(); + processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); + } + preParseListeners.add(new LoggingParseListener()); + } + + /** + * Called when a process flow is parsed so we can inject listeners. + */ + public static class LoggingParseListener extends AbstractBpmnParseListener { + private void injectLogExecutionListener(ActivityImpl activity) { + activity.addListener( + ExecutionListener.EVENTNAME_END, + new LoggingExecutionListener("END")); + + activity.addListener( + ExecutionListener.EVENTNAME_START, + new LoggingExecutionListener("START")); + + activity.addListener( + ExecutionListener.EVENTNAME_TAKE, + new LoggingExecutionListener("TAKE")); + } + + public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) { + } + + public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) { + // Inject these listeners only on the main start event for the flow, not on any embedded subflow start events + if (scope instanceof ProcessDefinitionEntity) { + startEventActivity.addListener(ExecutionListener.EVENTNAME_START, new URNMappingInitializerListener("START")); + startEventActivity.addListener(ExecutionListener.EVENTNAME_START, new LoggingInitializerListener("START")); + } + + injectLogExecutionListener(startEventActivity); + } + + public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseExclusiveGateway(Element exclusiveGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseInclusiveGateway(Element inclusiveGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseParallelGateway(Element parallelGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseScriptTask(Element scriptTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseBusinessRuleTask(Element businessRuleTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseTask(Element taskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseManualTask(Element manualTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseEndEvent(Element endEventElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseBoundaryTimerEventDefinition(Element timerEventDefinition, boolean interrupting, ActivityImpl timerActivity) { + injectLogExecutionListener(timerActivity); + } + + public void parseBoundaryErrorEventDefinition(Element errorEventDefinition, boolean interrupting, ActivityImpl activity, ActivityImpl nestedErrorEventActivity) { + injectLogExecutionListener(activity); + } + + public void parseSubProcess(Element subProcessElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) { + //injectLogExecutionListener(activity); + } + + public void parseSendTask(Element sendTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseMultiInstanceLoopCharacteristics(Element activityElement, Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseIntermediateTimerEventDefinition(Element timerEventDefinition, ActivityImpl timerActivity) { + injectLogExecutionListener(timerActivity); + } + + public void parseRootElement(Element rootElement, List processDefinitions) { + //injectLogExecutionListener(activity); + } + + public void parseReceiveTask(Element receiveTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseIntermediateSignalCatchEventDefinition(Element signalEventDefinition, ActivityImpl signalActivity) { + injectLogExecutionListener(signalActivity); + } + + public void parseBoundarySignalEventDefinition(Element signalEventDefinition, boolean interrupting, ActivityImpl signalActivity) { + injectLogExecutionListener(signalActivity); + } + + public void parseEventBasedGateway(Element eventBasedGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseTransaction(Element transactionElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseCompensateEventDefinition(Element compensateEventDefinition, ActivityImpl compensationActivity) { + injectLogExecutionListener(compensationActivity); + } + + public void parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseIntermediateCatchEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + public void parseBoundaryEvent(Element boundaryEventElement, ScopeImpl scopeElement, ActivityImpl nestedActivity) { + injectLogExecutionListener(nestedActivity); + } + + public void parseIntermediateMessageCatchEventDefinition(Element messageEventDefinition, ActivityImpl nestedActivity) { + injectLogExecutionListener(nestedActivity); + } + + public void parseBoundaryMessageEventDefinition(Element element, boolean interrupting, ActivityImpl messageActivity) { + injectLogExecutionListener(messageActivity); + } + } + + /** + * Initializes URN mapping variables on process entry. + */ + public static class URNMappingInitializerListener implements ExecutionListener { + private String event; + + public URNMappingInitializerListener(String eventData) { + this.event = eventData; + } + + public String getEvent() { + return event; + } + + public void notify(DelegateExecution execution) throws Exception { + ProcessEngineConfigurationImpl processEngineConfiguration = + Context.getProcessEngineConfiguration(); + loadURNProperties(execution, processEngineConfiguration); + } + + private void loadURNProperties(DelegateExecution execution, + ProcessEngineConfigurationImpl processEngineConfiguration) { + Map bpmnProps = PropertyConfiguration.getInstance().getProperties("mso.bpmn.properties"); + if (bpmnProps == null) { + LOGGER.debug("Unable to load mso.bpmn.properties; loading URN Mapping from DB"); + + LOGGER.error (MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, + "Unable to load mso.bpmn.properties; loading URN Mapping from DB"); + + loadFromDB(execution, processEngineConfiguration); + } else { + String fsEnabled = bpmnProps.get(FSPROPKEY); + if (fsEnabled != null) { + if (Boolean.parseBoolean(fsEnabled)) { + LOGGER.debug("File system loading is enabled; loading URN properties from File system"); + LOGGER.info(MessageEnum.BPMN_GENERAL_INFO, "BPMN", "File system loading is enabled; loading URN properties from File System"); + loadFromFileSystem(execution); + } else { + LOGGER.debug("File system loading is disabled; loading URN properties from DB"); + LOGGER.info (MessageEnum.BPMN_GENERAL_INFO, "BPMN", "File system loading is disabled; loading URN properties from DB"); + + loadFromDB(execution, processEngineConfiguration); + } + } else { + + LOGGER.error (MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, + "Unable to retrieve URNMapping.FileSystemLoading.Enabled from mso.bpmn.properties; loading URN Mapping from DB"); + + loadFromDB(execution, processEngineConfiguration); + } + } + } + + private void loadFromFileSystem(DelegateExecution execution) { + PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); + Map props = propertyConfiguration.getProperties("mso.bpmn.urn.properties"); + for (String key : props.keySet()) { + String varName = URNMapping.createIdentifierFromURN(key); + String varValue = props.get(key); + execution.setVariable(varName, varValue); + } + } + + private void loadFromDB(DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) { + Command> command = new Command>() { + @SuppressWarnings("unchecked") + public List execute(CommandContext commandContext) { + return (List) commandContext.getDbSqlSession().selectList( + "mso.urnMapping.selectAll", null); + } + }; + + CustomMyBatisSessionFactory sessionFactory = new CustomMyBatisSessionFactory(); + sessionFactory.initFromProcessEngineConfiguration(processEngineConfiguration, + "customMyBatisConfiguration.xml"); + + List mappings = sessionFactory.getCommandExecutorTxRequired().execute(command); + + if (mappings != null && mappings.size() > 0) { + for (URNMapping mapping : mappings) { + String varName = URNMapping.createIdentifierFromURN(mapping.getName()); + String varValue = mapping.getValue(); + + LOGGER.debug("URN Mapping = '" + mapping.getName() + + "', setting variable '" + varName + "' to '" + varValue + "'"); + + execution.setVariable(varName, varValue); + } + } + } + } + + /** + * Sets the isDebugLogEnabled variable on process entry. + */ + public static class LoggingInitializerListener implements ExecutionListener { + private String event; + + public LoggingInitializerListener(String eventData) { + this.event = eventData; + } + + public String getEvent() { + return event; + } + + public void notify(DelegateExecution execution) throws Exception { + String processKey = execution.getProcessEngineServices().getRepositoryService() + .getProcessDefinition(execution.getProcessDefinitionId()).getKey(); + + // If a "true" value is already injected, e.g. from a top-level flow, it SHOULD NOT be + // overridden by the value in the URN mapping. This allows a top-level flow and all + // invoked subflows to be debugged by turning on the debug flag for just the top-level + // flow, assuming the isDebugEnabled flag variable is passed from the top-level flow to + // its subflows. + + // If a "false" value is already injected, e.g. from a top-level flow, it SHOULD be + // overridden by the value in the URN mapping. This allows a subflow to be debugged + // without turning on the the debug flag for the top-level flow. + + String injectedValue = (String) execution.getVariable("isDebugLogEnabled"); + String urnValue = "true".equals(execution.getVariable("URN_log_debug_" + processKey)) ? "true" : "false"; + + if ("true".equals(injectedValue)) { + LOGGER.debug("Setting isDebugLogEnabled to \"" + injectedValue + "\" for process: " + processKey + " (injected value)"); + execution.setVariable("isDebugLogEnabled", injectedValue); + } else { + LOGGER.debug("Setting isDebugLogEnabled to \"" + urnValue + "\" for process: " + processKey + " (from URN mapping)"); + execution.setVariable("isDebugLogEnabled", urnValue); + } + } + } + + /** + * Logs details about the current activity. + */ + public static class LoggingExecutionListener implements ExecutionListener { + private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + private static ConcurrentHashMap startTimes = new ConcurrentHashMap(); + + private String event; + + public LoggingExecutionListener(String event) { + this.event = event; + } + + public String getEvent() { + return event; + } + + public void notify(DelegateExecution execution) throws Exception { + BPMNLogger.debug( + (String) execution.getVariable("isDebugLogEnabled"), + "Logging for activity---------------:" + event + ":" + + execution.getCurrentActivityName() + + ", processDefinitionId=" + + execution.getProcessDefinitionId() + ", activtyId=" + + execution.getCurrentActivityId() + ", activtyName='" + + execution.getCurrentActivityName() + "'" + + ", processInstanceId=" + + execution.getProcessInstanceId() + ", businessKey=" + + execution.getProcessBusinessKey() + ", executionId=" + + execution.getId()); + + if (!isBlank(execution.getCurrentActivityName())) { + try { + String id = execution.getId(); + if ("START".equals(event) && id != null ) { + startTimes.put(id, (Long)System.currentTimeMillis()); + } else if ("END".equals(event) && id != null) { + String prefix = (String) execution.getVariable("prefix"); + + if (prefix != null ) { + MsoLogger.setServiceName("MSO." + prefix.substring(0,prefix.length()-1)); + } + + String requestId = (String) execution.getVariable("att-mso-request-id"); + String svcid = (String) execution.getVariable("att-mso-service-instance-id"); + MsoLogger.setLogContext(requestId, svcid); + long startTime = startTimes.remove(id); + + if (startTime != 0) { + + LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + event + ": " + execution.getCurrentActivityName(), "BPMN", execution.getCurrentActivityName(), null); + + } + } + } catch(Exception e) { + // Do nothing + } + } + } + + private boolean isBlank(Object object) { + return object == null || object.toString().trim().equals(""); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java new file mode 100644 index 0000000000..10386d721e --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/plugins/WorkflowExceptionPlugin.java @@ -0,0 +1,170 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core.plugins; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.ExecutionListener; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.camunda.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior; +import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener; +import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener; +import org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration; +import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity; +import org.camunda.bpm.engine.impl.pvm.PvmTransition; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.process.TransitionImpl; +import org.camunda.bpm.engine.impl.util.xml.Element; + +import org.openecomp.mso.bpmn.core.BPMNLogger; +import org.openecomp.mso.bpmn.core.WorkflowException; + +/** + * This plugin does the following: + *

    + *
  1. + * Adds logic at the start of every Call Activity to remove any existing + * WorkflowException object from the execution (saving a copy of it in a + * different variable). + *
  2. + *
  3. + * Adds logic at the end of every Call Activity to generate a MSOWorkflowException + * event if there is a WorkflowException object in the execution. + *
  4. + *
+ */ +public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { + + @Override + public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) { + List preParseListeners = + processEngineConfiguration.getCustomPreBPMNParseListeners(); + + if (preParseListeners == null) { + preParseListeners = new ArrayList(); + processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); + } + + preParseListeners.add(new WorkflowExceptionParseListener()); + } + + public static class WorkflowExceptionParseListener extends AbstractBpmnParseListener { + @Override + public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) { + AtomicInteger triggerTaskIndex = new AtomicInteger(1); + List activities = new ArrayList(processDefinition.getActivities()); + recurse(activities, triggerTaskIndex); + } + + /** + * Helper method that recurses (into subprocesses) over all the listed activities. + * @param activities a list of workflow activities + * @param triggerTaskIndex the index of the next trigger task (mutable) + */ + private void recurse(List activities, AtomicInteger triggerTaskIndex) { + for (ActivityImpl activity : activities) { + String type = (String) activity.getProperty("type"); + + if ("callActivity".equals(type)) { + // Add a WorkflowExceptionResetListener to clear the WorkflowException + // variable when each Call Activity starts. + + activity.addListener( + ExecutionListener.EVENTNAME_START, + new WorkflowExceptionResetListener()); + + // Add a WorkflowExceptionTriggerTask after the call activity. + // It must be a task because a listener cannot be used to generate + // an event. Throwing BpmnError from an execution listener will + // cause the process to die. + + List outTransitions = + new ArrayList(activity.getOutgoingTransitions()); + + for (PvmTransition transition : outTransitions) { + String triggerTaskId = "WorkflowExceptionTriggerTask_" + triggerTaskIndex; + + ActivityImpl triggerTask = activity.getFlowScope().createActivity(triggerTaskId); + + ClassDelegateActivityBehavior behavior = new ClassDelegateActivityBehavior( + WorkflowExceptionTriggerTask.class.getName(), + new ArrayList(0)); + + triggerTask.setActivityBehavior(behavior); + triggerTask.setName("Workflow Exception Trigger Task " + triggerTaskIndex); + triggerTaskIndex.getAndIncrement(); + + TransitionImpl transitionImpl = (TransitionImpl) transition; + TransitionImpl triggerTaskOutTransition = triggerTask.createOutgoingTransition(); + triggerTaskOutTransition.setDestination((ActivityImpl)transitionImpl.getDestination()); + transitionImpl.setDestination(triggerTask); + } + } else if ("subProcess".equals(type)) { + recurse(new ArrayList(activity.getActivities()), triggerTaskIndex); + } + } + } + } + + /** + * If there is a WorkflowException object in the execution, this method + * removes it (saving a copy of it in a different variable). + */ + public static class WorkflowExceptionResetListener implements ExecutionListener { + public void notify(DelegateExecution execution) throws Exception { + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + int index = 1; + String saveName = "SavedWorkflowException" + index; + while (execution.getVariable(saveName) != null) { + saveName = "SavedWorkflowException" + (++index); + } + + BPMNLogger.debug((String)execution.getVariable("isDebugLogEnabled"), + "WorkflowExceptionResetTask is moving WorkflowException to " + saveName); + + execution.setVariable(saveName, workflowException); + execution.setVariable("WorkflowException", null); + } + } + } + + /** + * Generates an MSOWorkflowException event if there is a WorkflowException + * object in the execution. + */ + public static class WorkflowExceptionTriggerTask implements JavaDelegate { + public void execute(DelegateExecution execution) throws Exception { + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + BPMNLogger.debug((String)execution.getVariable("isDebugLogEnabled"), + "WorkflowExceptionTriggerTask is generating a MSOWorkflowException event"); + throw new BpmnError("MSOWorkflowException"); + } + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java new file mode 100644 index 0000000000..42114758b0 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java @@ -0,0 +1,340 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core.xml; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * XML transformation methods and other useful functions. + */ +public final class XmlTool { + + private static final Map ENTITIES = new HashMap(); + + static { + ENTITIES.put("amp", new Integer(38)); + ENTITIES.put("quot", new Integer(34)); + ENTITIES.put("lt", new Integer(60)); + ENTITIES.put("gt", new Integer(62)); + } + + /** + * Normalizes and formats XML. This method consolidates and moves all namespace + * declarations to the root element. The result will not have an XML prolog or + * a trailing newline. + * @param xml the XML to normalize + * @throws IOException + * @throws TransformerException + * @throws ParserConfigurationException + * @throws SAXException + * @throws XPathExpressionException + */ + public static String normalize(Object xml) throws IOException, TransformerException, + ParserConfigurationException, SAXException, XPathExpressionException { + + if (xml == null) { + return null; + } + + Source xsltSource = new StreamSource(new StringReader( + readResourceFile("normalize-namespaces.xsl"))); + + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + dbFactory.setNamespaceAware(true); + DocumentBuilder db = dbFactory.newDocumentBuilder(); + InputSource source = new InputSource(new StringReader(String.valueOf(xml))); + Document doc = db.parse(source); + + // Start of code to remove whitespace outside of tags + XPath xPath = XPathFactory.newInstance().newXPath(); + NodeList nodeList = (NodeList) xPath.evaluate( + "//text()[normalize-space()='']", doc, XPathConstants.NODESET); + + for (int i = 0; i < nodeList.getLength(); ++i) { + Node node = nodeList.item(i); + node.getParentNode().removeChild(node); + } + // End of code to remove whitespace outside of tags + + // the factory pattern supports different XSLT processors + TransformerFactory transformerFactory = TransformerFactory.newInstance(); + Transformer transformer = transformerFactory.newTransformer(xsltSource); + + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + + StringWriter writer = new StringWriter(); + transformer.transform(new DOMSource(doc), new StreamResult(writer)); + return writer.toString().trim(); + } + + /** + * Encodes a value so it can be used inside an XML text element. + * @param s the string to encode + * @return the encoded string + */ + public static String encode(Object value) { + if (value == null) { + return null; + } + + String s = String.valueOf(value); + StringBuilder out = new StringBuilder(); + boolean modified = false; + + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + + if (c == '<') { + out.append("<"); + modified = true; + } else if (c == '>') { + out.append(">"); + modified = true; + } else if (c == '&') { + out.append("&"); + modified = true; + } else if (c < 32 || c > 126) { + out.append("&#" + (int)c + ";"); + modified = true; + } else { + out.append(c); + } + } + + if (modified) { + return out.toString(); + } else { + return s; + } + } + + /** + * Encodes a value so it can be used inside an XML attribute. + * @param s the string to encode + * @return the encoded string + */ + public static String encodeAttr(Object value) { + if (value == null) { + return null; + } + + String s = String.valueOf(value); + StringBuilder out = new StringBuilder(); + boolean modified = false; + + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + + if (c == '<') { + out.append("<"); + modified = true; + } else if (c == '>') { + out.append(">"); + modified = true; + } else if (c == '"') { + out.append("""); + modified = true; + } else if (c == '&') { + out.append("&"); + modified = true; + } else if (c < 32 || c > 126) { + out.append("&#" + (int)c + ";"); + modified = true; + } else { + out.append(c); + } + } + + if (modified) { + return out.toString(); + } else { + return s; + } + } + + /** + * Decodes XML entities in a string value + * @param value a value with embedded XML entities + * @return the decoded string + */ + public static String decode(Object value) { + if (value == null) { + return null; + } + + String s = String.valueOf(value); + + StringBuilder out = new StringBuilder(s.length()); + int ampIndex = s.indexOf("&"); + int lastEnd = 0; + + while (ampIndex >= 0) { + int nextAmpIndex = s.indexOf("&", ampIndex + 1); + int nextSemiIndex = s.indexOf(";", ampIndex + 1); + if (nextSemiIndex != -1 && (nextAmpIndex == -1 || nextSemiIndex < nextAmpIndex)) { + int code = -1; + String entity = s.substring(ampIndex + 1, nextSemiIndex); + + try { + if (entity.startsWith("#")) { + code = Integer.parseInt(entity.substring(1), 10); + } else { + if (ENTITIES.containsKey(entity)) { + code = ENTITIES.get(entity); + } + } + } catch (NumberFormatException x) { + // Do nothing + } + + out.append(s.substring(lastEnd, ampIndex)); + lastEnd = nextSemiIndex + 1; + if (code >= 0 && code <= 0xffff) { + out.append((char) code); + } else { + out.append("&"); + out.append(entity); + out.append(";"); + } + } + + ampIndex = nextAmpIndex; + } + + out.append(s.substring(lastEnd)); + return out.toString(); + } + + /** + * Removes the preamble, if present, from an XML document. + * @param xml the XML document + * @return a possibly modified document + */ + public static String removePreamble(Object xml) { + if (xml == null) { + return null; + } + + return String.valueOf(xml).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", ""); + } + + /** + * Removes namespaces and namespace declarations from an XML document. + * @param xml the XML document + * @return a possibly modified document + */ + public static String removeNamespaces(Object xml) { + if (xml == null) { + return null; + } + + String text = String.valueOf(xml); + + // remove xmlns declaration + text = text.replaceAll("xmlns.*?(\"|\').*?(\"|\')", ""); + // remove opening tag prefix + text = text.replaceAll("(<)(\\w+:)(.*?>)", "$1$3"); + // remove closing tags prefix + text = text.replaceAll("()", "$1$3"); + // remove extra spaces left when xmlns declarations are removed + text = text.replaceAll("\\s+>", ">"); + + return text; + } + + + /** + * Reads the specified resource file and return the contents as a string. + * @param file Name of the resource file + * @return the contents of the resource file as a String + * @throws IOException if there is a problem reading the file + */ + private static String readResourceFile(String file) throws IOException { + InputStream stream = null; + try { + stream = XmlTool.class.getClassLoader().getResourceAsStream(file); + + if (stream == null) { + throw new FileNotFoundException("No such resource file: " + file); + } + + Reader reader = new InputStreamReader(stream, "UTF-8"); + StringBuilder out = new StringBuilder(); + char[] buf = new char[1024]; + int n; + + while ((n = reader.read(buf)) >= 0) { + out.append(buf, 0, n); + } + + stream.close(); + stream = null; + return out.toString(); + } finally { + if (stream != null) { + try { + stream.close(); + } catch (Exception e) { + // Ignore + } + } + } + } + + /** + * Instantiation is not allowed. + */ + private XmlTool() { + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/test/CamundaDBSetup.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/test/CamundaDBSetup.java new file mode 100644 index 0000000000..13eed2d530 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/test/CamundaDBSetup.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.test; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * Sets up the unit test (H2) database for Camunda. + */ +public class CamundaDBSetup { + private static boolean isDBConfigured = false; + + public static synchronized void configure() throws SQLException { + if (isDBConfigured) { + return; + } + + System.out.println("Configuring the Camunda H2 database for MSO"); + + Connection connection = null; + PreparedStatement stmt = null; + + try { + connection = DriverManager.getConnection( + "jdbc:h2:mem:camunda;DB_CLOSE_DELAY=-1", "sa", ""); + + stmt = connection.prepareStatement("delete from ACT_HI_VARINST"); + stmt.executeUpdate(); + stmt.close(); + stmt = null; + + stmt = connection.prepareStatement("ALTER TABLE ACT_HI_VARINST alter column TEXT_ clob"); + stmt.executeUpdate(); + stmt.close(); + stmt = null; + + stmt = connection.prepareStatement("ALTER TABLE ACT_HI_VARINST alter column NAME_ clob"); + stmt.executeUpdate(); + stmt.close(); + stmt = null; + + stmt = connection.prepareStatement("delete from ACT_HI_DETAIL"); + stmt.executeUpdate(); + stmt.close(); + stmt = null; + + stmt = connection.prepareStatement("ALTER TABLE ACT_HI_DETAIL alter column TEXT_ clob"); + stmt.executeUpdate(); + stmt.close(); + stmt = null; + + stmt = connection.prepareStatement("ALTER TABLE ACT_HI_DETAIL alter column NAME_ clob"); + stmt.executeUpdate(); + stmt.close(); + stmt = null; + + stmt = connection.prepareStatement("ALTER TABLE ACT_RU_VARIABLE alter column TEXT_ clob"); + stmt.executeUpdate(); + stmt.close(); + stmt = null; + + connection.close(); + connection = null; + + isDBConfigured = true; + } catch (SQLException e) { + System.out.println("CamundaDBSetup caught " + e.getClass().getSimpleName()); + e.printStackTrace(); + } finally { + if (stmt != null) { + try { + stmt.close(); + } catch (Exception e) { + // Ignore + } + } + + if (connection != null) { + try { + connection.close(); + } catch (Exception e) { + // Ignore + } + } + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/test/PropertyConfigurationSetup.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/test/PropertyConfigurationSetup.java new file mode 100644 index 0000000000..6f1cd7d8cc --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/test/PropertyConfigurationSetup.java @@ -0,0 +1,315 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.test; + +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.openecomp.mso.bpmn.core.PropertyConfiguration; + +/** + * Sets up mso.bpmn.properties and mso.bpmn.urn.properties for unit tests. + */ +public class PropertyConfigurationSetup { + + private static Path msoConfigPath = null; + private static Path bpmnPropertiesPath = null; + private static Path bpmnUrnPropertiesPath = null; + private static boolean modifiedConfiguration = false; + + /** + * Ensures that the the PropertyConfiguration is initialized and that the + * property data is reset to initial values. Any extra properties that are + * specified will be merged with the initial values. The following example + * shows how a test can specify a replacement URN mapping property. + *
+	 *     Map urnProperties =
+	 *         PropertyConfigurationSetup.createBpmnUrnProperties();
+	 *     urnProperties.add("mso.po.timeout", "PT1M");
+	 *     PropertyConfiguration.init(urnProperties);
+	 * 
+ * @param args one or more maps created with createBpmnProperties() + * and/or createBpmnUrnProperties() + */ + public static synchronized void init(Object ... args) throws IOException { + + Map extraBpmnProperties = null; + Map extraBpmnUrnProperties = null; + + boolean propertiesSpecified = false; + + for (Object arg : args) { + @SuppressWarnings("unchecked") + Map properties = (Map) arg; + + String type = properties.get("PROPERTIES-TYPE"); + + if (PropertyConfiguration.MSO_BPMN_PROPERTIES.equals(type)) { + if (properties.size() > 1) { + extraBpmnProperties = properties; + propertiesSpecified = false; + } + } else if (PropertyConfiguration.MSO_BPMN_URN_PROPERTIES.equals(type)) { + if (properties.size() > 1) { + extraBpmnUrnProperties = properties; + propertiesSpecified = false; + } + } else { + throw new IllegalArgumentException("Not a supported PROPERTIES-TYPE map"); + } + } + + // There are three cases in which we need to change the existing configuration: + // 1) There is no existing configuration, i.e. first time setup + // 2) The existing configuration was modified, i.e. it has non-default values + // 3) Non-default values are specified for this initialization + + if (msoConfigPath == null || modifiedConfiguration || propertiesSpecified) { + modifiedConfiguration = propertiesSpecified; + + Path bpmnPropertiesSourcePath = Paths.get("src", "test", "resources", "mso.bpmn.properties"); + Path bpmnUrnPropertiesSourcePath = Paths.get("src", "test", "resources", "mso.bpmn.urn.properties"); + + if (msoConfigPath == null) { + // Initialize from scratch. + msoConfigPath = Files.createTempDirectory("mso-config-path-"); + System.setProperty("mso.config.path", msoConfigPath.toString()); + msoConfigPath.toFile().deleteOnExit(); + + bpmnPropertiesPath = msoConfigPath.resolve("mso.bpmn.properties"); + mergeCopy(bpmnPropertiesSourcePath, extraBpmnProperties, bpmnPropertiesPath); + bpmnPropertiesPath.toFile().deleteOnExit(); + + bpmnUrnPropertiesPath = msoConfigPath.resolve("mso.bpmn.urn.properties"); + mergeCopy(bpmnUrnPropertiesSourcePath, extraBpmnUrnProperties, bpmnUrnPropertiesPath); + bpmnUrnPropertiesPath.toFile().deleteOnExit(); + + PropertyConfiguration.getInstance(); + } else { + // Just reset the data. + PropertyConfiguration.getInstance().clearCache(); + mergeCopy(bpmnPropertiesSourcePath, extraBpmnProperties, bpmnPropertiesPath); + mergeCopy(bpmnUrnPropertiesSourcePath, extraBpmnUrnProperties, bpmnUrnPropertiesPath); + } + } + } + + /** + * Resets the PropertyConfiguration to its initial state, as if it had never + * been started. Note that this is a very expensive option and should not + * be needed by most unit tests. + * @throws IOException + */ + public static synchronized void nuke() throws IOException { + if (msoConfigPath == null) { + return; + } + + PropertyConfiguration.getInstance().shutDown(); + + bpmnUrnPropertiesPath.toFile().delete(); + bpmnUrnPropertiesPath = null; + + bpmnPropertiesPath.toFile().delete(); + bpmnPropertiesPath = null; + + msoConfigPath.toFile().delete(); + msoConfigPath = null; + + System.setProperty("mso.config.path", null); + + modifiedConfiguration = false; + } + + /** + * Create a map to hold properties to be added to mso.bpmn.properties. + */ + public static Map createBpmnProperties() { + Map properties = new HashMap(); + properties.put("PROPERTIES-TYPE", PropertyConfiguration.MSO_BPMN_PROPERTIES); + return properties; + } + + /** + * Create a map to hold properties to be added to mso.bpmn.urn.properties. + */ + public static Map createBpmnUrnProperties() { + Map properties = new HashMap(); + properties.put("PROPERTIES-TYPE", PropertyConfiguration.MSO_BPMN_URN_PROPERTIES); + return properties; + } + + /** + * Adds (or replaces) the specified values in the mso.bpmn.urn.properties file. + * Note that properties added this way may take some time to be loaded by the + * PropertyConfiguration, just like they do when a property file is updated on + * a real MSO system. This method will optionally wait for the new properties + * to be loaded. Timeout results in an IOException. + * @param values new properties + * @param wait maximum amount of time to wait for new properties to be loaded, + * in milliseconds. A value of zero means, "Do not wait." + * @throws IOException + */ + public static synchronized void addProperties(Map properties, long wait) + throws IOException, InterruptedException { + + if (msoConfigPath == null) { + throw new IllegalStateException(); + } + + String type = properties.get("PROPERTIES-TYPE"); + Path path; + + if (PropertyConfiguration.MSO_BPMN_PROPERTIES.equals(type)) { + path = bpmnPropertiesPath; + } else if (PropertyConfiguration.MSO_BPMN_URN_PROPERTIES.equals(type)) { + path = bpmnUrnPropertiesPath; + } else { + throw new IllegalArgumentException("Not a supported PROPERTIES-TYPE map"); + } + + String oldTimestamp = PropertyConfiguration.getInstance().getProperties(type) + .get(PropertyConfiguration.TIMESTAMP_PROPERTY); + + modifiedConfiguration = true; + addProperties(properties, path); + + if (wait <= 0) { + return; + } + + long endTime = System.currentTimeMillis() + wait; + + while (true) { + Thread.sleep(250); + + String newTimestamp = PropertyConfiguration.getInstance().getProperties(type) + .get(PropertyConfiguration.TIMESTAMP_PROPERTY); + + if (newTimestamp != oldTimestamp) { + return; + } + + long now = System.currentTimeMillis(); + + if (now >= endTime) { + throw new IOException("Timed out after " + wait + + "ms waiting for PropertyConfiguration change"); + } + } + } + + /** + * Helper method that adds properties to the specified file. + */ + private static void addProperties(Map values, Path path) + throws IOException { + + FileReader fileReader = null; + FileOutputStream outputStream = null; + + try { + fileReader = new FileReader(path.toFile()); + Properties properties = new Properties(); + properties.load(fileReader); + + for (String key : values.keySet()) { + if (!key.equals("PROPERTIES-TYPE")) { + properties.setProperty(key, values.get(key)); + } + } + + outputStream = new FileOutputStream(path.toFile()); + properties.store(outputStream, "Custom Test Properties"); + } finally { + if (fileReader != null) { + try { + fileReader.close(); + } catch (IOException e) { + // Ignore + } + } + + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + // Ignore + } + } + } + } + + /** + * Helper method that copies properties from the specified source file, and + * optionally merges them with the specified extra values, then writes the + * whole mess to the destination file. + */ + private static void mergeCopy(Path sourcePath, Map extraValues, Path destPath) + throws IOException { + if (extraValues == null || extraValues.isEmpty()) { + Files.copy(sourcePath, destPath, StandardCopyOption.REPLACE_EXISTING); + return; + } + + FileReader fileReader = null; + FileOutputStream outputStream = null; + + try { + fileReader = new FileReader(sourcePath.toFile()); + Properties properties = new Properties(); + properties.load(fileReader); + + for (String key : extraValues.keySet()) { + if (!key.equals("PROPERTIES-TYPE")) { + properties.setProperty(key, extraValues.get(key)); + } + } + + outputStream = new FileOutputStream(destPath.toFile()); + properties.store(outputStream, "Custom Test Properties"); + } finally { + if (fileReader != null) { + try { + fileReader.close(); + } catch (IOException e) { + // Ignore + } + } + + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + // Ignore + } + } + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/resources/customMyBatisConfiguration.xml b/bpmn/MSOCoreBPMN/src/main/resources/customMyBatisConfiguration.xml new file mode 100644 index 0000000000..2c3d5dad0a --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/resources/customMyBatisConfiguration.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/bpmn/MSOCoreBPMN/src/main/resources/normalize-namespaces.xsl b/bpmn/MSOCoreBPMN/src/main/resources/normalize-namespaces.xsl new file mode 100644 index 0000000000..56c8a00987 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/resources/normalize-namespaces.xsl @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + : + + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOCoreBPMN/src/main/resources/urnMapping.xml b/bpmn/MSOCoreBPMN/src/main/resources/urnMapping.xml new file mode 100644 index 0000000000..fd5d586278 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/resources/urnMapping.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BPMNLoggerESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BPMNLoggerESTest.java new file mode 100644 index 0000000000..71b9e089c3 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BPMNLoggerESTest.java @@ -0,0 +1,30 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:35:04 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.junit.Test; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class BPMNLoggerESTest extends BPMNLoggerESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + BPMNLogger.debug("true", "<,A1M\"[ K3\\u"); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + BPMNLogger.debug("trud", (String) null); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + BPMNLogger bPMNLogger0 = new BPMNLogger(); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BPMNLoggerESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BPMNLoggerESTestscaffolding.java new file mode 100644 index 0000000000..2449157b43 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BPMNLoggerESTestscaffolding.java @@ -0,0 +1,106 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:35:04 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class BPMNLoggerESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.BPMNLogger"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(BPMNLoggerESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.logger.MsoLogger", + "org.openecomp.mso.logger.MessageEnum", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "com.att.eelf.configuration.EELFLogger", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.configuration.EELFLogger$Level", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "com.att.eelf.configuration.SLF4jWrapper", + "org.openecomp.mso.bpmn.core.BPMNLogger", + "com.att.eelf.i18n.EELFResourceManager" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(BPMNLoggerESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.openecomp.mso.logger.MsoLogger", + "com.att.eelf.i18n.EELFResourceManager", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFLogger$Level", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.logger.MessageEnum", + "org.openecomp.mso.bpmn.core.BPMNLogger" + ); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BadInjectedFieldExceptionESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BadInjectedFieldExceptionESTest.java new file mode 100644 index 0000000000..113c819f8c --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BadInjectedFieldExceptionESTest.java @@ -0,0 +1,24 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:35:23 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class BadInjectedFieldExceptionESTest extends BadInjectedFieldExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + BadInjectedFieldException badInjectedFieldException0 = new BadInjectedFieldException("", "", ""); + BadInjectedFieldException badInjectedFieldException1 = new BadInjectedFieldException("y#,,", "4tX0!<", (Object) badInjectedFieldException0, (Throwable) badInjectedFieldException0); + assertFalse(badInjectedFieldException1.equals((Object)badInjectedFieldException0)); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BadInjectedFieldExceptionESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BadInjectedFieldExceptionESTestscaffolding.java new file mode 100644 index 0000000000..69ee3dcd48 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/BadInjectedFieldExceptionESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:35:23 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class BadInjectedFieldExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.BadInjectedFieldException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(BadInjectedFieldExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.bpmn.core.BadInjectedFieldException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(BadInjectedFieldExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.bpmn.core.BadInjectedFieldException" + ); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java new file mode 100644 index 0000000000..6176029075 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java @@ -0,0 +1,255 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.xml.sax.SAXException; +import org.custommonkey.xmlunit.Diff; + +import org.openecomp.mso.bpmn.core.json.JsonUtils; +import org.openecomp.mso.bpmn.core.xml.XmlTool; + +/** + * @version 1.0 + */ +public class JsonUtilsTest { + + private static final String EOL = "\n"; + private String xmlReq = + "" + EOL + + " " + EOL + + " DEV-VF-0021" + EOL + + " CREATE_VF_MODULE" + EOL + + " PORTAL" + EOL + + " " + EOL + + " " + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " STMTN5MMSC21" + EOL + + " asc_heat-int" + EOL + + " STMTN5MMSC21-MMSC::module-0-0" + EOL + + " STMTN5MMSC21-MMSC::model-1-0" + EOL + + " true" + EOL + + " 00000000-0000-0000-0000-000000000000" + EOL + + " 1.0" + EOL + + " 999999999-0000-0000-0000-000000000000" + EOL + + " 1.5" + EOL + + " 00000000-0000-0000-0000-000000000000" + EOL + + " SDN-ETHERNET-INTERNET" + EOL + + " fba1bd1e195a404cacb9ce17a9b2b421" + EOL + + " pending-delete" + EOL + + " RDM2WAGPLCP" + EOL + + " 1" + EOL + + " " + EOL + + " " + EOL + + " network1111" + EOL + + " server1111" + EOL + + " " + EOL + + "" + EOL; + + private String xmlReqNoAttrs = + "" + EOL + + " " + EOL + + " DELETE_VF_MODULE" + EOL + + " PORTAL" + EOL + + " " + EOL + + " " + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " STMTN5MMSC21" + EOL + + " asc_heat-int" + EOL + + " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + + " STMTN5MMSC21-MMSC::module-0-0" + EOL + + " 00000000-0000-0000-0000-000000000000" + EOL + + " SDN-ETHERNET-INTERNET" + EOL + + " fba1bd1e195a404cacb9ce17a9b2b421" + EOL + + " pending-delete" + EOL + + " RDM2WAGPLCP" + EOL + + " " + EOL + + " " + EOL + + "" + EOL; + + // JSON request w/ embedded XML will be read from a file + private String jsonReq = null; + + @Before + public void initialize() { + File file = new File("src/test/resources/request.json"); + FileInputStream fis = null; + + try { + fis = new FileInputStream(file); + BufferedReader br = new BufferedReader(new InputStreamReader(fis)); + jsonReq = br.readLine(); + if (jsonReq != null) { + System.out.println("initialize(): json request: " + jsonReq); + } else { + System.out.println("initialize(): failed to read json request from src/test/resources/request.json"); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (fis != null) + fis.close(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } + + @After + public void cleanup(){ + } + + @Test + public void testConversion() { + // Note: the current version of the JsonUtils.json2xml() method + // does not support converting the JSONObject representation + // of XML attributes (JSONArray) back to XML. So this test will + // only succeed if the original XML does not contain attributes + + // save a copy of the xml with the namespaces removed + String xmlIn = XmlTool.removeNamespaces(xmlReqNoAttrs); + // strip all the whitespace + xmlIn = xmlIn.replaceAll("\\s+",""); + String json = JsonUtils.xml2json(xmlReqNoAttrs); + System.out.println("testConversion(): xml request to json: " + json); + String xmlOut = JsonUtils.json2xml(json); + System.out.println("testConversion(): json request back to xml: " + xmlOut); + + // strip all the whitespace + xmlOut = xmlOut.replaceAll("\\s+",""); +// System.out.println("testConversion(): xml in: " + xmlIn); +// System.out.println("testConversion(): xml out: " + xmlOut); + + Diff diffXml; + try { + diffXml = new Diff(xmlIn, xmlOut); + Assert.assertTrue(diffXml.similar()); +// Assert.assertTrue(diffXml.identical()); + } catch (SAXException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void testRetrieval() { + String json = JsonUtils.xml2json(xmlReq); + System.out.println("testRetrieval(): xml request to json: " + json); + // full JSON path + String value = JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-name"); + Assert.assertEquals(value, "STMTN5MMSC21"); + value = JsonUtils.getJsonValue(json, "vnf-request.request-info.action"); + Assert.assertEquals(value, "CREATE_VF_MODULE"); + // retrieving an integer + value = JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.persona-model-version"); + Assert.assertEquals(value, "1"); + // retrieving a float + value = JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-persona-model-version"); + Assert.assertEquals(value, "1.5"); + // retrieving a boolean + value = JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.is-base-module"); + Assert.assertEquals(value, "true"); + // attempt to retrieve a value for a non-existent field + value = JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.bad"); + Assert.assertEquals(value, null); + // retrieving a parameter value (originally a XML attribute) + value = JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "server"); +// Assert.assertEquals(value, "[{\"content\":\"network1111\",\"name\":\"network\"},{\"content\":\"server1111\",\"name\":\"server\"}]"); + Assert.assertEquals(value, "server1111"); + value = JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "badParam"); + Assert.assertEquals(value, null); + // by field name/key + value = JsonUtils.getJsonValueForKey(json, "source"); + Assert.assertEquals(value, "PORTAL"); + value = JsonUtils.getJsonValueForKey(json, "vnf-module"); + Assert.assertEquals(value, null); + } + + @Test + public void testUpdate() { + String json = JsonUtils.xml2json(xmlReq); + System.out.println("testUpdate(): xml request to json: " + json); + // the add should be successful + String jsonUpd = JsonUtils.addJsonValue(json, "vnf-request.request-info.comment", "Some comment"); +// System.out.println("testUpdate(): post add json request: " + jsonUpd); + String value = JsonUtils.getJsonValue(jsonUpd, "vnf-request.request-info.comment"); + Assert.assertEquals(value, "Some comment"); + // the add should be ignored as the field already exists + jsonUpd = JsonUtils.addJsonValue(jsonUpd, "vnf-request.vnf-inputs.vnf-name", "STMTN5MMSC22"); + value = JsonUtils.getJsonValue(jsonUpd, "vnf-request.vnf-inputs.vnf-name"); + Assert.assertEquals(value, "STMTN5MMSC21"); + // the update should be successful + jsonUpd = JsonUtils.updJsonValue(jsonUpd, "vnf-request.vnf-inputs.vnf-name", "STMTN5MMSC22"); +// System.out.println("testUpdate(): post update json request: " + jsonUpd); + value = JsonUtils.getJsonValue(jsonUpd, "vnf-request.vnf-inputs.vnf-name"); + Assert.assertEquals(value, "STMTN5MMSC22"); + // the delete should be successful + jsonUpd = JsonUtils.delJsonValue(jsonUpd, "vnf-request.request-info.comment"); +// System.out.println("testUpdate(): post delete json request: " + jsonUpd); + value = JsonUtils.getJsonValue(jsonUpd, "vnf-request.request-info.comment"); + Assert.assertEquals(value, null); + // the delete should fail as field 'vnf-model' does not exist + String jsonCur = jsonUpd; + jsonUpd = JsonUtils.delJsonValue(jsonUpd, "vnf-request.vnf-inputs.vnf-module"); + Assert.assertEquals(jsonCur, jsonUpd); + } + + @Test + public void testEmbededXmlRetrievalConversion() { + try { + // extract the embedded XML from the request + String value = JsonUtils.getJsonValue(jsonReq, "variables.bpmnRequest.value"); + String xmlReq = XmlTool.removeNamespaces(XmlTool.normalize(value)); + System.out.println("testEmbededXmlRetrievalConversion(): xml payload: " + xmlReq); + // strip all the whitespace +// xmlIn = xmlIn.replaceAll("\\s+",""); + String json = JsonUtils.xml2json(xmlReq); + System.out.println("testEmbededXmlRetrievalConversion(): xml request to json: " + json); + String xmlOut = JsonUtils.json2xml(json); + System.out.println("testEmbededXmlRetrievalConversion(): json request back to xml: " + xmlOut); + Diff diffXml; + try { + // compare the XML before and after + diffXml = new Diff(xmlReq, xmlOut); + Assert.assertTrue(diffXml.similar()); + } catch (SAXException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/LogTaskESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/LogTaskESTest.java new file mode 100644 index 0000000000..70e505095e --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/LogTaskESTest.java @@ -0,0 +1,41 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:29:34 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class LogTaskESTest extends LogTaskESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + LogTask logTask0 = null; + try { + logTask0 = new LogTask(); + fail("Expecting exception: NoClassDefFoundError"); + + } catch(NoClassDefFoundError e) { + } + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + ExecutionImpl executionImpl0 = new ExecutionImpl(); + LogTask logTask0 = null; + try { + logTask0 = new LogTask(); + fail("Expecting exception: NoClassDefFoundError"); + + } catch(NoClassDefFoundError e) { + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/LogTaskESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/LogTaskESTestscaffolding.java new file mode 100644 index 0000000000..ab7ee56884 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/LogTaskESTestscaffolding.java @@ -0,0 +1,342 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:29:34 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class LogTaskESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.LogTask"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(LogTaskESTestscaffolding.class.getClassLoader() , + "org.camunda.bpm.engine.impl.persistence.entity.IdentityLinkEntity", + "org.camunda.bpm.engine.impl.pvm.process.TransitionImpl", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution", + "org.camunda.bpm.engine.impl.context.CaseExecutionContext", + "org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransformFactory", + "org.camunda.bpm.engine.impl.pvm.PvmScope", + "org.camunda.bpm.engine.delegate.JavaDelegate", + "org.camunda.bpm.engine.runtime.ProcessInstance", + "org.camunda.bpm.engine.impl.tree.TreeWalker$WalkCondition", + "org.camunda.bpm.application.ProcessApplicationReference", + "org.camunda.bpm.engine.delegate.BpmnModelExecutionContext", + "org.camunda.bpm.engine.impl.jobexecutor.FailedJobCommandFactory", + "org.camunda.bpm.engine.delegate.DelegateExecution", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration", + "org.camunda.bpm.engine.delegate.CmmnModelExecutionContext", + "org.camunda.bpm.engine.impl.persistence.entity.util.FormPropertyStartContext", + "com.att.eelf.i18n.EELFMsgs", + "org.camunda.bpm.engine.impl.javax.el.ELContext", + "org.camunda.bpm.engine.impl.core.variable.event.VariableEventDispatcher", + "org.camunda.bpm.engine.variable.type.ValueType", + "org.camunda.bpm.engine.impl.interceptor.CommandContextListener", + "org.camunda.bpm.engine.impl.core.variable.mapping.IoMapping", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance", + "org.camunda.bpm.engine.repository.CaseDefinition", + "org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity", + "org.camunda.bpm.engine.impl.db.HasDbRevision", + "org.camunda.bpm.model.bpmn.instance.FlowElement", + "org.camunda.bpm.engine.delegate.Expression", + "org.camunda.bpm.engine.variable.type.SerializableValueType", + "org.camunda.bpm.engine.impl.pvm.PvmActivity", + "org.camunda.bpm.engine.impl.cfg.BpmnParseFactory", + "org.camunda.bpm.model.bpmn.instance.BpmnModelElementInstance", + "org.camunda.bpm.model.cmmn.instance.CmmnModelElementInstance", + "org.camunda.bpm.engine.impl.pvm.PvmException", + "org.camunda.bpm.engine.task.DelegationState", + "org.camunda.bpm.engine.impl.core.variable.VariableMapImpl", + "org.camunda.bpm.application.ProcessApplicationUnavailableException", + "org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition", + "org.camunda.bpm.engine.delegate.DelegateCaseExecution", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration", + "org.camunda.bpm.engine.runtime.CaseExecution", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition", + "org.camunda.bpm.engine.impl.core.variable.scope.SimpleVariableStore", + "org.camunda.bpm.engine.repository.ProcessDefinition", + "org.camunda.bpm.engine.impl.pvm.process.ScopeImpl", + "org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl", + "org.camunda.bpm.engine.impl.pvm.runtime.AtomicOperation", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "org.camunda.bpm.engine.task.IdentityLink", + "org.camunda.bpm.engine.impl.interceptor.SessionFactory", + "org.camunda.bpm.engine.delegate.DelegateTask", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation", + "org.camunda.bpm.engine.impl.pvm.process.ActivityStartBehavior", + "org.camunda.bpm.engine.impl.core.model.CoreActivity", + "org.camunda.bpm.model.bpmn.BpmnModelInstance", + "org.camunda.bpm.engine.delegate.VariableScope", + "org.camunda.bpm.engine.ProcessEngine", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl", + "org.camunda.bpm.engine.impl.interceptor.CommandContext", + "org.camunda.bpm.engine.impl.variable.listener.CaseVariableListenerInvocation", + "org.camunda.bpm.engine.impl.cfg.auth.ResourceAuthorizationProvider", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.camunda.bpm.engine.BadUserRequestException", + "org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity", + "org.camunda.bpm.engine.impl.context.ExecutionContext", + "org.camunda.bpm.engine.impl.persistence.entity.TaskEntity", + "org.camunda.bpm.engine.impl.context.Context", + "org.camunda.bpm.engine.authorization.Authorization", + "org.camunda.bpm.engine.ProcessEngineServices", + "org.camunda.bpm.engine.runtime.Execution", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl", + "org.camunda.bpm.engine.impl.pvm.process.Lane", + "org.camunda.bpm.engine.impl.pvm.process.ParticipantProcess", + "org.camunda.bpm.engine.impl.interceptor.CommandExecutor", + "org.camunda.bpm.engine.delegate.ProcessEngineServicesAware", + "org.camunda.bpm.engine.ProcessEngineConfiguration", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity", + "org.camunda.bpm.engine.impl.util.BitMaskUtil", + "org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition", + "org.camunda.bpm.engine.impl.cmmn.behavior.CmmnActivityBehavior", + "org.camunda.bpm.engine.impl.core.variable.event.VariableEvent", + "org.camunda.bpm.engine.delegate.BaseDelegateExecution", + "org.camunda.bpm.engine.impl.pvm.PvmExecution", + "org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity", + "org.camunda.bpm.engine.runtime.VariableInstance", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableStore", + "org.camunda.bpm.engine.runtime.Job", + "org.camunda.bpm.engine.runtime.Incident", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState$CaseExecutionStateImpl", + "org.camunda.bpm.model.xml.ModelInstance", + "org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl", + "org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity", + "org.openecomp.mso.entity.MsoRequest", + "org.camunda.bpm.engine.impl.core.variable.value.NullValueImpl", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl", + "org.camunda.bpm.model.bpmn.instance.UserTask", + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.camunda.bpm.engine.impl.variable.serializer.ValueFields", + "org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation", + "org.camunda.bpm.engine.impl.task.TaskDecorator", + "org.camunda.bpm.engine.impl.jobexecutor.JobExecutorContext", + "org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation", + "org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity", + "org.camunda.bpm.model.xml.instance.ModelElementInstance", + "org.camunda.bpm.engine.ProcessEngineException", + "org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState$SuspensionStateImpl", + "org.camunda.bpm.engine.impl.db.DbEntity", + "org.camunda.bpm.model.bpmn.instance.InteractionNode", + "org.camunda.bpm.engine.impl.task.TaskDefinition", + "org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution", + "org.camunda.bpm.engine.runtime.EventSubscription", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionDestroyScope", + "org.camunda.bpm.engine.impl.core.variable.value.UntypedValueImpl", + "org.camunda.bpm.model.bpmn.instance.Activity", + "org.camunda.bpm.engine.management.JobDefinition", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "com.att.eelf.configuration.EELFLogger$Level", + "org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior", + "org.camunda.bpm.engine.impl.core.variable.scope.MapBasedVariableStore", + "org.camunda.bpm.engine.impl.javax.el.ValueReference", + "org.camunda.bpm.engine.impl.persistence.entity.JobEntity", + "org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.ProcessInstanceStartContext", + "org.camunda.bpm.engine.delegate.DelegateCaseVariableInstance", + "org.camunda.bpm.engine.impl.pvm.PvmProcessElement", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntityVariableStore", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "org.camunda.bpm.engine.impl.delegate.DelegateInvocation", + "org.camunda.bpm.engine.impl.javax.el.ValueExpression", + "com.att.eelf.configuration.EELFLogger", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationFireProcessStart", + "org.camunda.bpm.engine.runtime.CaseInstance", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope", + "org.camunda.bpm.engine.impl.db.DbEntityLifecycleAware", + "org.camunda.bpm.engine.impl.pvm.process.ActivityImpl", + "org.camunda.bpm.engine.impl.core.model.CoreModelElement", + "org.camunda.bpm.engine.impl.interceptor.CommandInterceptor", + "org.camunda.bpm.engine.impl.pvm.PvmProcessInstance", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseSentryPartImpl", + "org.camunda.bpm.engine.variable.value.TypedValue", + "org.openecomp.mso.logger.MsoAlarmLogger", + "org.apache.ibatis.transaction.TransactionFactory", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnSentryPart", + "org.camunda.bpm.engine.impl.pvm.process.LaneSet", + "org.camunda.bpm.engine.delegate.DelegateListener", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution", + "org.camunda.bpm.engine.impl.persistence.entity.TaskEntityVariableStore", + "org.camunda.bpm.engine.delegate.ExecutionListener", + "org.camunda.bpm.engine.exception.NotAllowedException", + "org.camunda.bpm.engine.impl.history.event.HistoryEventType", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException", + "org.openecomp.mso.bpmn.core.LogTask", + "org.camunda.bpm.engine.impl.pvm.process.HasDIBounds", + "com.att.eelf.configuration.SLF4jWrapper", + "org.camunda.bpm.engine.task.Task", + "org.camunda.bpm.engine.impl.javax.el.Expression", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.AbstractPvmEventAtomicOperation", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInstanceEnd", + "org.camunda.bpm.engine.impl.context.CoreExecutionContext", + "org.camunda.bpm.engine.delegate.DelegateVariableInstance", + "org.camunda.bpm.model.bpmn.instance.FlowNode", + "org.openecomp.mso.logger.MsoLogger", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope", + "org.camunda.bpm.model.cmmn.CmmnModelInstance", + "org.camunda.bpm.model.bpmn.instance.Task", + "org.camunda.bpm.engine.variable.VariableMap", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState$ActivityInstanceStateImpl", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationProcessEnd", + "org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl", + "org.camunda.bpm.model.bpmn.instance.BaseElement", + "org.camunda.bpm.engine.exception.NullValueException", + "org.camunda.bpm.engine.impl.core.variable.scope.CoreVariableStore", + "org.camunda.bpm.engine.impl.context.BpmnExecutionContext", + "org.openecomp.mso.bpmn.core.BaseTask", + "org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState", + "org.apache.ibatis.session.SqlSessionFactory", + "org.camunda.bpm.engine.impl.variable.AbstractPersistentVariableStore", + "org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext", + "com.att.eelf.i18n.EELFResourceManager", + "org.camunda.bpm.engine.impl.el.FixedValue", + "org.camunda.bpm.engine.impl.core.delegate.CoreActivityBehavior", + "org.openecomp.mso.logger.MessageEnum", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "org.camunda.bpm.engine.SuspendedEntityInteractionException", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "org.camunda.bpm.engine.impl.db.HasDbReferences", + "org.camunda.bpm.engine.impl.tree.Collector", + "com.att.eelf.configuration.EELFManager", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext", + "org.camunda.bpm.engine.impl.core.operation.CoreAtomicOperation", + "org.camunda.bpm.engine.impl.el.Expression", + "org.camunda.bpm.engine.impl.pvm.PvmTransition", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState", + "org.camunda.bpm.model.cmmn.instance.CmmnElement", + "org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration", + "org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationProcessStart", + "org.camunda.bpm.engine.impl.jobexecutor.JobHandler", + "com.att.eelf.i18n.EELFResourceManager$1", + "org.camunda.bpm.engine.impl.core.instance.CoreExecution", + "org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance", + "org.camunda.bpm.engine.variable.type.PrimitiveValueType", + "org.camunda.bpm.engine.delegate.VariableListener", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$1" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(LogTaskESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope", + "org.camunda.bpm.engine.impl.core.instance.CoreExecution", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntityVariableStore", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState", + "org.camunda.bpm.engine.impl.context.Context", + "org.camunda.bpm.engine.impl.javax.el.Expression", + "org.camunda.bpm.engine.impl.javax.el.ValueExpression", + "org.camunda.bpm.engine.ProcessEngineException", + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl", + "org.camunda.bpm.engine.impl.core.model.CoreModelElement", + "org.camunda.bpm.engine.impl.core.model.CoreActivity", + "org.camunda.bpm.engine.impl.pvm.process.ScopeImpl", + "org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException", + "org.camunda.bpm.engine.impl.pvm.PvmException", + "org.camunda.bpm.engine.exception.NullValueException", + "org.camunda.bpm.engine.impl.core.variable.VariableMapImpl", + "org.camunda.bpm.engine.impl.persistence.entity.TaskEntity", + "org.camunda.bpm.engine.impl.pvm.process.ActivityImpl", + "org.camunda.bpm.engine.impl.pvm.process.ActivityStartBehavior", + "org.camunda.bpm.engine.impl.util.BitMaskUtil", + "org.camunda.bpm.engine.impl.core.variable.value.NullValueImpl", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInstanceEnd", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationProcessEnd", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionDestroyScope", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation", + "org.camunda.bpm.engine.impl.core.variable.value.UntypedValueImpl", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$1", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState", + "org.camunda.bpm.engine.impl.persistence.entity.JobEntity", + "org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity", + "org.openecomp.mso.logger.MsoLogger", + "com.att.eelf.i18n.EELFResourceManager", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFLogger$Level", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.logger.MessageEnum", + "org.openecomp.mso.logger.MsoAlarmLogger", + "org.openecomp.mso.bpmn.core.LogTask" + ); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldExceptionESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldExceptionESTest.java new file mode 100644 index 0000000000..f62d6afaf0 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldExceptionESTest.java @@ -0,0 +1,20 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:35:52 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.junit.Test; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class MissingInjectedFieldExceptionESTest extends MissingInjectedFieldExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + MissingInjectedFieldException missingInjectedFieldException0 = new MissingInjectedFieldException("", ""); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldExceptionESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldExceptionESTestscaffolding.java new file mode 100644 index 0000000000..03cb94f4e6 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/MissingInjectedFieldExceptionESTestscaffolding.java @@ -0,0 +1,85 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:35:52 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class MissingInjectedFieldExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.MissingInjectedFieldException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(MissingInjectedFieldExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(MissingInjectedFieldExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException" + ); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java new file mode 100644 index 0000000000..ff92355b8a --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/PropertyConfigurationTest.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import org.openecomp.mso.bpmn.test.PropertyConfigurationSetup; + +public class PropertyConfigurationTest { + @Before + public void beforeTest() throws IOException { + Map defaultProperties = PropertyConfigurationSetup.createBpmnProperties(); + defaultProperties.put("testValue", "testKey"); + PropertyConfigurationSetup.init(defaultProperties); + } + + @Test + public void testPropertyFileWatcher() throws InterruptedException, IOException { + Assert.assertEquals(true, PropertyConfiguration.getInstance().isFileWatcherRunning()); + } + + @Test + public void testPropertyLoading() throws IOException, InterruptedException { + PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); + Map props = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES); + Assert.assertNotNull(props); + Assert.assertEquals("testValue", props.get("testKey")); + } + + @Test + public void testPropertyReload() throws IOException, InterruptedException { + PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); + Map properties = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES); + Assert.assertNotNull(properties); + Assert.assertEquals("testValue", properties.get("testKey")); + + Map newProperties = PropertyConfigurationSetup.createBpmnProperties(); + newProperties.put("newKey", "newValue"); + PropertyConfigurationSetup.addProperties(newProperties, 10000); + + // Reload and check for the new value + properties = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES); + Assert.assertNotNull(properties); + Assert.assertEquals("newValue", properties.get("newKey")); + } + + @Test(expected=IllegalArgumentException.class) + public void testPropertyFileDoesNotExists_NotIntheList() throws IOException { + PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); + propertyConfiguration.getProperties("badfile.properties"); + Assert.fail("Expected IllegalArgumentException"); + } + + @Test(expected=java.lang.UnsupportedOperationException.class) + public void testPropertyModificationException() throws IOException { + PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); + Map props = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES); + Assert.assertNotNull(props); + Assert.assertEquals("testValue", props.get("testKey")); + props.put("newKey", "newvalue"); + } + + @Test + public void testNotAllowedPropertyReloading() throws IOException { + Path msoConfigPath = Paths.get(System.getProperty("mso.config.path")); + Path backupPropFilePath = msoConfigPath.resolve("backup-" + PropertyConfiguration.MSO_BPMN_PROPERTIES); + + try { + // Create a new file... a backup file + Files.createFile(backupPropFilePath); + + // Load properties + PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); + Map props = propertyConfiguration.getProperties(PropertyConfiguration.MSO_BPMN_PROPERTIES); + Assert.assertNotNull(props); + Assert.assertEquals("testValue", props.get("testKey")); + + // Update the backup file + Path bpmnPropertiesSourcePath = Paths.get("src", "test", "resources", "mso.bpmn.properties"); + Files.copy(bpmnPropertiesSourcePath, backupPropFilePath, StandardCopyOption.REPLACE_EXISTING); + + // Cache size should remain the same + Assert.assertEquals(1, PropertyConfiguration.getInstance().cacheSize()); + } finally { + backupPropFilePath.toFile().delete(); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadConfigTaskESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadConfigTaskESTest.java new file mode 100644 index 0000000000..6422685f92 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadConfigTaskESTest.java @@ -0,0 +1,58 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:29:36 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ReadConfigTaskESTest extends ReadConfigTaskESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + ReadConfigTask readConfigTask0 = new ReadConfigTask(); + ExecutionImpl executionImpl0 = new ExecutionImpl(); + Expression expression0 = mock(Expression.class, new ViolatedAssumptionAnswer()); + doReturn((Object) null).when(expression0).getValue(any(org.camunda.bpm.engine.delegate.VariableScope.class)); + PrivateAccess.setVariable((Class) ReadConfigTask.class, readConfigTask0, "propertiesFile", (Object) expression0); + try { + readConfigTask0.execute(executionImpl0); + fail("Expecting exception: RuntimeException"); + + } catch(RuntimeException e) { + // + // ReadConfigTask injected field 'propertiesFile' is bad: required field has null value + // + verifyException("org.openecomp.mso.bpmn.core.BaseTask", e); + } + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + ReadConfigTask readConfigTask0 = new ReadConfigTask(); + ExecutionImpl executionImpl0 = new ExecutionImpl(); + try { + readConfigTask0.execute(executionImpl0); + fail("Expecting exception: RuntimeException"); + + } catch(RuntimeException e) { + // + // ReadConfigTask injected field 'propertiesFile' is bad: missing required field + // + verifyException("org.openecomp.mso.bpmn.core.BaseTask", e); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadConfigTaskESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadConfigTaskESTestscaffolding.java new file mode 100644 index 0000000000..c134c9cca9 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadConfigTaskESTestscaffolding.java @@ -0,0 +1,331 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:29:36 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ReadConfigTaskESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.ReadConfigTask"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ReadConfigTaskESTestscaffolding.class.getClassLoader() , + "org.camunda.bpm.engine.impl.pvm.process.TransitionImpl", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution", + "org.camunda.bpm.engine.impl.context.CaseExecutionContext", + "org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransformFactory", + "org.camunda.bpm.engine.impl.pvm.PvmScope", + "org.camunda.bpm.engine.delegate.JavaDelegate", + "org.camunda.bpm.engine.impl.tree.TreeWalker$WalkCondition", + "org.camunda.bpm.engine.runtime.ProcessInstance", + "org.camunda.bpm.application.ProcessApplicationReference", + "org.camunda.bpm.engine.delegate.BpmnModelExecutionContext", + "org.camunda.bpm.engine.impl.jobexecutor.FailedJobCommandFactory", + "org.camunda.bpm.engine.delegate.DelegateExecution", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration", + "org.camunda.bpm.engine.delegate.CmmnModelExecutionContext", + "org.camunda.bpm.engine.impl.persistence.entity.util.FormPropertyStartContext", + "com.att.eelf.i18n.EELFMsgs", + "org.camunda.bpm.engine.impl.javax.el.ELContext", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInstanceStart", + "org.camunda.bpm.engine.impl.core.variable.event.VariableEventDispatcher", + "org.camunda.bpm.engine.variable.type.ValueType", + "org.camunda.bpm.engine.impl.interceptor.CommandContextListener", + "org.camunda.bpm.engine.impl.core.variable.mapping.IoMapping", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationInterruptScope", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance", + "org.camunda.bpm.engine.repository.CaseDefinition", + "org.camunda.bpm.engine.impl.db.HasDbRevision", + "org.camunda.bpm.model.bpmn.instance.FlowElement", + "org.camunda.bpm.engine.delegate.Expression", + "org.camunda.bpm.engine.variable.type.SerializableValueType", + "org.camunda.bpm.engine.impl.pvm.PvmActivity", + "org.camunda.bpm.engine.impl.cfg.BpmnParseFactory", + "org.camunda.bpm.model.bpmn.instance.BpmnModelElementInstance", + "org.camunda.bpm.model.cmmn.instance.CmmnModelElementInstance", + "org.camunda.bpm.engine.impl.pvm.PvmException", + "org.camunda.bpm.engine.impl.core.variable.VariableMapImpl", + "org.camunda.bpm.application.ProcessApplicationUnavailableException", + "org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition", + "org.camunda.bpm.engine.delegate.DelegateCaseExecution", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerTake", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityNotifyListenerEnd", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration", + "org.camunda.bpm.engine.runtime.CaseExecution", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition", + "org.camunda.bpm.engine.impl.core.variable.scope.SimpleVariableStore", + "org.camunda.bpm.engine.repository.ProcessDefinition", + "org.camunda.bpm.engine.impl.pvm.process.ScopeImpl", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityStartConcurrent", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.AbstractPvmAtomicOperationTransitionNotifyListenerTake", + "org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "org.camunda.bpm.engine.impl.pvm.runtime.AtomicOperation", + "org.camunda.bpm.engine.impl.interceptor.SessionFactory", + "org.camunda.bpm.engine.delegate.DelegateTask", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation", + "org.camunda.bpm.engine.impl.pvm.process.ActivityStartBehavior", + "org.camunda.bpm.engine.impl.core.model.CoreActivity", + "org.camunda.bpm.model.bpmn.BpmnModelInstance", + "org.camunda.bpm.engine.delegate.VariableScope", + "org.camunda.bpm.engine.ProcessEngine", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl", + "org.camunda.bpm.engine.impl.interceptor.CommandContext", + "org.camunda.bpm.engine.impl.variable.listener.CaseVariableListenerInvocation", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.camunda.bpm.engine.BadUserRequestException", + "org.camunda.bpm.engine.impl.context.ExecutionContext", + "org.camunda.bpm.engine.impl.persistence.entity.TaskEntity", + "org.camunda.bpm.engine.impl.context.Context", + "org.camunda.bpm.engine.ProcessEngineServices", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl", + "org.camunda.bpm.engine.runtime.Execution", + "org.camunda.bpm.engine.impl.pvm.process.Lane", + "org.camunda.bpm.engine.impl.pvm.process.ParticipantProcess", + "org.camunda.bpm.engine.impl.interceptor.CommandExecutor", + "org.camunda.bpm.engine.delegate.ProcessEngineServicesAware", + "org.camunda.bpm.engine.ProcessEngineConfiguration", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity", + "org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition", + "org.camunda.bpm.engine.impl.cmmn.behavior.CmmnActivityBehavior", + "org.camunda.bpm.engine.impl.core.variable.event.VariableEvent", + "org.camunda.bpm.engine.delegate.BaseDelegateExecution", + "org.camunda.bpm.engine.impl.pvm.PvmExecution", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityStartCreateScope", + "org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableStore", + "org.camunda.bpm.engine.runtime.VariableInstance", + "org.camunda.bpm.engine.runtime.Job", + "org.camunda.bpm.engine.runtime.Incident", + "org.camunda.bpm.model.xml.ModelInstance", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityStart", + "org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl", + "org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity", + "org.openecomp.mso.entity.MsoRequest", + "org.camunda.bpm.engine.impl.core.variable.value.NullValueImpl", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl", + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.camunda.bpm.engine.impl.variable.serializer.ValueFields", + "org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation", + "org.camunda.bpm.engine.impl.task.TaskDecorator", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInitStackNotifyListenerStart", + "org.camunda.bpm.engine.impl.jobexecutor.JobExecutorContext", + "org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation", + "org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationsTransitionInterruptFlowScope", + "org.camunda.bpm.model.xml.instance.ModelElementInstance", + "org.camunda.bpm.engine.ProcessEngineException", + "org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState$SuspensionStateImpl", + "org.camunda.bpm.engine.impl.db.DbEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerEnd", + "org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationFireActivityEnd", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationStartTransitionNotifyListenerTake", + "org.camunda.bpm.engine.runtime.EventSubscription", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionDestroyScope", + "org.camunda.bpm.engine.impl.core.variable.value.UntypedValueImpl", + "org.camunda.bpm.engine.management.JobDefinition", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "com.att.eelf.configuration.EELFLogger$Level", + "org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior", + "org.camunda.bpm.engine.impl.core.variable.scope.MapBasedVariableStore", + "org.camunda.bpm.engine.impl.persistence.entity.JobEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.ProcessInstanceStartContext", + "org.camunda.bpm.engine.delegate.DelegateCaseVariableInstance", + "org.camunda.bpm.engine.impl.pvm.PvmProcessElement", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntityVariableStore", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "org.camunda.bpm.engine.impl.delegate.DelegateInvocation", + "com.att.eelf.configuration.EELFLogger", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationFireProcessStart", + "org.camunda.bpm.engine.runtime.CaseInstance", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope", + "org.camunda.bpm.engine.impl.db.DbEntityLifecycleAware", + "org.openecomp.mso.bpmn.core.ReadConfigTask", + "org.camunda.bpm.engine.impl.pvm.process.ActivityImpl", + "org.camunda.bpm.engine.impl.core.model.CoreModelElement", + "org.camunda.bpm.engine.impl.interceptor.CommandInterceptor", + "org.camunda.bpm.engine.impl.pvm.PvmProcessInstance", + "org.camunda.bpm.engine.variable.value.TypedValue", + "org.apache.ibatis.transaction.TransactionFactory", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnSentryPart", + "org.camunda.bpm.engine.impl.pvm.process.LaneSet", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInitStack", + "org.camunda.bpm.engine.delegate.DelegateListener", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution", + "org.camunda.bpm.engine.delegate.ExecutionListener", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationDeleteCascadeFireActivityEnd", + "org.camunda.bpm.engine.exception.NotAllowedException", + "org.camunda.bpm.engine.impl.history.event.HistoryEventType", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException", + "org.camunda.bpm.engine.impl.pvm.process.HasDIBounds", + "com.att.eelf.configuration.SLF4jWrapper", + "org.camunda.bpm.engine.task.Task", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityEnd", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.AbstractPvmEventAtomicOperation", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInstanceEnd", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationDeleteCascade", + "org.camunda.bpm.engine.impl.context.CoreExecutionContext", + "org.camunda.bpm.engine.delegate.DelegateVariableInstance", + "org.openecomp.mso.logger.MsoLogger", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope", + "org.camunda.bpm.engine.variable.VariableMap", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState$ActivityInstanceStateImpl", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationProcessEnd", + "org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl", + "org.camunda.bpm.model.bpmn.instance.BaseElement", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateConcurrentExecution", + "org.camunda.bpm.engine.exception.NullValueException", + "org.camunda.bpm.engine.impl.core.variable.scope.CoreVariableStore", + "org.camunda.bpm.engine.impl.context.BpmnExecutionContext", + "org.openecomp.mso.bpmn.core.BaseTask", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityStartInterruptEventScope", + "org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityStartCancelScope", + "org.apache.ibatis.session.SqlSessionFactory", + "org.camunda.bpm.engine.impl.variable.AbstractPersistentVariableStore", + "org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext", + "com.att.eelf.i18n.EELFResourceManager", + "org.camunda.bpm.engine.impl.core.delegate.CoreActivityBehavior", + "org.openecomp.mso.logger.MessageEnum", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionCreateScope", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "org.camunda.bpm.engine.SuspendedEntityInteractionException", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCancelActivity", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "org.camunda.bpm.engine.impl.db.HasDbReferences", + "org.camunda.bpm.engine.impl.tree.Collector", + "com.att.eelf.configuration.EELFManager", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext", + "org.camunda.bpm.engine.impl.core.operation.CoreAtomicOperation", + "org.camunda.bpm.engine.impl.pvm.PvmTransition", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState", + "org.camunda.bpm.model.cmmn.instance.CmmnElement", + "org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration", + "org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity", + "com.att.eelf.i18n.EELFResourceManager$1", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationProcessStart", + "org.camunda.bpm.engine.impl.core.instance.CoreExecution", + "org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance", + "org.camunda.bpm.engine.variable.type.PrimitiveValueType", + "org.camunda.bpm.engine.delegate.VariableListener", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$1" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ReadConfigTaskESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.openecomp.mso.logger.MsoLogger", + "com.att.eelf.i18n.EELFResourceManager", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFLogger$Level", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.logger.MessageEnum", + "org.openecomp.mso.bpmn.core.ReadConfigTask", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope", + "org.camunda.bpm.engine.impl.core.instance.CoreExecution", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntityVariableStore", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState", + "org.camunda.bpm.engine.impl.context.Context", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl", + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.camunda.bpm.engine.ProcessEngineException", + "org.camunda.bpm.engine.exception.NullValueException", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInstanceEnd", + "org.camunda.bpm.engine.impl.core.variable.value.UntypedValueImpl", + "org.camunda.bpm.engine.impl.core.variable.VariableMapImpl", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationProcessEnd", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionDestroyScope", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation", + "org.camunda.bpm.engine.impl.pvm.PvmException", + "org.camunda.bpm.engine.impl.core.model.CoreModelElement", + "org.camunda.bpm.engine.impl.core.model.CoreActivity", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition", + "org.camunda.bpm.engine.impl.core.variable.value.NullValueImpl", + "org.camunda.bpm.engine.impl.pvm.process.ScopeImpl", + "org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl", + "org.camunda.bpm.engine.impl.pvm.process.ActivityImpl", + "org.camunda.bpm.engine.impl.pvm.process.ActivityStartBehavior", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$1", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution", + "org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity" + ); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadFileTaskESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadFileTaskESTest.java new file mode 100644 index 0000000000..741872af7a --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadFileTaskESTest.java @@ -0,0 +1,58 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:30:51 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ReadFileTaskESTest extends ReadFileTaskESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + ReadFileTask readFileTask0 = new ReadFileTask(); + ExecutionImpl executionImpl0 = new ExecutionImpl(); + Expression expression0 = mock(Expression.class, new ViolatedAssumptionAnswer()); + doReturn((Object) null).when(expression0).getValue(any(org.camunda.bpm.engine.delegate.VariableScope.class)); + PrivateAccess.setVariable((Class) ReadFileTask.class, readFileTask0, "inputVariable", (Object) expression0); + try { + readFileTask0.execute(executionImpl0); + fail("Expecting exception: RuntimeException"); + + } catch(RuntimeException e) { + // + // ReadFileTask injected field 'inputVariable' is bad: required field has null value + // + verifyException("org.openecomp.mso.bpmn.core.BaseTask", e); + } + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + ReadFileTask readFileTask0 = new ReadFileTask(); + ExecutionImpl executionImpl0 = new ExecutionImpl(); + try { + readFileTask0.execute(executionImpl0); + fail("Expecting exception: RuntimeException"); + + } catch(RuntimeException e) { + // + // ReadFileTask injected field 'inputVariable' is bad: missing required field + // + verifyException("org.openecomp.mso.bpmn.core.BaseTask", e); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadFileTaskESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadFileTaskESTestscaffolding.java new file mode 100644 index 0000000000..4b11c761cc --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/ReadFileTaskESTestscaffolding.java @@ -0,0 +1,339 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:30:51 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ReadFileTaskESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.ReadFileTask"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ReadFileTaskESTestscaffolding.class.getClassLoader() , + "org.camunda.bpm.engine.impl.pvm.process.TransitionImpl", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution", + "org.camunda.bpm.engine.impl.context.CaseExecutionContext", + "org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransformFactory", + "org.camunda.bpm.engine.impl.pvm.PvmScope", + "org.camunda.bpm.engine.delegate.JavaDelegate", + "org.camunda.bpm.engine.impl.tree.TreeWalker$WalkCondition", + "org.camunda.bpm.engine.runtime.ProcessInstance", + "org.camunda.bpm.application.ProcessApplicationReference", + "org.camunda.bpm.engine.delegate.BpmnModelExecutionContext", + "org.camunda.bpm.engine.impl.jobexecutor.FailedJobCommandFactory", + "org.openecomp.mso.bpmn.core.ReadFileTask", + "org.camunda.bpm.engine.delegate.DelegateExecution", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration", + "org.camunda.bpm.engine.delegate.CmmnModelExecutionContext", + "org.camunda.bpm.engine.impl.persistence.entity.util.FormPropertyStartContext", + "com.att.eelf.i18n.EELFMsgs", + "org.camunda.bpm.engine.impl.javax.el.ELContext", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInstanceStart", + "org.camunda.bpm.engine.impl.core.variable.event.VariableEventDispatcher", + "org.camunda.bpm.engine.variable.type.ValueType", + "org.camunda.bpm.engine.impl.interceptor.CommandContextListener", + "org.camunda.bpm.engine.impl.core.variable.mapping.IoMapping", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationInterruptScope", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance", + "org.camunda.bpm.engine.impl.db.HasDbRevision", + "org.camunda.bpm.model.bpmn.instance.FlowElement", + "org.camunda.bpm.engine.delegate.Expression", + "org.camunda.bpm.engine.variable.type.SerializableValueType", + "org.camunda.bpm.engine.impl.pvm.PvmActivity", + "org.camunda.bpm.engine.impl.cfg.BpmnParseFactory", + "org.camunda.bpm.model.bpmn.instance.BpmnModelElementInstance", + "org.camunda.bpm.model.cmmn.instance.CmmnModelElementInstance", + "org.camunda.bpm.engine.impl.pvm.PvmException", + "org.camunda.bpm.engine.impl.core.variable.VariableMapImpl", + "org.camunda.bpm.application.ProcessApplicationUnavailableException", + "org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition", + "org.camunda.bpm.engine.delegate.DelegateCaseExecution", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerTake", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityNotifyListenerEnd", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration", + "org.camunda.bpm.engine.runtime.CaseExecution", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition", + "org.camunda.bpm.engine.impl.core.variable.scope.SimpleVariableStore", + "org.camunda.bpm.engine.repository.ProcessDefinition", + "org.camunda.bpm.engine.impl.pvm.process.ScopeImpl", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityStartConcurrent", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.AbstractPvmAtomicOperationTransitionNotifyListenerTake", + "org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "org.camunda.bpm.engine.impl.pvm.runtime.AtomicOperation", + "org.camunda.bpm.engine.impl.interceptor.SessionFactory", + "org.camunda.bpm.engine.delegate.DelegateTask", + "org.camunda.bpm.engine.impl.pvm.process.ActivityStartBehavior", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation", + "org.camunda.bpm.engine.impl.core.model.CoreActivity", + "org.camunda.bpm.model.bpmn.BpmnModelInstance", + "org.camunda.bpm.engine.delegate.VariableScope", + "org.camunda.bpm.engine.ProcessEngine", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl", + "org.camunda.bpm.engine.impl.interceptor.CommandContext", + "org.camunda.bpm.engine.impl.variable.listener.CaseVariableListenerInvocation", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.camunda.bpm.engine.BadUserRequestException", + "org.camunda.bpm.engine.impl.context.ExecutionContext", + "org.camunda.bpm.engine.impl.persistence.entity.TaskEntity", + "org.camunda.bpm.engine.impl.context.Context", + "org.camunda.bpm.engine.ProcessEngineServices", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl", + "org.camunda.bpm.engine.runtime.Execution", + "org.camunda.bpm.engine.impl.pvm.process.Lane", + "org.camunda.bpm.engine.impl.pvm.process.ParticipantProcess", + "org.camunda.bpm.engine.impl.interceptor.CommandExecutor", + "org.camunda.bpm.engine.delegate.ProcessEngineServicesAware", + "org.camunda.bpm.engine.ProcessEngineConfiguration", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity", + "org.camunda.bpm.engine.impl.util.BitMaskUtil", + "org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition", + "org.camunda.bpm.engine.impl.cmmn.behavior.CmmnActivityBehavior", + "org.camunda.bpm.engine.impl.core.variable.event.VariableEvent", + "org.camunda.bpm.engine.delegate.BaseDelegateExecution", + "org.camunda.bpm.engine.impl.pvm.PvmExecution", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityStartCreateScope", + "org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableStore", + "org.camunda.bpm.engine.runtime.VariableInstance", + "org.camunda.bpm.engine.runtime.Job", + "org.camunda.bpm.engine.runtime.Incident", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState$CaseExecutionStateImpl", + "org.camunda.bpm.model.xml.ModelInstance", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityStart", + "org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl", + "org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity", + "org.openecomp.mso.entity.MsoRequest", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl", + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.camunda.bpm.engine.impl.variable.serializer.ValueFields", + "org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation", + "org.camunda.bpm.engine.impl.task.TaskDecorator", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInitStackNotifyListenerStart", + "org.camunda.bpm.engine.impl.jobexecutor.JobExecutorContext", + "org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation", + "org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationsTransitionInterruptFlowScope", + "org.camunda.bpm.model.xml.instance.ModelElementInstance", + "org.camunda.bpm.engine.ProcessEngineException", + "org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState$SuspensionStateImpl", + "org.camunda.bpm.engine.impl.db.DbEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerEnd", + "org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationFireActivityEnd", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationStartTransitionNotifyListenerTake", + "org.camunda.bpm.engine.runtime.EventSubscription", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionDestroyScope", + "org.camunda.bpm.engine.impl.core.variable.value.UntypedValueImpl", + "org.camunda.bpm.engine.management.JobDefinition", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "com.att.eelf.configuration.EELFLogger$Level", + "org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior", + "org.camunda.bpm.engine.impl.core.variable.scope.MapBasedVariableStore", + "org.camunda.bpm.engine.impl.javax.el.ValueReference", + "org.camunda.bpm.engine.impl.persistence.entity.JobEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.ProcessInstanceStartContext", + "org.camunda.bpm.engine.delegate.DelegateCaseVariableInstance", + "org.camunda.bpm.engine.impl.pvm.PvmProcessElement", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntityVariableStore", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "org.camunda.bpm.engine.impl.delegate.DelegateInvocation", + "org.camunda.bpm.engine.impl.javax.el.ValueExpression", + "com.att.eelf.configuration.EELFLogger", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationFireProcessStart", + "org.camunda.bpm.engine.runtime.CaseInstance", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope", + "org.camunda.bpm.engine.impl.db.DbEntityLifecycleAware", + "org.camunda.bpm.engine.impl.pvm.process.ActivityImpl", + "org.camunda.bpm.engine.impl.core.model.CoreModelElement", + "org.camunda.bpm.engine.impl.interceptor.CommandInterceptor", + "org.camunda.bpm.engine.impl.pvm.PvmProcessInstance", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseSentryPartImpl", + "org.camunda.bpm.engine.variable.value.TypedValue", + "org.apache.ibatis.transaction.TransactionFactory", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnSentryPart", + "org.camunda.bpm.engine.impl.pvm.process.LaneSet", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInitStack", + "org.camunda.bpm.engine.delegate.DelegateListener", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution", + "org.camunda.bpm.engine.delegate.ExecutionListener", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationDeleteCascadeFireActivityEnd", + "org.camunda.bpm.engine.exception.NotAllowedException", + "org.camunda.bpm.engine.impl.history.event.HistoryEventType", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException", + "org.camunda.bpm.engine.impl.pvm.process.HasDIBounds", + "com.att.eelf.configuration.SLF4jWrapper", + "org.camunda.bpm.engine.task.Task", + "org.camunda.bpm.engine.impl.javax.el.Expression", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityEnd", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.AbstractPvmEventAtomicOperation", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInstanceEnd", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationDeleteCascade", + "org.camunda.bpm.engine.impl.context.CoreExecutionContext", + "org.camunda.bpm.engine.delegate.DelegateVariableInstance", + "org.openecomp.mso.logger.MsoLogger", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope", + "org.camunda.bpm.model.cmmn.CmmnModelInstance", + "org.camunda.bpm.engine.variable.VariableMap", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState$ActivityInstanceStateImpl", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationProcessEnd", + "org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl", + "org.camunda.bpm.model.bpmn.instance.BaseElement", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateConcurrentExecution", + "org.camunda.bpm.engine.exception.NullValueException", + "org.camunda.bpm.engine.impl.core.variable.scope.CoreVariableStore", + "org.camunda.bpm.engine.impl.context.BpmnExecutionContext", + "org.openecomp.mso.bpmn.core.BaseTask", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityStartInterruptEventScope", + "org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityStartCancelScope", + "org.apache.ibatis.session.SqlSessionFactory", + "org.camunda.bpm.engine.impl.variable.AbstractPersistentVariableStore", + "org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext", + "com.att.eelf.i18n.EELFResourceManager", + "org.camunda.bpm.engine.impl.core.delegate.CoreActivityBehavior", + "org.openecomp.mso.logger.MessageEnum", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionCreateScope", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "org.camunda.bpm.engine.SuspendedEntityInteractionException", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCancelActivity", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "org.camunda.bpm.engine.impl.db.HasDbReferences", + "org.camunda.bpm.engine.impl.tree.Collector", + "com.att.eelf.configuration.EELFManager", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext", + "org.camunda.bpm.engine.impl.core.operation.CoreAtomicOperation", + "org.camunda.bpm.engine.impl.pvm.PvmTransition", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState", + "org.camunda.bpm.model.cmmn.instance.CmmnElement", + "org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration", + "org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity", + "com.att.eelf.i18n.EELFResourceManager$1", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationProcessStart", + "org.camunda.bpm.engine.impl.core.instance.CoreExecution", + "org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance", + "org.camunda.bpm.engine.variable.type.PrimitiveValueType", + "org.camunda.bpm.engine.delegate.VariableListener", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$1" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ReadFileTaskESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.openecomp.mso.logger.MsoLogger", + "com.att.eelf.i18n.EELFResourceManager", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFLogger$Level", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.logger.MessageEnum", + "org.openecomp.mso.bpmn.core.ReadFileTask", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope", + "org.camunda.bpm.engine.impl.core.instance.CoreExecution", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntityVariableStore", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState", + "org.camunda.bpm.engine.impl.javax.el.Expression", + "org.camunda.bpm.engine.impl.javax.el.ValueExpression", + "org.camunda.bpm.engine.impl.context.Context", + "org.camunda.bpm.engine.ProcessEngineException", + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.camunda.bpm.engine.exception.NullValueException", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException", + "org.camunda.bpm.engine.impl.core.model.CoreModelElement", + "org.camunda.bpm.engine.impl.core.model.CoreActivity", + "org.camunda.bpm.engine.impl.pvm.process.ScopeImpl", + "org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition", + "org.camunda.bpm.engine.impl.pvm.PvmException", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState", + "org.camunda.bpm.engine.impl.core.variable.VariableMapImpl", + "org.camunda.bpm.engine.impl.pvm.process.ActivityImpl", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityInstanceEnd", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationProcessEnd", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionDestroyScope", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$1", + "org.camunda.bpm.engine.impl.util.BitMaskUtil", + "org.camunda.bpm.engine.impl.pvm.process.TransitionImpl", + "org.camunda.bpm.engine.impl.core.variable.value.UntypedValueImpl" + ); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataESTest.java new file mode 100644 index 0000000000..e26f5a9a46 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataESTest.java @@ -0,0 +1,117 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:33:44 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RollbackDataESTest extends RollbackDataESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + RollbackData rollbackData0 = new RollbackData(); + rollbackData0.put("", "", ""); + String string0 = (String)rollbackData0.get("", "0-0|Ox?"); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + RollbackData rollbackData0 = new RollbackData(); + Serializable serializable0 = rollbackData0.get("", "0-0|Ox?"); + assertNull(serializable0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + RollbackData rollbackData0 = new RollbackData(); + rollbackData0.put("", "", ""); + String string0 = (String)rollbackData0.get("", ""); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + RollbackData rollbackData0 = new RollbackData(); + HashMap hashMap0 = new HashMap(); + HashMap hashMap1 = new HashMap(); + hashMap0.put("/0H\"wnR=^l|l$+qQDi", hashMap1); + PrivateAccess.setVariable((Class) RollbackData.class, rollbackData0, "dictionary", (Object) hashMap0); + Map map0 = rollbackData0.get("/0H\"wnR=^l|l$+qQDi"); + assertEquals(0, map0.size()); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + RollbackData rollbackData0 = new RollbackData(); + rollbackData0.put("RollbackData[]", "$", "RollbackData[]"); + Map map0 = rollbackData0.get("RollbackData[]"); + assertFalse(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + RollbackData rollbackData0 = new RollbackData(); + rollbackData0.put("org.openecomp.mso.bpmn.core.RollbackData", "org.openecomp.mso.bpmn.core.RollbackData", "!{=|?cluq? yk])."); + rollbackData0.get(""); + PrivateAccess.setVariable((Class) RollbackData.class, rollbackData0, "dictionary", (Object) null); + // Undeclared exception! + try { + rollbackData0.get("org.openecomp.mso.bpmn.core.RollbackData"); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.bpmn.core.RollbackData", e); + } + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + RollbackData rollbackData0 = new RollbackData(); + rollbackData0.put("$", "$", "RollbackData[]"); + rollbackData0.put("RollbackData[]", "$", "RollbackData[]"); + String string0 = rollbackData0.toString(); + assertEquals("RollbackData[${$=RollbackData[]},RollbackData[]{$=RollbackData[]}]", string0); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + RollbackData rollbackData0 = new RollbackData(); + rollbackData0.put("$", "$", "RollbackData[]"); + rollbackData0.put("$", "RollbackData[]", "RollbackData[]"); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + RollbackData rollbackData0 = new RollbackData(); + HashMap hashMap0 = new HashMap(); + HashMap hashMap1 = new HashMap(); + hashMap0.put("/0H\"wnR=^l|l$+qQDi", hashMap1); + PrivateAccess.setVariable((Class) RollbackData.class, rollbackData0, "dictionary", (Object) hashMap0); + boolean boolean0 = rollbackData0.hasType("/0H\"wnR=^l|l$+qQDi"); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test9() throws Throwable { + RollbackData rollbackData0 = new RollbackData(); + boolean boolean0 = rollbackData0.hasType("RollbackData[]"); + assertFalse(boolean0); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataESTestscaffolding.java new file mode 100644 index 0000000000..7dc6ca1e4e --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/RollbackDataESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:33:44 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RollbackDataESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.RollbackData"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RollbackDataESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.bpmn.core.RollbackData" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RollbackDataESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.bpmn.core.RollbackData" + ); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java new file mode 100644 index 0000000000..3f2f74d2f7 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java @@ -0,0 +1,262 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.core; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.test.Deployment; +import org.camunda.bpm.engine.test.ProcessEngineRule; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import org.openecomp.mso.bpmn.test.CamundaDBSetup; +import org.openecomp.mso.bpmn.test.PropertyConfigurationSetup; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Unit test for BaseTask class. + */ +public class TestBaseTask { + + @Rule + public ProcessEngineRule processEngineRule = new ProcessEngineRule(); + + @Before + public void beforeTest() throws Exception { + CamundaDBSetup.configure(); + PropertyConfigurationSetup.init(); + } + + @Test + @Deployment(resources={"BaseTaskTest.bpmn"}) + public void shouldInvokeService() { + Map variables = new HashMap(); + variables.put("firstName", "Jane"); + variables.put("lastName", "Doe"); + variables.put("age", (Integer)25); + variables.put("lastVisit", (Long)1438270117000L); + + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + processEngineRule.getTaskService(); + runtimeService.startProcessInstanceByKey("BaseTaskTest", variables); + } + + /** + * Unit test code for BaseTask. + */ + public static class TestTask extends BaseTask { + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + private Expression existingString; + private Expression nonExistingString; + private Expression existingStringFromVar; + private Expression nonExistingStringFromVar; + + private Expression existingInteger; + private Expression nonExistingInteger; + private Expression existingIntegerFromVar; + private Expression nonExistingIntegerFromVar; + + private Expression existingLong; + private Expression nonExistingLong; + private Expression existingLongFromVar; + private Expression nonExistingLongFromVar; + + private Expression existingOutputVar; + private Expression nonExistingOutputVar; + private Expression existingBadOutputVar; + + public void execute(DelegateExecution execution) throws Exception { + msoLogger.debug("Started executing " + getClass().getSimpleName()); + + /*********************************************************************/ + msoLogger.debug("Running String Field Tests"); + /*********************************************************************/ + + String s = getStringField(existingString, execution, "existingString"); + Assert.assertEquals("Hello World", s); + + try { + s = getStringField(nonExistingString, execution, "nonExistingString"); + Assert.fail("Expected BadInjectedFieldException for nonExistingString"); + } catch (Exception e) { + if (!(e instanceof BadInjectedFieldException)) { + Assert.fail("Expected BadInjectedFieldException for nonExistingString"); + } + } + + s = getOptionalStringField(existingString, execution, "existingString"); + Assert.assertEquals("Hello World", s); + + s = getOptionalStringField(nonExistingString, execution, "nonExistingString"); + Assert.assertEquals(null, s); + + /*********************************************************************/ + msoLogger.debug("Running String Expression Tests"); + /*********************************************************************/ + + s = getStringField(existingStringFromVar, execution, "existingStringFromVar"); + Assert.assertEquals("Jane", s); + + try { + s = getStringField(nonExistingStringFromVar, execution, "nonExistingStringFromVar"); + Assert.fail("Expected BadInjectedFieldException for nonExistingString"); + } catch (Exception e) { + if (!(e instanceof BadInjectedFieldException)) { + Assert.fail("Expected BadInjectedFieldException for nonExistingStringFromVar"); + } + } + + s = getOptionalStringField(existingStringFromVar, execution, "existingStringFromVar"); + Assert.assertEquals("Jane", s); + + s = getOptionalStringField(nonExistingStringFromVar, execution, "nonExistingStringFromVar"); + Assert.assertEquals(null, s); + + /*********************************************************************/ + msoLogger.debug("Running Integer Field Tests"); + /*********************************************************************/ + + Integer i = getIntegerField(existingInteger, execution, "existingInteger"); + Assert.assertEquals((Integer)42, i); + + try { + i = getIntegerField(nonExistingInteger, execution, "nonExistingInteger"); + Assert.fail("Expected BadInjectedFieldException for nonExistingInteger"); + } catch (Exception e) { + if (!(e instanceof BadInjectedFieldException)) { + Assert.fail("Expected BadInjectedFieldException for nonExistingInteger"); + } + } + + i = getOptionalIntegerField(existingInteger, execution, "existingInteger"); + Assert.assertEquals((Integer)42, i); + + i = getOptionalIntegerField(nonExistingInteger, execution, "nonExistingInteger"); + Assert.assertEquals(null, i); + + /*********************************************************************/ + msoLogger.debug("Running Integer Expression Tests"); + /*********************************************************************/ + + i = getIntegerField(existingIntegerFromVar, execution, "existingIntegerFromVar"); + Assert.assertEquals((Integer)25, i); + + try { + i = getIntegerField(nonExistingIntegerFromVar, execution, "nonExistingIntegerFromVar"); + Assert.fail("Expected BadInjectedFieldException for nonExistingInteger"); + } catch (Exception e) { + if (!(e instanceof BadInjectedFieldException)) { + Assert.fail("Expected BadInjectedFieldException for nonExistingIntegerFromVar"); + } + } + + i = getOptionalIntegerField(existingIntegerFromVar, execution, "existingIntegerFromVar"); + Assert.assertEquals((Integer)25, i); + + i = getOptionalIntegerField(nonExistingIntegerFromVar, execution, "nonExistingIntegerFromVar"); + Assert.assertEquals(null, i); + + /*********************************************************************/ + msoLogger.debug("Running Long Field Tests"); + /*********************************************************************/ + + Long l = getLongField(existingLong, execution, "existingLong"); + Assert.assertEquals((Long)123456789L, l); + + try { + l = getLongField(nonExistingLong, execution, "nonExistingLong"); + Assert.fail("Expected BadInjectedFieldException for nonExistingLong"); + } catch (Exception e) { + if (!(e instanceof BadInjectedFieldException)) { + Assert.fail("Expected BadInjectedFieldException for nonExistingLong"); + } + } + + l = getOptionalLongField(existingLong, execution, "existingLong"); + Assert.assertEquals((Long)123456789L, l); + + l = getOptionalLongField(nonExistingLong, execution, "nonExistingLong"); + Assert.assertEquals(null, l); + + /*********************************************************************/ + msoLogger.debug("Running Long Expression Tests"); + /*********************************************************************/ + + l = getLongField(existingLongFromVar, execution, "existingLongFromVar"); + Assert.assertEquals((Long)1438270117000L, l); + + try { + l = getLongField(nonExistingLongFromVar, execution, "nonExistingLongFromVar"); + Assert.fail("Expected BadInjectedFieldException for nonExistingLong"); + } catch (Exception e) { + if (!(e instanceof BadInjectedFieldException)) { + Assert.fail("Expected BadInjectedFieldException for nonExistingLongFromVar"); + } + } + + l = getOptionalLongField(existingLongFromVar, execution, "existingLongFromVar"); + Assert.assertEquals((Long)1438270117000L, l); + + l = getOptionalLongField(nonExistingLongFromVar, execution, "nonExistingLongFromVar"); + Assert.assertEquals(null, i); + + /*********************************************************************/ + msoLogger.debug("Running Output Variable Field Tests"); + /*********************************************************************/ + + String var = getOutputField(existingOutputVar, execution, "existingOutputVar"); + Assert.assertEquals("goodVariable", var); + + try { + var = getOutputField(nonExistingOutputVar, execution, "nonExistingOutputVar"); + Assert.fail("Expected BadInjectedFieldException for nonExistingString"); + } catch (Exception e) { + if (!(e instanceof BadInjectedFieldException)) { + Assert.fail("Expected BadInjectedFieldException for nonExistingString"); + } + } + + var = getOptionalOutputField(existingOutputVar, execution, "existingOutputVar"); + Assert.assertEquals("goodVariable", var); + + var = getOptionalOutputField(nonExistingOutputVar, execution, "nonExistingOutputVar"); + Assert.assertEquals(null, var); + + try { + var = getOutputField(existingBadOutputVar, execution, "existingBadOutputVar"); + Assert.fail("Expected BadInjectedFieldException for nonExistingString"); + } catch (Exception e) { + if (!(e instanceof BadInjectedFieldException)) { + Assert.fail("Expected BadInjectedFieldException for nonExistingString"); + } + } + + msoLogger.debug("Finished executing " + getClass().getSimpleName()); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/URNMappingsTaskESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/URNMappingsTaskESTest.java new file mode 100644 index 0000000000..64220f016d --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/URNMappingsTaskESTest.java @@ -0,0 +1,27 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:35:51 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.junit.Test; + +import static org.evosuite.shaded.org.mockito.Mockito.*; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class URNMappingsTaskESTest extends URNMappingsTaskESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + URNMappingsTask uRNMappingsTask0 = new URNMappingsTask(); + DelegateExecution delegateExecution0 = mock(DelegateExecution.class, new ViolatedAssumptionAnswer()); + uRNMappingsTask0.execute(delegateExecution0); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/URNMappingsTaskESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/URNMappingsTaskESTestscaffolding.java new file mode 100644 index 0000000000..93151d3271 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/URNMappingsTaskESTestscaffolding.java @@ -0,0 +1,103 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:35:51 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class URNMappingsTaskESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.URNMappingsTask"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(URNMappingsTaskESTestscaffolding.class.getClassLoader() , + "org.camunda.bpm.engine.delegate.BpmnModelExecutionContext", + "org.camunda.bpm.model.xml.instance.ModelElementInstance", + "org.camunda.bpm.engine.delegate.VariableScope", + "org.camunda.bpm.engine.delegate.ProcessEngineServicesAware", + "org.camunda.bpm.engine.variable.value.TypedValue", + "org.camunda.bpm.engine.delegate.DelegateExecution", + "org.camunda.bpm.engine.delegate.Expression", + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.camunda.bpm.model.bpmn.instance.BpmnModelElementInstance", + "org.openecomp.mso.bpmn.core.URNMappingsTask", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException", + "org.openecomp.mso.bpmn.core.BaseTask", + "org.camunda.bpm.engine.delegate.BaseDelegateExecution", + "org.camunda.bpm.engine.variable.VariableMap", + "org.camunda.bpm.engine.delegate.JavaDelegate", + "org.camunda.bpm.engine.ProcessEngineServices", + "org.camunda.bpm.model.bpmn.BpmnModelInstance", + "org.camunda.bpm.model.bpmn.instance.BaseElement", + "org.camunda.bpm.model.xml.ModelInstance", + "org.camunda.bpm.model.bpmn.instance.FlowElement" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(URNMappingsTaskESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException" + ); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/WorkflowExceptionESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/WorkflowExceptionESTest.java new file mode 100644 index 0000000000..1891c8d478 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/WorkflowExceptionESTest.java @@ -0,0 +1,88 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:35:37 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class WorkflowExceptionESTest extends WorkflowExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + WorkflowException workflowException0 = new WorkflowException("(YdK~.N3;c2C", 336, "(YdK~.N3;c2C"); + workflowException0.getProcessKey(); + assertEquals(336, workflowException0.getErrorCode()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + WorkflowException workflowException0 = new WorkflowException("", 0, ""); + workflowException0.getProcessKey(); + assertEquals(0, workflowException0.getErrorCode()); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + WorkflowException workflowException0 = new WorkflowException((String) null, 0, "^Y:"); + String string0 = workflowException0.getErrorMessage(); + assertEquals(0, workflowException0.getErrorCode()); + assertNotNull(string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + WorkflowException workflowException0 = new WorkflowException("", 1216, ""); + workflowException0.getErrorMessage(); + assertEquals(1216, workflowException0.getErrorCode()); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + WorkflowException workflowException0 = new WorkflowException("", 0, ""); + int int0 = workflowException0.getErrorCode(); + assertEquals(0, int0); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + WorkflowException workflowException0 = new WorkflowException((String) null, (-1911), (String) null); + int int0 = workflowException0.getErrorCode(); + assertEquals((-1911), int0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + WorkflowException workflowException0 = new WorkflowException((String) null, 336, (String) null); + workflowException0.getErrorMessage(); + assertEquals(336, workflowException0.getErrorCode()); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + WorkflowException workflowException0 = new WorkflowException((String) null, 336, (String) null); + int int0 = workflowException0.getErrorCode(); + assertEquals(336, int0); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + WorkflowException workflowException0 = new WorkflowException((String) null, 336, (String) null); + workflowException0.getProcessKey(); + assertEquals(336, workflowException0.getErrorCode()); + } + + @Test(timeout = 4000) + public void test9() throws Throwable { + WorkflowException workflowException0 = new WorkflowException((String) null, 336, (String) null); + String string0 = workflowException0.toString(); + assertEquals("WorkflowException[processKey=null,errorCode=336,errorMessage=null]", string0); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/WorkflowExceptionESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/WorkflowExceptionESTestscaffolding.java new file mode 100644 index 0000000000..88e0e0f96f --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/WorkflowExceptionESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:35:37 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class WorkflowExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.WorkflowException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(WorkflowExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.bpmn.core.WorkflowException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(WorkflowExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.bpmn.core.WorkflowException" + ); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/XQueryScriptTaskESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/XQueryScriptTaskESTest.java new file mode 100644 index 0000000000..a14934193e --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/XQueryScriptTaskESTest.java @@ -0,0 +1,81 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:28:14 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import java.io.IOException; +import net.sf.saxon.s9api.XQueryCompiler; +import net.sf.saxon.s9api.XQueryExecutable; +import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class XQueryScriptTaskESTest extends XQueryScriptTaskESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + XQueryScriptTask xQueryScriptTask0 = new XQueryScriptTask(); + XQueryCompiler xQueryCompiler0 = mock(XQueryCompiler.class, new ViolatedAssumptionAnswer()); + doReturn((XQueryExecutable) null).when(xQueryCompiler0).compile(any(java.io.InputStream.class)); + Object object0 = PrivateAccess.callMethod((Class) XQueryScriptTask.class, xQueryScriptTask0, "compile", (Object) xQueryCompiler0, (Class) XQueryCompiler.class, (Object) "", (Class) String.class); + assertNull(object0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + XQueryScriptTask xQueryScriptTask0 = new XQueryScriptTask(); + XQueryCompiler xQueryCompiler0 = mock(XQueryCompiler.class, new ViolatedAssumptionAnswer()); + try { + PrivateAccess.callMethod((Class) XQueryScriptTask.class, xQueryScriptTask0, "compile", (Object) xQueryCompiler0, (Class) XQueryCompiler.class, (Object) "Sk##N$V^.", (Class) String.class); + fail("Expecting exception: IOException"); + + } catch(IOException e) { + // + // Resource not found: Sk##N$V^. + // + verifyException("org.openecomp.mso.bpmn.core.XQueryScriptTask", e); + } + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + XQueryScriptTask xQueryScriptTask0 = new XQueryScriptTask(); + try { + PrivateAccess.callMethod((Class) XQueryScriptTask.class, xQueryScriptTask0, "compile", (Object) null, (Class) XQueryCompiler.class, (Object) "", (Class) String.class); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.bpmn.core.XQueryScriptTask", e); + } + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + XQueryScriptTask xQueryScriptTask0 = new XQueryScriptTask(); + ExecutionImpl executionImpl0 = new ExecutionImpl(); + try { + xQueryScriptTask0.execute(executionImpl0); + fail("Expecting exception: RuntimeException"); + + } catch(RuntimeException e) { + // + // XQueryScriptTask injected field 'scriptFile' is bad: missing required field + // + verifyException("org.openecomp.mso.bpmn.core.BaseTask", e); + } + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/XQueryScriptTaskESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/XQueryScriptTaskESTestscaffolding.java new file mode 100644 index 0000000000..b0c1585e59 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/XQueryScriptTaskESTestscaffolding.java @@ -0,0 +1,533 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:28:14 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class XQueryScriptTaskESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.XQueryScriptTask"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(XQueryScriptTaskESTestscaffolding.class.getClassLoader() , + "net.sf.saxon.pattern.PatternFinder", + "net.sf.saxon.pattern.AnyNodeTest", + "net.sf.saxon.tree.linked.TextImpl", + "net.sf.saxon.tree.linked.ElementImpl", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution", + "org.camunda.bpm.engine.impl.context.CaseExecutionContext", + "org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransformFactory", + "org.camunda.bpm.engine.impl.pvm.PvmScope", + "net.sf.saxon.type.TypeHierarchy", + "net.sf.saxon.trans.Mode", + "org.camunda.bpm.engine.impl.tree.TreeWalker$WalkCondition", + "org.camunda.bpm.engine.runtime.ProcessInstance", + "net.sf.saxon.trans.CompilerInfo", + "net.sf.saxon.type.ConversionResult", + "net.sf.saxon.type.ItemType", + "net.sf.saxon.om.NamePool", + "net.sf.saxon.value.NumericValue", + "org.camunda.bpm.engine.impl.jobexecutor.FailedJobCommandFactory", + "net.sf.saxon.s9api.Processor", + "net.sf.saxon.om.NameChecker", + "org.camunda.bpm.engine.impl.persistence.entity.util.FormPropertyStartContext", + "net.sf.saxon.expr.sort.SimpleCollation", + "net.sf.saxon.z.IntIterator", + "net.sf.saxon.expr.PendingUpdateList", + "net.sf.saxon.om.NamespaceBinding", + "net.sf.saxon.lib.StaticQueryContextFactory", + "net.sf.saxon.serialize.charcode.CharacterSet", + "net.sf.saxon.event.Receiver", + "org.camunda.bpm.model.bpmn.instance.FlowElement", + "net.sf.saxon.om.AbstractItem", + "net.sf.saxon.lib.ExternalObjectModel", + "net.sf.saxon.event.LocationProvider", + "org.camunda.bpm.engine.delegate.Expression", + "net.sf.saxon.value.QualifiedNameValue", + "net.sf.saxon.om.MutableDocumentInfo", + "org.camunda.bpm.engine.impl.pvm.PvmActivity", + "org.camunda.bpm.engine.impl.cfg.BpmnParseFactory", + "org.camunda.bpm.model.bpmn.instance.BpmnModelElementInstance", + "net.sf.saxon.pattern.NodeTest", + "net.sf.saxon.om.NamespaceException", + "net.sf.saxon.lib.EnvironmentVariableResolver", + "org.camunda.bpm.application.ProcessApplicationUnavailableException", + "net.sf.saxon.expr.instruct.Procedure", + "net.sf.saxon.om.Sequence", + "org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition", + "net.sf.saxon.type.ValidationFailure", + "org.camunda.bpm.engine.delegate.DelegateCaseExecution", + "net.sf.saxon.tree.iter.UnfailingIterator", + "net.sf.saxon.type.AnySimpleType", + "org.camunda.bpm.engine.runtime.CaseExecution", + "net.sf.saxon.event.ProxyReceiver", + "net.sf.saxon.lib.ConversionRules", + "net.sf.saxon.lib.OutputURIResolver", + "net.sf.saxon.expr.instruct.ValidatingInstruction", + "net.sf.saxon.om.FunctionItem", + "net.sf.saxon.om.MutableNodeInfo", + "org.camunda.bpm.engine.impl.pvm.process.ScopeImpl", + "net.sf.saxon.pattern.PatternWithPredicate", + "net.sf.saxon.expr.ErrorExpression", + "net.sf.saxon.om.Name10Checker", + "net.sf.saxon.event.ComplexContentOutputter", + "org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "org.camunda.bpm.engine.impl.pvm.runtime.AtomicOperation", + "org.camunda.bpm.engine.delegate.DelegateTask", + "net.sf.saxon.style.LiteralResultElement", + "org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation", + "org.camunda.bpm.engine.impl.core.model.CoreActivity", + "net.sf.saxon.tree.iter.LookaheadIterator", + "net.sf.saxon.om.AtomicSequence", + "net.sf.saxon.s9api.XQueryCompiler", + "net.sf.saxon.pattern.LocalNameTest", + "net.sf.saxon.pattern.PatternParser", + "net.sf.saxon.expr.instruct.SlotManager", + "net.sf.saxon.PreparedStylesheet", + "org.camunda.bpm.engine.impl.interceptor.CommandContext", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "net.sf.saxon.lib.ParseOptions", + "net.sf.saxon.expr.ItemMappingIterator", + "net.sf.saxon.tree.iter.EmptyIterator", + "org.camunda.bpm.engine.impl.persistence.entity.TaskEntity", + "org.camunda.bpm.engine.impl.context.Context", + "net.sf.saxon.lib.LocalizerFactory", + "org.camunda.bpm.engine.ProcessEngineServices", + "org.camunda.bpm.engine.runtime.Execution", + "org.camunda.bpm.engine.impl.interceptor.CommandExecutor", + "net.sf.saxon.s9api.ItemType$1", + "org.camunda.bpm.engine.delegate.ProcessEngineServicesAware", + "org.camunda.bpm.engine.ProcessEngineConfiguration", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity", + "net.sf.saxon.s9api.ItemType$2", + "net.sf.saxon.s9api.ItemType$3", + "org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition", + "net.sf.saxon.pattern.NodeKindTest", + "org.camunda.bpm.engine.impl.core.variable.event.VariableEvent", + "net.sf.saxon.expr.LetExpression", + "org.camunda.bpm.engine.delegate.BaseDelegateExecution", + "net.sf.saxon.s9api.XdmItem", + "net.sf.saxon.expr.Binding", + "net.sf.saxon.expr.instruct.ParentNodeConstructor", + "org.camunda.bpm.engine.runtime.VariableInstance", + "org.camunda.bpm.engine.runtime.Incident", + "net.sf.saxon.om.NamespaceResolver", + "net.sf.saxon.expr.instruct.AnalyzeString", + "net.sf.saxon.z.IntHashMap", + "org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity", + "net.sf.saxon.expr.instruct.ResultDocument", + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.camunda.bpm.engine.impl.variable.serializer.ValueFields", + "net.sf.saxon.type.StringToDouble", + "net.sf.saxon.value.SequenceType", + "net.sf.saxon.type.ComplexType", + "org.camunda.bpm.engine.impl.jobexecutor.JobExecutorContext", + "net.sf.saxon.type.AnyType", + "org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity", + "net.sf.saxon.expr.StaticContext", + "org.camunda.bpm.engine.ProcessEngineException", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState$SuspensionStateImpl", + "net.sf.saxon.lib.SerializerFactory", + "net.sf.saxon.tree.util.SteppingNode", + "net.sf.saxon.functions.IntegratedFunctionLibrary", + "net.sf.saxon.evpull.PullEvent", + "net.sf.saxon.expr.XPathContextMinor", + "org.camunda.bpm.engine.management.JobDefinition", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "net.sf.saxon.om.DocumentInfo", + "net.sf.saxon.om.QNameException", + "org.camunda.bpm.engine.impl.javax.el.ValueReference", + "org.camunda.bpm.engine.impl.persistence.entity.JobEntity", + "net.sf.saxon.type.SchemaComponentVisitor", + "net.sf.saxon.z.AbstractIntSet", + "net.sf.saxon.tree.iter.AxisIterator", + "net.sf.saxon.s9api.XdmValue", + "net.sf.saxon.lib.CollationURIResolver", + "org.openecomp.mso.bpmn.core.XQueryScriptTask", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntityVariableStore", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "org.camunda.bpm.engine.impl.delegate.DelegateInvocation", + "net.sf.saxon.tree.tiny.AppendableCharSequence", + "net.sf.saxon.om.GroundedValue", + "net.sf.saxon.tree.linked.NodeFactory", + "net.sf.saxon.type.SchemaDeclaration", + "net.sf.saxon.tree.linked.CommentImpl", + "org.camunda.bpm.engine.impl.interceptor.CommandInterceptor", + "org.camunda.bpm.engine.variable.value.TypedValue", + "net.sf.saxon.trans.BuiltInRuleSet", + "org.apache.ibatis.transaction.TransactionFactory", + "net.sf.saxon.value.AtomicValue", + "net.sf.saxon.trans.NonDelegatingURIResolver", + "net.sf.saxon.functions.VendorFunctionLibrary", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution", + "net.sf.saxon.pattern.PatternParser20", + "net.sf.saxon.expr.instruct.TraceExpression", + "org.camunda.bpm.engine.exception.NotAllowedException", + "net.sf.saxon.Configuration", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException", + "net.sf.saxon.tree.util.FastStringBuffer", + "net.sf.saxon.tree.linked.NodeImpl", + "com.att.eelf.configuration.SLF4jWrapper", + "org.camunda.bpm.engine.task.Task", + "org.camunda.bpm.engine.impl.javax.el.Expression", + "net.sf.saxon.type.Type", + "net.sf.saxon.s9api.XdmNode", + "net.sf.saxon.value.QNameValue", + "org.camunda.bpm.engine.impl.context.CoreExecutionContext", + "org.openecomp.mso.logger.MsoLogger", + "net.sf.saxon.type.SchemaType", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope", + "net.sf.saxon.java.JavaPlatform$1", + "net.sf.saxon.expr.instruct.ElementCreator", + "net.sf.saxon.om.Item", + "org.camunda.bpm.engine.variable.VariableMap", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState$ActivityInstanceStateImpl", + "net.sf.saxon.lib.SchemaURIResolver", + "org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl", + "org.camunda.bpm.engine.impl.core.variable.scope.CoreVariableStore", + "net.sf.saxon.lib.ModuleURIResolver", + "org.camunda.bpm.engine.impl.context.BpmnExecutionContext", + "net.sf.saxon.expr.parser.ExpressionVisitor", + "net.sf.saxon.om.SequenceIterator", + "net.sf.saxon.z.IntHashSet", + "net.sf.saxon.type.BuiltInType", + "org.apache.ibatis.session.SqlSessionFactory", + "net.sf.saxon.expr.instruct.Executable", + "net.sf.saxon.om.DocumentPool", + "net.sf.saxon.expr.LastPositionFinder", + "net.sf.saxon.expr.instruct.TailCallReturner", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "net.sf.saxon.type.BuiltInAtomicType", + "org.camunda.bpm.engine.SuspendedEntityInteractionException", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "com.att.eelf.configuration.EELFManager", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext", + "org.camunda.bpm.engine.impl.core.operation.CoreAtomicOperation", + "org.camunda.bpm.engine.impl.pvm.PvmTransition", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState", + "org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity", + "org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance", + "net.sf.saxon.pattern.ContentTypeTest", + "net.sf.saxon.query.QueryParser", + "net.sf.saxon.om.NodeName", + "net.sf.saxon.value.Closure", + "net.sf.saxon.expr.instruct.FixedElement", + "org.camunda.bpm.engine.impl.pvm.process.TransitionImpl", + "net.sf.saxon.s9api.ConstructedItemType", + "net.sf.saxon.lib.Numberer", + "org.camunda.bpm.engine.delegate.JavaDelegate", + "net.sf.saxon.om.IdentityComparable", + "net.sf.saxon.z.IntSet", + "org.camunda.bpm.application.ProcessApplicationReference", + "net.sf.saxon.pattern.QNameTest", + "org.camunda.bpm.engine.delegate.BpmnModelExecutionContext", + "net.sf.saxon.expr.sort.SortKeyDefinition", + "net.sf.saxon.style.XSLAnalyzeString", + "org.camunda.bpm.engine.delegate.DelegateExecution", + "org.camunda.bpm.engine.delegate.CmmnModelExecutionContext", + "net.sf.saxon.expr.instruct.ValueOf", + "net.sf.saxon.type.AnyItemType", + "com.att.eelf.i18n.EELFMsgs", + "org.camunda.bpm.engine.impl.javax.el.ELContext", + "net.sf.saxon.expr.instruct.WithParam", + "org.camunda.bpm.engine.impl.core.variable.event.VariableEventDispatcher", + "net.sf.saxon.expr.Assignation", + "net.sf.saxon.value.StringToDouble11", + "org.camunda.bpm.engine.variable.type.ValueType", + "net.sf.saxon.style.StylesheetModule", + "net.sf.saxon.value.EmptySequence", + "org.camunda.bpm.engine.impl.interceptor.CommandContextListener", + "org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance", + "net.sf.saxon.style.PrincipalStylesheetModule", + "net.sf.saxon.type.PlainType", + "org.camunda.bpm.engine.repository.CaseDefinition", + "org.camunda.bpm.engine.impl.db.HasDbRevision", + "net.sf.saxon.query.StaticQueryContext", + "net.sf.saxon.expr.instruct.SimpleNodeConstructor", + "net.sf.saxon.trans.DynamicLoader", + "net.sf.saxon.s9api.ItemType$BuiltInAtomicItemType", + "org.camunda.bpm.engine.variable.type.SerializableValueType", + "net.sf.saxon.event.SaxonLocator", + "net.sf.saxon.expr.parser.Optimizer", + "org.camunda.bpm.engine.impl.pvm.PvmException", + "org.camunda.bpm.engine.impl.core.variable.VariableMapImpl", + "net.sf.saxon.expr.sort.Sortable", + "net.sf.saxon.type.ExternalObjectType", + "net.sf.saxon.expr.Literal", + "net.sf.saxon.style.StyleElement", + "org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition", + "org.camunda.bpm.engine.impl.core.variable.scope.SimpleVariableStore", + "net.sf.saxon.type.ValidationException", + "org.camunda.bpm.engine.repository.ProcessDefinition", + "net.sf.saxon.style.AbsentExtensionElement", + "net.sf.saxon.style.XSLStylesheet", + "net.sf.saxon.query.XQueryFunctionBinder", + "net.sf.saxon.Platform", + "net.sf.saxon.om.AbsolutePath", + "net.sf.saxon.style.SourceBinding", + "org.camunda.bpm.engine.impl.interceptor.SessionFactory", + "net.sf.saxon.trace.InstructionInfo", + "net.sf.saxon.pattern.NameTest", + "net.sf.saxon.trans.XPathException", + "net.sf.saxon.pattern.ItemTypePattern", + "org.camunda.bpm.model.bpmn.BpmnModelInstance", + "net.sf.saxon.type.SimpleType", + "net.sf.saxon.tree.linked.ProcInstImpl", + "net.sf.saxon.expr.instruct.UserFunction", + "net.sf.saxon.event.SequenceReceiver", + "org.camunda.bpm.engine.delegate.VariableScope", + "net.sf.saxon.event.FilterFactory", + "org.camunda.bpm.engine.ProcessEngine", + "org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl", + "org.camunda.bpm.engine.impl.variable.listener.CaseVariableListenerInvocation", + "org.camunda.bpm.engine.BadUserRequestException", + "net.sf.saxon.expr.Callable", + "org.camunda.bpm.engine.impl.context.ExecutionContext", + "net.sf.saxon.tree.tiny.TinyTree", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl", + "net.sf.saxon.tree.iter.EmptyAxisIterator", + "net.sf.saxon.om.NotationSet", + "net.sf.saxon.expr.CollationMap", + "net.sf.saxon.tree.util.AttributeCollectionImpl", + "net.sf.saxon.type.UnionType", + "net.sf.saxon.expr.instruct.GeneralVariable", + "net.sf.saxon.trans.LicenseException", + "org.camunda.bpm.engine.impl.pvm.PvmExecution", + "net.sf.saxon.functions.FunctionLibrary", + "net.sf.saxon.lib.StandardURIResolver", + "org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableStore", + "net.sf.saxon.type.TypeHierarchy$2", + "net.sf.saxon.trans.Mode$RuleAction", + "org.camunda.bpm.engine.runtime.Job", + "net.sf.saxon.type.TypeHierarchy$1", + "org.camunda.bpm.model.xml.ModelInstance", + "net.sf.saxon.om.FingerprintedNode", + "org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl", + "net.sf.saxon.tree.linked.ParentNodeImpl", + "net.sf.saxon.type.ErrorType", + "org.openecomp.mso.entity.MsoRequest", + "net.sf.saxon.value.NotationValue", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl", + "net.sf.saxon.s9api.ItemType", + "net.sf.saxon.type.Untyped", + "net.sf.saxon.expr.parser.PathMap$PathMapRoot", + "net.sf.saxon.expr.instruct.AttributeCreator", + "org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation", + "net.sf.saxon.expr.instruct.AttributeSet", + "net.sf.saxon.trans.Mode$RuleFilter", + "net.sf.saxon.s9api.XdmAtomicValue", + "net.sf.saxon.om.AttributeCollection", + "org.camunda.bpm.model.xml.instance.ModelElementInstance", + "net.sf.saxon.expr.sort.RuleBasedSubstringMatcher", + "org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration", + "org.camunda.bpm.engine.impl.db.DbEntity", + "net.sf.saxon.java.JavaPlatform", + "org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution", + "org.camunda.bpm.engine.runtime.EventSubscription", + "net.sf.saxon.lib.URIChecker", + "net.sf.saxon.tree.linked.DocumentImpl", + "net.sf.saxon.s9api.XQueryExecutable", + "net.sf.saxon.expr.instruct.FixedAttribute", + "net.sf.saxon.expr.XPathContextMajor", + "net.sf.saxon.type.AtomicType", + "net.sf.saxon.expr.instruct.DocumentInstr", + "net.sf.saxon.expr.Expression", + "net.sf.saxon.serialize.charcode.CharacterSetFactory", + "com.att.eelf.configuration.EELFLogger$Level", + "org.camunda.bpm.engine.impl.core.variable.scope.MapBasedVariableStore", + "net.sf.saxon.tree.util.Navigator", + "net.sf.saxon.pattern.NamespaceTest", + "org.camunda.bpm.engine.impl.pvm.runtime.ProcessInstanceStartContext", + "org.camunda.bpm.engine.delegate.DelegateCaseVariableInstance", + "org.camunda.bpm.engine.impl.pvm.PvmProcessElement", + "org.camunda.bpm.engine.impl.javax.el.ValueExpression", + "net.sf.saxon.tree.iter.ReversibleIterator", + "com.att.eelf.configuration.EELFLogger", + "net.sf.saxon.event.Builder", + "org.camunda.bpm.engine.runtime.CaseInstance", + "net.sf.saxon.s9api.SaxonApiException", + "org.camunda.bpm.engine.impl.db.DbEntityLifecycleAware", + "net.sf.saxon.om.StructuredQName", + "org.camunda.bpm.engine.impl.pvm.process.ActivityImpl", + "org.camunda.bpm.engine.impl.core.model.CoreModelElement", + "org.camunda.bpm.engine.impl.pvm.PvmProcessInstance", + "net.sf.saxon.style.StyleNodeFactory", + "net.sf.saxon.expr.instruct.Instruction", + "net.sf.saxon.functions.FunctionLibraryList", + "org.camunda.bpm.engine.delegate.DelegateListener", + "net.sf.saxon.event.TeeOutputter", + "net.sf.saxon.lib.CollectionURIResolver", + "net.sf.saxon.type.SchemaException", + "net.sf.saxon.serialize.CDATAFilter", + "net.sf.saxon.lib.StringCollator", + "net.sf.saxon.expr.XPathContext", + "net.sf.saxon.lib.SourceResolver", + "net.sf.saxon.expr.MappingFunction", + "net.sf.saxon.expr.Container", + "net.sf.saxon.type.SchemaComponent", + "net.sf.saxon.om.Name11Checker", + "net.sf.saxon.expr.parser.ExpressionParser", + "org.camunda.bpm.engine.impl.history.event.HistoryEventType", + "net.sf.saxon.event.PipelineConfiguration", + "net.sf.saxon.tree.wrapper.SiblingCountingNode", + "org.camunda.bpm.engine.impl.pvm.process.HasDIBounds", + "net.sf.saxon.value.MemoClosure", + "net.sf.saxon.value.DecimalValue", + "org.camunda.bpm.engine.delegate.DelegateVariableInstance", + "net.sf.saxon.TypeCheckerEnvironment", + "net.sf.saxon.serialize.AttributeSorter", + "net.sf.saxon.regex.RegularExpression", + "net.sf.saxon.style.DataElement", + "net.sf.saxon.lib.ExtensionFunctionDefinition", + "net.sf.saxon.lib.SubstringMatcher", + "net.sf.saxon.lib.TraceListener", + "org.camunda.bpm.model.bpmn.instance.BaseElement", + "net.sf.saxon.style.Declaration", + "net.sf.saxon.value.BooleanValue", + "net.sf.saxon.expr.parser.CodeInjector", + "net.sf.saxon.tree.util.DocumentNumberAllocator", + "net.sf.saxon.pattern.PatternThatSetsCurrent", + "net.sf.saxon.expr.instruct.Debugger", + "org.openecomp.mso.bpmn.core.BaseTask", + "net.sf.saxon.pattern.Pattern", + "net.sf.saxon.expr.parser.PathMap$PathMapNode", + "org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity", + "net.sf.saxon.expr.instruct.SavedNamespaceContext", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity", + "org.camunda.bpm.engine.impl.variable.AbstractPersistentVariableStore", + "org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext", + "com.att.eelf.i18n.EELFResourceManager", + "org.camunda.bpm.engine.impl.core.delegate.CoreActivityBehavior", + "net.sf.saxon.om.NodeInfo", + "net.sf.saxon.event.NamespaceReducer", + "org.openecomp.mso.logger.MessageEnum", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState", + "org.camunda.bpm.engine.impl.db.HasDbReferences", + "org.camunda.bpm.engine.impl.tree.Collector", + "net.sf.saxon.expr.StringLiteral", + "org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration", + "net.sf.saxon.expr.ItemMappingFunction", + "net.sf.saxon.expr.instruct.UseAttributeSets", + "com.att.eelf.i18n.EELFResourceManager$1", + "org.camunda.bpm.engine.impl.core.instance.CoreExecution", + "net.sf.saxon.tree.iter.GroundedIterator", + "org.camunda.bpm.engine.variable.type.PrimitiveValueType" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(XQueryScriptTaskESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "com.att.eelf.i18n.EELFResourceManager", + "org.openecomp.mso.logger.MessageEnum", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.openecomp.mso.logger.MsoLogger", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFLogger$Level", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.bpmn.core.XQueryScriptTask", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "org.camunda.bpm.engine.impl.javax.el.Expression", + "org.camunda.bpm.engine.impl.javax.el.ValueExpression", + "org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope", + "org.camunda.bpm.engine.impl.core.instance.CoreExecution", + "org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity", + "org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState", + "org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntityVariableStore", + "org.camunda.bpm.engine.impl.persistence.entity.SuspensionState", + "org.camunda.bpm.engine.impl.context.Context", + "org.camunda.bpm.engine.ProcessEngineException", + "org.openecomp.mso.bpmn.core.BadInjectedFieldException", + "org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl", + "org.openecomp.mso.bpmn.core.MissingInjectedFieldException", + "net.sf.saxon.java.JavaPlatform", + "net.sf.saxon.Configuration", + "net.sf.saxon.tree.linked.NodeImpl", + "net.sf.saxon.style.StyleElement", + "net.sf.saxon.style.LiteralResultElement", + "net.sf.saxon.style.AbsentExtensionElement", + "org.camunda.bpm.engine.impl.core.variable.VariableMapImpl", + "net.sf.saxon.tree.iter.EmptyIterator", + "net.sf.saxon.tree.iter.EmptyAxisIterator", + "net.sf.saxon.style.XSLAnalyzeString", + "net.sf.saxon.tree.util.Navigator", + "net.sf.saxon.om.NamespaceBinding", + "net.sf.saxon.type.AnySimpleType", + "net.sf.saxon.pattern.NodeTest", + "net.sf.saxon.pattern.AnyNodeTest", + "net.sf.saxon.type.AnyItemType", + "net.sf.saxon.type.Type", + "net.sf.saxon.z.IntHashMap", + "net.sf.saxon.type.AnyType", + "net.sf.saxon.type.Untyped", + "net.sf.saxon.type.ErrorType", + "net.sf.saxon.type.BuiltInType", + "net.sf.saxon.type.BuiltInAtomicType", + "net.sf.saxon.value.BooleanValue" + ); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsESTest.java new file mode 100644 index 0000000000..fec405ef96 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsESTest.java @@ -0,0 +1,165 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:28:11 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core.json; + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.util.Iterator; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.json.JSONObject; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class JsonUtilsESTest extends JsonUtilsESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + String string0 = JsonUtils.updJsonValue((String) null, "#", "#"); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + String string0 = JsonUtils.getJsonValueForKey((JSONObject) null, "LPZc4`q5w]IQMS.^'3"); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + String string0 = JsonUtils.getJsonParamValue("", ":bnv,&jl3bK", ""); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + String string0 = JsonUtils.getJsonParamValue("", "", "tuw[9j$Sz"); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + String string0 = JsonUtils.getJsonValue((String) null, ""); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + String string0 = JsonUtils.addJsonValue((String) null, (String) null, (String) null); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + String string0 = JsonUtils.xml2json("", (Boolean) null); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + String string0 = JsonUtils.xml2json((String) null); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + String string0 = JsonUtils.updJsonValue("tV a^wGCAwX", "tV a^wGCAwX", "tV a^wGCAwX"); + assertEquals("tV a^wGCAwX", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + String string0 = JsonUtils.updJsonValue("", "", ""); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + Boolean boolean0 = Boolean.TRUE; + String string0 = JsonUtils.json2xml("", boolean0); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + String string0 = JsonUtils.getJsonValueForKey("java.io.StringWriter@0000000003", "#"); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + Iterator iterator0 = JsonUtils.getJsonIterator((String) null); + assertNull(iterator0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + String string0 = JsonUtils.delJsonValue("java.io.StringWriter@0000000003", "java.io.StringWriter@0000000003"); + assertNotNull(string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + String string0 = JsonUtils.delJsonValue("", (String) null); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + Boolean boolean0 = new Boolean(true); + String string0 = JsonUtils.xml2json("Y~N~%]", boolean0); + assertNotNull(string0); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + String string0 = JsonUtils.delJsonValue((String) null, "/Y"); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + String string0 = JsonUtils.updJsonValue((String) null, (String) null, "/Y"); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + String string0 = JsonUtils.addJsonValue("java.io.StringWriter@0000000006", "/Y", (String) null); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + Boolean boolean0 = JsonUtils.jsonValueExists("getJsonValueForKey(): found value=", "/Y"); + String string0 = JsonUtils.xml2json("getJsonValueForKey(): found value=", boolean0); + assertNotNull(string0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + String string0 = JsonUtils.json2xml(")?Fx+Bu:)1&$EZEmzoV"); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + String string0 = JsonUtils.xml2json("java.io.StringWriter@0000000006"); + assertNotNull(string0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + Iterator iterator0 = JsonUtils.getJsonIterator("{+%2:*}4"); + assertNotNull(iterator0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + JsonUtils jsonUtils0 = new JsonUtils(); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsESTestscaffolding.java new file mode 100644 index 0000000000..6d05db0b80 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/json/JsonUtilsESTestscaffolding.java @@ -0,0 +1,120 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:28:11 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core.json; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class JsonUtilsESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.json.JsonUtils"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(JsonUtilsESTestscaffolding.class.getClassLoader() , + "org.json.JSONObject$Null", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "com.att.eelf.configuration.EELFLogger", + "org.json.JSONException", + "org.openecomp.mso.bpmn.core.xml.XmlTool", + "org.json.JSONObject", + "org.json.XML", + "com.att.eelf.configuration.SLF4jWrapper", + "com.att.eelf.i18n.EELFResourceManager", + "org.openecomp.mso.logger.MsoLogger", + "org.openecomp.mso.logger.MessageEnum", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "org.json.JSONTokener", + "org.openecomp.mso.bpmn.core.json.JsonUtils", + "com.att.eelf.configuration.EELFManager", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.configuration.EELFLogger$Level", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "com.att.eelf.i18n.EELFResourceManager$1", + "org.json.JSONArray", + "org.json.XMLTokener" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(JsonUtilsESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.bpmn.core.xml.XmlTool", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.json.JSONObject", + "org.json.XML", + "org.openecomp.mso.logger.MsoLogger", + "com.att.eelf.i18n.EELFResourceManager", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFLogger$Level", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.logger.MessageEnum", + "org.openecomp.mso.bpmn.core.json.JsonUtils", + "org.json.JSONException", + "org.json.XMLTokener" + ); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/mybatis/URNMappingESTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/mybatis/URNMappingESTest.java new file mode 100644 index 0000000000..9c17caeaf4 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/mybatis/URNMappingESTest.java @@ -0,0 +1,114 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:33:04 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core.mybatis; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class URNMappingESTest extends URNMappingESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + String string0 = URNMapping.createIdentifierFromURN("!`OYz|WztoeK|A&=&M"); + assertEquals("URN_OYz_WztoeK_A_M", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + URNMapping uRNMapping0 = new URNMapping(); + uRNMapping0.setValue("=F'A%"); + String string0 = uRNMapping0.getValue(); + assertEquals("=F'A%", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + URNMapping uRNMapping0 = new URNMapping(); + uRNMapping0.setValue(""); + String string0 = uRNMapping0.getValue(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + URNMapping uRNMapping0 = new URNMapping(); + uRNMapping0.setRev(""); + String string0 = uRNMapping0.getRev(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + URNMapping uRNMapping0 = new URNMapping(); + uRNMapping0.setName(""); + String string0 = uRNMapping0.getName(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + // Undeclared exception! + try { + URNMapping.createIdentifierFromURN((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.bpmn.core.mybatis.URNMapping", e); + } + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + String string0 = URNMapping.createIdentifierFromURN("mfJ\"%euO;@S_Xm"); + assertEquals("URN_mfJ_euO_S_Xm", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + URNMapping uRNMapping0 = new URNMapping(); + uRNMapping0.setRev(":pMWjfl,zq_IA"); + String string0 = uRNMapping0.getRev(); + assertEquals(":pMWjfl,zq_IA", string0); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + URNMapping uRNMapping0 = new URNMapping(); + String string0 = uRNMapping0.getName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + URNMapping uRNMapping0 = new URNMapping(); + String string0 = uRNMapping0.getRev(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + URNMapping uRNMapping0 = new URNMapping(); + String string0 = uRNMapping0.getValue(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + URNMapping uRNMapping0 = new URNMapping(); + uRNMapping0.setName("c<"); + String string0 = uRNMapping0.getName(); + assertEquals("c<", string0); + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/mybatis/URNMappingESTestscaffolding.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/mybatis/URNMappingESTestscaffolding.java new file mode 100644 index 0000000000..183ea84b58 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/mybatis/URNMappingESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:33:04 GMT 2016 + */ + +package org.openecomp.mso.bpmn.core.mybatis; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class URNMappingESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.bpmn.core.mybatis.URNMapping"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(URNMappingESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.bpmn.core.mybatis.URNMapping" + ); + } + + private static void resetClasses() { + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/resources/BaseTaskTest.bpmn b/bpmn/MSOCoreBPMN/src/test/resources/BaseTaskTest.bpmn new file mode 100644 index 0000000000..d94a0c5b21 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/resources/BaseTaskTest.bpmn @@ -0,0 +1,79 @@ + + + + + SequenceFlow_1 + + + + + Hello World + + + ${firstName} + + + ${undefinedVariable} + + + 42 + + + ${age} + + + ${undefinedVariable} + + + 123456789 + + + ${lastVisit} + + + ${undefinedVariable} + + + goodVariable + + + bad Variable + + + SequenceFlow_1 + SequenceFlow_2 + + + + + SequenceFlow_2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/test/resources/camunda.cfg.xml b/bpmn/MSOCoreBPMN/src/test/resources/camunda.cfg.xml new file mode 100644 index 0000000000..4858ea0c0e --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/resources/camunda.cfg.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOCoreBPMN/src/test/resources/logback-test.xml b/bpmn/MSOCoreBPMN/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..92876fcb19 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/resources/logback-test.xml @@ -0,0 +1,48 @@ + + + + + + + + %d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.properties b/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.properties new file mode 100644 index 0000000000..d329dbb207 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.properties @@ -0,0 +1,22 @@ +### +# ============LICENSE_START======================================================= +# ECOMP MSO +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +URNMapping.FileSystemLoading.Enabled=true +testKey=testValue diff --git a/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.urn.properties b/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.urn.properties new file mode 100644 index 0000000000..7fa587311a --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/resources/mso.bpmn.urn.properties @@ -0,0 +1,21 @@ +### +# ============LICENSE_START======================================================= +# ECOMP MSO +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +log.debug.TestTask=true diff --git a/bpmn/MSOCoreBPMN/src/test/resources/request.json b/bpmn/MSOCoreBPMN/src/test/resources/request.json new file mode 100644 index 0000000000..bdca336a0b --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/resources/request.json @@ -0,0 +1,28 @@ +{ + "variables": { + "bpmnRequest": { + "value": "\n \n d00eb185-b1d7-429e-aca3-42a61b459535\n Layer3ServiceActivateRequest\n OMX\n http://localhost:8080/simulada/CSI/SendManagedNetworkStatusNotification\n 19630501\n 1\n \n \n SDN-ETHERNET-INTERNET\n AA01|VLXM|003717||SW_INTERNET\n TEST_4306301\n \n \n \n \n 10\n Mbps\n ds\n \n \n none\n \n primary\n \n \n 1\n 32.10.30.116\n 32\n \n \n \n \n 1\n 2507:0CB4:85A5:0030:0000:0000:0000:0010\n 48\n \n \n \n Y\n Y\n Y\n Y\n \n \n Y\n N\n \n \n Y\n Y\n \n \n \n \n \n\n", + "type": "String" + }, + "host": { + "value": "localhost", + "type": "String" + }, + "att-mso-schema-version": { + "value": "v1", + "type": "String" + }, + "att-mso-request-id": { + "value": "d00eb185-b1d7-429e-aca3-42a61b459535", + "type": "String" + }, + "att-mso-service-instance-id": { + "value": "AA01|VLXM|003717||SW_INTERNET", + "type": "String" + }, + "att-mso-service-request-timeout": { + "value": "180", + "type": "String" + } + } +} -- cgit 1.2.3-korg