Archive for the ‘Java’ Category

Using Badboy to build JMeter Test Plans over an SSL

Wednesday, June 8th, 2011

I’ve just recently began using JMeter to stress/load test a Coldfusion application. After reading some blogs on JMeter I got everything set up locally and created a proxy site to my application. But I quickly realized that the proxy is not supported for applications running under an SSL.

The JMeter forum revealed that an easy way to create test cases under an SSL is to actually create the test with a program called Badboy. Luckily for me I’ve been using badboy for automated regression testing for the past year or so. I had never noticed however, that once a badboy test is created there is an export to JMeter option. After exporting a test case I then learned that the badboy export has not yet been updated to support JMeter 2.4. However, it does support JMeter 2.3.4

So the steps for setting up an environment for creating JMeter 2.4 test cases for an application running under an SSL are:

  1. Download JMeter 2.4 (http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi)
  2. Download JMeter 2.3 (http://archive.apache.org/dist/jakarta/jmeter/binaries/)
  3. Download BadBoy (http://www.badboy.com.au/download/index)

Note that both versions of JMeter are downloaded on the assumption that you will want to execute your JMeter tests in 2.4, but you will need 2.3 to make the test cases compatible with 2.4. If you are happy just using 2.3 then you will not need to download 2.4.

Once you have the necessary software do the following:

(more…)

Using Java to compare Coldfusion objects

Monday, November 22nd, 2010

This past weekend I was building some unit tests when I came across a situation where I needed to compare two Coldfusion objects for equality. If I had a way to simply assert true the equality of two objects would make the test infinitely more simple than what it need be.

I have never really had a need to do this before and am not aware of any way in coldfusion to compare complex objects against one another. However, since CF is built on the very powerful Java libraries it didn’t take much digging to turn up the Java equals() function that accepts an object to be compared against. It essentially works with something like:

isequal = object1.equals(object2);

Pretty straight forward. Let’s look at an example illustrating how to grab this function and utilize it using Coldfusion on Coldfusion objects.

Java Equals() in Coldfusion

<!--- get the Java Comparator class --->
<cfset variables.comparator = createObject("java", "java.util.Comparator") />

<!--- build the first object --->
<cfset variables.objectOne = structNew() />
<cfset variables.objectOne.name = "matt" />
<cfset variables.objectOne.lastname = "cook" />

<!--- build the second object --->
<cfset variables.objectTwo = structNew() />
<cfset variables.objectTwo.name = "matt" />
<cfset variables.objectTwo.lastname = "cook" />

<!--- compare the objects --->
<cfset variables.isEqual = variables.objectTwo.Equals(variables.objectOne) />

<!--- output the boolean --->
<cfdump var="#variables.isEqual#" />

(more…)

Setting print margins using Eclipse to maintain line character length

Friday, May 14th, 2010

Sometimes you may have standard line lengths with which to work when writing code. If this is the case and your using Coldfusion and Eclipse with the cfEclipse plugin you can maintain the character length consistency by setting up the print margins to n character length.

Point being that when running the cfeclipse plugin you need to choose CFEclipse > Editor in the preferences left navigation. In the options you will check ‘Show print margin’, set the ‘Print margin column’ text field to the desired character length, and if you choose the ‘Print margin’ option in the ‘Appearance color options’ select box. Then choose the color you wish the margin to be. This will set a line length that will show in the code editor pane. Of course it will not wrap the line. It is still your duty as a developer to wrap appropriately. Nonetheless it does give you a guide for where the line should wrap at least.

If you’re writing Java then you would select General > Editor > Text Editors in the preferences pane.  Although the display is slightly different, generally follow the same steps as above for showing the print margin.

If you’re using Coldfusion Builder you will follow the same exact directions as listed just above for showing the print margins writing Java.

Lastly, if you’re using Flex Builder 3 you will again follow the same directions as above for showing print margins writing Java.