From: Sergey Vladimirov Date: Tue, 12 Jul 2011 08:52:12 +0000 (+0000) Subject: add more detailed message about missing substring X-Git-Tag: REL_3_8_BETA4~196 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bca6a917357236ffd24b810535ad3b332ad9de02;p=poi.git add more detailed message about missing substring git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1145494 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java b/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java index a9650e8f39..598b734ed9 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/converter/TestWordToHtmlConverter.java @@ -37,6 +37,14 @@ import org.apache.poi.hwpf.HWPFDocument; */ public class TestWordToHtmlConverter extends TestCase { + private static void assertContains( String result, final String substring ) + { + if ( !result.contains( substring ) ) + fail( "Substring \"" + substring + + "\" not found in the following string: \"" + substring + + "\"" ); + } + private static String getHtmlText( final String sampleFileName ) throws Exception { @@ -66,58 +74,65 @@ public class TestWordToHtmlConverter extends TestCase public void testAIOOBTap() throws Exception { String result = getHtmlText( "AIOOB-Tap.doc" ); - assertTrue( result.substring( 0, 2000 ).contains( "" ) ); + assertContains( result.substring( 0, 2000 ), "
" ); } public void testBug33519() throws Exception { String result = getHtmlText( "Bug33519.doc" ); - assertTrue( result.contains( "Планински турове" ) ); - assertTrue( result.contains( "Явор Асенов" ) ); + assertContains( result, "Планински турове" ); + assertContains( result, "Явор Асенов" ); } public void testBug46610_2() throws Exception { String result = getHtmlText( "Bug46610_2.doc" ); - assertTrue( result - .contains( "012345678911234567892123456789312345678941234567890123456789112345678921234567893123456789412345678" ) ); + assertContains( + result, + "012345678911234567892123456789312345678941234567890123456789112345678921234567893123456789412345678" ); } public void testBug46817() throws Exception { String result = getHtmlText( "Bug46817.doc" ); - assertTrue( result.contains( "
" ) ); + final String substring = "
"; + assertContains( result, substring ); + } + + public void testBug48075() throws Exception + { + getHtmlText( "Bug48075.doc" ); } public void testDocumentProperties() throws Exception { String result = getHtmlText( "documentProperties.doc" ); - assertTrue( result.contains( "This is document title" ) ); - assertTrue( result - .contains( "" ) ); + assertContains( result, "This is document title" ); + assertContains( result, + "" ); } public void testEmailhyperlink() throws Exception { String result = getHtmlText( "Bug47286.doc" ); - assertTrue( result.contains( "provisastpet@mfa.gov.cy" ) ); + final String substring = "provisastpet@mfa.gov.cy"; + assertContains( result, substring ); } public void testEquation() throws Exception { String result = getHtmlText( "equation.doc" ); - assertTrue( result - .contains( "" ) ); + assertContains( result, "" ); } public void testHyperlink() throws Exception { String result = getHtmlText( "hyperlink.doc" ); - assertTrue( result.contains( "" ) ); - assertTrue( result.contains( "Hyperlink text" ) ); + assertContains( result, "" ); + assertContains( result, "Hyperlink text" ); } public void testInnerTable() throws Exception @@ -125,11 +140,6 @@ public class TestWordToHtmlConverter extends TestCase getHtmlText( "innertable.doc" ); } - public void testBug48075() throws Exception - { - getHtmlText( "Bug48075.doc" ); - } - public void testO_kurs_doc() throws Exception { getHtmlText( "o_kurs.doc" ); @@ -139,7 +149,7 @@ public class TestWordToHtmlConverter extends TestCase { String result = getHtmlText( "pageref.doc" ); - assertTrue( result.contains( "" ) ); - assertTrue( result.contains( "1" ) ); + assertContains( result, "" ); + assertContains( result, "1" ); } }