Blogbody Rotating Header Image

This blog has moved

After several days of playing with Posterous and Tumblr I’ve decided to move my blog over to http://blog.lightbody.net (powered by Tumbler).

If you are one of the few RSS subscribers still watching this blog (which would surprise me since it’s been ~2 years since my last post), it should auto switch over to the new blog since I’m using FeedBurner.

However, be on the lookout if you don’t see more regular updates because I really do fully intend to blog quite a bit more starting now :)

New Book: Apache Struts 2 Web Application Development

Great Article on Advanced Selenium

I was forwarded a great article on advanced Selenium techniques. Worth a read for anyone who uses Selenium. While the article focuses on ExtJS, the lessons in there can be applied for any website. Building Java (or perl or python, etc)-based components that represent the logical page is a technique I’ve used in the past, but it’s great to see it written up so clearly!

Security with Java Scripting (JRuby, Jython, Groovy, BeanShell, etc)

I’m looking to run some un-verified scripts (written in a yet-to-be-determined language, but needs to be Java-based, so JRuby, Groovy, Jython, BeanShell, etc are all candidates). I want these scripts to be able to do some things and restricted from doing other things.

Normally, I’d just go use Java’s SecurityManager and be done with it. That’s pretty simple and lets me restrict file and network access, the ability to shutdown the JVM, etc. And that will work well for the high level stuff I want to block off.

But there is some stuff I want to allow, but only via my custom API/library that I’ve providing. For example, I don’t want to allow direct network access to open up a URLConnection to yahoo.com, but I am OK if it is done with MyURLConnection. That is – there is a set of methods/classes that I want to allow and then everything else I want to be off limits.

I don’t believe this type of security can be done with the standard Java security model, but perhaps it can. I don’t have a specific requirement for performance or flexibility in the scripting language itself (the scripts will be simple procedural calls to my API with basic looping/branching). So even a “large” overhead that checks a security check on every reflection call is fine by me.

Suggestions?

IDEA 8: Buggy as Hell

