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

Commit 0fb03fd

Browse files
Merge pull request #15 from forcedotcom/proxy
Adding in parameters for using a proxy host connection
2 parents 92a13e1 + d79e0e1 commit 0fb03fd

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ mvn compile exec:java -Dexec.mainClass="com.sforce.cd.apexUnit.ApexUnitRunner"
5252
$manifest_Files_For_Apex_Test_Classes_To_Execute
5353
-manifest.files.with.source.class.names.for.code.coverage.computation
5454
$manifest_Files_For_Apex_Source_Classes_to_compute_code_coverage
55-
-max.test.execution.time.threshold
55+
-max.test.execution.time.threshold
5656
$max_time_threshold_for_test_execution_to_abort"
57+
-proxy.host
58+
$prox_host
59+
-proxy.port
60+
$proxy_port
5761

5862
```
5963
*Please replace all $xyz with the values specific to your environment/project*
@@ -73,13 +77,15 @@ Optional Parameters:
7377
- -manifest.files.with.test.class.names.to.execute : Manifest files containing the list of test classes to be executed
7478
- -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
7579
- -max.test.execution.time.threshold : Maximum execution time(in minutes) for a test before it gets aborted
80+
- -proxy.host : Proxy host for external access
81+
- -proxy.port : Proxy port for external access
7682
- -help : Displays options available for running this application
7783

7884
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)
7985

8086
Sample command:
8187
```java
82-
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"
88+
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"
8389
```
8490
Note: Multiple comma separated manifest files and regexes can be provided.Please do not include spaces while providing multiple regex or manifest files.
8591

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<groupId>com.sforce.cd.ApexUnit</groupId>
3333
<artifactId>ApexUnit-core</artifactId>
34-
<version>2.3.0.5</version>
34+
<version>2.3.0.6</version>
3535
<name>ApexUnit</name>
3636
<description>Apex Unit v 2.0 with enhanced metrics and advanced features</description>
3737
<!-- Fail fast for older Maven versions -->
@@ -208,4 +208,4 @@
208208
</dependency>
209209

210210
</dependencies>
211-
</project>
211+
</project>

src/main/java/com/sforce/cd/apexUnit/arguments/CommandLineArguments.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class CommandLineArguments {
5252
public static final String MAX_TEST_EXECUTION_TIME_THRESHOLD = "-max.test.execution.time.threshold";
5353
public static final String ORG_CLIENT_ID = "-org.client.id";
5454
public static final String ORG_CLIENT_SECRET = "-org.client.secret";
55+
public static final String PROXY_HOST = "-proxy.host";
56+
public static final String PROXY_PORT = "-proxy.port";
57+
5558
public static final String HELP = "-help";
5659

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

@@ -144,6 +151,14 @@ public static String getClientSecret() {
144151
return clientSecret;
145152
}
146153

154+
public static String getProxyHost() {
155+
return proxyHost;
156+
}
157+
158+
public static String getProxyPort() {
159+
return proxyPort;
160+
}
161+
147162
public static void setClientSecret(String clientSecret) {
148163
CommandLineArguments.clientSecret = clientSecret;
149164
}
@@ -153,3 +168,4 @@ public static boolean isHelp() {
153168

154169
}
155170
}
171+

src/main/java/com/sforce/cd/apexUnit/client/connection/ConnectionHandler.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ private PartnerConnection createConnection() {
110110
config.setUsername(CommandLineArguments.getUsername());
111111
config.setPassword(CommandLineArguments.getPassword());
112112
config.setAuthEndpoint(CommandLineArguments.getOrgUrl() + "/services/Soap/u/" + SUPPORTED_VERSION);
113+
114+
if (CommandLineArguments.getProxyHost() != null && CommandLineArguments.getProxyPort() !=null ){
115+
LOG.debug("Setting proxy configuraiton to " +
116+
CommandLineArguments.getProxyHost() +
117+
" on port " + CommandLineArguments.getProxyPort() );
118+
config.setProxy( CommandLineArguments.getProxyHost() , CommandLineArguments.getProxyPort());
119+
}
120+
113121
LOG.debug("creating connection for : " + CommandLineArguments.getUsername() + " "
114122
+ CommandLineArguments.getPassword() + " " + CommandLineArguments.getOrgUrl() + " "
115123
+ config.getUsername() + " " + config.getPassword() + " " + config.getAuthEndpoint());
@@ -169,7 +177,13 @@ private BulkConnection createBulkConnection() {
169177
config.setRestEndpoint(restEndPoint);
170178
config.setCompression(true);
171179
config.setTraceMessage(false);
172-
// config.setProxy("Proxy", 8080);
180+
181+
if (CommandLineArguments.getProxyHost() != null && CommandLineArguments.getProxyPort() !=null ){
182+
LOG.debug("Setting proxy configuraiton to " +
183+
CommandLineArguments.getProxyHost() +
184+
" on port " + CommandLineArguments.getProxyPort() );
185+
config.setProxy( CommandLineArguments.getProxyHost() , CommandLineArguments.getProxyPort());
186+
}
173187
try {
174188
bulkConnection = new BulkConnection(config);
175189
LOG.info("Bulk connection established.");
@@ -214,3 +228,4 @@ public static String logConnectionException(ConnectionException e, String soql)
214228
}
215229

216230
}
231+

0 commit comments

Comments
 (0)