1 package cintoo.messages.bundle.xml; 2 3 import org.testng.annotations.*; 4 import org.testng.Assert; 5 6 import java.util.*; 7 import java.io.InputStream ; 8 import java.io.IOException ; 9 10 import cintoo.messages.bundle.BaseResourceBundleFactory; 11 import cintoo.messages.bundle.BaseResourceBundle; 12 import api.cintoo.messages.bundle.BaseBundle; 13 14 public class TestBaseBundle { 15 16 private Locale locale; 17 private String name; 18 private BaseResourceBundleFactory factory; 19 20 @Configuration(beforeTestMethod = true) 21 public void setUp() { 22 factory = new BaseResourceBundleFactory(); 23 locale = new Locale("de", "de"); 24 name = "testp1"; 25 } 26 27 @Test 28 @ExpectedExceptions({ IllegalArgumentException .class }) 29 void testPreventParentCycle() { 30 BaseBundle bundle = null; 31 try { 32 bundle = factory.loadBundle(getStream(name, locale), locale); 33 } catch (IOException e) { 34 e.printStackTrace(); 35 } 36 bundle.setParent(bundle); 37 } 38 39 private InputStream getStream(String name, Locale locale) { 40 List<String > names = factory.expand(name, locale); 41 return this.getClass().getResourceAsStream("/" + names.get(0)); 42 } 43 44 } | Popular Tags |