From commits-return-46-apmail-jmeter-commits-archive=jmeter.apache.org@jmeter.apache.org Thu Nov 3 16:29:57 2011 Return-Path: X-Original-To: apmail-jmeter-commits-archive@minotaur.apache.org Delivered-To: apmail-jmeter-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1CF1678CC for ; Thu, 3 Nov 2011 16:29:57 +0000 (UTC) Received: (qmail 37654 invoked by uid 500); 3 Nov 2011 16:29:56 -0000 Delivered-To: apmail-jmeter-commits-archive@jmeter.apache.org Received: (qmail 37636 invoked by uid 500); 3 Nov 2011 16:29:56 -0000 Mailing-List: contact commits-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jmeter.apache.org Delivered-To: mailing list commits@jmeter.apache.org Received: (qmail 37629 invoked by uid 99); 3 Nov 2011 16:29:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Nov 2011 16:29:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Nov 2011 16:29:54 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0AE042388847 for ; Thu, 3 Nov 2011 16:29:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1197207 - /jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java Date: Thu, 03 Nov 2011 16:29:32 -0000 To: commits@jmeter.apache.org From: pmouawad@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111103162933.0AE042388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pmouawad Date: Thu Nov 3 16:29:32 2011 New Revision: 1197207 URL: http://svn.apache.org/viewvc?rev=1197207&view=rev Log: BUG_52033 : Default to jmeter.properties if start and end not set Handle errors in inputed start and endIndex Modified: jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java Modified: jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java?rev=1197207&r1=1197206&r2=1197207&view=diff ============================================================================== --- jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java (original) +++ jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java Thu Nov 3 16:29:32 2011 @@ -18,11 +18,14 @@ package org.apache.jmeter.config; +import org.apache.commons.lang.StringUtils; import org.apache.jmeter.engine.event.LoopIterationEvent; import org.apache.jmeter.testbeans.TestBean; import org.apache.jmeter.testelement.TestListener; +import org.apache.jmeter.util.JMeterUtils; import org.apache.jmeter.util.SSLManager; import org.apache.jorphan.logging.LoggingManager; +import org.apache.jorphan.util.JMeterStopTestException; import org.apache.log.Logger; /** @@ -35,6 +38,9 @@ public class KeystoreConfig extends Conf private static final long serialVersionUID = -5781402012242794890L; private Logger log = LoggingManager.getLoggerForClass(); + private static final String KEY_STORE_START_INDEX = "https.keyStoreStartIndex"; // $NON-NLS-1$ + private static final String KEY_STORE_END_INDEX = "https.keyStoreEndIndex"; // $NON-NLS-1$ + private String startIndex; private String endIndex; private String preload; @@ -79,11 +85,33 @@ public class KeystoreConfig extends Conf * {@inheritDoc} */ public void testStarted(String host) { + int startIndexAsInt = JMeterUtils.getPropDefault(KEY_STORE_START_INDEX, 0); + int endIndexAsInt = JMeterUtils.getPropDefault(KEY_STORE_END_INDEX, 0); + + if(!StringUtils.isEmpty(this.startIndex)) { + try { + startIndexAsInt = Integer.parseInt(this.startIndex); + } catch(NumberFormatException e) { + log.warn("Failed parsing startIndex :'"+this.startIndex+"', will default to:'"+startIndexAsInt+"', error message:"+ e.getMessage(), e); + } + } + + if(!StringUtils.isEmpty(this.endIndex)) { + try { + endIndexAsInt = Integer.parseInt(this.endIndex); + } catch(NumberFormatException e) { + log.warn("Failed parsing endIndex :'"+this.endIndex+"', will default to:'"+endIndexAsInt+"', error message:"+ e.getMessage(), e); + } + } + if(startIndexAsInt>endIndexAsInt) { + throw new JMeterStopTestException("Keystore Config error : Alias start index must be lower than Alias end index"); + } log.info("Configuring Keystore with (preload:"+preload+", startIndex:"+ - startIndex+", endIndex:"+endIndex); + startIndexAsInt+", endIndex:"+endIndexAsInt+")"); + SSLManager.getInstance().configureKeystore(Boolean.valueOf(preload), - Integer.parseInt(startIndex), - Integer.parseInt(endIndex)); + startIndexAsInt, + endIndexAsInt); } /**