From 6d1ca6c43cce83523da3bd840af5f5ae4836684f Mon Sep 17 00:00:00 2001 From: Maxime Sinclair Date: Wed, 10 Jul 2013 10:08:44 +0200 Subject: [PATCH] Check the content of the SVG --- .../sourceforge/plantuml/servlet/TestSVG.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/test/java/net/sourceforge/plantuml/servlet/TestSVG.java b/src/test/java/net/sourceforge/plantuml/servlet/TestSVG.java index eafc9eb..8a4f9d7 100644 --- a/src/test/java/net/sourceforge/plantuml/servlet/TestSVG.java +++ b/src/test/java/net/sourceforge/plantuml/servlet/TestSVG.java @@ -5,6 +5,8 @@ import com.meterware.httpunit.WebConversation; import com.meterware.httpunit.WebRequest; import com.meterware.httpunit.WebResponse; +import java.util.Scanner; + public class TestSVG extends WebappTestCase { /** * Verifies the generation of the SVG for the Bob -> Alice sample @@ -22,5 +24,30 @@ public class TestSVG extends WebappTestCase { assertTrue( diagramLen > 1000); assertTrue( diagramLen < 3000); } - + + /** + * Check the content of the SVG + */ + public void testSequenceDiagramContent() throws Exception { + WebConversation conversation = new WebConversation(); + WebRequest request = new GetMethodWebRequest(getServerUrl() + "svg/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000"); + WebResponse response = conversation.getResource( request); + // Analyze response + // Get the data contained in the XML + Scanner s = new Scanner(response.getInputStream()).useDelimiter("(<([^<>]+)>)+"); + String token; + int bobCounter = 0, aliceCounter = 0; + while(s.hasNext()) { + token = s.next(); + System.out.println("Token : " + token); + if (token.startsWith("Bob")) { + bobCounter++; + } + if (token.startsWith("Alice")) { + aliceCounter++; + } + } + assertTrue(bobCounter == 2); + assertTrue(aliceCounter == 2); + } }