Using Brut in Bloomreach 13

Hi all,

Currently we’re upgrading our Bloomreach environment to version 13.

In our implementation we’re using brut to unit test quite some functionality. These unit tests are extending the org.bloomreach.forge.brut.components.AbstractRepoTest class, which instantiates an ObjectConverter using a ObjectConverterFactoryBean.

In Hippo 13 this ObjectConverterFactoryBean implementation has changed, it now returns a VersionedObjectConverterProxy instance, to be used as an ObjectConverter. However, this proxy object is using a ContentTypesProvider, which is always null and there for our unit tests are failing.

I would expect that the solution is to set an instance of ContentTypesProvider on the ObjectConverterFactoryBean in the method AbstractRepoTest#setObjectConverter(). As this method is private I cannot do this (properly) myself.

Is anyone experiencing this problem as well? Or might there be another way to instantiate the ObjectConverter without using the VersionedObjectConverterProxy?

Thanks in advance,

Philippe.

Hey Philippe,

Can’t you set the object converter you want on the requestContext of the AbstractRepoTest class after its constructor is executed? So in your test class you could set your own object converter.

Can you share exactly how a test is failing? I’d like to reproduce this.

If you are able, you can also create an issue here: https://issues.onehippo.com/browse/HIPFORGE

Hi Baris,

Thanks for you response!

Below I’ve provided my stack trace:
Caused by: java.lang.NullPointerException at org.hippoecm.hst.content.beans.manager.VersionedObjectConverterProxy.getOrCreateObjectConverter(VersionedObjectConverterProxy.java:71) at org.hippoecm.hst.content.beans.manager.VersionedObjectConverterProxy.getObject(VersionedObjectConverterProxy.java:87) at org.hippoecm.hst.content.beans.manager.ObjectBeanManagerImpl.getObject(ObjectBeanManagerImpl.java:33) at org.bloomreach.forge.brut.components.AbstractRepoTest.setSiteContentBase(AbstractRepoTest.java:83) at nl.client.hippo.components.content.ComponentTest.init(ComponentTest.java:36) at nl.client.hippo.BaseTest.setup(BaseTest.java:41)

As you can see, at line 36 of ComponentTest I’m invoking:
setSiteContentBase("/content/documents/folder/folder");

Yes, I can re-set the objectConverter after the setup() of the AbstractRepoTest has been completed. But then I have to copy the entire body of the private AbstractRepoTest#setObjectConverter() method and set, for example, a Mockito mock as an objectConverter.

Although I don’t think it is the idea that you have to mock brut internally in order to make it work as designed.

I think this is reproducable in Bloomreach 13 by creating a test class, extend AbstractRepoTest via BaseComponentTest and invoke setSiteContentBase(Sting) from a test.

Regards,

Philippe.

I’m open to opening that method up to public. But isn’t this test class doing exactly you’re saying?


This test passes. What is the difference between this and yours? This is also v13 btw.

Yes it seems so, what happens if you set a breakpoint at:
setSiteContentBase("/content/documents/mychannel");
and debug these tests?

Does that and up in the constructor of VersionedObjectConverterProxy (line 63), where the contentTypesProvider is not null?

I think I found it, in version 13.4.0 of hst-core the ObjectConverterFactoryBean returns a VersionedObjectConverterProxy (containing that null reference for the contentTypesProvider) and in version 13.1.0 of hst-core the ObjectConverterFactoryBean return a ObjectConverterImpl.

It hits here org.bloomreach.forge.brut.components.AbstractRepoTest#setSiteContentBase . Everything runs smoothly. Yes, brut is now up to date with version 13.1.0. So if I upgrade to 13.4.0 I will face this issue also

Okay, I think that is what we can expect.

We can work around the problem, although it would of course be great if brut gets an upgrade to 13.4.0.

Thanks, Philippe.

Thanks Philippe for your input. I was just able to reproduce it. I’ll work on this and upgrade brut to 13.4.0 as soon as possible

1 Like

Thanks a lot!

Philippe