Skip to content

Commit

Permalink
MULE-8405: Removing parsing from resource loading logic. Adding test …
Browse files Browse the repository at this point in the history
…case for scenario.
  • Loading branch information
afelisatti committed Mar 25, 2015
1 parent 781d3f3 commit ce3314b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 59 deletions.
58 changes: 1 addition & 57 deletions core/src/main/java/org/mule/util/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static String getResourceAsString(final String resourceName, final Class
public static InputStream getResourceAsStream(final String resourceName,
final Class callingClass) throws IOException
{
return getResourceAsStream(parseResourceName(resourceName), callingClass, true, true);
return getResourceAsStream(resourceName, callingClass, true, true);
}

/**
Expand Down Expand Up @@ -194,62 +194,6 @@ public Object run()
}
return url;
}

/**
* This method checks whether the name of the resource needs to be parsed. If it
* is, it parses the name and tries to get the variable from the Environmental
* Variables configured on the system.
*
* @param src
*/
private static String parseResourceName(String src)
{
String var;
String[] split;
String ps = File.separator;

if (src.indexOf('$') > -1)
{
split = src.split("}");
}
else
{
return src;
}

var = split[0].substring(2);
var = SystemUtils.getenv(var);
if (split.length > 1)
{
if (var == null)
{
var = System.getProperty(split[0].substring(2));
if (var == null)
{
return split[1].substring(1);
}
else
{
return var + ps + split[1].substring(1);
}
}
else
{
return var + ps + split[1].substring(1);
}
}
else
{
if (var == null)
{
return "";
}
else
{
return var;
}
}
}

/**
* This method wraps {@link org.apache.commons.io.IOUtils}' <code>toString(InputStream)</code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.mule.api.construct.FlowConstruct;
import org.mule.tck.functional.EventCallback;
import org.mule.tck.functional.FunctionalTestComponent;
import org.mule.tck.junit4.rule.SystemProperty;
import org.mule.transport.http.HttpConstants;
import org.mule.transport.http.HttpsConnector;

Expand All @@ -25,10 +26,18 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import org.junit.Rule;
import org.junit.runners.Parameterized.Parameters;

public class HttpsFunctionalTestCase extends HttpFunctionalTestCase
{

public static final String SERVER_KEYSTORE_PATH = "serverKeystorePath";
public static final String SERVER_KEYSTORE = "serverKeystore";

@Rule
public SystemProperty serverKeystoreProperty = new SystemProperty(SERVER_KEYSTORE_PATH, SERVER_KEYSTORE);

public HttpsFunctionalTestCase(ConfigVariant variant, String configResources)
{
super(variant, configResources);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.transport.http.functional;

import org.mule.util.IOUtils;

import java.io.File;

import org.apache.commons.io.FileUtils;

public class HttpsSpecialCharKeystoreTestCase extends HttpsFunctionalTestCase
{

public HttpsSpecialCharKeystoreTestCase(ConfigVariant variant, String configResources)
{
super(variant, configResources);
}

@Override
protected void doSetUpBeforeMuleContextCreation() throws Exception
{
super.doSetUpBeforeMuleContextCreation();
File serverKeystore = new File(IOUtils.getResourceAsUrl(SERVER_KEYSTORE, getClass()).getPath());
File serverKeystoreCopy = new File(workingDirectory.getRoot().getPath() + "/dir$/serverKeystore");
FileUtils.copyFile(serverKeystore, serverKeystoreCopy);
//this is a SystemProperty rule defined in the superclass
System.setProperty(SERVER_KEYSTORE_PATH, serverKeystoreCopy.getPath());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<https:connector name="httpConnector">
<https:tls-client path="clientKeystore" storePassword="mulepassword"/>
<https:tls-key-store path="serverKeystore" keyPassword="mulepassword" storePassword="mulepassword"/>
<https:tls-key-store path="${serverKeystorePath}" keyPassword="mulepassword" storePassword="mulepassword"/>
<https:tls-server path="trustStore" storePassword="mulepassword"/>
</https:connector>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<https:connector name="httpConnector">
<https:tls-client path="clientKeystore" storePassword="mulepassword"/>
<https:tls-key-store path="serverKeystore" keyPassword="mulepassword" storePassword="mulepassword"/>
<https:tls-key-store path="${serverKeystorePath}" keyPassword="mulepassword" storePassword="mulepassword"/>
<https:tls-server path="trustStore" storePassword="mulepassword"/>
</https:connector>

Expand Down

0 comments on commit ce3314b

Please sign in to comment.