Here is a running list of all the bugs I’ve come across with IntelliJ IDEA 8 so far. Some of these may actually be thoughtful changes from the behavior in version 7, but they are annoying so I’m calling them bugs :)

  • Can no longer autocomplete lowercase for enums. For example, typing “TimeUnit.sec” does not prompt for TimeUnit.SECONDS. This used to work in IDEA 7 and is inconsistent with autocomplete for methods (“getcon” prompts “getConnectionTimeout”).
  • Pasting a block of code no longer always asks asks me to auto-import the classes needed to make the code work. It does in some cases, but not in others.
  • I don’t remember searching by files (Command-Shift-N) showing me .java files unless there was no other match for my search. This annoys me, since now when I search for “foo” I expect to see foo.jsp to be selected first (it’s listed first), but FooActionBean.java is listed at the bottom but sometimes it is preselected, making me have to use the arrow keys.
  • Sometimes, especially on more complex pages, HTML auto tag closing (ie: “<ul>” causes “</ul>” to be inserted) doesn’t work for all tags. I’ve seen cases where it works for <li> but not for <ul> or <div>.
  • <title> tags don’t get indented in a <head> tag unless there is additional content in the head section. This may have been done on purpose, but I don’t like it. I end up having to correct the indentation myself or running the auto-format, which is always risky.
  • Pasting HTML/JSP snippets from one part of a JSP to another part causes the indentation to be completely lost (shifted all the way to the left). In the previous versions, IDEA was smart enough to paste in and match the correct indentation level for the context I just pasted in to.
  • When renaming/moving a class, any JSP tag that references it (ie: “<s:link beanclass=’foo.Bar’>…”) will get HTML escaped, completely breaking the behavior and introducing a bug in to my code. Worst yet: it won’t even tell me, which is totally breaks my trust of IDEA’s traditionally excellent refactoring tools.
  • Related to the above – when tying a fully qualified class name in a JSP tag, typing lower case letters (“foobar”) will prompt the class “FooBar”. This is good. But when I press enter on the selected class, the resulting text is all lower case “foobar” rather than the actual class name. This is bad!
  • UPDATE 1: When a class doesn’t exist and IDEA prompts you to create the class, it suggests a bad default module. It used to suggest the module that the current code was in (which logically makes sense), but now it’s suggesting a different module, which I didn’t catch at first. I’m loosing my trust with IDEA :(
  • UPDATE 2: When debugging, the “Run to Cursor” feature seems to never work. Hovering my mouse over it produces a very nice “null” tooltip.
  • UPDATE 3: Clicking on the left margin on a blank line produces an error claiming that “Method breakpoints may dramatically slow down debugging” – despite the fact that I didn’t add a method-level breakpoint.
  • UPDATE 4: Command-P does not show parameter information for Pattern.compile unless the cursor is placed immediately to the right of the opening parenthesis. It appears this is due to the internal support for syntax highlighting of regexes.
  • UPDATE 4: Related to the last one – normally IDEA is smart enough to know that when I type a double quote and I’m inside of a string, it will not add a new one and instead will replace the double quote character to the right of my cursor. This doesn’t work in regexes.
  • UPDATE 5: The debugger seems incredibly slow now. Perhaps it’s from one of those phantom “method breakpoints” it thinks I’ve turned on, but the Frames, Debugger, and Watches tabs are now really slow. So slow I can watch them render and evaluate – something that never happened in IDEA 7.
  • UPDATE 6: As we all know, pressing dot will prompt the list of methods and fields available to call. I use this all the time – so much so that I put the auto-complete time down from the default of 1000ms to 0ms. Unfortunately, a regression from 7 to 8 happened that breaks chained method calls using this feature. For example, typing “mapEntry.” will prompt me for “getValue()” and “getKey()”. If I navigate using the arrow keys to “getValue()” and then press “.” again, I expect to now see the method list for the instance in the Map.Entry value. Instead, “getValue().” is completed, but then I have to press control-space to get the next list. Lame!
  • UPDATE 7: Pasting in the code “Gson gson = new Gson();” prompts me to import the “Gson” on both the right hand side and the left hand side.
  • UPDATE 8: Despite having the SQL support plugin enabled on both my laptop and my desktop, only my laptop is doing any sort of SQL syntax support for *.sql files. Very odd.

There are a lot more and I’ll update this list as I find them. This was just the ones I wrote down while coding this morning. Got some of your own to share? Add them in the comments and I’ll roll ‘em in here to share with the JetBrains team.

Did you know Selenium has a blog?

It’s true – it does! Check it out here and subscribe to the RSS feed here.

Why your web startup will fail

A great article by Eric Karjaluoto on all the difficulties of a startup. Tons of great reasons to avoid doing a startup, but at the end of the day, this is what it all comes back to:

With all of that said, I have to emphasize that little of this really matters. If you’re inclined to start a startup, nothing anyone says will stand in your way, nor, should it. If you have the bug to make something, it’s impossible to shake, and in my mind can be one of the best life experiences you can have.

[From Why your web startup will fail]

SEO Optimization for Micro ISVs

I’m a huge fan of Balsamiq, which also is a self-described “Micro ISV“. One of the things they do well is communicate everything they are up to on their blog. Early on I decided I’d leave the official BrowserMob blog a bit more sparse so that it only had content that my customers cared about. The rest (marketing ideas, business status updates, etc) would be left for this blog. This is one of those posts :)

A friend of mine let me know that Google recently did a toolbar PageRank update, which is the best place to get a basic idea of where your page rank sits. This got us talking about simple SEO optimization tricks I could do that wouldn’t take all my time. This is important for a micro ISV like my company.

