You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2011/11/03 17:29:32 UTC

svn commit: r1197207 - /jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java

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);
     }
 
     /**



Re: svn commit: r1197207 - /jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java

Posted by sebb <se...@gmail.com>.
On 3 November 2011 16:49, Philippe Mouawad <ph...@gmail.com> wrote:
> Only useful case is when you make many tests with different JMX files and
> don't want to use Keystore Config but I agree it's not a big argument :-) .

The keystore is currently enabled if the System property is defined.

If the KeystoreConfig were enhanced to include the keystore file name,
then we could change the code to only use the Keystore if the Config
element is present.
This would behave more like the CookieManager.

Howerer this would be a change to existing tests that use keystores.

However, we can use the KeystoreConfig as the only means to configure
the indexes; if a user wants to vary the values at run time they can
always use the __P() function.

> Should I remove them everywhere ?
>

I need to think a bit more about it.

>
> On Thu, Nov 3, 2011 at 5:43 PM, sebb <se...@gmail.com> wrote:
>
>> On 3 November 2011 16:29,  <pm...@apache.org> wrote:
>> > 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
>>
>> I don't think we need to support the properties.
>> They were introduced after 2.5.1, so have not been in a released product.
>>
>> Not sure using the property gains anything.
>>
>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>

Re: svn commit: r1197207 - /jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java

Posted by Philippe Mouawad <ph...@gmail.com>.
Only useful case is when you make many tests with different JMX files and
don't want to use Keystore Config but I agree it's not a big argument :-) .
Should I remove them everywhere ?



On Thu, Nov 3, 2011 at 5:43 PM, sebb <se...@gmail.com> wrote:

> On 3 November 2011 16:29,  <pm...@apache.org> wrote:
> > 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
>
> I don't think we need to support the properties.
> They were introduced after 2.5.1, so have not been in a released product.
>
> Not sure using the property gains anything.
>



-- 
Cordialement.
Philippe Mouawad.

Re: svn commit: r1197207 - /jmeter/trunk/src/components/org/apache/jmeter/config/KeystoreConfig.java

Posted by sebb <se...@gmail.com>.
On 3 November 2011 16:29,  <pm...@apache.org> wrote:
> 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

I don't think we need to support the properties.
They were introduced after 2.5.1, so have not been in a released product.

Not sure using the property gains anything.