/* BEGIN LICENSE
 * Copyright © Blue Mind SAS, 2012-2016
 *
 * This file is part of Blue Mind. Blue Mind is a messaging and collaborative
 * solution.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of either the GNU Affero General Public License as
 * published by the Free Software Foundation (version 3 of the License)
 * or the CeCILL as published by CeCILL.info (version 2 of the License).
 *
 * There are special exceptions to the terms and conditions of the
 * licenses as they are applied to this program. See LICENSE.txt in
 * the directory of this program distribution.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See LICENSE.txt
 * END LICENSE
 */
package net.bluemind.bm.agent.test;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.bluemind.agent.client.AgentClientModule;
import net.bluemind.agent.client.internal.config.ClientConfig;
import net.bluemind.agent.config.SSLConfig;
import net.bluemind.agent.server.AgentServerModule;
import net.bluemind.agent.server.Command;
import net.bluemind.agent.server.internal.config.ServerConfig;

public class TestApplication {

	private static final Logger logger = LoggerFactory.getLogger(TestApplication.class);

	public static void main(String[] args) throws Exception {

		ServerConfig serverConfig = new ServerConfig("localhost", 8080, SSLConfig.noSSL());
		AgentServerModule.run(serverConfig, () -> {
			System.out.println("server running");
			ClientConfig clientConfig = new ClientConfig("localhost", 8080, "agent-1", SSLConfig.noSSL());
			AgentClientModule.run(clientConfig, () -> {
				System.out.println("client  running");
				String[] pathParameters = new String[0];
				Map<String, String> queryParameters = new HashMap<>();
				queryParameters.put("port", "22");
				queryParameters.put("host", "ubuntu-bmcore2.lan");
				queryParameters.put("localPort", "8081");
				Command command = new Command("GET", "port-redirect", "agent-1", pathParameters, queryParameters);
				AgentServerModule.command(command);
			});
		});

		logger.info("Application is running... Type anything to stop");
		System.in.read();

		AgentClientModule.stop();
		AgentServerModule.stop();
	}

}

@@ -1858,16 +1858,341 @@
 ng%22);%0A%09%09
+%09%09Command command = portForwardingExample(%22localhost%22);%0A%09%09%09%09AgentServerModule.command(command);%0A%09%09%09%7D);%0A%09%09%7D);%0A%0A%09%09logger.info(%22Application is running... Type anything to stop%22);%0A%09%09System.in.read();%0A%0A%09%09AgentClientModule.stop();%0A%09%09AgentServerModule.stop();%0A%09%7D%0A%0A%09private static Command portForwardingExample(String mySSHServer) %7B%0A
 %09%09String
@@ -2226,18 +2226,16 @@
 ing%5B0%5D;%0A
-%09%09
 %09%09Map%3CSt
@@ -2283,18 +2283,16 @@
 ap%3C%3E();%0A
-%09%09
 %09%09queryP
@@ -2316,26 +2316,24 @@
 rt%22, %2222%22);%0A
-%09%09
 %09%09queryParam
@@ -2354,33 +2354,22 @@
 t%22, 
-%22ubuntu-bmcore2.lan%22
+mySSHServer
 );%0A
-%09%09
 %09%09qu
@@ -2404,26 +2404,24 @@
 %22, %228081%22);%0A
-%09%09
 %09%09Command co
@@ -2515,201 +2515,22 @@
 ;%0A%09%09
-%09%09AgentServerModule.command(command);%0A%09%09%09%7D);%0A%09%09%7D);%0A%0A%09%09logger.info(%22Application is running... Type anything to stop%22);%0A%09%09System.in.read();%0A%0A%09%09AgentClientModule.stop();%0A%09%09AgentServerModule.stop()
+return command
 ;%0A%09%7D

add test application