/*
 * Copyright © 2015 Cask Data, Inc.
 *
 * 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.
 */

package co.cask.cdap.templates.etl.realtime.sources;

import co.cask.cdap.templates.etl.realtime.jms.JmsProvider;
import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 * This class is used to provide mock JMS ConnectionFactory for testing JMS realtime template source.
 */
public class MockJmsProvider implements JmsProvider {

  private ConnectionFactory connectionFactory;
  private Destination destination;

  public MockJmsProvider(String destinationName) throws NamingException {
    connectionFactory =  new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");

    // Set JNDI Context
    Context jndiContext = new InitialContext();
    destination = (Destination) jndiContext.lookup(destinationName);
  }

  @Override
  public ConnectionFactory getConnectionFactory() {
    return connectionFactory;
  }

  @Override
  public Destination getDestination() {
    return destination;
  }
}

@@ -1092,16 +1092,124 @@
 ovider %7B
+%0A  public static final String CONNECTION_URL = %22vm://localhost?broker.persistent=false&broker.useJmx=false%22;
 %0A%0A  priv
@@ -1418,48 +1418,22 @@
 ory(
-%22vm://localhost?broker.persistent=false%22
+CONNECTION_URL
 );%0A%0A

Fix socket port used exception for ActiveMQConnectionFactory by turning off jmx.