1 package cintoo.messages.bundle; 2 3 import java.util.Locale ; 4 import java.util.List ; 5 6 import org.testng.annotations.*; 7 import org.testng.Assert; 8 9 public class TestExpander { 10 11 @Test 12 public void testExpandWithVariant() { 13 List <String > names = Expander.expand("base", new Locale ("de", "de", "ch"), ".x"); 14 Assert.assertEquals(names.size(), 4, "Expand returns correct number of names"); 15 Assert.assertTrue(equals(names, new String []{"base.x", "base_de.x", "base_de_DE.x", "base_de_DE_ch.x"}), "Expand returns correct names"); 16 } 17 18 private boolean equals(List <String > is, String [] should) { 19 if (is.size() != should.length) { 20 return false; 21 } 22 boolean result = true; 23 for (String toCheck: should) { 24 if (! is.contains(toCheck)) { 25 result = false; 26 } 27 } 28 return result; 29 } 30 } 31 | Popular Tags |