Vincent Massol wrote:
Hi Thomas,
On Jul 13, 2009, at 3:20 PM, tmortagne (SVN) wrote:
Author: tmortagne Date: 2009-07-13 15:20:03 +0200 (Mon, 13 Jul 2009) New Revision: 21910
[snip]
public void testIncludeMacroWithNewContext() throws Exception { - String expected = "beginDocument\n" - + "beginMacroMarkerStandalone [velocity] [] [$myvar]\n" - + "beginParagraph\n" - + "onWord [hello]\n" - + "endParagraph\n" - + "endMacroMarkerStandalone [velocity] [] [$myvar]\n" - + "endDocument"; + String expected = + "beginDocument\n" + "beginMacroMarkerStandalone [velocity] [] [$myvar]\n" + "beginParagraph\n" + + "onWord [hello]\n" + "endParagraph\n" + "endMacroMarkerStandalone [velocity] [] [$myvar]\n" + + "endDocument";
I much prefer my version. Can you please rollback? Again an example why applying code style automatically sucks :)
Why don't you use a StringBuffer?
// Since it's not in the same context, we verify that a Velocity variable set in the including page is not // seen in the included page. @@ -88,21 +91,19 @@
// Create a Macro transformation context with the Macro transformation object defined so that the include // macro can transform included page which is using a new context. - MacroTransformation macroTransformation = + MacroTransformation macroTransformation = (MacroTransformation) getComponentManager().lookup(Transformation.class, "macro"); MacroTransformationContext context = new MacroTransformationContext(); context.setMacroTransformation(macroTransformation); - + List<Block> blocks = macro.execute(parameters, null, context);
assertBlocks(expected, blocks); } - + public void testIncludeMacroWithCurrentContext() throws Exception { - String expected = "beginDocument\n" - + "onMacroStandalone [someMacro] []\n" - + "endDocument"; + String expected = "beginDocument\n" + "onMacroStandalone [someMacro] []\n" + "endDocument";
again
again
IncludeMacro macro = (IncludeMacro) getComponentManager().lookup(Macro.class, "include");
mockDocumentAccessBridge .expects(once()).method("isDocumentViewable").will(returnValue(true)); @@ -119,7 +120,7 @@
assertBlocks(expected, blocks); } - + public void testIncludeMacroWithNoDocumentSpecified() throws Exception { IncludeMacro macro = (IncludeMacro) getComponentManager().lookup(Macro.class, "include"); @@ -129,8 +130,8 @@ macro.execute(parameters, null, new MacroTransformationContext()); fail("An exception should have been thrown"); } catch (MacroExecutionException expected) { - assertEquals("You must specify a 'document' parameter pointing to the document to include.", - expected.getMessage()); + assertEquals("You must specify a 'document' parameter pointing to the document to include.", expected + .getMessage());
again a brilliant example why it sucks... :(
Can you store the long string in a separate variable (maybe a StringBuffer if it's really long)? Thanks, Marius