Monday, December 17, 2012

How to change your jenkins theme

Why? 

Because I have two environments: development and production. They look very similar and I don't whant to broke production environment during testing

How?

1) Install theme plugin
 
 2) Add your css and js (and img) files under %JEKINNS_INSTALLATION_PATH%/userContent folder

 3) Add links to these files in configuration
 

4)* You may left blank field with JS file if you don't have one

 

What I've got?

With css below 
 #top-panel > * {
    background-color : #B80000 !important;
 }
I've got this result

Wednesday, October 10, 2012

EnvMan4J

Short story 

Recently I evaluated couple of code generation Java frameworks and I faced with one interesting issue. Every framework or application server wants to have XXX_HOME variable and %XXX_HOME%/bin element in a path variable.
I dreamed about tool that do such thing for a long time. And now I decided to write it. I choose Lazarus to write this tool because it must be native application (in case I need to set JAVA_HOME ;) ). Now this program works fine with Windows (I have only one open issue). Hope I will also make Linux version.

Where to get

You may get this application from my github https://github.com/crc83/EnvMan4J

Case study

I made short screen cast because it's better to see once than to hear many times. You may find it here

Monday, August 20, 2012

Eclipse plugins that I like and dislike

EclEmma - code coverage
Checkstyle - check style
Subverse - svn client (remove) TortoiseSVN plugin instead
LogViewer - for Log viewing
JInto -messages (deletes comments in message files)
Jautodoc - javadocs generator
InstaSearch - quick search in all files
GoToFile - fast go to file http://www.muermann.org/gotofile/update
Eclipse2ant - creates ant build script easily (ugly ant script)
Subclipse - svn client  http://subclipse.tigris.org/update_1.8.x
QuickImage - for picture viewer (useful in pair with bug tracing system)
AnyEdit - easily replace tabs by spaces and vice versa http://andrei.gmxhome.de/eclipse/
ContextMenu - invokes Explorer context menu http://timealias.bplaced.net/ContextMenuPlugin/update/
EasyShell - Opens system shell in eclipse
GrepConsole - Allows you colorify console output

Wednesday, July 25, 2012

Vim in four days

Vim is the one of the most powerful and widely used text editor. But how can you learn it staying at home with children. The answer is simple and straightforward. You can learn vim by rough memorizing. 
For inspiration you may use any youtube screencast
As a step by step guide I use this book. I read one chapter in 10-20 minutes. Then I try to recollect shortcuts while playing with children. At the evening or on the next morning I try to use them. And here is result of past three days.

1-st day

  • Navigation keys "hjkl".
  • Insert {"i"} and normal {Esc} mode. 
  • page up and page down {CTRL-U CTRL-D}
  • undo {"u"} and block undo {"U"}
  • Home {"^"} and end {"$"}

2-nd day

  • Word by word navigation {"b" "w"}
  • Delete word {"dw"}or couple of words {"d5w"}
  • Append characters to the end {"A"}
  • Delete line {"dd"}
  • append line {"o" "O"}

3-rd day

  • Join lines {"J"} or join five lines at once {"5J"}
  • Find character "s" in line {"fs"}
  • Repeat last modifcation {"."}
  • Record macro for key "n" {"qn" commands... then "q"}
  • Invoke recorded macro {"@n"}

4-th day

I skipped some parts since I don't need it in near future (and they are boring :) ). These parts are:
  • Filtering 
  • Working with windows
Then I stucked with visual block mode. I even can't turn it on (with CTRL-V hotkey). I googled a little bit and found the solution. Use CTRL-Q instead of CTRL-V on Windows.
Visual block mode I'm going to learn with tecnique read and try because I can't imagine behavior of VIM.
BTW: Vrapper fo Eclipse still doesn't support visual block mode.

Sunday, March 11, 2012

Using ZTL (Zkoss testing language) framework and Concordion for integration testing



To use ZTL for integration testing we have to inherit org.zkoss.ztl.ZKClientTestCase. We should initialize some variables for testcase (for example in constructor)
            target = "http://localhost:8080/ZK-demo";
            browsers = getBrowsers("iexplore");
            _timeout=100;
To use Concordion we also have to inherit org.concordion.integration.junit3.ConcordionTestCase. But Java doesn’t allow us to use multiple inheritances. So we should replace one of inheritances to usage. I did it for ZKClientTestCase. All of the fields listed above are protected. I made class ZKIntegrationTestCase that inherits ZKClientTestCase. In that class I made public setters and getters for those fields. So we don’t need to use inheritance for ZTL
public class SpecTest extends ConcordionTestCase{
      private ZKIntegrationTestCase ZKFunctionalTestCase zk;

      public SpecTest() {
            zk = new ZKIntegrationTestCaseZKFunctionalTestCase();
            zk.setTarget("http://localhost:8080/ZK-demo");
            zk.setBrowsers(zk.makeListOfBrowsers("iexplore"));
            zk._setTimeout(100);
You may find patched ZTL library (ztl), sample project(ZK-demo) and sample test project(ztl-demo) here: https://github.com/crc83/ztl
Hope it help you make quick rampup.

All about Concordion you may find here: http://www.concordion.org/
Original ZTL you may also find at github: https://github.com/zkoss/ztl
And forum about ZTL issues is here: http://www.zkoss.org/forum/listComment/17556/1/20

Tuesday, January 10, 2012

Fluent interface in java


Simple and robust.

Task

I need to have several sets of methods of class, that can be invoked in special order using fluent interface. For example I need to have always first init(int a) method in a chain. In a second chain I need to have add(int a) and reset() methods. For the third chain I’d like to have dec(int a) and getValue() methods. getValue() method will return a result.

Solution

It’s good idea to use inner classes.
package org.sbelei;

public class FluentInterfaceSample {
     
      private SecondChain chain2;
      private ThirdChain chain3;
     
      private int value;

      {
            chain2 = new SecondChain();
            chain3 = new ThirdChain();
      }
     
      public static FluentInterfaceSample create(){
            return new FluentInterfaceSample();
      }
     
      public SecondChain init(int start){
            value = start;
            return chain2;
      }
     
      class SecondChain {
            public ThirdChain add(int a){
                  value += a;
                  return chain3;
            }
           
            public ThirdChain reset(){
                  value = 0;
                  return chain3;
            }
      }
     
      class ThirdChain {
            public ThirdChain dec(int b){
                  value -=b;
                  return chain3;
            }
           
            public int getValue(){
                  return value;
            }
      }
     
      public static void main(String[] args){
            int b = create().init(31).add(12).dec(10).getValue();
            System.out.println(b);
      }
}