UnitTest is failed

Dear all,

I’m trying to use “mvn test” to test a UnitTest class. As known is “I18nServiceTest”.

First of all, I used the command line above for testing this class and then the FAILURE message was responded.

After that, I tried commenting all of its content almost. But still let a few of statement and one of them is available which is


localeManager.setCurrentLocale( Locale.UK );

And the final result is that till FAILURE.

What’s wrong here ? What should I do is this case ? Have I missed anything which is important in ?

Anyway, I do also test an another class is "TranslationStoreTest". Doing as the same way for this one, commenting all of its content and just one statement is active

translationStore.addTranslation( translation1a );

The received result is also FAILURE

(See more at the attached figure is below)

Waiting for your opinion on this problem. Thanks to everyone !

···

Hieu.HISPVietnam
Good Health !

Opppss, Sorry about forgot the enclosed files

···

On Fri, Oct 30, 2009 at 4:14 PM, Hieu Dang Duy hieu.hispvietnam@gmail.com wrote:

Dear all,

I’m trying to use “mvn test” to test a UnitTest class. As known is “I18nServiceTest”.

First of all, I used the command line above for testing this class and then the FAILURE message was responded.

After that, I tried commenting all of its content almost. But still let a few of statement and one of them is available which is


localeManager.setCurrentLocale( Locale.UK );

And the final result is that till FAILURE.

What’s wrong here ? What should I do is this case ? Have I missed anything which is important in ?

Anyway, I do also test an another class is "TranslationStoreTest". Doing as the same way for this one, commenting all of its content and just one statement is active

translationStore.addTranslation( translation1a );

The received result is also FAILURE

(See more at the attached figure is below)

Waiting for your opinion on this problem. Thanks to everyone !

Hieu.HISPVietnam
Good Health !


Hieu.HISPVietnam
Good Health !

Hi Hieu,

I am pretty sure this is caused by the changes you did to the TranslationService lately… So I guess you need to figure it out ;.)

Lars

···

On Fri, Oct 30, 2009 at 10:14 AM, Hieu Dang Duy hieu.hispvietnam@gmail.com wrote:

Dear all,

I’m trying to use “mvn test” to test a UnitTest class. As known is “I18nServiceTest”.

First of all, I used the command line above for testing this class and then the FAILURE message was responded.

After that, I tried commenting all of its content almost. But still let a few of statement and one of them is available which is


localeManager.setCurrentLocale( Locale.UK );

And the final result is that till FAILURE.

What’s wrong here ? What should I do is this case ? Have I missed anything which is important in ?

Anyway, I do also test an another class is "TranslationStoreTest". Doing as the same way for this one, commenting all of its content and just one statement is active

translationStore.addTranslation( translation1a );

The received result is also FAILURE

(See more at the attached figure is below)

Waiting for your opinion on this problem. Thanks to everyone !

Hieu.HISPVietnam
Good Health !

Dear Lars and everyone,

Accuracy, I had modified TranslationService class and also its relevant others.
But I assure that I did not do any change on LocaleManager class, even two implementing classes of this one. But when using mvn test for it only and result is still failed. Why? Actually that, I do not understand what’s going on here? Very very very strange !

I am not good at Unit test case. Please help me solve this issue !

Please have a look at back in UnitTest_Bug_1.jpg figure.

MyTest.java (2.82 KB)

···

Anyway !

In this email, I will present out everything what I’ve done with Translation module as step by step by the each question and you guys can have a look at the attached files to get more reference.

  1. Why must modify DefaultI18nService class ?

  2. Which classes were also modified too ?

  3. How did I do a test on the UnitTest file and What are they ?


  1. Why must modify DefaultI18nService class ?

As the presenting previously email, I had shown to you guys the logical bug which I’d got while testing on Translation module.

Map<String, String> convertTranslations( Collection translations )

This private method which is using for converting an input collection of translation to a map of translation with the key is property’s name and the value is property’s value.

So far ago, I recognized that its source would be well-done with the collection which contains one translation object only. One translation object have got only one property’s unique name. For example: name, shortname, comment, etc…

But the method above is really not well-done when received a collection which contains many translation object. Thus, I have tried fixing its logic and more flexible.

With the owned idea is that used the combination key as <Integer, String> or more exactly the map of translation should be as form

key :: objectID + “_” + the name of property
value :: the value of property

***See Figure 1 ***


  1. Which classes were also modified too ?

dhis-i18n-db ::
JAVA: I18nService, DefaultI18nService, DefaultTranslationService, HibernateTranslationStore.

XML: beans

dhis-api ::
JAVA: TranslationStore, TranslationService.


  1. How did I do a test on the UnitTest file and What are they ?

There are two classes TranslationStoreTest and I18nServiceTest

I tried commenting on all of their methods’ definition. And then, create a new one as MyTest.java file as an UnitTest class. Its content which is very very simple (file has been attached). It has only one method like this:

*********@Test
public void testAnything() throws Exception
{
assertTrue( id1 != id2 );

    localeManager.setCurrentLocale( Locale.GERMAN );
}***

Next, using mvn test command for third of them. Finally, the response error was showing at MyTest class. I recognized is that from localeManager object.

That’s all !

2009/10/30 Lars Helge Øverland larshelge@gmail.com

Hi Hieu,

I am pretty sure this is caused by the changes you did to the TranslationService lately… So I guess you need to figure it out ;.)

Lars


Hieu.HISPVietnam
Good Health !

Dear Lars,

I have reverted all of things back to their original pharse which thing I had done/modified on Translation and I18nService, also the relevant others. To be sssured that the whole unit test cases are fine in tesing. Used the maven test for all of them again.

How can you guess what will be happened ?

Yup! The answer is the FAILURE message occured in two unit test classes I18nServiceTest.java and TranslationStoreTest.java. Or maybe I am wrong but still have got a question:

“Where is the real problem while everything is above has been reverted again as originally?”

Are you thinking of DhisSpringTest ?

···

Dear Bob,

Can I have you take a look at your WeeklyPeriodTypeTest case again if have a free hand ? Because of using maven for testing will show BUILD FAILURE ?

Thanks you guys !

2009/10/30 Lars Helge Øverland larshelge@gmail.com

Hi Hieu,

I am pretty sure this is caused by the changes you did to the TranslationService lately… So I guess you need to figure it out ;.)

Lars


Hieu.HISPVietnam
Good Health !