From fd2b6e7c02f0aa47374ced89699bb6a3b8789fa1 Mon Sep 17 00:00:00 2001 From: Maxime Sinclair Date: Thu, 6 Feb 2014 18:28:06 +0100 Subject: [PATCH] [TASK] Checkstyle report and mvn site configuration --- pom.xml | 56 ++++++++ src/main/config/checkstyle.xml | 125 ++++++++++++++++++ .../plantuml/servlet/AsciiServlet.java | 4 +- .../plantuml/servlet/DiagramResponse.java | 10 +- .../plantuml/servlet/ImgServlet.java | 4 +- .../plantuml/servlet/MapServlet.java | 6 +- .../plantuml/servlet/OldProxyServlet.java | 6 +- .../plantuml/servlet/PlantUmlServlet.java | 10 +- .../plantuml/servlet/ProxyServlet.java | 27 ++-- .../plantuml/servlet/SvgServlet.java | 4 +- .../plantuml/servlet/UmlDiagramService.java | 8 +- .../sourceforge/plantuml/servlet/Welcome.java | 4 +- .../servlet/utility/Configuration.java | 10 +- .../servlet/utility/NullOutputStream.java | 6 +- .../servlet/utility/UmlExtractor.java | 9 +- .../plantuml/servlet/TestCharset.java | 8 +- .../plantuml/servlet/TestForm.java | 14 +- .../plantuml/servlet/TestImage.java | 8 +- .../sourceforge/plantuml/servlet/TestMap.java | 15 ++- .../plantuml/servlet/TestOldProxy.java | 8 +- .../plantuml/servlet/TestProxy.java | 10 +- .../plantuml/servlet/TestUtils.java | 4 +- 22 files changed, 273 insertions(+), 83 deletions(-) create mode 100644 src/main/config/checkstyle.xml diff --git a/pom.xml b/pom.xml index 5fc280b..14d05a8 100644 --- a/pom.xml +++ b/pom.xml @@ -60,8 +60,64 @@ true + + org.apache.maven.plugins + maven-site-plugin + 3.0-beta-3 + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.6 + + + + index + dependencies + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + private + true + + + + html + + javadoc + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.11 + + ${basedir}/src/main/config/checkstyle.xml + UTF-8 + false + + + + + checkstyle + + + + + + UTF-8 8.0.4.v20111024 diff --git a/src/main/config/checkstyle.xml b/src/main/config/checkstyle.xml new file mode 100644 index 0000000..6161e07 --- /dev/null +++ b/src/main/config/checkstyle.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/net/sourceforge/plantuml/servlet/AsciiServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/AsciiServlet.java index 2c931c0..30e23be 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/AsciiServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/AsciiServlet.java @@ -3,7 +3,7 @@ * ======================================================================== * * Project Info: http://plantuml.sourceforge.net - * + * * This file is part of PlantUML. * * PlantUML is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ package net.sourceforge.plantuml.servlet; import net.sourceforge.plantuml.FileFormat; -/* +/* * ASCII servlet of the webapp. * This servlet produces the UML sequence diagram in text format. */ diff --git a/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java b/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java index 271586d..51de6e2 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/DiagramResponse.java @@ -3,7 +3,7 @@ * ======================================================================== * * Project Info: http://plantuml.sourceforge.net - * + * * This file is part of PlantUML. * * PlantUML is free software; you can redistribute it and/or modify it @@ -66,7 +66,7 @@ class DiagramResponse { SourceStringReader reader = new SourceStringReader(uml); reader.generateImage(response.getOutputStream(), new FileFormatOption(format, false)); } - + void sendMap(String uml) throws IOException { if (StringUtils.isDiagramCacheable(uml)) { addHeaderForCache(); @@ -76,11 +76,11 @@ class DiagramResponse { String map = reader.generateImage(new NullOutputStream(), new FileFormatOption(FileFormat.PNG, false)); String[] mapLines = map.split("[\\r\\n]"); PrintWriter httpOut = response.getWriter(); - for (int i=2; (i+1) Alice" sample + * Verifies the preservation of unicode characters for the + * "participant Bob [[http://www.snow.com/❄]]\nBob -> Alice" sample */ public void testUnicodeInCMap() throws Exception { WebConversation conversation = new WebConversation(); - WebRequest request = new GetMethodWebRequest(getServerUrl() + "map/AqWiAibCpYn8p2jHSCfFKeYEpYWfAR3IroylBzShpiilrqlEpzL_DBSbDfOB9Azhf-2OavcS2W00"); + WebRequest request = new GetMethodWebRequest(getServerUrl() + + "map/AqWiAibCpYn8p2jHSCfFKeYEpYWfAR3IroylBzShpiilrqlEpzL_DBSbDfOB9Azhf-2OavcS2W00"); WebResponse response = conversation.getResource(request); // Analyze response // Verifies the Content-Type header diff --git a/src/test/java/net/sourceforge/plantuml/servlet/TestForm.java b/src/test/java/net/sourceforge/plantuml/servlet/TestForm.java index 8b63a88..a72bc2f 100644 --- a/src/test/java/net/sourceforge/plantuml/servlet/TestForm.java +++ b/src/test/java/net/sourceforge/plantuml/servlet/TestForm.java @@ -17,7 +17,7 @@ public class TestForm extends WebappTestCase { WebRequest request = new GetMethodWebRequest(getServerUrl()); WebResponse response = conversation.getResponse(request); // Analyze response - WebForm forms[] = response.getForms(); + WebForm[] forms = response.getForms(); assertEquals(2, forms.length); assertEquals("url", forms[1].getParameterNames()[0]); assertTrue(forms[1].getParameterValue("url").endsWith("/png/" + TestUtils.SEQBOB)); @@ -38,7 +38,7 @@ public class TestForm extends WebappTestCase { formUMLText.setParameter("text", "version"); response = formUMLText.submit(); // Analyze response - WebForm forms[] = response.getForms(); + WebForm[] forms = response.getForms(); assertEquals(2, forms.length); // Ensure the Text field is correct assertEquals("version", forms[0].getParameterValue("text")); @@ -60,7 +60,7 @@ public class TestForm extends WebappTestCase { formUMLText.setParameter("text", ""); response = formUMLText.submit(); // Analyze response - WebForm forms[] = response.getForms(); + WebForm[] forms = response.getForms(); assertEquals(2, forms.length); // Ensure the Text field is empty assertNull(forms[0].getParameterValue("text")); @@ -82,7 +82,7 @@ public class TestForm extends WebappTestCase { formUrl.setParameter("url", ""); response = formUrl.submit(); // Analyze response - WebForm forms[] = response.getForms(); + WebForm[] forms = response.getForms(); assertEquals(2, forms.length); // Ensure the Text field is empty assertNull(forms[0].getParameterValue("text")); @@ -104,7 +104,7 @@ public class TestForm extends WebappTestCase { formDitaaText.setParameter("text", "@startditaa \n*--> \n@endditaa"); response = formDitaaText.submit(); // Analyze response - WebForm forms[] = response.getForms(); + WebForm[] forms = response.getForms(); assertEquals(2, forms.length); // Ensure the Text field is correct assertTrue(forms[0].getParameterValue("text").startsWith("@startditaa")); @@ -129,7 +129,7 @@ public class TestForm extends WebappTestCase { // Ensure the generated image is present assertEquals(1, response.getImages().length); // Ensure the image map is present - HTMLElement maps[] = response.getElementsByTagName("map"); + HTMLElement[] maps = response.getElementsByTagName("map"); assertEquals(1, maps.length); } @@ -143,7 +143,7 @@ public class TestForm extends WebappTestCase { WebRequest request = new GetMethodWebRequest(getServerUrl() + "form?url=" + TestUtils.SEQBOB); WebResponse response = conversation.getResponse(request); // Analyze response - WebForm forms[] = response.getForms(); + WebForm[] forms = response.getForms(); assertEquals(2, forms.length); // Ensure the Text field is filled assertEquals(forms[0].getParameterValue("text"), "@startuml\nBob -> Alice : hello\n@enduml"); diff --git a/src/test/java/net/sourceforge/plantuml/servlet/TestImage.java b/src/test/java/net/sourceforge/plantuml/servlet/TestImage.java index 6463d07..cbeeb6c 100644 --- a/src/test/java/net/sourceforge/plantuml/servlet/TestImage.java +++ b/src/test/java/net/sourceforge/plantuml/servlet/TestImage.java @@ -60,10 +60,10 @@ public class TestImage extends WebappTestCase { // Consume the response InputStream responseStream = response.getInputStream(); while (responseStream.read() != -1) { - ; // Do nothing + // Do nothing } } - + /** * Verifies that the HTTP header of a diagram incites the browser to cache it. */ @@ -78,7 +78,7 @@ public class TestImage extends WebappTestCase { // Consume the response InputStream responseStream = response.getInputStream(); while (responseStream.read() != -1) { - ; // Do nothing + // Do nothing } - } + } } diff --git a/src/test/java/net/sourceforge/plantuml/servlet/TestMap.java b/src/test/java/net/sourceforge/plantuml/servlet/TestMap.java index fda2bce..89f81ab 100644 --- a/src/test/java/net/sourceforge/plantuml/servlet/TestMap.java +++ b/src/test/java/net/sourceforge/plantuml/servlet/TestMap.java @@ -8,17 +8,18 @@ import com.meterware.httpunit.WebResponse; public class TestMap extends WebappTestCase { /** * Verifies the generation of the MAP for the following sample: - * + * * participant Bob [[http://www.yahoo.com]] * Bob -> Alice : [[http://www.google.com]] hello */ public void testSimpleSequenceDiagram() throws Exception { WebConversation conversation = new WebConversation(); - WebRequest request = new GetMethodWebRequest(getServerUrl() + "map/AqWiAibCpYn8p2jHSCfFKeYEpYWfAR3IroylBzUhJCp8pzTBpi-DZUK2IUhQAJZcP2QdAbYXgalFpq_FIOKeLCX8pSd91m00"); + WebRequest request = new GetMethodWebRequest(getServerUrl() + + "map/AqWiAibCpYn8p2jHSCfFKeYEpYWfAR3IroylBzUhJCp8pzTBpi-DZUK2IUhQAJZcP2QdAbYXgalFpq_FIOKeLCX8pSd91m00"); WebResponse response = conversation.getResource(request); // Analyze response // Verifies the Content-Type header - assertEquals("Response content type is not TEXT PLAIN", "text/plain", response.getContentType()); + assertEquals("Response content type is not TEXT PLAIN", "text/plain", response.getContentType()); assertEquals("Response character set is not UTF-8", "UTF-8", response.getCharacterSet()); // Get the content, check its first characters and verify its size String diagram = response.getText(); @@ -34,15 +35,17 @@ public class TestMap extends WebappTestCase { */ public void testSequenceDiagramContent() throws Exception { WebConversation conversation = new WebConversation(); - WebRequest request = new GetMethodWebRequest(getServerUrl() + "map/AqWiAibCpYn8p2jHSCfFKeYEpYWfAR3IroylBzUhJCp8pzTBpi-DZUK2IUhQAJZcP2QdAbYXgalFpq_FIOKeLCX8pSd91m00"); + WebRequest request = new GetMethodWebRequest(getServerUrl() + + "map/AqWiAibCpYn8p2jHSCfFKeYEpYWfAR3IroylBzUhJCp8pzTBpi-DZUK2IUhQAJZcP2QdAbYXgalFpq_FIOKeLCX8pSd91m00"); WebResponse response = conversation.getResource(request); // Analyze response // Get the data contained in the XML String map = response.getText(); assertTrue("Response is not a list of tags", map.matches("(<([^<>]+)>)+")); - assertTrue("Response doesn't contain the area structure", map.matches(".*(area shape=\".+\" id=\".+\" href=\".+\").*")); + assertTrue("Response doesn't contain the area structure", + map.matches(".*(area shape=\".+\" id=\".+\" href=\".+\").*")); } - + /** * Check the empty MAP of a sequence diagram without link * This test uses the simple Bob -> Alice diff --git a/src/test/java/net/sourceforge/plantuml/servlet/TestOldProxy.java b/src/test/java/net/sourceforge/plantuml/servlet/TestOldProxy.java index e304ee1..2ea912b 100644 --- a/src/test/java/net/sourceforge/plantuml/servlet/TestOldProxy.java +++ b/src/test/java/net/sourceforge/plantuml/servlet/TestOldProxy.java @@ -15,7 +15,8 @@ public class TestOldProxy extends WebappTestCase { */ public void testDefaultProxy() throws Exception { WebConversation conversation = new WebConversation(); - WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/" + getServerUrl() + "resource/test2diagrams.txt"); + WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/" + getServerUrl() + + "resource/test2diagrams.txt"); WebResponse response = conversation.getResource(request); // Analyze response // Verifies the Content-Type header @@ -38,7 +39,8 @@ public class TestOldProxy extends WebappTestCase { public void testProxyWithFormat() throws Exception { WebConversation conversation = new WebConversation(); - WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/svg/" + getServerUrl() + "resource/test2diagrams.txt"); + WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/svg/" + getServerUrl() + + "resource/test2diagrams.txt"); WebResponse response = conversation.getResource(request); // Analyze response // Verifies the Content-Type header @@ -61,7 +63,7 @@ public class TestOldProxy extends WebappTestCase { // Analyze response, it must be the empty form // Verifies the Content-Type header assertEquals("Response content type is not HTML", "text/html", response.getContentType()); - WebForm forms[] = response.getForms(); + WebForm[] forms = response.getForms(); assertEquals(2, forms.length); } } diff --git a/src/test/java/net/sourceforge/plantuml/servlet/TestProxy.java b/src/test/java/net/sourceforge/plantuml/servlet/TestProxy.java index 1640723..6893df0 100644 --- a/src/test/java/net/sourceforge/plantuml/servlet/TestProxy.java +++ b/src/test/java/net/sourceforge/plantuml/servlet/TestProxy.java @@ -14,12 +14,12 @@ public class TestProxy extends WebappTestCase { */ public void testDefaultProxy() throws Exception { WebConversation conversation = new WebConversation(); - WebRequest request = new GetMethodWebRequest(getServerUrl() - + "proxy?src=" + getServerUrl() + "resource/test2diagrams.txt"); + WebRequest request = new GetMethodWebRequest(getServerUrl() + + "proxy?src=" + getServerUrl() + "resource/test2diagrams.txt"); WebResponse response = conversation.getResource(request); // Analyze response // Verifies the Content-Type header - assertEquals( "Response content type is not PNG", "image/png", response.getContentType()); + assertEquals("Response content type is not PNG", "image/png", response.getContentType()); // Get the image and verify its size (~2000 bytes) InputStream responseStream = response.getInputStream(); ByteArrayOutputStream imageStream = new ByteArrayOutputStream(); @@ -38,8 +38,8 @@ public class TestProxy extends WebappTestCase { /* public void testProxyWithFormat() throws Exception { WebConversation conversation = new WebConversation(); - WebRequest request = new GetMethodWebRequest(getServerUrl() - + "proxy?format=svg&src=" + getServerUrl() + "resource/test2diagrams.txt"); + WebRequest request = new GetMethodWebRequest(getServerUrl() + + "proxy?format=svg&src=" + getServerUrl() + "resource/test2diagrams.txt"); WebResponse response = conversation.getResource(request); // Analyze response // Verifies the Content-Type header diff --git a/src/test/java/net/sourceforge/plantuml/servlet/TestUtils.java b/src/test/java/net/sourceforge/plantuml/servlet/TestUtils.java index 5c52809..97262e9 100644 --- a/src/test/java/net/sourceforge/plantuml/servlet/TestUtils.java +++ b/src/test/java/net/sourceforge/plantuml/servlet/TestUtils.java @@ -9,12 +9,12 @@ public class TestUtils { /* * Theses strings are the compressed form of a PlantUML diagram. */ - + /* * version */ public static final String VERSION = "AqijAixCpmC0"; - + /* * Bob -> Alice : hello */