cancel
Showing results for 
Search instead for 
Did you mean: 

Tests failing on fresh checkout

ashish
Champ in-the-making
Champ in-the-making
We just started on a project where we have decided to use Alfresco as the CMS tool. As we might be making some modifications, and adding some features specific to our requirement, I was trying to do an initial checkout and run all the tests to ensure that we started from a clean base. But we hit a roadblock with some of the tests failing.
First one which failed was RegistryServiceImplTest.testProperUsage. We had some issue with these assertions:

assertNull("Missing key should return null value. Returned: " + registryService.getProperty(KEY_A_B_C_0), registryService.getProperty(KEY_A_B_C_0));
assertNull("Missing key should return null value. Returned: " + registryService.getProperty(KEY_A_B_C_D_0), registryService.getProperty(KEY_A_B_C_D_0));
assertNull("Missing key should return null value. Returned: " + registryService.getProperty(KEY_X_Y_Z_0), registryService.getProperty(KEY_X_Y_Z_0));


To find out if everything else was ok, we commented those three lines, then we got another failing test - ADMLuceneTest. The test result snippet here:
<failure message="expected:<1> but was:<0>" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: expected:<1> but was:<0> at org.alfresco.repo.search.impl.lucene.ADMLuceneTest.runBaseTests(ADMLuceneTest.java:3765) at org.alfresco.repo.search.impl.lucene.ADMLuceneTest.testSortIssue_AR_1515__AND__AR_1466(ADMLuceneTest.java:481)</failure>


I am wondering what we could be missing in the setup, as we haven't made any changes yet to cause the tests to fail.
4 REPLIES 4

janv
Employee
Employee
The first test should run OK. What is your dev environment … OS, JVM, IDE ? Are you running from Ant or the IDE ?

The second test requires that the javac encoding is set to UTF-8 (see also build.properties).

Regards,
Jan

janv
Employee
Employee
I notice that the first test was not re-runnable (due to testCopy) hence would only succeed once after a fresh install/bootstrap. I have now fixed the test by changing:

assertNull("Missing key should return null value", registryService.getProperty(KEY_X_Y_Z_0));
to

assertNull("Missing key should return null value", registryService.getProperty(KEY_DOES_NOT_EXIST));
Thanks,
Jan

ashish
Champ in-the-making
Champ in-the-making
Thanks for the reply, and the fix.

Our dev environment is Win XP, JDK 1.6.0_04 and Eclipse.
We are trying to run the tests from Ant.
Running tests from IDE fails even more miserably with issues with the classpath, but could be due to the fact that I have always used IntelliJ, and Eclipse seems a bit unfamiliar to me. But I was just trying to follow the setup directions given on the wiki.

The same RegistryServiceImplTest failed with "java.io.FileNotFoundException: class path resource [alfresco/application-context.xml] cannot be opened because it does not exist".

For the second test, if it requires javac encoding to be set to UTF-8, then thats already the case in build.properties, as you pointed out. Any reason why it should still fail?

Regards,
Ashish

janv
Employee
Employee
If you have downloaded and setup your env as per http://wiki.alfresco.com/wiki/Alfresco_SVN_Development_Environment and cleaned and re-built everything using:

cd <dev-head>/code/root
ant build-tomcat
then you can try running individual test classes, eg:
ant run-test -Dtestcase=org.alfresco.repo.admin.registry.RegistryServiceImplTest -Dprojectdir=./projects/repository
In the first test, please check that 'application-context.xml' still exists in '<dev-head>/code/root/projects/repository/config/alfresco' (as referenced by 'classpath.unit.test' in 'build.xml') and that the basedir has not been overridden, eg.

ant dump-env-properties
In the second test, you will also need to pre-configure your DB character set to be UTF8 by default. For example, if you're using MySQL on Windows then you can use MySQL Administrator -> Startup Variables -> Advanced panel to set the Default Character Set to 'utf8'.

Regards,
Jan