webtier@glassfish.java.net

JSF2: Unable to Unit Test classes extending UIComponentBase

From: Lincoln Baxter, III <lincolnbaxter_at_gmail.com>
Date: Mon, 16 Mar 2009 22:28:46 -0400

Has anyone seen this yet? (This is from the 1.29.2009 build)

Seems like if not operating in an initialized Faces environment (Eg. In
a Unit Test,) it is not possible to add children to the a class
extending UIComponentBase.

Thoughts?
Thanks,
Lincoln

java.lang.NullPointerException
        at
javax.faces.component.UIComponentBase.isPostbackAndRestoreView(UIComponentBase.java:1627)
        at
javax.faces.component.UIComponentBase.doPostAddProcessing(UIComponentBase.java:1576)
        at
javax.faces.component.UIComponentBase.setParent(UIComponentBase.java:371)
        at javax.faces.component.UIComponentBase
$ChildrenList.add(UIComponentBase.java:2022)
        at javax.faces.component.UIComponentBase
$ChildrenList.add(UIComponentBase.java:1994)
        at
com.ocpsoft.pretty.component.PrettyUrlBuilderTest.setUpBeforeClass(PrettyUrlBuilderTest.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.junit.runners.model.FrameworkMethod
$1.runReflectiveCall(FrameworkMethod.java:44)
        at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
        at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
        at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)