// Path: src/main/java/org/jembi/openhim/DefaultChannelComponent.java
// public static class URLMapping {
// 	private String urlPattern;
// 	private String host;
// 	private String port;
// 	private String username;
// 	private String password;
// 	private String authType;
// 	private String allowUnsecured;
// 	private String path;
// 	private String pathTransform;
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (!(obj instanceof URLMapping)) {
// 			return false;
// 		}
// 		URLMapping mapping = (URLMapping) obj;
// 		if (urlPattern.equals(mapping.getUrlPattern())
// 			&& host.equals(mapping.getHost())
// 			&& port.equals(mapping.getPort())) {
// 				
// 			return true;
// 		}
// 		return false;
// 	}
// 		
// 	public String getAuthType() {
// 		return authType;
// 	}
// 
// 	public void setAuthType(String authType) {
// 		this.authType = authType;
// 	}
// 
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	public void setUsername(String username) {
// 		this.username = username;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// 	public String getUrlPattern() {
// 		return urlPattern;
// 	}
// 
// 	public void setUrlPattern(String urlPattern) {
// 		this.urlPattern = urlPattern;
// 	}
// 
// 	public String getHost() {
// 		return host;
// 	}
// 
// 	public void setHost(String host) {
// 		this.host = host;
// 	}
// 
// 	public String getPort() {
// 		return port;
// 	}
// 
// 	public void setPort(String port) {
// 		this.port = port;
// 	}
// 
// 	public String getAllowUnsecured() {
// 		return allowUnsecured;
// 	}
// 
// 	public void setAllowUnsecured(String allowUnsecured) {
// 		this.allowUnsecured = allowUnsecured;
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// 
// 	public void setPath(String path) {
// 		this.path = path;
// 	}
// 
// 	public String getPathTransform() {
// 		return pathTransform;
// 	}
// 
// 	public void setPathTransform(String pathTransform) {
// 		this.pathTransform = pathTransform;
// 	}
// }
// 
// Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
// 
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public DefaultChannelInvalidConfigException() {}
// 
// 	public DefaultChannelInvalidConfigException(String message) {
// 		super(message);
// 	}
// 
// 	public DefaultChannelInvalidConfigException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 	public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }


import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.io.IOException;
import org.jembi.openhim.DefaultChannelComponent.URLMapping;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
	
	private void test_pathRedirection(String path, String targetPath) throws JsonParseException, JsonMappingException, IOException, DefaultChannelInvalidConfigException {
		DefaultChannelComponent dcc = new DefaultChannelComponent();
		dcc.readMappings();

		URLMapping mapping = dcc.findURLMapping(Scheme.HTTPS, path);
		MuleMessage mockMsg = mock(MuleMessage.class);
		RestfulHttpRequest req = new RestfulHttpRequest();
		req.setPath(path);
		
		dcc.setMessagePropertiesFromMapping(req, mockMsg, mapping);
		verify(mockMsg).setProperty(eq("http.host"), eq("localhost"), eq(PropertyScope.OUTBOUND));
		verify(mockMsg).setProperty(eq("http.port"), eq("8080"), eq(PropertyScope.OUTBOUND));
		verify(mockMsg).setProperty(eq("path"), eq(targetPath), eq(PropertyScope.OUTBOUND));
	}
	

	@Test
	public void test_pathRedirection_invalid() throws DefaultChannelInvalidConfigException, JsonParseException, JsonMappingException, IOException {
		//cannot specify both path and pathTransform
		
		try {
			DefaultChannelComponent dcc = new DefaultChannelComponent();
			MuleMessage mockMsg = mock(MuleMessage.class);
			URLMapping mapping = mock(URLMapping.class);

			when(mapping.getPath()).thenReturn("path");
			when(mapping.getPathTransform()).thenReturn("pathTransform");
			dcc.setMessagePropertiesFromMapping(new RestfulHttpRequest(), mockMsg, mapping);
			fail();
// Path: src/main/java/org/jembi/openhim/DefaultChannelComponent.java
// public static class URLMapping {
// 	private String urlPattern;
// 	private String host;
// 	private String port;
// 	private String username;
// 	private String password;
// 	private String authType;
// 	private String allowUnsecured;
// 	private String path;
// 	private String pathTransform;
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (!(obj instanceof URLMapping)) {
// 			return false;
// 		}
// 		URLMapping mapping = (URLMapping) obj;
// 		if (urlPattern.equals(mapping.getUrlPattern())
// 			&& host.equals(mapping.getHost())
// 			&& port.equals(mapping.getPort())) {
// 				
// 			return true;
// 		}
// 		return false;
// 	}
// 		
// 	public String getAuthType() {
// 		return authType;
// 	}
// 
// 	public void setAuthType(String authType) {
// 		this.authType = authType;
// 	}
// 
// 	public String getUsername() {
// 		return username;
// 	}
// 
// 	public void setUsername(String username) {
// 		this.username = username;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// 	public String getUrlPattern() {
// 		return urlPattern;
// 	}
// 
// 	public void setUrlPattern(String urlPattern) {
// 		this.urlPattern = urlPattern;
// 	}
// 
// 	public String getHost() {
// 		return host;
// 	}
// 
// 	public void setHost(String host) {
// 		this.host = host;
// 	}
// 
// 	public String getPort() {
// 		return port;
// 	}
// 
// 	public void setPort(String port) {
// 		this.port = port;
// 	}
// 
// 	public String getAllowUnsecured() {
// 		return allowUnsecured;
// 	}
// 
// 	public void setAllowUnsecured(String allowUnsecured) {
// 		this.allowUnsecured = allowUnsecured;
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// 
// 	public void setPath(String path) {
// 		this.path = path;
// 	}
// 
// 	public String getPathTransform() {
// 		return pathTransform;
// 	}
// 
// 	public void setPathTransform(String pathTransform) {
// 		this.pathTransform = pathTransform;
// 	}
// }
// 
// Path: src/main/java/org/jembi/openhim/RestfulHttpRequest.java
// public static enum Scheme { HTTP, HTTPS }
// 
// Path: src/main/java/org/jembi/openhim/exception/DefaultChannelInvalidConfigException.java
// public class DefaultChannelInvalidConfigException extends Exception {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public DefaultChannelInvalidConfigException() {}
// 
// 	public DefaultChannelInvalidConfigException(String message) {
// 		super(message);
// 	}
// 
// 	public DefaultChannelInvalidConfigException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 	public DefaultChannelInvalidConfigException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }


// Path: src/test/java/org/jembi/openhim/DefaultChannelComponentTest.java
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.io.IOException;
import org.jembi.openhim.DefaultChannelComponent.URLMapping;
import org.jembi.openhim.RestfulHttpRequest.Scheme;
import org.jembi.openhim.exception.DefaultChannelInvalidConfigException;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.transport.PropertyScope;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;

	
	private void test_pathRedirection(String path, String targetPath) throws JsonParseException, JsonMappingException, IOException, DefaultChannelInvalidConfigException {
		DefaultChannelComponent dcc = new DefaultChannelComponent();
		dcc.readMappings();

		URLMapping mapping = dcc.findURLMapping(Scheme.HTTPS, path);
		MuleMessage mockMsg = mock(MuleMessage.class);
		RestfulHttpRequest req = new RestfulHttpRequest();
		req.setPath(path);
		
		dcc.setMessagePropertiesFromMapping(req, mockMsg, mapping);
		verify(mockMsg).setProperty(eq("http.host"), eq("localhost"), eq(PropertyScope.OUTBOUND));
		verify(mockMsg).setProperty(eq("http.port"), eq("8080"), eq(PropertyScope.OUTBOUND));
		verify(mockMsg).setProperty(eq("path"), eq(targetPath), eq(PropertyScope.OUTBOUND));
	}
	

	@Test
	public void test_pathRedirection_invalid() throws DefaultChannelInvalidConfigException, JsonParseException, JsonMappingException, IOException {
		//cannot specify both path and pathTransform
		
		try {
			DefaultChannelComponent dcc = new DefaultChannelComponent();
			MuleMessage mockMsg = mock(MuleMessage.class);
			URLMapping mapping = mock(URLMapping.class);

			when(mapping.getPath()).thenReturn("path");
			when(mapping.getPathTransform()).thenReturn("pathTransform");
			dcc.setMessagePropertiesFromMapping(new RestfulHttpRequest(), mockMsg, mapping);
			fail();
		} catch (DefaultChannelInvalidConfigException ex) {