Link from log console output to a line of code in IntelliJ

Whilst playing around with some code analysis I thought it would be useful to be able to output a hyperlink back to a line of code in the IDE console. As it happens, you can “Trick” IntelliJ to do this with the following log statement:

    @Test
    public void canClickOnAFileInTheConsoleAndGoToTheLineOfCode() {
        log.info(String.format(“Check it at %s. (%s.java:%d)”,
            getClass().getName(), getClass().getSimpleName(), 15));
    }

The pattern it seems to match is something like at {classFullName}.{identifier}({classSimpleName}.java)

classFullName has to be a valid class name.
identifier is usually used for the method name, but it can be anything. The full stop is nescessary. So in the example above, I put a space in there and so it reads like a sentance.

Anyone know a another way to do this?

UPDATE:

Actually it seems that you can get something similar if you output a full path name, e.g.:

    File f = new File(“./src/test/resource/testfiles/level_01/level_01_01/file_01_01_A.txt”);
    log.info(f.getAbsolutePath() + “:” + 34);

This will create a link in the output window to the line of the file. Nice.

Share

MacWidgets – Java Swing looking native on OS X

I just discovered Exploding Pixels’ MacWidgets. Its a beautiful library. Literally just pasted a couple of lines of code into my Java app and now it looks right at home on the os x desktop. I’m running JDK 1.6 on Leopard.

Here is is in action:

macwidgets-demo

And here is the code (its been edited slightly so may not copy and paste, but you get the idea) …

 
        MacUtils.makeWindowLeopardStyle(getRootPane());
 
        UnifiedToolBar toolBar = new UnifiedToolBar();
 
        JButton button = new JButton(“My Button”);
        button.putClientProperty(“JButton.buttonType”, “textured”);
        toolBar.addComponentToLeft(button);
 
        getContentPane().add(toolBar.getComponent(), BorderLayout.NORTH);
 
        BottomBar bottomBar = new BottomBar(BottomBarSize.SMALL);
        bottomBar.addComponentToLeft(MacWidgetFactory.createEmphasizedLabel(” Status”));
 
        getContentPane().add(bottomBar.getComponent(), BorderLayout.SOUTH);
 
Share

Passing System Properties and Environment Variables to unit tests in Maven – Update

Unfortunately there was an bug in my previous post.

I had naively assumed that the syntax for environment variables was the same as for system properties but alas not.

The correct code is:


    package
        <plugins>
        <plugin>
               org.apache.maven.plugins
               maven-surefire-plugin
               2.4.2
               
                   
                       some value
                   
                   
                       <property>
                           acceptance.test.host
                           ${acceptance.test.host}
                       </property>
                   
                
           </plugin>
       </plugins>

Share