Best damned pickles in the world.

Up until yesterday, i had not found a good way to test my LDAP client code besides manually testing it, which is simply unacceptable from my standpoint.

But thanks to this stack overflow anwer I was lead to the Unboundid LDAP SDK.

After playing around writing tests with it, I quickly refactored my test code into an annotation based test utility that allows me to easily start up the server and seed it with information. I’ve put the code on Github.

Update 2013-01-28 - ldap-test-utils should be in Maven Central in a day or two. I released version 1.0.0. If you have any feature requests, submit them on github.

We use Rally at work for managing our development efforts. The tool itself is OK but something as simple as creating a defect can take too long. Some defects were going unreported because it was too cumbersome to enter even very minor cosmetic bugs. A couple of years ago I used a Rally tool for creating defects from screenshots and this was great but apparently it’s no longer maintained. In lieu of creating an entire application I decided to glue together the actions via Apple’s Automator application, some AppleScript and Ruby.

The first thing I did was to use the excellent Rally APIs via the rally_rest_api gem for Ruby. This allows you pretty much full access to all of your information in Rally, even uploading screenshots. I created a simple script called createdefect.rb that uses the API, creates a defect in a project and attaches the screenshot. The script itself takes only three arguments at this point : the defect title, the file name to attach and the Rally project. Here’s an example:

./createdefect.rb “This is my defect” “~/Desktop/bug01.png” “Rizzo”

This creates a defect in the project “Rizzo (new SSO)” with the given title and attachment. The project doesn’t have to match exactly, a downcase.start_with? predicate is used to locate the project.

With Ruby script working, I wanted a way to invoke it using a shortcut key or through the services menu on my Mac. I had used Automator before so I figured I could get it done that way. I created a Service Workflow in automator that invoked the ruby script. Before invocation however, I needed to get some input from the user (me) to pass to the script.

First - the title. I wrote an apple script to get feedback from the user using the ‘display dialog’ commands in AppleScript. Unfortunately, it wasn’t until after completion that I noticed that a simple “Ask for Text” action exists in Automator. Oh well.

Second - the project. I found a nice forum post (sorry i lost the link) that shows how to use the “choose from list” applescript function. This allowed me to supply a list of projects from which to choose.

Third - the image. This is built in to Automator. When you create an automator service, you define the type of input that is accepted. I chose ‘image files’.

So, the entire automator workflow essentially goes like this:

  1. accept image file(s)
  2. Set “ImageFile” variable to the input.
  3. Run AppleScript to get the Defect Title via a dialog box
  4. Set “Title” variable to AppleScript output
  5. Run AppleScript to allow the user to choose the project
  6. Set “RallyProject” to the user choice
  7. Get Variable (“Title”)
  8. Get Variable (“RallyProject”)
  9. Get Variable (“ImageFile”)
  10. Run Shell Script /Users/trevershick/bin/createdefect.rb “$1” “$3” “$2” | grep “defect created”
  11. Run AppleScript to display the created defect number

Automator

Workflow Results (in screenshots)

Invoke the Service

image

Provide a Defect Title

image

Choose a Project

image

Defect Confirmation

image

Result in Rally

image

Issues

I had several issues working with Ruby and the Automator. Mainly I had issues because I use rvm and when Automator executes shell scripts, it doesn’t have the benefit of rvm. I worked around this issue by using the stock Ruby install on the mac to test/run the createdefect.rb script which also required gems be installed globally on the mac. Perhaps I could have worked around this by invoking rvm or by installing rvm as the root user but I simply didn’t care enough to do that. The stock ruby install works fine.

Code

a simple and easy tip or speeding up Terminal

I do development and sometimes I have to recreate issues with actual data which means using other people’s email addresses. Obviously I don’t want to send them email while i’m testing so I use Apache James as a local only email server.

Here are the steps i use to set this up.

Download and Run James Server

From http://james.apache.org/download.cgi or directly from http://mirror.nyi.net/apache//james/server/apache-james-2.3.2.zip and extract to a folder.

As i’m running a mac, I added the following to run.sh. If you’re on a windows machine, this step may not be required.

Start the server…

On a mac

bin/run.sh

On windows

bin/run.bat

Create a local email account

    $ telnet localhost 4555
    Trying ::1...
    telnet: connect to address ::1: Connection refused
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    JAMES Remote Administration Tool 2.3.2
    Please enter your login and password
    Login id:
    root
    Password:
    root
    adduser me me
    User me added

Remove the Remote Delivery Mailet

Remove ( or comment out ) the Remote Delivery mailet in <james_home>/apps/james/SAR-INF/config.xml . Open the file and search on ‘class=”RemoteDelivery”’, and comment out the whole stanza.

Forward all email to the local account

Important

It’s very important that you configure the forwarding mailet to be in the same place where the RemoteDelivery mailet was. If you put it too early in the config.xml you may get errors when it attempts to forward a message.

Insert the following mailet in the place where the RemoteDelivery mailet was previously located in ( <james_home>/apps/james/SAR-INF/config.xml ).

Run the Server

Save your changes in the config.xml file and start the server.

On a mac

sudo bin/run.sh

On windows

bin/run.bat

Test the Mail Server

Send an email to me@localhost and use a POP client to ‘get’ the email. You should see it.
Send an email to anywhere@anywhere.net and retrieve the message, it should be redirected to your local inbox.


Install Mutt

On a mac I use homebrew ( http://mxcl.github.com/homebrew/ ), and simply run:

brew install mutt

Configure Mutt

Run Mutt

  1. send a test email by pressing ‘m’ to get started, test me@localhost first
  2. after the mail is sent, press ‘G’ to get the mail from the pop server, you should have received the email you sent.
  3. repeat with an external email address - all email flowing to your local server should be redirected to me@localhost .

So, search.maven.org is a great site, but i don’t want to bring up a browser just to find artifacts. In an effort to bone-up on my groovy I thought i’d create a groovy script that would search for me.

Feel free to use this script, and if you can improve it, fork it and make ur own changes.

In this post i make the claim that you might be an a-hole if you have a variable name longer than ‘in the garden of eden’… Well, ‘yesIKnowItShouldBeSingleton’ is my violation of this rule. wonk wonk…

If your variable name has more syllables than “In the garden of eden” then you might be an a-hole.


Object queryImplUnderConstruction;

I came across this page today. I was providing some information to these guys and apparently I had put ‘anyhoo’ at the bottom of the page. Made me laugh at least.