@Before public void setUp() { PropertyConfigurator.configure( CssBundleCharsetCleanerPostProcessorTest.class.getResource( "/postprocessor/cssbundlecharset/log4j-test.properties")); AppenderForTesting.clear(); when(bundle.getId()).thenReturn("/bundle1.css"); }
@Test public void testPostProcessBundleWithDifferentCharsetWarning() throws Exception { CssCharsetFilterPostProcessor processor = new CssCharsetFilterPostProcessor(); StringBuffer sb = new StringBuffer( FileUtils.readClassPathFile( "postprocessor/cssbundlecharset/different-charset-decl-bundle.css")); BundleProcessingStatus status = new BundleProcessingStatus(BundleProcessingStatus.FILE_PROCESSING_TYPE, bundle, null, null); StringBuffer ret = processor.postProcessBundle(status, sb); assertEquals( FileUtils.readClassPathFile( "postprocessor/cssbundlecharset/different-charset-decl-bundle-result.css"), ret.toString()); String[] messages = AppenderForTesting.getMessages(); assertEquals(2, messages.length); assertEquals( "The bundle '/bundle1.css' contains CSS with different charset declaration.", messages[1]); }