Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #15 from forcedotcom/proxy
Browse files Browse the repository at this point in the history
Adding in parameters for using a proxy host connection
  • Loading branch information
adarsh-ramakrishna-sfdc committed Jan 9, 2016
2 parents 92a13e1 + d79e0e1 commit 0fb03fd
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ mvn compile exec:java -Dexec.mainClass="com.sforce.cd.apexUnit.ApexUnitRunner"
$manifest_Files_For_Apex_Test_Classes_To_Execute
-manifest.files.with.source.class.names.for.code.coverage.computation
$manifest_Files_For_Apex_Source_Classes_to_compute_code_coverage
-max.test.execution.time.threshold
-max.test.execution.time.threshold
$max_time_threshold_for_test_execution_to_abort"
-proxy.host
$prox_host
-proxy.port
$proxy_port

```
*Please replace all $xyz with the values specific to your environment/project*
Expand All @@ -73,13 +77,15 @@ Optional Parameters:
- -manifest.files.with.test.class.names.to.execute : Manifest files containing the list of test classes to be executed
- -manifest.files.with.source.class.names.for.code.coverage.computation : Manifest files containing the list of Apex classes for which code coverage is to be computed
- -max.test.execution.time.threshold : Maximum execution time(in minutes) for a test before it gets aborted
- -proxy.host : Proxy host for external access
- -proxy.port : Proxy port for external access
- -help : Displays options available for running this application

Note: User must provide either of the (-regex.for.selecting.source.classes.for.code.coverage.computation OR -manifest.files.with.source.class.names.for.code.coverage.computation) AND either of -(regex.for.selecting.test.classes.to.execute OR -manifest.files.with.test.class.names.to.execute)

Sample command:
```java
mvn compile exec:java -Dexec.mainClass="com.sforce.cd.apexUnit.ApexUnitRunner" -Dexec.args=" -org.login.url https://na14.salesforce.com -org.username test****@salesforce.com -org.password ****** -org.wide.code.coverage.threshold 75 -team.code.coverage.threshold 80 -org.client.id ******* -org.client.secret ***** -regex.for.selecting.test.classes.to.execute Sample*Test,Sample*test -regex.for.selecting.source.classes.for.code.coverage.computation Sample,Mobile,Wrapper -manifest.files.with.test.class.names.to.execute ManifestFile.txt -manifest.files.with.source.class.names.for.code.coverage.computation ClassManifestFile.txt -max.test.execution.time.threshold 10"
mvn compile exec:java -Dexec.mainClass="com.sforce.cd.apexUnit.ApexUnitRunner" -Dexec.args=" -org.login.url https://na14.salesforce.com -org.username test****@salesforce.com -org.password ****** -org.wide.code.coverage.threshold 75 -team.code.coverage.threshold 80 -org.client.id ******* -org.client.secret ***** -regex.for.selecting.test.classes.to.execute Sample*Test,Sample*test -regex.for.selecting.source.classes.for.code.coverage.computation Sample,Mobile,Wrapper -manifest.files.with.test.class.names.to.execute ManifestFile.txt -manifest.files.with.source.class.names.for.code.coverage.computation ClassManifestFile.txt -max.test.execution.time.threshold 10 -proxy.host your.proxy-if-required.net -proxy.port 8080"
```
Note: Multiple comma separated manifest files and regexes can be provided.Please do not include spaces while providing multiple regex or manifest files.

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<groupId>com.sforce.cd.ApexUnit</groupId>
<artifactId>ApexUnit-core</artifactId>
<version>2.3.0.5</version>
<version>2.3.0.6</version>
<name>ApexUnit</name>
<description>Apex Unit v 2.0 with enhanced metrics and advanced features</description>
<!-- Fail fast for older Maven versions -->
Expand Down Expand Up @@ -208,4 +208,4 @@
</dependency>

</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class CommandLineArguments {
public static final String MAX_TEST_EXECUTION_TIME_THRESHOLD = "-max.test.execution.time.threshold";
public static final String ORG_CLIENT_ID = "-org.client.id";
public static final String ORG_CLIENT_SECRET = "-org.client.secret";
public static final String PROXY_HOST = "-proxy.host";
public static final String PROXY_PORT = "-proxy.port";

public static final String HELP = "-help";

/*
Expand Down Expand Up @@ -86,6 +89,10 @@ public class CommandLineArguments {
static private String clientId;
@Parameter(names = ORG_CLIENT_SECRET, description = "Client Secret associated with the org.", required = true)
static private String clientSecret;
@Parameter(names = PROXY_HOST, description = "Proxy host if required for access.", required = false)
static private String proxyHost;
@Parameter(names = PROXY_PORT, description = "Proxy port if required for access.", validateWith = PositiveIntegerValidator.class, required = false)
static private String proxyPort;
@Parameter(names = HELP, help = true, description = "Displays options available for running this application")
static private boolean help;

Expand Down Expand Up @@ -144,6 +151,14 @@ public static String getClientSecret() {
return clientSecret;
}

public static String getProxyHost() {
return proxyHost;
}

public static String getProxyPort() {
return proxyPort;
}

public static void setClientSecret(String clientSecret) {
CommandLineArguments.clientSecret = clientSecret;
}
Expand All @@ -153,3 +168,4 @@ public static boolean isHelp() {

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ private PartnerConnection createConnection() {
config.setUsername(CommandLineArguments.getUsername());
config.setPassword(CommandLineArguments.getPassword());
config.setAuthEndpoint(CommandLineArguments.getOrgUrl() + "/services/Soap/u/" + SUPPORTED_VERSION);

if (CommandLineArguments.getProxyHost() != null && CommandLineArguments.getProxyPort() !=null ){
LOG.debug("Setting proxy configuraiton to " +
CommandLineArguments.getProxyHost() +
" on port " + CommandLineArguments.getProxyPort() );
config.setProxy( CommandLineArguments.getProxyHost() , CommandLineArguments.getProxyPort());
}

LOG.debug("creating connection for : " + CommandLineArguments.getUsername() + " "
+ CommandLineArguments.getPassword() + " " + CommandLineArguments.getOrgUrl() + " "
+ config.getUsername() + " " + config.getPassword() + " " + config.getAuthEndpoint());
Expand Down Expand Up @@ -169,7 +177,13 @@ private BulkConnection createBulkConnection() {
config.setRestEndpoint(restEndPoint);
config.setCompression(true);
config.setTraceMessage(false);
// config.setProxy("Proxy", 8080);

if (CommandLineArguments.getProxyHost() != null && CommandLineArguments.getProxyPort() !=null ){
LOG.debug("Setting proxy configuraiton to " +
CommandLineArguments.getProxyHost() +
" on port " + CommandLineArguments.getProxyPort() );
config.setProxy( CommandLineArguments.getProxyHost() , CommandLineArguments.getProxyPort());
}
try {
bulkConnection = new BulkConnection(config);
LOG.info("Bulk connection established.");
Expand Down Expand Up @@ -214,3 +228,4 @@ public static String logConnectionException(ConnectionException e, String soql)
}

}

5 comments on commit 0fb03fd

@tfuda
Copy link
Contributor

@tfuda tfuda commented on 0fb03fd Jan 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adarsh-ramakrishna-sfdc I updated my fork with this code change. When I clean and compile, I get the following compilation errors:

[INFO] Compiling 22 source files to C:\Users\tom\Development\Java\git\ApexUnit\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] \Users\tom\Development\Java\git\ApexUnit\src\main\java\com\sforce\cd\apexUnit\client\connection\ConnectionHandler.java:[118,92] error: incompatible types: String cannot be converted to int
[ERROR] \Users\tom\Development\Java\git\ApexUnit\src\main\java\com\sforce\cd\apexUnit\client\connection\ConnectionHandler.java:[185,91] error: incompatible types: String cannot be converted to int

I believe the type of proxyPort property in CommandLineArguments.java should be changed from a String to an Integer, because the value for the proxy port argument passed to the ConnectionConfig.setProxy method is expected to be an int, and String cannot be implicitly converted to int.

@adarsh-ramakrishna-sfdc
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tfuda
Yes Compilation fails.
@pauldavidchristian : Can you please look into this?
Or shall I fix this issue?

@tfuda
Copy link
Contributor

@tfuda tfuda commented on 0fb03fd Jan 15, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tfuda
Copy link
Contributor

@tfuda tfuda commented on 0fb03fd Jan 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See issue #19 and PR #20.

@adarsh-ramakrishna-sfdc
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tfuda
I have reviewed The PR and @vamshi-sfdc will review the PR next

Please sign in to comment.