The lists of things I have already done or plan to do for BrowserMob are:

  • Use H1 tags near the top of the page, matching the TITLE tags exactly.
  • Make page titles unique for all the important pages (pricing, contact, signup, etc).
  • Use META tags for keywords and description. While not super important, they don’t hurt much either.
  • Use important keywords (“load testing”, “performance testing”, “Selenium”, etc) in the page titles.
  • Use some of the same keywords in the URLs themselves (ie: /load-testing-support vs. /contact).

These are the basics I can do quickly. Beyond that, the real push towards a higher PageRank will only happen with real work. My first guest post in support of BrowserMob was recently posted on Ajaxian. This drove 10X more traffic and signups to the site when compared to our last peak day.

More importantly, it’s now one of the most authoritative documents on the search “Ajax load testing”. While it doesn’t link to my business, it offers credibility that I know what I’m talking about (btw – awesome to see Dojo masters enjoyed the article). It also links to my business, so someone who is really interested in the subject not only learns about it, but now can also choose to check out BrowserMob if they want.

Going forward, my marketing plan will involve a lot of this type of activity. I want to get the word out there that load testing can be easier and more affordable. I’ll continue writing articles on the BrowserMob blog, but I’ll also be writing most guest posts on popular sites. I’ll also be asking industry experts to blog their thoughts on the business, product, and idea on their blog (good or bad).

Hat tip: many of these ideas formulated after I read Balsamiq’s excellent post on startup marketing advice.

Plans for Selenium in 2009

I just posted on the BrowserMob blog my thoughts on how 2009 will turn out for the Selenium world. This is in addition to a new blog post on the Selenium blog about our short term plans to get a 1.0 release out.

Please take a look and let us know what you think.

Tip: Compact Logging in Java

One of the little touches I added to Able, which came from code originally in BrowserMob, was a nice little JDK logging formatter. It is designed to work with modern IDEs (IntelliJ IDEA being my personal favorite) and their ability to understand shorthand notation for classes.

As I was building BrowserMob, I was getting irritated by long package and class names as well as the fact that my log messages weren’t lined up nicely. For example, I’d get:

INFO 12/29 19:26:28 org.directwebremoting.impl.StartupUtil - Starting: DwrGuiceServlet v3.0.0.109.dev
INFO 12/29 19:26:31 com.browsermob.stripes.WelcomeActionBean - Some log message
INFO 12/29 19:26:37 com.browsermob.stripes.WelcomeActionBean - Some log message

I tried a simple formatter that truncated the class name, but the result wasn’t very helpful, since the class name (usually the most important part) would get cut off when the package name was too long:

INFO 12/29 19:26:28 org.directwebremotin - Starting: DwrGuiceServlet v3.0.0.109.dev
INFO 12/29 19:26:31 com.browsermob.strip - Some log message
INFO 12/29 19:26:37 com.browsermob.strip - Some log message

That was when I realized that often the package name wasn’t that useful, especially since they were often very predictable and unique even in a compact state. For example, in the past developers I have worked with would often write “n.s.s.c.StripesFilter” as a short hand for “net.sourceforge.stripes.controller.StripesFilter”. So why not use this for logging too? The result was much easier on the eyes:

INFO 12/29 19:26:28 o.d.i.StartupUtil    - Starting: DwrGuiceServlet v3.0.0.109.dev
INFO 12/29 19:26:31 c.b.s.WelcomeAction~ - Some log message
INFO 12/29 19:26:37 c.b.s.WelcomeAction~ - Some log message

Basically, the packages would get cut down to the first letter of each sub-package. If the class name pushes the whole thing beyond 20 characters, then a tilde is added to indicate the name is longer than could fit.

The nice thing about this is that it works beautifully with modern IDEs. I can copy the text “c.b.s.WelcomeAction” and locate that string in IDEA and it’ll know what I mean:

200812291142.jpg

If you want to use this formatter, you can find the code here in the Able source repository. It could probably get some performance improvements, such as some simple memoization, so feel free to send any tweaks you make my way. Do you have any neat tricks you do with logging? If so, please share in the comments!