1 /* 2 * $Header: /cvsroot/ebxmlrr/jaxr/test/com/sun/xml/registry/ebxml/infomodel/InternationlStringImplTest.java,v 1.1 2003/08/10 09:22:43 doballve Exp $ 3 * 4 * ==================================================================== 5 * 6 * This code is subject to the freebxml License, Version 1.1 7 * 8 * Copyright (c) 2003 freebxml.org. All rights reserved. 9 * 10 * ==================================================================== 11 */ 12 package com.sun.xml.registry.ebxml.infomodel; 13 14 import com.sun.xml.registry.ebxml.*; 15 import com.sun.xml.registry.ebxml.ApelonJAXRTestSetup; 16 import com.sun.xml.registry.ebxml.infomodel.ExtensibleObjectImpl; 17 import javax.xml.registry.*; 18 import javax.xml.registry.infomodel.*; 19 import java.util.*; 20 import com.sun.xml.registry.ebxml.util.I18nUtil; 21 import javax.xml.registry.JAXRException; 22 import junit.framework.*; 23 import junit.textui.TestRunner; 24 import org.oasis.ebxml.registry.bindings.rim.RegistryObjectType; 25 import org.oasis.ebxml.registry.bindings.rim.SlotType1; 26 27 /*** 28 * jUnit Test for InternationlStringImpl. 29 * 30 * @author Diego Ballve / Republica Corp. 31 */ 32 public class InternationlStringImplTest extends TestCase { 33 34 static ApelonJAXRTestSetup setup = null; 35 36 public InternationlStringImplTest(java.lang.String testName) { 37 super(testName); 38 } 39 40 public static void main(java.lang.String[] args) { 41 try { 42 TestRunner.run(suite()); 43 } catch (Throwable t) { 44 System.out.println("Throwable: " + t.getClass().getName() 45 + " Message: " + t.getMessage()); 46 t.printStackTrace(); 47 } 48 } 49 50 public static Test suite() throws Exception { 51 TestSuite suite = new TestSuite(InternationlStringImplTest.class); 52 setup = new ApelonJAXRTestSetup(suite); 53 return setup; 54 } 55 56 /*** Test of addSlot method, of class com.sun.xml.registry.ebxml.infomodel.ExtensibleObjectImpl. */ 57 public void testGetClosestValue() throws Exception { 58 System.out.println("/ntestGetClosestValue"); 59 60 Locale DEFAULT_LOCALE = Locale.getDefault(); 61 try { 62 Locale.setDefault(new Locale("pt","BR")); 63 64 Locale loc_empty = new Locale(""); 65 Locale loc_en = new Locale("en"); 66 Locale loc_en_US = new Locale("en", "US"); 67 Locale loc_en_UK = new Locale("en", "UK"); 68 Locale loc_en_UK_var = new Locale("en", "UK", "var"); 69 70 Locale loc_pt = new Locale("pt"); 71 Locale loc_pt_BR = new Locale("pt", "BR"); 72 Locale loc_pt_PT = new Locale("pt", "PT"); 73 74 Locale loc_fi = new Locale("fi"); 75 Locale loc_fi_FI = new Locale("fi", "FI"); 76 Locale loc_fi_FI_var = new Locale("fi", "FI", "var"); 77 78 InternationalStringImpl iString = (InternationalStringImpl)setup.getLCM() 79 .createInternationalString(loc_en_US, loc_en_US.toString()); 80 //???? assertNull("Empty IString value be null.", iString.getClosestValue(Locale.getDefault())); 81 82 // iString.addLocalizedString(setup.getLCM().createLocalizedString(loc_en, loc_en.toString())); 83 assertEquals(loc_en_US.toString(), iString.getClosestValue(loc_pt)); 84 85 iString.addLocalizedString(setup.getLCM().createLocalizedString(loc_pt, loc_pt.toString())); 86 assertEquals(loc_pt.toString(), iString.getClosestValue(loc_pt)); 87 assertEquals(loc_pt.toString(), iString.getClosestValue(loc_pt_PT)); 88 assertEquals(loc_pt.toString(), iString.getClosestValue(loc_pt_BR)); 89 assertEquals(loc_pt.toString(), iString.getClosestValue(loc_fi)); 90 assertEquals(loc_pt.toString(), iString.getClosestValue(loc_fi_FI)); 91 92 iString.addLocalizedString(setup.getLCM().createLocalizedString(loc_pt_BR, loc_pt_BR.toString())); 93 assertEquals(loc_pt.toString(), iString.getClosestValue(loc_pt)); 94 assertEquals(loc_pt.toString(), iString.getClosestValue(loc_pt_PT)); 95 assertEquals(loc_pt_BR.toString(), iString.getClosestValue(loc_pt_BR)); 96 assertEquals(loc_pt_BR.toString(), iString.getClosestValue(loc_fi)); 97 assertEquals(loc_pt_BR.toString(), iString.getClosestValue(loc_fi_FI)); 98 99 iString.addLocalizedString(setup.getLCM().createLocalizedString(loc_fi, loc_fi.toString())); 100 iString.addLocalizedString(setup.getLCM().createLocalizedString(loc_fi_FI, loc_fi_FI.toString())); 101 iString.addLocalizedString(setup.getLCM().createLocalizedString(loc_fi_FI_var, loc_fi_FI_var.toString())); 102 assertEquals(loc_pt.toString(), iString.getClosestValue(loc_pt)); 103 assertEquals(loc_pt.toString(), iString.getClosestValue(loc_pt_PT)); 104 assertEquals(loc_pt_BR.toString(), iString.getClosestValue(loc_pt_BR)); 105 assertEquals(loc_fi.toString(), iString.getClosestValue(loc_fi)); 106 assertEquals(loc_fi_FI.toString(), iString.getClosestValue(loc_fi_FI)); 107 assertEquals(loc_fi_FI_var.toString(), iString.getClosestValue(loc_fi_FI_var)); 108 } catch (Exception e) { 109 throw e; 110 } finally { 111 Locale.setDefault(DEFAULT_LOCALE); 112 } 113 } 114 115 }

This page was automatically generated by Maven