2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.apps.uservice.test.adapt.jms;
23 import static org.onap.policy.apex.apps.uservice.test.adapt.jms.TestJMS2JMS.HOST;
24 import static org.onap.policy.apex.apps.uservice.test.adapt.jms.TestJMS2JMS.JMS_TOPIC_APEX_IN;
25 import static org.onap.policy.apex.apps.uservice.test.adapt.jms.TestJMS2JMS.JMS_TOPIC_APEX_OUT;
26 import static org.onap.policy.apex.apps.uservice.test.adapt.jms.TestJMS2JMS.PORT;
27 import static org.onap.policy.apex.apps.uservice.test.adapt.jms.TestJMS2JMS.connectionFactory;
29 import java.util.HashMap;
30 import java.util.Hashtable;
32 import java.util.Properties;
34 import javax.naming.Binding;
35 import javax.naming.Context;
36 import javax.naming.Name;
37 import javax.naming.NameClassPair;
38 import javax.naming.NameParser;
39 import javax.naming.NamingEnumeration;
40 import javax.naming.NamingException;
42 import org.apache.activemq.command.ActiveMQTopic;
43 import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
46 * @author Liam Fallon (liam.fallon@ericsson.com)
48 public class TestContext implements Context {
50 private Properties testProperties;
52 public TestContext() {
54 testProperties = new Properties();
56 final Map<String, Object> params = new HashMap<String, Object>();
57 params.put("host", HOST);
58 params.put("port", PORT);
59 testProperties.put("ConnectionFactory", connectionFactory);
60 testProperties.put(JMS_TOPIC_APEX_IN, new ActiveMQTopic(JMS_TOPIC_APEX_IN));
61 testProperties.put(JMS_TOPIC_APEX_OUT, new ActiveMQTopic(JMS_TOPIC_APEX_OUT));
62 } catch (final Exception e) {
64 throw new ApexRuntimeException("Context initiation failed", e);
69 public Object lookup(final Name name) throws NamingException {
74 public Object lookup(final String name) throws NamingException {
75 return testProperties.get(name);
79 public void bind(final Name name, final Object obj) throws NamingException {}
82 public void bind(final String name, final Object obj) throws NamingException {}
85 public void rebind(final Name name, final Object obj) throws NamingException {}
88 public void rebind(final String name, final Object obj) throws NamingException {}
91 public void unbind(final Name name) throws NamingException {}
94 public void unbind(final String name) throws NamingException {}
97 public void rename(final Name oldName, final Name newName) throws NamingException {}
100 public void rename(final String oldName, final String newName) throws NamingException {}
103 public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException {
108 public NamingEnumeration<NameClassPair> list(final String name) throws NamingException {
113 public NamingEnumeration<Binding> listBindings(final Name name) throws NamingException {
118 public NamingEnumeration<Binding> listBindings(final String name) throws NamingException {
123 public void destroySubcontext(final Name name) throws NamingException {}
126 public void destroySubcontext(final String name) throws NamingException {}
129 public Context createSubcontext(final Name name) throws NamingException {
134 public Context createSubcontext(final String name) throws NamingException {
139 public Object lookupLink(final Name name) throws NamingException {
144 public Object lookupLink(final String name) throws NamingException {
149 public NameParser getNameParser(final Name name) throws NamingException {
154 public NameParser getNameParser(final String name) throws NamingException {
159 public Name composeName(final Name name, final Name prefix) throws NamingException {
164 public String composeName(final String name, final String prefix) throws NamingException {
169 public Object addToEnvironment(final String propName, final Object propVal) throws NamingException {
174 public Object removeFromEnvironment(final String propName) throws NamingException {
179 public Hashtable<?, ?> getEnvironment() throws NamingException {
184 public void close() throws NamingException {}
187 public String getNameInNamespace() throws NamingException {