2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2023 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.testsuites.integration.uservice.adapt.jms;
24 import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.HOST;
25 import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.JMS_TOPIC_APEX_IN;
26 import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.JMS_TOPIC_APEX_OUT;
27 import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.PORT;
29 import java.util.HashMap;
30 import java.util.Hashtable;
32 import java.util.Properties;
33 import javax.naming.Binding;
34 import javax.naming.Context;
35 import javax.naming.Name;
36 import javax.naming.NameClassPair;
37 import javax.naming.NameParser;
38 import javax.naming.NamingEnumeration;
39 import javax.naming.NamingException;
40 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
41 import org.apache.activemq.artemis.jms.client.ActiveMQTopic;
42 import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
45 * The Class TestContext.
47 * @author Liam Fallon (liam.fallon@ericsson.com)
49 public class TestContext implements Context {
51 private Properties testProperties;
54 * Instantiates a new test context.
56 public TestContext() {
58 testProperties = new Properties();
60 final Map<String, Object> params = new HashMap<String, Object>();
61 params.put("host", HOST);
62 params.put("port", PORT);
63 testProperties.put("ConnectionFactory", new ActiveMQConnectionFactory(TestJms2Jms.SERVER_URI));
64 testProperties.put(JMS_TOPIC_APEX_IN, new ActiveMQTopic(JMS_TOPIC_APEX_IN));
65 testProperties.put(JMS_TOPIC_APEX_OUT, new ActiveMQTopic(JMS_TOPIC_APEX_OUT));
66 } catch (final Exception e) {
68 throw new ApexRuntimeException("Context initiation failed", e);
76 public Object lookup(final Name name) throws NamingException {
84 public Object lookup(final String name) throws NamingException {
85 return testProperties.get(name);
92 public void bind(final Name name, final Object obj) throws NamingException {
100 public void bind(final String name, final Object obj) throws NamingException {
108 public void rebind(final Name name, final Object obj) throws NamingException {
116 public void rebind(final String name, final Object obj) throws NamingException {
124 public void unbind(final Name name) throws NamingException {
132 public void unbind(final String name) throws NamingException {
140 public void rename(final Name oldName, final Name newName) throws NamingException {
148 public void rename(final String oldName, final String newName) throws NamingException {
156 public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException {
164 public NamingEnumeration<NameClassPair> list(final String name) throws NamingException {
172 public NamingEnumeration<Binding> listBindings(final Name name) throws NamingException {
180 public NamingEnumeration<Binding> listBindings(final String name) throws NamingException {
188 public void destroySubcontext(final Name name) throws NamingException {
196 public void destroySubcontext(final String name) throws NamingException {
204 public Context createSubcontext(final Name name) throws NamingException {
212 public Context createSubcontext(final String name) throws NamingException {
220 public Object lookupLink(final Name name) throws NamingException {
228 public Object lookupLink(final String name) throws NamingException {
236 public NameParser getNameParser(final Name name) throws NamingException {
244 public NameParser getNameParser(final String name) throws NamingException {
252 public Name composeName(final Name name, final Name prefix) throws NamingException {
260 public String composeName(final String name, final String prefix) throws NamingException {
268 public Object addToEnvironment(final String propName, final Object propVal) throws NamingException {
276 public Object removeFromEnvironment(final String propName) throws NamingException {
284 public Hashtable<?, ?> getEnvironment() throws NamingException {
292 public void close() throws NamingException {
300 public String getNameInNamespace() throws NamingException {