package com.puppycrawl.tools.checkstyle.api; import static org.junit.Assert.*; import java.io.Serializable; import org.junit.Test; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DefaultContext; public class TestAutomaticBean { private static Configuration dc = configureConfiguration(); private static Configuration configureConfiguration(){ DefaultConfiguration dc = new DefaultConfiguration("myconfig"); dc.addAttribute("some", "thing"); dc.addAttribute("any", "body"); dc.addAttribute("here", "there"); return dc; } public static class MyBean extends AutomaticBean implements Serializable{ private String some, any, here; public MyBean(){} public String getSome(){ return some; } public void setSome(String val){ some = val; } public String getAny(){ return any; } public void setAny(String val){ any = val; } public String getHere(){ return here; } public void setHere(String val){ here = val; } public void assertInternals() throws CheckstyleException{ assertNotNull(getConfiguration()); finishLocalSetup(); setupChild(null); } } @Test public void test() throws CheckstyleException{ MyBean bean = new MyBean(); bean.configure(dc); bean.assertInternals(); DefaultContext mycontext = new DefaultContext(); mycontext.add("some", "other value"); mycontext.add("any", "other value"); mycontext.add("here", "somewhere else"); bean.contextualize(mycontext); } }