summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-08-30 09:37:29 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-08-31 19:23:41 +0100
commitf32508381ce0b555fc14978cbaa458aa4e2d91c5 (patch)
tree1cab66e5372b6467f288ae1351ce836e4eba2d03 /plugins
parent052038c7a7e0b385462b3b653b7d06094d472df3 (diff)
Use parameter service in apex
Switch parameter handling in apex to use the ONAP PF common parameter service Change-Id: Id318d19c726b18b1a69c630fa81ca7d695355e9c Issue-ID: POLICY-954 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java47
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java5
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java9
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/default-jgroups-tcp.xml76
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml (renamed from plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml.sample)35
-rw-r--r--plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java61
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java54
-rw-r--r--plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java4
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java21
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java24
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java22
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java22
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java30
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java34
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java159
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java26
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java28
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java24
-rw-r--r--plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java19
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java8
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java16
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java87
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java109
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java13
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java12
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java2
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java34
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java17
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java5
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java5
30 files changed, 664 insertions, 344 deletions
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
index c999c95f0..c3c137349 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-hazelcast/src/test/java/org/onap/policy/apex/plugins/context/distribution/hazelcast/HazelcastContextDistributorTest.java
@@ -22,13 +22,19 @@ package org.onap.policy.apex.plugins.context.distribution.hazelcast;
import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate;
import org.onap.policy.apex.context.test.distribution.ContextInstantiation;
import org.onap.policy.apex.context.test.distribution.ContextUpdate;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -37,13 +43,45 @@ public class HazelcastContextDistributorTest {
// Logger for this class
private static final XLogger logger = XLoggerFactory.getXLogger(HazelcastContextDistributorTest.class);
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+ @Before
+ public void beforeTest() {
+ contextParameters = new ContextParameters();
+
+ contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
+ contextParameters.getDistributorParameters().setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
+ contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+
+ contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
@Test
public void testContextAlbumUpdateHazelcast() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextAlbumUpdateHazelcast test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS);
new ContextAlbumUpdate().testContextAlbumUpdate();
logger.debug("Ran testContextAlbumUpdateHazelcast test");
@@ -53,8 +91,6 @@ public class HazelcastContextDistributorTest {
public void testContextInstantiationHazelcast() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextInstantiationHazelcast test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS);
new ContextInstantiation().testContextInstantiation();
logger.debug("Ran testContextInstantiationHazelcast test");
@@ -64,11 +100,8 @@ public class HazelcastContextDistributorTest {
public void testContextUpdateHazelcast() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextUpdateHazelcast test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(HAZEL_CAST_PLUGIN_CLASS);
new ContextUpdate().testContextUpdate();
logger.debug("Ran testContextUpdateHazelcast test");
}
-
}
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java
index 9361d0b4c..d6a04dd7c 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributor.java
@@ -25,8 +25,9 @@ import java.util.Map;
import org.infinispan.Cache;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.impl.distribution.AbstractDistributor;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -71,7 +72,7 @@ public class InfinispanContextDistributor extends AbstractDistributor {
if (infinispanManager == null) {
// Get the parameters from the parameter service
final InfinispanDistributorParameters parameters =
- ParameterService.getParameters(InfinispanDistributorParameters.class);
+ ParameterService.get(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
LOGGER.debug("initiating Infinispan with the parameters: " + parameters);
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java
index d73955224..539a732cf 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanDistributorParameters.java
@@ -21,7 +21,6 @@
package org.onap.policy.apex.plugins.context.distribution.infinispan;
import org.onap.policy.apex.context.parameters.DistributorParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
/**
* Distributor parameters for the Infinspan Distributor.
@@ -30,9 +29,9 @@ import org.onap.policy.apex.model.basicmodel.service.ParameterService;
*/
public class InfinispanDistributorParameters extends DistributorParameters {
// @formatter:off
-
+
/** The default Infinispan configuration file location. */
- public static final String DEFAULT_INFINISPAN_DISTRIBUTION_CONFIG_FILE = "/infinispan/infinispan.xml";
+ public static final String DEFAULT_INFINISPAN_DISTRIBUTION_CONFIG_FILE = "infinispan/infinispan.xml";
/** The default Infinispan jgroups configuration file location. */
public static final String DEFAULT_INFINISPAN_DISTRIBUTION_JGROUPS_FILE = null;
@@ -54,9 +53,7 @@ public class InfinispanDistributorParameters extends DistributorParameters {
* The Constructor.
*/
public InfinispanDistributorParameters() {
- super(InfinispanDistributorParameters.class.getCanonicalName());
- ParameterService.registerParameters(InfinispanDistributorParameters.class, this);
- ParameterService.registerParameters(DistributorParameters.class, this);
+ super();
}
/**
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/default-jgroups-tcp.xml b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/default-jgroups-tcp.xml
new file mode 100644
index 000000000..028cf1df6
--- /dev/null
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/default-jgroups-tcp.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2016-2018 Ericsson. 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.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<config xmlns="urn:org:jgroups"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.0.xsd">
+ <TCP bind_addr="${jgroups.tcp.address:127.0.0.1}"
+ bind_port="${jgroups.tcp.port:7800}"
+ enable_diagnostics="false"
+ thread_naming_pattern="pl"
+ send_buf_size="640k"
+ sock_conn_timeout="300"
+ bundler_type="no-bundler"
+
+ thread_pool.min_threads="${jgroups.thread_pool.min_threads:0}"
+ thread_pool.max_threads="${jgroups.thread_pool.max_threads:200}"
+ thread_pool.keep_alive_time="60000"
+ />
+ <MPING bind_addr="${jgroups.tcp.address:127.0.0.1}"
+ mcast_addr="${jgroups.mping.mcast_addr:228.2.4.6}"
+ mcast_port="${jgroups.mping.mcast_port:43366}"
+ ip_ttl="${jgroups.udp.ip_ttl:2}"
+ />
+ <MERGE3 min_interval="10000"
+ max_interval="30000"
+ />
+ <FD_SOCK />
+ <FD_ALL timeout="60000"
+ interval="15000"
+ timeout_check_interval="5000"
+ />
+ <VERIFY_SUSPECT timeout="5000" />
+ <pbcast.NAKACK2 use_mcast_xmit="false"
+ xmit_interval="100"
+ xmit_table_num_rows="50"
+ xmit_table_msgs_per_row="1024"
+ xmit_table_max_compaction_time="30000"
+ resend_last_seqno="true"
+ />
+ <UNICAST3 xmit_interval="100"
+ xmit_table_num_rows="50"
+ xmit_table_msgs_per_row="1024"
+ xmit_table_max_compaction_time="30000"
+ conn_expiry_timeout="0"
+ />
+ <pbcast.STABLE stability_delay="500"
+ desired_avg_gossip="5000"
+ max_bytes="1M"
+ />
+ <pbcast.GMS print_local_addr="false"
+ install_view_locally_first="true"
+ join_timeout="${jgroups.join_timeout:5000}"
+ />
+ <MFC max_credits="2m"
+ min_threshold="0.40"
+ />
+ <FRAG3/>
+</config>
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml.sample b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml
index 302eac935..5b416f50d 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml.sample
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/main/resources/infinispan/infinispan.xml
@@ -19,22 +19,23 @@
============LICENSE_END=========================================================
-->
-<infinispan xmlns="urn:infinispan:config:8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infinispan:config:8.0 http://infinispan.org/schemas/infinispan-config-8.0.xsd">
- <jgroups>
- <stack-file name="tcpStack" path="default-configs/default-jgroups-tcp.xml" />
- </jgroups>
+<infinispan xmlns="urn:infinispan:config:8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:infinispan:config:8.0 http://infinispan.org/schemas/infinispan-config-8.0.xsd">
+ <jgroups>
+ <stack-file name="external-file" path="infinispan/default-jgroups-tcp.xml" />
+ </jgroups>
- <cache-container name="ApexCacheContainer" default-cache="TestContext_0.0.1">
- <transport cluster="apexCluster" stack="tcpStack" />
- <jmx />
- <replicated-cache name="LargeContextMap_0.0.1" mode="SYNC" statistics="true">
- <state-transfer enabled="true" />
- </replicated-cache>
- <replicated-cache name="LongSameTypeContextMap_0.0.1" mode="SYNC" statistics="true">
- <state-transfer enabled="true" />
- </replicated-cache>
- <replicated-cache name="TestContext_0.0.1" mode="SYNC">
- <state-transfer enabled="true" />
- </replicated-cache>
- </cache-container>
+ <cache-container name="ApexCacheContainer" default-cache="TestContext_0.0.1">
+ <transport cluster="apexCluster" stack="external-file" />
+ <jmx />
+ <replicated-cache name="LargeContextMap_0.0.1" mode="SYNC" statistics="true">
+ <state-transfer enabled="true" />
+ </replicated-cache>
+ <replicated-cache name="LongSameTypeContextMap_0.0.1" mode="SYNC" statistics="true">
+ <state-transfer enabled="true" />
+ </replicated-cache>
+ <replicated-cache name="TestContext_0.0.1" mode="SYNC">
+ <state-transfer enabled="true" />
+ </replicated-cache>
+ </cache-container>
</infinispan>
diff --git a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
index 34fa7d439..862dcef83 100644
--- a/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
+++ b/plugins/plugins-context/plugins-context-distribution/plugins-context-distribution-infinispan/src/test/java/org/onap/policy/apex/plugins/context/distribution/infinispan/InfinispanContextDistributorTest.java
@@ -21,14 +21,20 @@ package org.onap.policy.apex.plugins.context.distribution.infinispan;
import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.context.test.distribution.ContextAlbumUpdate;
import org.onap.policy.apex.context.test.distribution.ContextInstantiation;
import org.onap.policy.apex.context.test.distribution.ContextUpdate;
import org.onap.policy.apex.context.test.distribution.SequentialContextInstantiation;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -37,14 +43,47 @@ public class InfinispanContextDistributorTest {
private static final String PLUGIN_CLASS = InfinispanContextDistributor.class.getCanonicalName();
+ private SchemaParameters schemaParameters;
+ private ContextParameters contextParameters;
+
+ @Before
+ public void beforeTest() {
+ contextParameters = new ContextParameters();
+
+ contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
+ InfinispanDistributorParameters inifinispanDistributorParameters = new InfinispanDistributorParameters();
+ inifinispanDistributorParameters.setName(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ inifinispanDistributorParameters.setPluginClass(PLUGIN_CLASS);
+ contextParameters.setDistributorParameters(inifinispanDistributorParameters);
+ contextParameters.getLockManagerParameters().setName(ContextParameterConstants.LOCKING_GROUP_NAME);
+ contextParameters.getPersistorParameters().setName(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+
+ ParameterService.register(contextParameters);
+ ParameterService.register(contextParameters.getDistributorParameters());
+ ParameterService.register(contextParameters.getLockManagerParameters());
+ ParameterService.register(contextParameters.getPersistorParameters());
+
+ schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
+
+ ParameterService.register(schemaParameters);
+ }
+
+ @After
+ public void afterTest() {
+ ParameterService.deregister(schemaParameters);
+
+ ParameterService.deregister(contextParameters.getDistributorParameters());
+ ParameterService.deregister(contextParameters.getLockManagerParameters());
+ ParameterService.deregister(contextParameters.getPersistorParameters());
+ ParameterService.deregister(contextParameters);
+ }
+
@Test
public void testContextAlbumUpdateInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextAlbumUpdateInfinispan test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
- new InfinispanDistributorParameters();
-
new ContextAlbumUpdate().testContextAlbumUpdate();
logger.debug("Ran testContextAlbumUpdateInfinispan test");
@@ -54,10 +93,6 @@ public class InfinispanContextDistributorTest {
public void testContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextInstantiationInfinispan test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
- new InfinispanDistributorParameters();
-
new ContextInstantiation().testContextInstantiation();
logger.debug("Ran testContextInstantiationInfinispan test");
@@ -67,10 +102,6 @@ public class InfinispanContextDistributorTest {
public void testContextUpdateInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testContextUpdateInfinispan test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
- new InfinispanDistributorParameters();
-
new ContextUpdate().testContextUpdate();
logger.debug("Ran testContextUpdateInfinispan test");
@@ -80,14 +111,8 @@ public class InfinispanContextDistributorTest {
public void testSequentialContextInstantiationInfinispan() throws ApexModelException, IOException, ApexException {
logger.debug("Running testSequentialContextInstantiationInfinispan test . . .");
- final ContextParameters contextParameters = new ContextParameters();
- contextParameters.getDistributorParameters().setPluginClass(PLUGIN_CLASS);
- new InfinispanDistributorParameters();
-
new SequentialContextInstantiation().testSequentialContextInstantiation();
logger.debug("Ran testSequentialContextInstantiationInfinispan test");
}
-
-
}
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java
index 477a010fa..d2976d799 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManager.java
@@ -33,13 +33,13 @@ import org.apache.zookeeper.CreateMode;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.impl.locking.AbstractLockManager;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class CuratorLockManager manages the Curator interface towards Zookeeper for administering
- * the Apex Context Album instance locks..
+ * The Class CuratorLockManager manages the Curator interface towards Zookeeper for administering the Apex Context Album
+ * instance locks..
*/
public class CuratorLockManager extends AbstractLockManager {
// Logger for this class
@@ -65,8 +65,8 @@ public class CuratorLockManager extends AbstractLockManager {
/*
* (non-Javadoc)
*
- * @see org.onap.policy.apex.context.impl.locking.AbstractLockManager#init(org.onap.policy.apex.
- * model. basicmodel.concepts.AxArtifactKey)
+ * @see org.onap.policy.apex.context.impl.locking.AbstractLockManager#init(org.onap.policy.apex. model.
+ * basicmodel.concepts.AxArtifactKey)
*/
@Override
public void init(final AxArtifactKey key) throws ContextException {
@@ -75,23 +75,22 @@ public class CuratorLockManager extends AbstractLockManager {
super.init(key);
// Get the lock manager parameters
- final CuratorLockManagerParameters lockParameters =
- ParameterService.getParameters(CuratorLockManagerParameters.class);
+ final CuratorLockManagerParameters lockParameters = ParameterService
+ .get(CuratorLockManagerParameters.class.getSimpleName());
// Check if the curator address has been set
curatorZookeeperAddress = lockParameters.getZookeeperAddress();
if (curatorZookeeperAddress == null || curatorZookeeperAddress.trim().length() == 0) {
- LOGGER.warn(
- "could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
+ LOGGER.warn("could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
throw new ContextException(
- "could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
+ "could not set up Curator locking, check if the curator Zookeeper address parameter is set correctly");
}
// Set up the curator framework we'll use
curatorFramework = CuratorFrameworkFactory.builder().connectString(curatorZookeeperAddress)
- .retryPolicy(new ExponentialBackoffRetry(lockParameters.getZookeeperConnectSleepTime(),
- lockParameters.getZookeeperContextRetries()))
- .build();
+ .retryPolicy(new ExponentialBackoffRetry(lockParameters.getZookeeperConnectSleepTime(),
+ lockParameters.getZookeeperContextRetries()))
+ .build();
// Listen for changes on the Curator connection
curatorFramework.getConnectionStateListenable().addListener(new CuratorManagerConnectionStateListener());
@@ -102,22 +101,22 @@ public class CuratorLockManager extends AbstractLockManager {
// Wait for the connection to be made
try {
curatorFramework.blockUntilConnected(
- lockParameters.getZookeeperConnectSleepTime() * lockParameters.getZookeeperContextRetries(),
- TimeUnit.MILLISECONDS);
+ lockParameters.getZookeeperConnectSleepTime() * lockParameters.getZookeeperContextRetries(),
+ TimeUnit.MILLISECONDS);
} catch (final InterruptedException e) {
// restore the interrupt status
Thread.currentThread().interrupt();
- LOGGER.warn("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", wait for connection timed out");
- throw new ContextException("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", wait for connection timed out");
+ String message = "error connecting to Zookeeper server at \"" + curatorZookeeperAddress
+ + "\", wait for connection timed out";
+ LOGGER.warn(message);
+ throw new ContextException(message);
}
if (!curatorFramework.getZookeeperClient().isConnected()) {
- LOGGER.warn("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", see error log for details");
- throw new ContextException("could not connect to Zookeeper server at \"" + curatorZookeeperAddress
- + "\", see error log for details");
+ String message = "could not connect to Zookeeper server at \"" + curatorZookeeperAddress
+ + "\", see error log for details";
+ LOGGER.warn(message);
+ throw new ContextException(message);
}
// We'll use Ephemeral nodes for locks on the Zookeeper server
@@ -129,8 +128,7 @@ public class CuratorLockManager extends AbstractLockManager {
/*
* (non-Javadoc)
*
- * @see
- * org.onap.policy.apex.core.context.impl.locking.AbstractLockManager#getReentrantReadWriteLock(
+ * @see org.onap.policy.apex.core.context.impl.locking.AbstractLockManager#getReentrantReadWriteLock(
* java.lang.String)
*/
@Override
@@ -140,7 +138,7 @@ public class CuratorLockManager extends AbstractLockManager {
return new CuratorReentrantReadWriteLock(curatorFramework, "/" + lockId);
} else {
throw new ContextException("creation of lock using Zookeeper server at \"" + curatorZookeeperAddress
- + "\", failed, see error log for details");
+ + "\", failed, see error log for details");
}
}
@@ -176,8 +174,8 @@ public class CuratorLockManager extends AbstractLockManager {
return;
}
- LOGGER.info("curator state of client \"" + curatorFramework + "\" connected to \"" + curatorZookeeperAddress
- + "\" changed to " + newState);
+ LOGGER.info("curator state of client \"{}\" connected to \"{}\" changed to {}", curatorFramework,
+ curatorZookeeperAddress, newState);
if (newState != ConnectionState.CONNECTED) {
shutdown();
diff --git a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java
index 9e8d5d2af..ac936d436 100644
--- a/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java
+++ b/plugins/plugins-context/plugins-context-locking/plugins-context-locking-curator/src/main/java/org/onap/policy/apex/plugins/context/locking/curator/CuratorLockManagerParameters.java
@@ -21,7 +21,6 @@
package org.onap.policy.apex.plugins.context.locking.curator;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
/**
* Bean class for Curator locking parameters.
@@ -49,8 +48,7 @@ public class CuratorLockManagerParameters extends LockManagerParameters {
* The Constructor.
*/
public CuratorLockManagerParameters() {
- super(CuratorLockManagerParameters.class.getCanonicalName());
- ParameterService.registerParameters(CuratorLockManagerParameters.class, this);
+ super();
}
/**
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java
index 65eef39c2..5198e82e0 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaAAI.java
@@ -26,10 +26,12 @@ import java.io.IOException;
import org.apache.avro.generic.GenericData.Array;
import org.apache.avro.generic.GenericRecord;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -37,6 +39,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -51,15 +54,29 @@ public class TestAvroSchemaAAI {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
+
aaiInventoryResponseSchema =
TextFileUtils.getTextFileAsString("src/test/resources/avsc/AAIInventoryResponseItemType.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testAAIResponsePolicy() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", aaiInventoryResponseSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", aaiInventoryResponseSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java
index 21fab66d9..b72b2ca10 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaArray.java
@@ -25,10 +25,12 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericData.Array;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -36,6 +38,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -51,15 +54,28 @@ public class TestAvroSchemaArray {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
longArraySchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/ArrayExampleLong.avsc");
addressArraySchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/ArrayExampleAddress.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testArrayInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", addressArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -77,7 +93,7 @@ public class TestAvroSchemaArray {
@Test
public void testLongArrayUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "Avro", longArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", longArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -89,7 +105,7 @@ public class TestAvroSchemaArray {
@Test
public void testAddressArrayUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "Avro", addressArraySchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", addressArraySchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java
index ae19cd31a..47a5c969c 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaEnum.java
@@ -26,10 +26,12 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import org.apache.avro.generic.GenericData.EnumSymbol;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -37,6 +39,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -51,14 +54,27 @@ public class TestAvroSchemaEnum {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
enumSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/EnumSchema.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testEnumInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", enumSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", enumSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -73,7 +89,7 @@ public class TestAvroSchemaEnum {
@Test
public void testEnumUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "Avro", enumSchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", enumSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java
index 41f622115..6d709645f 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaFixed.java
@@ -27,10 +27,12 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import org.apache.avro.generic.GenericData.Fixed;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -38,6 +40,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -52,14 +55,27 @@ public class TestAvroSchemaFixed {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
fixedSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/FixedSchema.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testFixedInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", fixedSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", fixedSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -82,7 +98,7 @@ public class TestAvroSchemaFixed {
@Test
public void testFixedUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "Avro", fixedSchema);
+ new AxContextSchema(new AxArtifactKey("AvroArray", "0.0.1"), "AVRO", fixedSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java
index 1e1a0bee0..9cb027acf 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperBadSchemas.java
@@ -23,15 +23,18 @@ package org.onap.policy.apex.plugins.context.schema.avro;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -45,12 +48,25 @@ public class TestAvroSchemaHelperBadSchemas {
public void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
+ }
+
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@Test
public void badSchemaTest() {
- final AxContextSchema avroBadSchema0 = new AxContextSchema(new AxArtifactKey("AvroBad0", "0.0.1"), "Avro", "}");
+ final AxContextSchema avroBadSchema0 = new AxContextSchema(new AxArtifactKey("AvroBad0", "0.0.1"), "AVRO", "}");
schemas.getSchemasMap().put(avroBadSchema0.getKey(), avroBadSchema0);
try {
@@ -61,7 +77,7 @@ public class TestAvroSchemaHelperBadSchemas {
.startsWith("AvroTest:0.0.1: avro context schema \"AvroBad0:0.0.1\" schema is invalid"));
}
- final AxContextSchema avroBadSchema1 = new AxContextSchema(new AxArtifactKey("AvroBad1", "0.0.1"), "Avro", "");
+ final AxContextSchema avroBadSchema1 = new AxContextSchema(new AxArtifactKey("AvroBad1", "0.0.1"), "AVRO", "");
schemas.getSchemasMap().put(avroBadSchema1.getKey(), avroBadSchema1);
try {
@@ -73,7 +89,7 @@ public class TestAvroSchemaHelperBadSchemas {
}
final AxContextSchema avroBadSchema2 =
- new AxContextSchema(new AxArtifactKey("AvroBad2", "0.0.1"), "Avro", "{}");
+ new AxContextSchema(new AxArtifactKey("AvroBad2", "0.0.1"), "AVRO", "{}");
schemas.getSchemasMap().put(avroBadSchema2.getKey(), avroBadSchema2);
try {
@@ -85,7 +101,7 @@ public class TestAvroSchemaHelperBadSchemas {
}
final AxContextSchema avroBadSchema3 =
- new AxContextSchema(new AxArtifactKey("AvroBad3", "0.0.1"), "Avro", "{zooby}");
+ new AxContextSchema(new AxArtifactKey("AvroBad3", "0.0.1"), "AVRO", "{zooby}");
schemas.getSchemasMap().put(avroBadSchema3.getKey(), avroBadSchema3);
try {
@@ -97,7 +113,7 @@ public class TestAvroSchemaHelperBadSchemas {
}
final AxContextSchema avroBadSchema4 =
- new AxContextSchema(new AxArtifactKey("AvroBad4", "0.0.1"), "Avro", "{\"zooby\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBad4", "0.0.1"), "AVRO", "{\"zooby\"}");
schemas.getSchemasMap().put(avroBadSchema4.getKey(), avroBadSchema4);
try {
@@ -109,7 +125,7 @@ public class TestAvroSchemaHelperBadSchemas {
}
final AxContextSchema avroBadSchema5 =
- new AxContextSchema(new AxArtifactKey("AvroBad5", "0.0.1"), "Avro", "{\"type\": \"zooby\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBad5", "0.0.1"), "AVRO", "{\"type\": \"zooby\"}");
schemas.getSchemasMap().put(avroBadSchema5.getKey(), avroBadSchema5);
try {
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java
index a710a2376..1f078879d 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperMarshal.java
@@ -24,16 +24,19 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -47,13 +50,26 @@ public class TestAvroSchemaHelperMarshal {
public void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
+ }
+
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
}
@Test
public void testNullMarshal() {
final AxContextSchema avroNullSchema =
- new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "Avro", "{\"type\": \"null\"}");
+ new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO", "{\"type\": \"null\"}");
schemas.getSchemasMap().put(avroNullSchema.getKey(), avroNullSchema);
final SchemaHelper schemaHelper0 =
@@ -67,7 +83,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testBooleanMarshal() {
final AxContextSchema avroBooleanSchema =
- new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "Avro", "{\"type\": \"boolean\"}");
+ new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO", "{\"type\": \"boolean\"}");
schemas.getSchemasMap().put(avroBooleanSchema.getKey(), avroBooleanSchema);
final SchemaHelper schemaHelper1 =
@@ -98,7 +114,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testIntMarshal() {
final AxContextSchema avroIntSchema =
- new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "Avro", "{\"type\": \"int\"}");
+ new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO", "{\"type\": \"int\"}");
schemas.getSchemasMap().put(avroIntSchema.getKey(), avroIntSchema);
final SchemaHelper schemaHelper2 =
@@ -130,7 +146,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testLongMarshal() {
final AxContextSchema avroLongSchema =
- new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "Avro", "{\"type\": \"long\"}");
+ new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO", "{\"type\": \"long\"}");
schemas.getSchemasMap().put(avroLongSchema.getKey(), avroLongSchema);
final SchemaHelper schemaHelper3 =
@@ -160,7 +176,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testFloatMarshal() {
final AxContextSchema avroFloatSchema =
- new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "Avro", "{\"type\": \"float\"}");
+ new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO", "{\"type\": \"float\"}");
schemas.getSchemasMap().put(avroFloatSchema.getKey(), avroFloatSchema);
final SchemaHelper schemaHelper4 =
@@ -195,7 +211,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testDoubleMarshal() {
final AxContextSchema avroDoubleSchema =
- new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "Avro", "{\"type\": \"double\"}");
+ new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO", "{\"type\": \"double\"}");
schemas.getSchemasMap().put(avroDoubleSchema.getKey(), avroDoubleSchema);
final SchemaHelper schemaHelper5 =
@@ -229,7 +245,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testStringMarshal() {
final AxContextSchema avroStringSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "Avro", "{\"type\": \"string\"}");
+ new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"string\"}");
schemas.getSchemasMap().put(avroStringSchema.getKey(), avroStringSchema);
final SchemaHelper schemaHelper7 =
@@ -257,7 +273,7 @@ public class TestAvroSchemaHelperMarshal {
@Test
public void testBytesMarshal() {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "Avro", "{\"type\": \"bytes\"}");
+ new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO", "{\"type\": \"bytes\"}");
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java
index 725ebb221..db7edd673 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaHelperUnmarshal.java
@@ -25,16 +25,19 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.apache.avro.util.Utf8;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -48,24 +51,37 @@ public class TestAvroSchemaHelperUnmarshal {
public void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
}
- // @Test
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
+ @Test
public void testNullUnmarshal() {
- final AxContextSchema avroNullSchema =
- new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "Avro", "{\"type\": \"null\"}");
+ final AxContextSchema avroNullSchema = new AxContextSchema(new AxArtifactKey("AvroNull", "0.0.1"), "AVRO",
+ "{\"type\": \"null\"}");
schemas.getSchemasMap().put(avroNullSchema.getKey(), avroNullSchema);
- final SchemaHelper schemaHelper0 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroNullSchema.getKey());
+ final SchemaHelper schemaHelper0 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroNullSchema.getKey());
try {
schemaHelper0.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
assertEquals("AvroTest:0.0.1: could not create an instance, schema class for the schema is null",
- e.getMessage());
+ e.getMessage());
}
assertEquals(null, schemaHelper0.unmarshal("null"));
@@ -74,28 +90,26 @@ public class TestAvroSchemaHelperUnmarshal {
schemaHelper0.unmarshal("123");
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: object \"123\" Avro unmarshalling failed: Expected null. Got VALUE_NUMBER_INT",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: object \"123\" Avro unmarshalling failed: Expected null. Got VALUE_NUMBER_INT",
+ e.getMessage());
}
}
- // @Test
+ @Test
public void testBooleanUnmarshal() {
- final AxContextSchema avroBooleanSchema =
- new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "Avro", "{\"type\": \"boolean\"}");
+ final AxContextSchema avroBooleanSchema = new AxContextSchema(new AxArtifactKey("AvroBoolean", "0.0.1"), "AVRO",
+ "{\"type\": \"boolean\"}");
schemas.getSchemasMap().put(avroBooleanSchema.getKey(), avroBooleanSchema);
- final SchemaHelper schemaHelper1 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroBooleanSchema.getKey());
+ final SchemaHelper schemaHelper1 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroBooleanSchema.getKey());
try {
schemaHelper1.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\" using the default constructor \"Boolean()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\" using the default constructor \"Boolean()\"",
+ e.getMessage());
}
assertEquals(true, schemaHelper1.createNewInstance("true"));
@@ -105,28 +119,27 @@ public class TestAvroSchemaHelperUnmarshal {
schemaHelper1.unmarshal(0);
fail("Test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: object \"0\" Avro unmarshalling failed: Expected boolean. Got VALUE_NUMBER_INT",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: object \"0\" of type \"java.lang.Integer\" must be assignable to "
+ + "\"java.lang.Boolean\" or be a Json string representation of it for "
+ + "Avro unmarshalling", e.getMessage());
}
}
- // @Test
+ @Test
public void testIntUnmarshal() {
- final AxContextSchema avroIntSchema =
- new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "Avro", "{\"type\": \"int\"}");
+ final AxContextSchema avroIntSchema = new AxContextSchema(new AxArtifactKey("AvroInt", "0.0.1"), "AVRO",
+ "{\"type\": \"int\"}");
schemas.getSchemasMap().put(avroIntSchema.getKey(), avroIntSchema);
- final SchemaHelper schemaHelper2 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroIntSchema.getKey());
+ final SchemaHelper schemaHelper2 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroIntSchema.getKey());
try {
schemaHelper2.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Integer\" using the default constructor \"Integer()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Integer\" using the default constructor \"Integer()\"",
+ e.getMessage());
}
assertEquals(123, schemaHelper2.createNewInstance("123"));
@@ -142,40 +155,39 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().startsWith(
- "AvroTest:0.0.1: object \"2147483648\" Avro unmarshalling failed: Numeric value (2147483648) out of range of int"));
+ "AvroTest:0.0.1: object \"2147483648\" Avro unmarshalling failed: Numeric value (2147483648) out of range of int"));
}
try {
schemaHelper2.unmarshal("-2147483649");
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().startsWith(
- "AvroTest:0.0.1: object \"-2147483649\" Avro unmarshalling failed: Numeric value (-2147483649) out of range of int"));
+ "AvroTest:0.0.1: object \"-2147483649\" Avro unmarshalling failed: Numeric value (-2147483649) out of range of int"));
}
try {
schemaHelper2.unmarshal(null);
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
- // @Test
+ @Test
public void testLongUnmarshal() {
- final AxContextSchema avroLongSchema =
- new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "Avro", "{\"type\": \"long\"}");
+ final AxContextSchema avroLongSchema = new AxContextSchema(new AxArtifactKey("AvroLong", "0.0.1"), "AVRO",
+ "{\"type\": \"long\"}");
schemas.getSchemasMap().put(avroLongSchema.getKey(), avroLongSchema);
- final SchemaHelper schemaHelper3 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroLongSchema.getKey());
+ final SchemaHelper schemaHelper3 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroLongSchema.getKey());
try {
schemaHelper3.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\" using the default constructor \"Long()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\" using the default constructor \"Long()\"",
+ e.getMessage());
}
assertEquals(123456789L, schemaHelper3.createNewInstance("123456789"));
@@ -191,47 +203,46 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().startsWith(
- "AvroTest:0.0.1: object \"9223372036854775808\" Avro unmarshalling failed: Numeric value (9223372036854775808) out of range of long"));
+ "AvroTest:0.0.1: object \"9223372036854775808\" Avro unmarshalling failed: Numeric value (9223372036854775808) out of range of long"));
}
try {
schemaHelper3.unmarshal("-9223372036854775809");
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().startsWith(
- "AvroTest:0.0.1: object \"-9223372036854775809\" Avro unmarshalling failed: Numeric value (-9223372036854775809) out of range of long"));
+ "AvroTest:0.0.1: object \"-9223372036854775809\" Avro unmarshalling failed: Numeric value (-9223372036854775809) out of range of long"));
}
try {
schemaHelper3.unmarshal("\"Hello\"");
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected long. Got VALUE_STRING"));
+ "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected long. Got VALUE_STRING"));
}
try {
schemaHelper3.unmarshal(null);
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
- // @Test
+ @Test
public void testFloatUnmarshal() {
- final AxContextSchema avroFloatSchema =
- new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "Avro", "{\"type\": \"float\"}");
+ final AxContextSchema avroFloatSchema = new AxContextSchema(new AxArtifactKey("AvroFloat", "0.0.1"), "AVRO",
+ "{\"type\": \"float\"}");
schemas.getSchemasMap().put(avroFloatSchema.getKey(), avroFloatSchema);
- final SchemaHelper schemaHelper4 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroFloatSchema.getKey());
+ final SchemaHelper schemaHelper4 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroFloatSchema.getKey());
try {
schemaHelper4.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Float\" using the default constructor \"Float()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Float\" using the default constructor \"Float()\"",
+ e.getMessage());
}
assertEquals(1.2345F, schemaHelper4.createNewInstance("1.2345"));
@@ -249,33 +260,32 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected float. Got VALUE_STRING"));
+ "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected float. Got VALUE_STRING"));
}
try {
schemaHelper4.unmarshal(null);
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
- // @Test
+ @Test
public void testDoubleUnmarshal() {
- final AxContextSchema avroDoubleSchema =
- new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "Avro", "{\"type\": \"double\"}");
+ final AxContextSchema avroDoubleSchema = new AxContextSchema(new AxArtifactKey("AvroDouble", "0.0.1"), "AVRO",
+ "{\"type\": \"double\"}");
schemas.getSchemasMap().put(avroDoubleSchema.getKey(), avroDoubleSchema);
- final SchemaHelper schemaHelper5 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroDoubleSchema.getKey());
+ final SchemaHelper schemaHelper5 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroDoubleSchema.getKey());
try {
schemaHelper5.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Double\" using the default constructor \"Double()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Double\" using the default constructor \"Double()\"",
+ e.getMessage());
}
assertEquals(1.2345E06, schemaHelper5.createNewInstance("1.2345E06"));
@@ -293,25 +303,25 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected double. Got VALUE_STRING"));
+ "AvroTest:0.0.1: object \"\"Hello\"\" Avro unmarshalling failed: Expected double. Got VALUE_STRING"));
}
try {
schemaHelper5.unmarshal(null);
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
@Test
public void testStringUnmarshal() {
- final AxContextSchema avroStringSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "Avro", "{\"type\": \"string\"}");
+ final AxContextSchema avroStringSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO",
+ "{\"type\": \"string\"}");
schemas.getSchemasMap().put(avroStringSchema.getKey(), avroStringSchema);
- final SchemaHelper schemaHelper7 =
- new SchemaHelperFactory().createSchemaHelper(testKey, avroStringSchema.getKey());
+ final SchemaHelper schemaHelper7 = new SchemaHelperFactory().createSchemaHelper(testKey,
+ avroStringSchema.getKey());
assertEquals("", schemaHelper7.createNewInstance(""));
assertEquals("1.2345E06", schemaHelper7.createNewInstance("1.2345E06"));
@@ -332,14 +342,14 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
@Test
public void testBytesUnmarshal() {
- final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "Avro", "{\"type\": \"bytes\"}");
+ final AxContextSchema avroSchema = new AxContextSchema(new AxArtifactKey("AvroString", "0.0.1"), "AVRO",
+ "{\"type\": \"bytes\"}");
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -348,9 +358,8 @@ public class TestAvroSchemaHelperUnmarshal {
schemaHelper.createNewInstance();
fail("test should throw an exception here");
} catch (final Exception e) {
- assertEquals(
- "AvroTest:0.0.1: could not create an instance of class \"java.lang.Byte[]\" using the default constructor \"Byte[]()\"",
- e.getMessage());
+ assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Byte[]\" using the default constructor \"Byte[]()\"",
+ e.getMessage());
}
final byte[] newBytes = (byte[]) schemaHelper.createNewInstance("\"hello\"");
assertEquals(5, newBytes.length);
@@ -365,7 +374,7 @@ public class TestAvroSchemaHelperUnmarshal {
fail("Test should throw an exception here");
} catch (final Exception e) {
assertTrue(e.getMessage().equals(
- "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
+ "AvroTest:0.0.1: object \"null\" Avro unmarshalling failed: String to read from cannot be null!"));
}
}
}
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java
index 33ca512b9..7bf6b0029 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaMap.java
@@ -27,10 +27,12 @@ import java.io.IOException;
import java.util.HashMap;
import org.apache.avro.util.Utf8;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -38,6 +40,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -54,17 +57,30 @@ public class TestAvroSchemaMap {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
longMapSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleLong.avsc");
addressMapSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleAddress.avsc");
addressMapSchemaInvalidFields =
TextFileUtils.getTextFileAsString("src/test/resources/avsc/MapExampleAddressInvalidFields.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testMapInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", addressMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", addressMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -82,7 +98,7 @@ public class TestAvroSchemaMap {
@Test
public void testLongMapUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "Avro", longMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", longMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -94,7 +110,7 @@ public class TestAvroSchemaMap {
@Test
public void testAddressMapUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "Avro", addressMapSchema);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -106,7 +122,7 @@ public class TestAvroSchemaMap {
@Test
public void testAddressMapUnmarshalMarshalInvalidFields() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "Avro", addressMapSchemaInvalidFields);
+ new AxContextSchema(new AxArtifactKey("AvroMap", "0.0.1"), "AVRO", addressMapSchemaInvalidFields);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java
index e14236064..000dcc9fd 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaRecord.java
@@ -25,10 +25,12 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericRecord;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -36,6 +38,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -53,7 +56,6 @@ public class TestAvroSchemaRecord {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
recordSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExample.avsc");
recordSchemaVPN = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPN.avsc");
recordSchemaVPNReuse = TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleVPNReuse.avsc");
@@ -61,10 +63,24 @@ public class TestAvroSchemaRecord {
TextFileUtils.getTextFileAsString("src/test/resources/avsc/RecordExampleInvalidFields.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Test
public void testRecordInit() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", recordSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -80,7 +96,7 @@ public class TestAvroSchemaRecord {
@Test
public void testRecordUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", recordSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -92,7 +108,7 @@ public class TestAvroSchemaRecord {
@Test
public void testRecordUnmarshalMarshalInvalid() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", recordSchemaInvalidFields);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaInvalidFields);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -103,7 +119,7 @@ public class TestAvroSchemaRecord {
@Test
public void testVPNRecordUnmarshalMarshal() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", recordSchemaVPN);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVPN);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -114,7 +130,7 @@ public class TestAvroSchemaRecord {
@Test
public void testVPNRecordReuse() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", recordSchemaVPNReuse);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", recordSchemaVPNReuse);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java
index 100b51d44..33cb20328 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestAvroSchemaUnion.java
@@ -25,11 +25,13 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.apache.avro.generic.GenericRecord;
+import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -37,6 +39,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -51,15 +54,28 @@ public class TestAvroSchemaUnion {
public void initTest() throws IOException {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
uinionSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/UnionExample.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
@Ignore
@Test
public void testUnionAllFields() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", uinionSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -76,7 +92,7 @@ public class TestAvroSchemaUnion {
@Test
public void testUnionOptionalField() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", uinionSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
@@ -94,7 +110,7 @@ public class TestAvroSchemaUnion {
@Test
public void testUnionNullField() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", uinionSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", uinionSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java
index 026125af9..42764a1ca 100644
--- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java
+++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/TestHealthCheckSchema.java
@@ -28,10 +28,12 @@ import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericData.Record;
import org.apache.avro.generic.GenericRecord;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -39,6 +41,7 @@ import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.utilities.TextFileUtils;
+import org.onap.policy.common.parameters.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -53,15 +56,27 @@ public class TestHealthCheckSchema {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
- new SchemaParameters().getSchemaHelperParameterMap().put("Avro", new AvroSchemaHelperParameters());
healthCheckSchema = TextFileUtils.getTextFileAsString("src/test/resources/avsc/HealthCheckBodyType.avsc");
}
+ @Before
+ public void initContext() {
+ SchemaParameters schemaParameters = new SchemaParameters();
+ schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ schemaParameters.getSchemaHelperParameterMap().put("AVRO", new AvroSchemaHelperParameters());
+ ParameterService.register(schemaParameters);
+
+ }
+
+ @After
+ public void clearContext() {
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
@Test
public void testHealthCheck() throws IOException {
final AxContextSchema avroSchema =
- new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "Avro", healthCheckSchema);
+ new AxContextSchema(new AxArtifactKey("AvroRecord", "0.0.1"), "AVRO", healthCheckSchema);
schemas.getSchemasMap().put(avroSchema.getKey(), avroSchema);
final SchemaHelper schemaHelper = new SchemaHelperFactory().createSchemaHelper(testKey, avroSchema.getKey());
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java
index 878882d6b..93174b941 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java
@@ -96,7 +96,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
InitialContext jmsContext = null;
ConnectionFactory connectionFactory = null;
try {
- jmsContext = new InitialContext(jmsConsumerProperties.getJMSConsumerProperties());
+ jmsContext = new InitialContext(jmsConsumerProperties.getJmsConsumerProperties());
connectionFactory = (ConnectionFactory) jmsContext.lookup(jmsConsumerProperties.getConnectionFactory());
// Check if we actually got a connection factory
@@ -107,7 +107,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
} catch (final Exception e) {
final String errorMessage = "lookup of JMS connection factory \""
+ jmsConsumerProperties.getConnectionFactory() + "\" failed for JMS consumer properties \""
- + jmsConsumerProperties.getJMSConsumerProperties() + "\"";
+ + jmsConsumerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -123,7 +123,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS topic \"" + jmsConsumerProperties.getConsumerTopic()
- + "\" failed for JMS consumer properties \"" + jmsConsumerProperties.getJMSConsumerProperties()
+ + "\" failed for JMS consumer properties \"" + jmsConsumerProperties.getJmsConsumerProperties()
+ "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
@@ -136,7 +136,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
connection.start();
} catch (final Exception e) {
final String errorMessage = "connection to the JMS server failed for JMS properties \""
- + jmsConsumerProperties.getJMSConsumerProperties() + "\"";
+ + jmsConsumerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java
index edf78637d..86e9555f9 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java
@@ -58,9 +58,6 @@ public class ApexJMSProducer implements ApexEventProducer {
// The connection to the JMS server
private Connection connection;
- // The topic on which we send events to JMS
- private Topic jmsOutgoingTopic;
-
// The JMS session on which we will send events
private Session jmsSession;
@@ -96,7 +93,7 @@ public class ApexJMSProducer implements ApexEventProducer {
InitialContext jmsContext = null;
ConnectionFactory connectionFactory = null;
try {
- jmsContext = new InitialContext(jmsProducerProperties.getJMSProducerProperties());
+ jmsContext = new InitialContext(jmsProducerProperties.getJmsProducerProperties());
connectionFactory = (ConnectionFactory) jmsContext.lookup(jmsProducerProperties.getConnectionFactory());
// Check if we actually got a connection factory
@@ -107,12 +104,13 @@ public class ApexJMSProducer implements ApexEventProducer {
} catch (final Exception e) {
final String errorMessage = "lookup of JMS connection factory \""
+ jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
// Lookup the topic on which we will send events
+ Topic jmsOutgoingTopic;
try {
jmsOutgoingTopic = (Topic) jmsContext.lookup(jmsProducerProperties.getProducerTopic());
@@ -123,7 +121,7 @@ public class ApexJMSProducer implements ApexEventProducer {
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS topic \"" + jmsProducerProperties.getProducerTopic()
- + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJMSProducerProperties()
+ + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJmsProducerProperties()
+ "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
@@ -136,7 +134,7 @@ public class ApexJMSProducer implements ApexEventProducer {
connection.start();
} catch (final Exception e) {
final String errorMessage = "connection to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -146,7 +144,7 @@ public class ApexJMSProducer implements ApexEventProducer {
jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
} catch (final Exception e) {
final String errorMessage = "creation of session to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -157,7 +155,7 @@ public class ApexJMSProducer implements ApexEventProducer {
} catch (final Exception e) {
final String errorMessage =
"creation of producer for sending events to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJMSConsumerProperties() + "\"";
+ + jmsProducerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java
index dfa8dc28a..80977b5d8 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java
@@ -25,6 +25,8 @@ import java.util.Properties;
import javax.naming.Context;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for JMS as an event carrier technology.
@@ -99,7 +101,7 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
// JMS carrier parameters
private String connectionFactory = DEFAULT_CONNECTION_FACTORY;
private String initialContextFactory = DEFAULT_INITIAL_CONTEXT_FACTORY;
- private String providerURL = DEFAULT_PROVIDER_URL;
+ private String providerUrl = DEFAULT_PROVIDER_URL;
private String securityPrincipal = DEFAULT_SECURITY_PRINCIPAL;
private String securityCredentials = DEFAULT_SECURITY_CREDENTIALS;
private String producerTopic = DEFAULT_PRODUCER_TOPIC;
@@ -113,7 +115,7 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
* service.
*/
public JMSCarrierTechnologyParameters() {
- super(JMSCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the JMS carrier technology
this.setLabel(JMS_CARRIER_TECHNOLOGY_LABEL);
@@ -126,15 +128,8 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
*
* @return the JMS producer properties
*/
- public Properties getJMSProducerProperties() {
- final Properties jmsProperties = new Properties();
-
- jmsProperties.put(PROPERTY_INITIAL_CONTEXT_FACTORY, initialContextFactory);
- jmsProperties.put(PROPERTY_PROVIDER_URL, providerURL);
- jmsProperties.put(PROPERTY_SECURITY_PRINCIPAL, securityPrincipal);
- jmsProperties.put(PROPERTY_SECURITY_CREDENTIALS, securityCredentials);
-
- return jmsProperties;
+ public Properties getJmsProducerProperties() {
+ return getJmsProperties();
}
/**
@@ -142,11 +137,20 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
*
* @return the jms consumer properties
*/
- public Properties getJMSConsumerProperties() {
+ public Properties getJmsConsumerProperties() {
+ return getJmsProperties();
+ }
+
+ /**
+ * Gets the JMS consumer properties.
+ *
+ * @return the jms consumer properties
+ */
+ private Properties getJmsProperties() {
final Properties jmsProperties = new Properties();
jmsProperties.put(PROPERTY_INITIAL_CONTEXT_FACTORY, initialContextFactory);
- jmsProperties.put(PROPERTY_PROVIDER_URL, providerURL);
+ jmsProperties.put(PROPERTY_PROVIDER_URL, providerUrl);
jmsProperties.put(PROPERTY_SECURITY_PRINCIPAL, securityPrincipal);
jmsProperties.put(PROPERTY_SECURITY_CREDENTIALS, securityCredentials);
@@ -176,8 +180,8 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
*
* @return the provider URL
*/
- public String getProviderURL() {
- return providerURL;
+ public String getProviderUrl() {
+ return providerUrl;
}
/**
@@ -246,10 +250,10 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
/**
* Sets the provider URL.
*
- * @param providerURL the provider URL
+ * @param providerUrl the provider URL
*/
- public void setProviderURL(final String providerURL) {
- this.providerURL = providerURL;
+ public void setProviderUrl(final String providerUrl) {
+ this.providerUrl = providerUrl;
}
/**
@@ -321,48 +325,51 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
if (initialContextFactory == null || initialContextFactory.trim().length() == 0) {
- errorMessageBuilder
- .append(" initialContextFactory not specified, must be specified as a string that is a class"
- + " that implements the interface org.jboss.naming.remote.client.InitialContextFactory\n");
+ result.setResult("initialContextFactory", ValidationStatus.INVALID,
+ "initialContextFactory must be specified as a string that is a class that implements the "
+ + "interface org.jboss.naming.remote.client.InitialContextFactory");
}
- if (providerURL == null || providerURL.trim().length() == 0) {
- errorMessageBuilder.append(
- " providerURL not specified, must be specified as a URL string that specifies the location of "
- + "configuration information for the service provider to use such as remote://localhost:4447\n");
+ if (providerUrl == null || providerUrl.trim().length() == 0) {
+ result.setResult("providerUrl", ValidationStatus.INVALID,
+ "providerUrl must be specified as a URL string that specifies the location of "
+ + "configuration information for the service provider to use "
+ + "such as remote://localhost:4447");
}
if (securityPrincipal == null || securityPrincipal.trim().length() == 0) {
- errorMessageBuilder.append(
- " securityPrincipal not specified, must be specified the identity of the principal for authenticating the caller to the service\n");
+ result.setResult("securityPrincipal", ValidationStatus.INVALID,
+ "securityPrincipal must be specified the identity of the principal for authenticating "
+ + "the caller to the service");
}
if (securityCredentials == null || securityCredentials.trim().length() == 0) {
- errorMessageBuilder.append(" securityCredentials not specified, must be specified as "
- + "the credentials of the principal for authenticating the caller to the service\n");
+ result.setResult("securityCredentials", ValidationStatus.INVALID,
+ " securityCredentials must be specified as the credentials of the "
+ + "principal for authenticating the caller to the service");
}
if (producerTopic == null || producerTopic.trim().length() == 0) {
- errorMessageBuilder.append(
- " producerTopic not specified, must be a string that identifies the JMS topic on which Apex will send events\n");
+ result.setResult("producerTopic", ValidationStatus.INVALID,
+ " producerTopic must be a string that identifies the JMS topic "
+ + "on which Apex will send events");
}
if (consumerTopic == null || consumerTopic.trim().length() == 0) {
- errorMessageBuilder.append(
- " consumerTopic not specified, must be a string that identifies the JMS topic on which Apex will recieve events\n");
+ result.setResult("consumerTopic", ValidationStatus.INVALID,
+ " consumerTopic must be a string that identifies the JMS topic "
+ + "on which Apex will recieve events");
}
if (consumerWaitTime < 0) {
- errorMessageBuilder.append(" consumerWaitTime [" + consumerWaitTime
- + "] invalid, must be specified as consumerWaitTime >= 0\n");
+ result.setResult("consumerWaitTime", ValidationStatus.INVALID,
+ "[" + consumerWaitTime + "] invalid, must be specified as consumerWaitTime >= 0");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java
index 2357b1807..5ce96662e 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KAFKACarrierTechnologyParameters.java
@@ -25,6 +25,8 @@ import java.util.Collection;
import java.util.Properties;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for Kafka as an event carrier technology.
@@ -42,6 +44,9 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
/** The consumer plugin class for the Kafka carrier technology. */
public static final String KAFKA_EVENT_CONSUMER_PLUGIN_CLASS = ApexKafkaConsumer.class.getCanonicalName();
+ // Repeated strings in messages
+ private static final String SPECIFY_AS_STRING_MESSAGE = "not specified, must be specified as a string";
+
// Default parameter values
private static final String DEFAULT_ACKS = "all";
private static final String DEFAULT_BOOTSTRAP_SERVERS = "localhost:9092";
@@ -102,7 +107,7 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
* service.
*/
public KAFKACarrierTechnologyParameters() {
- super(KAFKACarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the kafka carrier technology
this.setLabel(KAFKA_CARRIER_TECHNOLOGY_LABEL);
@@ -308,89 +313,107 @@ public class KAFKACarrierTechnologyParameters extends CarrierTechnologyParameter
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
- if (bootstrapServers == null || bootstrapServers.trim().length() == 0) {
- errorMessageBuilder
- .append(" bootstrapServers not specified, must be specified as a string of form host:port\n");
+ if (isNullOrBlank(bootstrapServers)) {
+ result.setResult("bootstrapServers", ValidationStatus.INVALID,
+ "not specified, must be specified as a string of form host:port");
}
- if (acks == null || acks.trim().length() == 0) {
- errorMessageBuilder.append(" acks not specified, must be specified as a string with values [0|1|all]\n");
+ if (isNullOrBlank(acks)) {
+ result.setResult("acks", ValidationStatus.INVALID,
+ "not specified, must be specified as a string with values [0|1|all]");
}
if (retries < 0) {
- errorMessageBuilder.append(" retries [" + retries + "] invalid, must be specified as retries >= 0\n");
+ result.setResult(PROPERTY_RETRIES, ValidationStatus.INVALID,
+ "[" + retries + "] invalid, must be specified as retries >= 0");
}
if (batchSize < 0) {
- errorMessageBuilder
- .append(" batchSize [" + batchSize + "] invalid, must be specified as batchSize >= 0\n");
+ result.setResult("batchSize", ValidationStatus.INVALID,
+ "[" + batchSize + "] invalid, must be specified as batchSize >= 0");
}
if (lingerTime < 0) {
- errorMessageBuilder
- .append(" lingerTime [" + lingerTime + "] invalid, must be specified as lingerTime >= 0\n");
+ result.setResult("lingerTime", ValidationStatus.INVALID,
+ "[" + lingerTime + "] invalid, must be specified as lingerTime >= 0");
}
if (bufferMemory < 0) {
- errorMessageBuilder
- .append(" bufferMemory [" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0\n");
+ result.setResult("bufferMemory", ValidationStatus.INVALID,
+ "[" + bufferMemory + "] invalid, must be specified as bufferMemory >= 0");
}
- if (groupId == null || groupId.trim().length() == 0) {
- errorMessageBuilder.append(" groupId not specified, must be specified as a string\n");
+ if (isNullOrBlank(groupId)) {
+ result.setResult("groupId", ValidationStatus.INVALID, SPECIFY_AS_STRING_MESSAGE);
}
if (autoCommitTime < 0) {
- errorMessageBuilder.append(
- " autoCommitTime [" + autoCommitTime + "] invalid, must be specified as autoCommitTime >= 0\n");
+ result.setResult("autoCommitTime", ValidationStatus.INVALID,
+ "[" + autoCommitTime + "] invalid, must be specified as autoCommitTime >= 0");
}
if (sessionTimeout < 0) {
- errorMessageBuilder.append(
- " sessionTimeout [" + sessionTimeout + "] invalid, must be specified as sessionTimeout >= 0\n");
+ result.setResult("sessionTimeout", ValidationStatus.INVALID,
+ "[" + sessionTimeout + "] invalid, must be specified as sessionTimeout >= 0");
}
- if (producerTopic == null || producerTopic.trim().length() == 0) {
- errorMessageBuilder.append(" producerTopic not specified, must be specified as a string\n");
+ if (isNullOrBlank(producerTopic)) {
+ result.setResult("producerTopic", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
if (consumerPollTime < 0) {
- errorMessageBuilder.append(" consumerPollTime [" + consumerPollTime
- + "] invalid, must be specified as consumerPollTime >= 0\n");
+ result.setResult("consumerPollTime", ValidationStatus.INVALID,
+ "[" + consumerPollTime + "] invalid, must be specified as consumerPollTime >= 0");
}
- if (consumerTopicList == null || consumerTopicList.length == 0) {
- errorMessageBuilder.append(" consumerTopicList not specified, must be specified as a list of strings\n");
+ validateConsumerTopicList(result);
+
+ if (isNullOrBlank(keySerializer)) {
+ result.setResult("keySerializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- for (final String consumerTopic : consumerTopicList) {
- if (consumerTopic == null || consumerTopic.trim().length() == 0) {
- errorMessageBuilder.append(" invalid consumer topic \"" + consumerTopic
- + "\" specified on consumerTopicList, consumer topics must be specified as strings\n");
- }
+ if (isNullOrBlank(valueSerializer)) {
+ result.setResult("valueSerializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- if (keySerializer == null || keySerializer.trim().length() == 0) {
- errorMessageBuilder.append(" keySerializer not specified, must be specified as a string\n");
+ if (isNullOrBlank(keyDeserializer)) {
+ result.setResult("keyDeserializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- if (valueSerializer == null || valueSerializer.trim().length() == 0) {
- errorMessageBuilder.append(" valueSerializer not specified, must be specified as a string\n");
+ if (isNullOrBlank(valueDeserializer)) {
+ result.setResult("valueDeserializer", ValidationStatus.INVALID,
+ SPECIFY_AS_STRING_MESSAGE);
}
- if (keyDeserializer == null || keyDeserializer.trim().length() == 0) {
- errorMessageBuilder.append(" keyDeserializer not specified, must be specified as a string\n");
+ return result;
+ }
+
+ private void validateConsumerTopicList(final GroupValidationResult result) {
+ if (consumerTopicList == null || consumerTopicList.length == 0) {
+ result.setResult("consumerTopicList", ValidationStatus.INVALID,
+ "not specified, must be specified as a list of strings");
}
- if (valueDeserializer == null || valueDeserializer.trim().length() == 0) {
- errorMessageBuilder.append(" valueDeserializer not specified, must be specified as a string\n");
+ StringBuilder consumerTopicStringBuilder = new StringBuilder();
+ for (final String consumerTopic : consumerTopicList) {
+ if (consumerTopic == null || consumerTopic.trim().length() == 0) {
+ consumerTopicStringBuilder.append(consumerTopic + "/");
+ }
+ }
+ if (consumerTopicStringBuilder.length() > 0) {
+ result.setResult("consumerTopicList", ValidationStatus.INVALID,
+ "invalid consumer topic list entries found: /" + consumerTopicStringBuilder.toString());
}
+ }
- return errorMessageBuilder.toString();
+ private boolean isNullOrBlank(final String stringValue) {
+ return stringValue == null || stringValue.trim().length() == 0;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java
index e07593c55..59d19f76b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RESTClientCarrierTechnologyParameters.java
@@ -21,6 +21,8 @@
package org.onap.policy.apex.plugins.event.carrier.restclient;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for REST as an event carrier technology with Apex as a REST client.
@@ -60,7 +62,7 @@ public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyPara
* service.
*/
public RESTClientCarrierTechnologyParameters() {
- super(RESTClientCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(RESTCLIENT_CARRIER_TECHNOLOGY_LABEL);
@@ -115,20 +117,19 @@ public class RESTClientCarrierTechnologyParameters extends CarrierTechnologyPara
return "RESTClientCarrierTechnologyParameters [url=" + url + ", httpMethod=" + httpMethod + "]";
}
-
/*
*
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
// Check if the URL has been set for event output
if (getURL() == null) {
- errorMessageBuilder.append(" no URL has been set for event sending on REST client");
+ result.setResult("url", ValidationStatus.INVALID, "no URL has been set for event sending on REST client");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java
index eb5870058..9b841d768 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RESTRequestorCarrierTechnologyParameters.java
@@ -68,7 +68,7 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP
* service.
*/
public RESTRequestorCarrierTechnologyParameters() {
- super(RESTRequestorCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(RESTREQUESTOR_CARRIER_TECHNOLOGY_LABEL);
@@ -122,14 +122,4 @@ public class RESTRequestorCarrierTechnologyParameters extends CarrierTechnologyP
public String toString() {
return "RESTRequestorCarrierTechnologyParameters [url=" + url + ", httpMethod=" + httpMethod + "]";
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
- */
- @Override
- public String validate() {
- return "";
- }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java
index d4eb434c7..70d567b0d 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/apps/uservice/test/adapt/restrequestor/TestRESTRequestor.java
@@ -286,6 +286,6 @@ public class TestRESTRequestor {
System.setErr(stderr);
assertTrue(outString.contains(
- "event input for peered mode \"REQUESTOR\": peer \"RestRequestorProducer\" for event handler \"RestRequestorConsumer\" does not exist or is not defined as being synchronous"));
+ "peer \"RestRequestorProducer for peered mode REQUESTOR does not exist or is not defined with the same peered mode"));
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java
index 47e31fffa..cd7f388f2 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RESTServerCarrierTechnologyParameters.java
@@ -21,6 +21,8 @@
package org.onap.policy.apex.plugins.event.carrier.restserver;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for REST as an event carrier technology with Apex as a REST client.
@@ -63,7 +65,7 @@ public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyPara
* service.
*/
public RESTServerCarrierTechnologyParameters() {
- super(RESTServerCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(RESTSERVER_CARRIER_TECHNOLOGY_LABEL);
@@ -105,32 +107,30 @@ public class RESTServerCarrierTechnologyParameters extends CarrierTechnologyPara
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
// Check if host is defined, it is only defined on REST server consumers
if (standalone) {
- if (host != null) {
- if (host.trim().length() == 0) {
- errorMessageBuilder.append(" host not specified, must be host as a string\n");
- }
+ if (host != null && host.trim().length() == 0) {
+ result.setResult("host", ValidationStatus.INVALID,
+ "host not specified, host must be specified as a string");
}
// Check if port is defined, it is only defined on REST server consumers
- if (port != -1) {
- if (port < MIN_USER_PORT || port > MAX_USER_PORT) {
- errorMessageBuilder
- .append(" port [" + port + "] invalid, must be specified as 1024 <= port <= 6535\n");
- }
+ if (port != -1 && port < MIN_USER_PORT || port > MAX_USER_PORT) {
+ result.setResult("port", ValidationStatus.INVALID,
+ "[" + port + "] invalid, must be specified as 1024 <= port <= 65535");
}
} else {
- if (host != null || port != -1) {
- errorMessageBuilder.append(" host and port are specified only in standalone mode\n");
+ if (host != null) {
+ result.setResult("host", ValidationStatus.INVALID, "host is specified only in standalone mode");
+ }
+ if (port != -1) {
+ result.setResult("port", ValidationStatus.INVALID, "port is specified only in standalone mode");
}
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java
index e8009a5d8..e04a81d1d 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/WEBSOCKETCarrierTechnologyParameters.java
@@ -21,6 +21,8 @@
package org.onap.policy.apex.plugins.event.carrier.websocket;
import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for Kafka as an event carrier technology.
@@ -56,7 +58,7 @@ public class WEBSOCKETCarrierTechnologyParameters extends CarrierTechnologyParam
* parameter service.
*/
public WEBSOCKETCarrierTechnologyParameters() {
- super(WEBSOCKETCarrierTechnologyParameters.class.getCanonicalName());
+ super();
// Set the carrier technology properties for the web socket carrier technology
this.setLabel(WEB_SCOKET_CARRIER_TECHNOLOGY_LABEL);
@@ -97,19 +99,18 @@ public class WEBSOCKETCarrierTechnologyParameters extends CarrierTechnologyParam
* @see org.onap.policy.apex.apps.uservice.parameters.ApexParameterValidator#validate()
*/
@Override
- public String validate() {
- final StringBuilder errorMessageBuilder = new StringBuilder();
-
- errorMessageBuilder.append(super.validate());
+ public GroupValidationResult validate() {
+ final GroupValidationResult result = super.validate();
if (wsClient && (host == null || host.trim().length() == 0)) {
- errorMessageBuilder.append(" host not specified, must be host as a string\n");
+ result.setResult("host", ValidationStatus.INVALID, "host not specified, must be host as a string");
}
if (port < MIN_USER_PORT || port > MAX_USER_PORT) {
- errorMessageBuilder.append(" port [" + port + "] invalid, must be specified as 1024 <= port <= 6535\n");
+ result.setResult("port", ValidationStatus.INVALID,
+ "[" + port + "] invalid, must be specified as 1024 <= port <= 65535");
}
- return errorMessageBuilder.toString();
+ return result;
}
}
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
index 40196eb8a..c5f6cb781 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlEventProtocol.java
@@ -37,7 +37,6 @@ import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
@@ -48,13 +47,14 @@ import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.HeaderDelimitedTextBlockReader;
import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.TextBlock;
+import org.onap.policy.common.parameters.ParameterService;
public class TestYamlEventProtocol {
@BeforeClass
public static void registerTestEventsAndSchemas() throws IOException {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
- ParameterService.registerParameters(SchemaParameters.class, schemaParameters);
+ ParameterService.register(schemaParameters, true);
AxContextSchemas schemas = new AxContextSchemas();
@@ -199,6 +199,7 @@ public class TestYamlEventProtocol {
@AfterClass
public static void unregisterTestEventsAndSchemas() {
ModelService.clear();
+ ParameterService.clear();
}
@Test
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
index 126a01df7..57b4b72d6 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/test/java/org/onap/policy/apex/plugins/event/protocol/yaml/TestYamlPluginStability.java
@@ -34,7 +34,6 @@ import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.service.ParameterService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
@@ -43,6 +42,7 @@ import org.onap.policy.apex.model.eventmodel.concepts.AxField;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
+import org.onap.policy.common.parameters.ParameterService;
public class TestYamlPluginStability {
static AxEvent testEvent;
@@ -51,7 +51,7 @@ public class TestYamlPluginStability {
public static void registerTestEventsAndSchemas() throws IOException {
SchemaParameters schemaParameters = new SchemaParameters();
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
- ParameterService.registerParameters(SchemaParameters.class, schemaParameters);
+ ParameterService.register(schemaParameters);
AxContextSchemas schemas = new AxContextSchemas();
@@ -89,6 +89,7 @@ public class TestYamlPluginStability {
@AfterClass
public static void unregisterTestEventsAndSchemas() {
ModelService.clear();
+ ParameterService.clear();
}
@Test