mirror of
https://github.com/octoleo/plantuml-server.git
synced 2024-12-22 16:58:54 +00:00
Merge pull request #48 from jessetan/add-eps-to-server
Support EPS and EPS text output
This commit is contained in:
commit
335a0b4080
@ -61,6 +61,7 @@ class DiagramResponse {
|
|||||||
Map<FileFormat, String> map = new HashMap<FileFormat, String>();
|
Map<FileFormat, String> map = new HashMap<FileFormat, String>();
|
||||||
map.put(FileFormat.PNG, "image/png");
|
map.put(FileFormat.PNG, "image/png");
|
||||||
map.put(FileFormat.SVG, "image/svg+xml");
|
map.put(FileFormat.SVG, "image/svg+xml");
|
||||||
|
map.put(FileFormat.EPS, "application/postscript");
|
||||||
map.put(FileFormat.UTXT, "text/plain;charset=UTF-8");
|
map.put(FileFormat.UTXT, "text/plain;charset=UTF-8");
|
||||||
CONTENT_TYPE = Collections.unmodifiableMap(map);
|
CONTENT_TYPE = Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.sourceforge.net
|
||||||
|
*
|
||||||
|
* This file is part of PlantUML.
|
||||||
|
*
|
||||||
|
* PlantUML is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PlantUML distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.FileFormat;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EPS servlet of the webapp.
|
||||||
|
* This servlet produces the UML diagram in EPS format.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class EpsServlet extends UmlDiagramService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FileFormat getOutputFormat() {
|
||||||
|
return FileFormat.EPS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.sourceforge.net
|
||||||
|
*
|
||||||
|
* This file is part of PlantUML.
|
||||||
|
*
|
||||||
|
* PlantUML is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PlantUML distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
* USA.
|
||||||
|
*/
|
||||||
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.FileFormat;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EPS servlet of the webapp.
|
||||||
|
* This servlet produces the UML diagram in EPS format.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class EpsTextServlet extends UmlDiagramService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FileFormat getOutputFormat() {
|
||||||
|
return FileFormat.EPS_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -110,6 +110,12 @@ public class OldProxyServlet extends HttpServlet {
|
|||||||
if (format.equals("svg")) {
|
if (format.equals("svg")) {
|
||||||
return FileFormat.SVG;
|
return FileFormat.SVG;
|
||||||
}
|
}
|
||||||
|
if (format.equals("eps")) {
|
||||||
|
return FileFormat.EPS;
|
||||||
|
}
|
||||||
|
if (format.equals("epstext")) {
|
||||||
|
return FileFormat.EPS_TEXT;
|
||||||
|
}
|
||||||
if (format.equals("txt")) {
|
if (format.equals("txt")) {
|
||||||
return FileFormat.ATXT;
|
return FileFormat.ATXT;
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,12 @@ public class ProxyServlet extends HttpServlet {
|
|||||||
if (format.equals("svg")) {
|
if (format.equals("svg")) {
|
||||||
return FileFormat.SVG;
|
return FileFormat.SVG;
|
||||||
}
|
}
|
||||||
|
if (format.equals("eps")) {
|
||||||
|
return FileFormat.EPS;
|
||||||
|
}
|
||||||
|
if (format.equals("epstext")) {
|
||||||
|
return FileFormat.EPS_TEXT;
|
||||||
|
}
|
||||||
if (format.equals("txt")) {
|
if (format.equals("txt")) {
|
||||||
return FileFormat.UTXT;
|
return FileFormat.UTXT;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ abstract HttpServlet <|-- MapServlet
|
|||||||
abstract HttpServlet <|-- ProxyServlet
|
abstract HttpServlet <|-- ProxyServlet
|
||||||
UmlDiagramService <|-- PngServlet
|
UmlDiagramService <|-- PngServlet
|
||||||
UmlDiagramService <|-- SvgServlet
|
UmlDiagramService <|-- SvgServlet
|
||||||
|
UmlDiagramService <|-- EpsServlet
|
||||||
|
UmlDiagramService <|-- EpsTextServlet
|
||||||
UmlDiagramService <|-- AsciiServlet
|
UmlDiagramService <|-- AsciiServlet
|
||||||
UmlDiagramService o- DiagramResponse
|
UmlDiagramService o- DiagramResponse
|
||||||
MapServlet o-- DiagramResponse
|
MapServlet o-- DiagramResponse
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<p>This package is in charge of the JEE PlantUml Server.</p>
|
<p>This package is in charge of the JEE PlantUml Server.</p>
|
||||||
<p>there are 2 kind of servlets in this package :<br>
|
<p>there are 2 kind of servlets in this package :<br>
|
||||||
- Interactive servlets : Welcome, PlantUmlServlet that are in charge of the web pages dedicated to human users.<br>
|
- Interactive servlets : Welcome, PlantUmlServlet that are in charge of the web pages dedicated to human users.<br>
|
||||||
- Service servlets : ImgServlet, SvgServlet, AsciiServlet, ProxyServlet that only produce a diagram as output.<br>
|
- Service servlets : ImgServlet, SvgServlet, EpsServlet, EpsTextServlet, AsciiServlet, ProxyServlet that only produce a diagram as output.<br>
|
||||||
<br>
|
<br>
|
||||||
Structure of the service part of the PlantUmlServer: <br>
|
Structure of the service part of the PlantUmlServer: <br>
|
||||||
<img src="http://www.plantuml.com/plantuml/img/XP51ReCm44Ntd6AMH0etwAPIbNPJjIhg0OoPm4WsTiPZrAZDtGk5913IP3b_dlx_7jTK8g3riWUBja0EIJsLf7RbJDeIcavHHH1MMa0R5G9yMlD4gc9bS-IMDC9t0k1ZOKX3wwY4qZsZf2yYlYSCoWVk8WO1tgrX9WVlce30mQywZrFGQ9OBKrD1XPAxo1hJenAPPlo636uSMoKz_1R5HndcT9KSag7tMFeKshU-qDBhxTRJW6sV_FVCW4qv6foRMJFRloe_tntEvvnamSDFbYqlUuFjZCVv1lJExcj_n9R_DZ1DTOV8stl4Oz14_pCkkpnqSgxVRPVhQV5hm2y0" />
|
<img src="http://www.plantuml.com/plantuml/img/XP51ReCm44Ntd6AMH0etwAPIbNPJjIhg0OoPm4WsTiPZrAZDtGk5913IP3b_dlx_7jTK8g3riWUBja0EIJsLf7RbJDeIcavHHH1MMa0R5G9yMlD4gc9bS-IMDC9t0k1ZOKX3wwY4qZsZf2yYlYSCoWVk8WO1tgrX9WVlce30mQywZrFGQ9OBKrD1XPAxo1hJenAPPlo636uSMoKz_1R5HndcT9KSag7tMFeKshU-qDBhxTRJW6sV_FVCW4qv6foRMJFRloe_tntEvvnamSDFbYqlUuFjZCVv1lJExcj_n9R_DZ1DTOV8stl4Oz14_pCkkpnqSgxVRPVhQV5hm2y0" />
|
||||||
|
@ -23,6 +23,14 @@
|
|||||||
<servlet-name>svgservlet</servlet-name>
|
<servlet-name>svgservlet</servlet-name>
|
||||||
<servlet-class>net.sourceforge.plantuml.servlet.SvgServlet</servlet-class>
|
<servlet-class>net.sourceforge.plantuml.servlet.SvgServlet</servlet-class>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>epsservlet</servlet-name>
|
||||||
|
<servlet-class>net.sourceforge.plantuml.servlet.EpsServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>epstextservlet</servlet-name>
|
||||||
|
<servlet-class>net.sourceforge.plantuml.servlet.EpsTextServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>asciiservlet</servlet-name>
|
<servlet-name>asciiservlet</servlet-name>
|
||||||
<servlet-class>net.sourceforge.plantuml.servlet.AsciiServlet</servlet-class>
|
<servlet-class>net.sourceforge.plantuml.servlet.AsciiServlet</servlet-class>
|
||||||
@ -68,6 +76,14 @@
|
|||||||
<servlet-name>svgservlet</servlet-name>
|
<servlet-name>svgservlet</servlet-name>
|
||||||
<url-pattern>/svg/*</url-pattern>
|
<url-pattern>/svg/*</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>epsservlet</servlet-name>
|
||||||
|
<url-pattern>/eps/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>epstextservlet</servlet-name>
|
||||||
|
<url-pattern>/epstext/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>asciiservlet</servlet-name>
|
<servlet-name>asciiservlet</servlet-name>
|
||||||
<url-pattern>/txt/*</url-pattern>
|
<url-pattern>/txt/*</url-pattern>
|
||||||
|
@ -12,6 +12,7 @@ public class AllTests extends TestSuite {
|
|||||||
suite.addTestSuite(TestImage.class);
|
suite.addTestSuite(TestImage.class);
|
||||||
suite.addTestSuite(TestAsciiArt.class);
|
suite.addTestSuite(TestAsciiArt.class);
|
||||||
suite.addTestSuite(TestSVG.class);
|
suite.addTestSuite(TestSVG.class);
|
||||||
|
suite.addTestSuite(TestEPS.class);
|
||||||
suite.addTestSuite(TestProxy.class);
|
suite.addTestSuite(TestProxy.class);
|
||||||
suite.addTestSuite(TestMap.class);
|
suite.addTestSuite(TestMap.class);
|
||||||
suite.addTestSuite(TestCharset.class);
|
suite.addTestSuite(TestCharset.class);
|
||||||
|
27
src/test/java/net/sourceforge/plantuml/servlet/TestEPS.java
Normal file
27
src/test/java/net/sourceforge/plantuml/servlet/TestEPS.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
|
import com.meterware.httpunit.GetMethodWebRequest;
|
||||||
|
import com.meterware.httpunit.WebConversation;
|
||||||
|
import com.meterware.httpunit.WebRequest;
|
||||||
|
import com.meterware.httpunit.WebResponse;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class TestEPS extends WebappTestCase {
|
||||||
|
/**
|
||||||
|
* Verifies the generation of the EPS for the Bob -> Alice sample
|
||||||
|
*/
|
||||||
|
public void testSimpleSequenceDiagram() throws Exception {
|
||||||
|
WebConversation conversation = new WebConversation();
|
||||||
|
WebRequest request = new GetMethodWebRequest(getServerUrl() + "eps/" + TestUtils.SEQBOB);
|
||||||
|
WebResponse response = conversation.getResource(request);
|
||||||
|
// Analyze response
|
||||||
|
// Verifies the Content-Type header
|
||||||
|
assertEquals("Response content type is not EPS", "application/postscript", response.getContentType());
|
||||||
|
// Get the content and verify its size
|
||||||
|
String diagram = response.getText();
|
||||||
|
int diagramLen = diagram.length();
|
||||||
|
assertTrue(diagramLen > 10000);
|
||||||
|
assertTrue(diagramLen < 12000);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user