junit - Unit testing with Liferay 6.2 -


i using liferay-plugins-sdk-6.2, have created table "patients" , corresponding model , services using service builder. trying create junit test logic. i've looked lot of forum threads regarding this, 6.2 i've created following structure: (btw: using ant)

-docroot -test   -unit     -src   -integration     -src 

and part gives me trouble...

@test public void testvalidatepatient() throws systemexception {     patient patient = new patientimpl();     ... } 

when run test (from ant test), following exception:

java.lang.exceptionininitializererror      patientmodelimpl.<clinit>(patientmodelimpl.java:92)     validatorutiltest.testvalidatepatient(validatorutiltest.java:29) caused by: java.lang.nullpointerexception     @ com.liferay.portal.kernel.configuration.configurationfactoryutil.getconfiguration(configurationfactoryutil.java:27)     @ com.liferay.util.service.serviceprops.<init>(serviceprops.java:66)     @ com.liferay.util.service.serviceprops.<clinit>(serviceprops.java:70) 

and lead me magical code:

public static final boolean entity_cache_enabled = getterutil.getboolean(com.liferay.util.service.serviceprops.get(          "value.object.entity.cache.enabled.com.methodia.khearos.model.patient"),         true); 

it seems serviceprops cannot instantiated, (just testing) removed serviceprops.get calls , placed corresponding default values. after that, ran test again , worked charm.

so question here how configure things properly, have configuration? or there other workaround doesn't requires me modify service builder code?

especially if it's unit tests should able go without service builder initialization. imho unit test touches outside entity (like: database) not proper unit test. should able pass implementation class of patient interface validator work (you want test validator, not patient implementation.

you don't want unittest servicebuilder's persistence works. rather integration test.

so: (tm) create patientfortestimpl autogenerating methods, getters , setters, or use 1 of common mocking libraries on fly , use object testing validator.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -