Skip to content
Volodymyr Krasnikov edited this page Jan 23, 2014 · 10 revisions

Welcome to the nicebean wiki!

About

Yet another tool which saves brain cycles. It is very raw so far. So it is for internal home usage only :)

When to use it?

Typing areas of application

  1. Testing marshalling/unmarshalling of pojo's when you focus on a protocol and not on data
  2. You need to fill all fields of 'fat' pojo object and again you don't bother of data

How to use it?

Consider you have somewhere in your classpath a bean:

public class Person { 
    private String name;
    private int age;
    private byte[] privateArray;
    private Person bestFriend;
    ... // long list of properties, constructors and accessor methods
}

And you want just to use it

@RunWith(NiceBeanRunner.class)
public class BeanOfBeanTest
{
  @Nice Person person; // mark it

  @Test public void test() {
 	  assertNotNull(person); // and you get fully populated bean instance here
	  assertNotNull(person.getBestFriend());
	  assertNotNull(person.getBestFriend().getBestFriend());
	  ... so on
  }
}

If the runner's place is already occupied by another runner (or you just don't like jUnit runner at all) you can go this way

  ...
  @Nice Person person;
  
  @Before public void setUp(){
      NiceBean.init(this);
  }

  @Test public void test() { ...

For more insight please have a look on a test/ source folder

Clone this wiki locally