<commit_before>package io.syndesis.qe.utils;

import org.apache.activemq.ActiveMQConnectionFactory;

import cz.xtf.jms.JmsClient;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.client.LocalPortForward;
import lombok.extern.slf4j.Slf4j;
import org.apache.qpid.jms.JmsConnectionFactory;

@Slf4j
public class JmsClientManager implements AutoCloseable {

    private String jmsUrl;
    private int jmsPort;
    private String jmsPodName = "broker-amq";
    private String jmsUser = "amq";
    private String jmsPass = "<PASSWORD>";
    private String protocol;
    private LocalPortForward jmsLocalPortForward = null;
    private JmsClient jmsClient;

    public JmsClientManager(String protocol) {
        initValues(protocol);
    }

    private void initValues(String protocol) {
        this.protocol = protocol;
        switch (protocol) {
            case "tcp":
            case "openwire":
                jmsPort = 61616;
                jmsUrl = "tcp://127.0.0.1:" + jmsPort;
                break;
            case "amqp":
                jmsPort = 5672;
                jmsUrl = "amqp://127.0.0.1:" + jmsPort;
                break;
        }
    }

    public JmsClient getClient() {

        if (jmsLocalPortForward == null || !jmsLocalPortForward.isAlive()) {
            //can be the same pod twice forwarded to different ports? YES
            Pod  pod = OpenShiftUtils.xtf().getAnyPod("app", jmsPodName);
            log.info("POD NAME: *{}*", pod.getMetadata().getName());
            jmsLocalPortForward = OpenShiftUtils.portForward(pod, jmsPort, jmsPort);
        }
        return this.initClient();
    }

    public void close() {
        if (jmsClient != null) {
            jmsClient.disconnect();
        }
        TestUtils.terminateLocalPortForward(jmsLocalPortForward);
    }

    private JmsClient initClient() {
        if (jmsClient == null) {
            switch (protocol) {
                case "openwire":
                    ActiveMQConnectionFactory jmsFactory = new ActiveMQConnectionFactory();
                    jmsFactory.setBrokerURL(jmsUrl);
                    jmsFactory.setUserName(jmsUser);
                    jmsFactory.setPassword(jmsPass);
                    jmsClient = new JmsClient(jmsFactory);
                case "amqp":
                    JmsConnectionFactory jmsConnectionFactory = new JmsConnectionFactory(jmsUser, jmsPass, jmsUrl);
                    jmsClient = new JmsClient(jmsConnectionFactory);
            }
        }
        return jmsClient;
    }
}<commit_msg>fix(utils): Fix switch construction in JmsManager (#471)<commit_after>package io.syndesis.qe.utils;

import org.apache.activemq.ActiveMQConnectionFactory;

import cz.xtf.jms.JmsClient;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.client.LocalPortForward;
import lombok.extern.slf4j.Slf4j;
import org.apache.qpid.jms.JmsConnectionFactory;

@Slf4j
public class JmsClientManager implements AutoCloseable {

    private String jmsUrl;
    private int jmsPort;
    private String jmsPodName = "broker-amq";
    private String jmsUser = "amq";
    private String jmsPass = "<PASSWORD>";
    private String protocol;
    private LocalPortForward jmsLocalPortForward = null;
    private JmsClient jmsClient;

    public JmsClientManager(String protocol) {
        initValues(protocol);
    }

    private void initValues(String protocol) {
        this.protocol = protocol;
        switch (protocol) {
            case "tcp":
            case "openwire":
                jmsPort = 61616;
                jmsUrl = "tcp://127.0.0.1:" + jmsPort;
                break;
            case "amqp":
                jmsPort = 5672;
                jmsUrl = "amqp://127.0.0.1:" + jmsPort;
                break;
        }
    }

    public JmsClient getClient() {

        if (jmsLocalPortForward == null || !jmsLocalPortForward.isAlive()) {
            //can be the same pod twice forwarded to different ports? YES
            Pod pod = OpenShiftUtils.xtf().getAnyPod("app", jmsPodName);
            log.info("POD NAME: *{}*", pod.getMetadata().getName());
            jmsLocalPortForward = OpenShiftUtils.portForward(pod, jmsPort, jmsPort);
        }
        return this.initClient();
    }

    public void close() {
        if (jmsClient != null) {
            jmsClient.disconnect();
            jmsClient = null;
        }
        TestUtils.terminateLocalPortForward(jmsLocalPortForward);
    }

    private JmsClient initClient() {
        if (jmsClient == null) {
            switch (protocol) {
                case "tcp":
                case "openwire":
                    ActiveMQConnectionFactory jmsFactory = new ActiveMQConnectionFactory();
                    jmsFactory.setBrokerURL(jmsUrl);
                    jmsFactory.setUserName(jmsUser);
                    jmsFactory.setPassword(<PASSWORD>);
                    jmsClient = new JmsClient(jmsFactory);
                    break;
                case "amqp":
                    JmsConnectionFactory jmsConnectionFactory = new JmsConnectionFactory(jmsUser, jmsPass, jmsUrl);
                    jmsClient = new JmsClient(jmsConnectionFactory);
                    break;
            }
        }
        return jmsClient;
    }
}
{'fraction_non_alphanumeric': 0.09546403492123742, 'fraction_numerical': 0.010438413361169102, 'mean_word_length': 2.062173155142359, 'pattern_counts': {'":': 11, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5044536', 'n_tokens_mistral': 1582, 'n_tokens_neox': 1484, 'n_words': 312}