public static ResourceBundleService prepareBundleService(Locale locale) throws IOException { ResourceBundleService bundleService = EasyMock.createMock(ResourceBundleService.class); EasyMock.expect(bundleService.getResourceBundle("labels", locale)) .andReturn( new PropertyResourceBundle( new InputStreamReader( new ByteArrayInputStream(DocumentServiceTest.BUNLDE.getBytes()), Charset.forName("UTF-8")))) .anyTimes(); EasyMock.expect(bundleService.getResourceBundle("base", locale)) .andReturn( new PropertyResourceBundle( new InputStreamReader( new ByteArrayInputStream(DocumentServiceTest.BUNLDE.getBytes()), Charset.forName("UTF-8")))) .anyTimes(); return bundleService; }
@Test public void testInputTemplateTest() throws IOException { Provider<Locale> localeProvider = EasyMock.createMock(_TestLocaleProvider.class); EasyMock.expect(localeProvider.get()).andReturn(Locale.getDefault()).anyTimes(); ResourceBundleService resb = EasyMock.createMock(ResourceBundleService.class); PropertyResourceBundle resourceBundle = new PropertyResourceBundle(new StringReader(BUNDLES)); EasyMock.expect(resb.getResourceBundle("labels", Locale.getDefault())) .andReturn(resourceBundle) .anyTimes(); KConfiguration conf = EasyMock.createMock(KConfiguration.class); EasyMock.replay(localeProvider, resb, conf); DeleteProcessesInput temp = new DeleteProcessesInput(); temp.configuration = conf; temp.localesProvider = localeProvider; temp.resourceBundleService = resb; StringWriter nstr = new StringWriter(); temp.renderInput(null, nstr, new Properties()); Assert.assertNotNull(nstr.toString()); }