Getting Buffered$SourceException in unit test but not in production code

I have a view with the following field

ObjectProperty<Double> balance = new ObjectProperty<Double>(0.0); connected to a TextField.

When actually running the code everything works, and when creating the AdminView from unit tests in
the AdminView constructor can be run without causing an exception.

But when I tried to create a unit test for the AdminView, class the AdminView constructor failed with a Buffered$SourceException in the view constructor:

Caused by:$ConversionException: Unable to convert value of type java.lang.Double to presentation type class java.lang. String. No converter is set and the types are not compatible. The test failed here (setting the property datasource on the text field):

Is some global initialization missing from my unit test?
a lot of initialization
, but I don’t know what might be significiant for AdminView.


  • Steinar

When I run all tests in
and subdirectories, the tests run green, including my previously failing AdminViewTest.

So something in my test setup is sufficient to set up the stuff that is missing when I run the AdminViewTest on its own. I have tried to copy in stuff from the working tests, but I haven’t found anything that works yet.

What was needed, was to create a Session object and call Session.setCurrent() with the session, before creating the AdminView.

I only needed to create the Session once before the tests were run, so I could put it in the static @BeforeClass method:

@BeforeClass public static void beforeAllTests() throws ServletException, ServiceException { setupFakeOsgiServices(); session = createSession(); } @Test public void testUpdateFormsAfterAccountIsSelected() throws ServiceException, ServletException { VaadinSession.setCurrent(session); VaadinRequest request = createMockVaadinRequest("http://localhost:8181/ukelonn/"); AdminView view = new AdminView(request); The code is