| Thread Previous • Date Previous • Date Next • Thread Next |
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.
---------------------------------------------------------------------------------------------------------------------------------------------------
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<Translation>
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 *
---------------------------------------------------------------------------------------------------------------------------------------------------
2) Which classes were also modified too ?
*dhis-i18n-db ::*
JAVA: *I18nService, DefaultI18nService, DefaultTranslationService,
HibernateTranslationStore.*
XML: *beans*
*dhis-api ::*
JAVA: *TranslationStore, TranslationService.*
---------------------------------------------------------------------------------------------------------------------------------------------------
3) 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@xxxxxxxxx>
>
> 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 !
Attachment:
dhis_i18n_db_DefaultI18nService.JPG
Description: JPEG image
Attachment:
dhis_i18n_db_UnitTest_Bug_1.JPG
Description: JPEG image
package org.hisp.dhis.translation;
/*
* Copyright (c) 2004-2007, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Locale;
import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.i18n.locale.LocaleManager;
import org.junit.Test;
public class MyTest
extends DhisSpringTest
{
private LocaleManager localeManager;
// -------------------------------------------------------------------------
// Set up/tear down
// -------------------------------------------------------------------------
@Override
public void setUpTest()
{
localeManager = (LocaleManager)getBean("org.hisp.dhis.i18n.locale.LocaleManagerDb");
}
// -------------------------------------------------------------------------
// Testdata
// -------------------------------------------------------------------------
private int id1 = 0;
private int id2 = 1;
// -------------------------------------------------------------------------
// Tests
// -------------------------------------------------------------------------
@Test
public void testAnything()
throws Exception
{
assertTrue( id1 != id2 );
localeManager.setCurrentLocale( Locale.GERMAN );
// fail(localeManager.toString());
}
}
| Thread Previous • Date Previous • Date Next • Thread Next |