diff --git a/README.md b/README.md index bfba008..48bc0eb 100644 --- a/README.md +++ b/README.md @@ -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* @@ -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. diff --git a/pom.xml b/pom.xml index cb971e5..02b84f7 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ com.sforce.cd.ApexUnit ApexUnit-core - 2.3.0.5 + 2.3.0.6 ApexUnit Apex Unit v 2.0 with enhanced metrics and advanced features @@ -208,4 +208,4 @@ - \ No newline at end of file + diff --git a/src/main/java/com/sforce/cd/apexUnit/arguments/CommandLineArguments.java b/src/main/java/com/sforce/cd/apexUnit/arguments/CommandLineArguments.java index 0cbefee..d3ff016 100644 --- a/src/main/java/com/sforce/cd/apexUnit/arguments/CommandLineArguments.java +++ b/src/main/java/com/sforce/cd/apexUnit/arguments/CommandLineArguments.java @@ -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"; /* @@ -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; @@ -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; } @@ -153,3 +168,4 @@ public static boolean isHelp() { } } + diff --git a/src/main/java/com/sforce/cd/apexUnit/client/connection/ConnectionHandler.java b/src/main/java/com/sforce/cd/apexUnit/client/connection/ConnectionHandler.java index 16460d8..1b0675c 100644 --- a/src/main/java/com/sforce/cd/apexUnit/client/connection/ConnectionHandler.java +++ b/src/main/java/com/sforce/cd/apexUnit/client/connection/ConnectionHandler.java @@ -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()); @@ -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."); @@ -214,3 +228,4 @@ public static String logConnectionException(ConnectionException e, String soql) } } +