mirror of
https://github.com/octoleo/plantuml-server.git
synced 2024-11-05 20:37:53 +00:00
Merge pull request #2 from plalloni/master
Build migrated to maven, tests self-contained, etc.
This commit is contained in:
commit
b0c46ef805
19
.classpath
19
.classpath
@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
|
||||||
<classpathentry kind="src" path="test/src"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
|
|
||||||
<classpathentry kind="lib" path="test/lib/junit-3.8.1.jar"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="owner.project.facets" value="jst.web"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="owner.project.facets" value="java"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="lib" path="test/lib/httpunit.jar"/>
|
|
||||||
<classpathentry kind="output" path="content/WEB-INF/classes"/>
|
|
||||||
</classpath>
|
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,5 +1,2 @@
|
|||||||
/user.property
|
target
|
||||||
/content/WEB-INF/classes
|
.*
|
||||||
/plantuml.war
|
|
||||||
/dist
|
|
||||||
|
|
||||||
|
31
.project
31
.project
@ -1,31 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>plantumlservlet</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
<project>Servers</project>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
|
||||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" path="content"/>
|
|
||||||
<classpathentry kind="output" path=""/>
|
|
||||||
</classpath>
|
|
@ -1,3 +0,0 @@
|
|||||||
#Thu Feb 17 12:10:42 CET 2011
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
encoding/<project>=UTF-8
|
|
@ -1,12 +0,0 @@
|
|||||||
#Thu Feb 17 12:07:22 CET 2011
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,3 +0,0 @@
|
|||||||
#Thu Feb 17 12:12:34 CET 2011
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
|
@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project-modules id="moduleCoreId" project-version="1.5.0">
|
|
||||||
<wb-module deploy-name="plantumlservlet">
|
|
||||||
<wb-resource deploy-path="/" source-path="/content"/>
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/test/src"/>
|
|
||||||
<property name="java-output-path" value="/plantumlservlet/WEB-INF/classes"/>
|
|
||||||
<property name="context-root" value="plantuml"/>
|
|
||||||
</wb-module>
|
|
||||||
</project-modules>
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<faceted-project>
|
|
||||||
<runtime name="Apache Tomcat v6.0"/>
|
|
||||||
<installed facet="java" version="1.6"/>
|
|
||||||
<installed facet="jst.web" version="2.4"/>
|
|
||||||
</faceted-project>
|
|
@ -1 +0,0 @@
|
|||||||
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
|
|
@ -1 +0,0 @@
|
|||||||
Window
|
|
@ -1,3 +0,0 @@
|
|||||||
#Thu Feb 17 12:12:34 CET 2011
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.wst.ws.service.policy.projectEnabled=false
|
|
21
README
21
README
@ -1,21 +0,0 @@
|
|||||||
* PlantUMLServlet description
|
|
||||||
*****************************
|
|
||||||
PlantUMLServlet is a PlantUML extension to generate images on-the-fly.
|
|
||||||
To know more about PlantUML, please visit http://plantuml.sourceforge.net/
|
|
||||||
|
|
||||||
* How to build the project
|
|
||||||
**************************
|
|
||||||
To build the project you need to install the following components :
|
|
||||||
- java jdk 1.6.0 or above
|
|
||||||
- apache tomcat 6.0 or above
|
|
||||||
- apache ant 1.7 or above
|
|
||||||
|
|
||||||
If the tomcat home directory is not /tomcat, you have to create at
|
|
||||||
the root of the project a text file named user.property and
|
|
||||||
containing the following line:
|
|
||||||
tomcat-home=<your tomcat home dir>
|
|
||||||
|
|
||||||
For example, on a Windows environment, your user.property file can be:
|
|
||||||
tomcat-home=C:/tools/Tomcat6.0
|
|
||||||
|
|
||||||
To build the war, just run "ant" at the root directory of the project.
|
|
24
README.md
Normal file
24
README.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
PlantUMLServlet description
|
||||||
|
===========================
|
||||||
|
|
||||||
|
PlantUMLServlet is a PlantUML extension to generate images on-the-fly.
|
||||||
|
|
||||||
|
To know more about PlantUML, please visit http://plantuml.sourceforge.net/.
|
||||||
|
|
||||||
|
How to build the project
|
||||||
|
========================
|
||||||
|
|
||||||
|
To build the project you need to install the following components:
|
||||||
|
|
||||||
|
* java jdk 1.6.0 or above
|
||||||
|
* apache maven 3.0.2 or above
|
||||||
|
|
||||||
|
To build the war, just run "mvn package" at the root directory of the project to produce
|
||||||
|
plantuml.war in the target/ directory.
|
||||||
|
|
||||||
|
How to testrun the project
|
||||||
|
==========================
|
||||||
|
|
||||||
|
To run the application deployed on an embedded jetty server run "mvn jetty:run-war"
|
||||||
|
and go to http://localhost:8080/plantuml with your favorite web browser (after it finishes
|
||||||
|
to start up).
|
88
build.xml
88
build.xml
@ -1,88 +0,0 @@
|
|||||||
<project default="main" basedir=".">
|
|
||||||
|
|
||||||
<target name="main" depends="clean,war">
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<taskdef name="junit"
|
|
||||||
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
|
|
||||||
<classpath>
|
|
||||||
<pathelement location="test/lib/junit-3.8.1.jar" />
|
|
||||||
</classpath>
|
|
||||||
</taskdef>
|
|
||||||
|
|
||||||
|
|
||||||
<target name="init">
|
|
||||||
<!-- overwrite with your own values in a user.property file -->
|
|
||||||
<property file="user.property" />
|
|
||||||
<property name="target" value="dist" description="Target directory of the build"/>
|
|
||||||
<property name="tomcat-home" value="/tomcat" description="Home directory of Tomcat"/>
|
|
||||||
<property name="debug" value="false" />
|
|
||||||
<mkdir dir="${target}" />
|
|
||||||
<path id="project-classpath">
|
|
||||||
<fileset dir="content/WEB-INF/lib" includes="*.jar" />
|
|
||||||
<fileset dir="${tomcat-home}/lib" includes="*.jar" />
|
|
||||||
</path>
|
|
||||||
<path id="test-classpath">
|
|
||||||
<fileset dir="test/lib" includes="*.jar" />
|
|
||||||
<pathelement location="${target}"/>
|
|
||||||
</path>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="clean" depends="init">
|
|
||||||
<delete file="${target}/plantuml.war" />
|
|
||||||
<delete>
|
|
||||||
<fileset dir="${target}" includes="**/*.class"/>
|
|
||||||
</delete>
|
|
||||||
<delete dir="${target}/root" />
|
|
||||||
<delete dir="content/WEB-INF/classes" />
|
|
||||||
<mkdir dir="content/WEB-INF/classes" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="compile" depends="init">
|
|
||||||
<javac srcdir="src" destdir="content/WEB-INF/classes" debug="${debug}" classpathref="project-classpath" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="prepare" depends="init">
|
|
||||||
<!-- So that we can use the ${TSTAMP}, ${DSTAMP} -->
|
|
||||||
<tstamp />
|
|
||||||
<filter token="timestamp" value="${DSTAMP}"/>
|
|
||||||
<copy todir="${target}/root" filtering="true" >
|
|
||||||
<fileset dir="content">
|
|
||||||
<include name="*.jsp*"/>
|
|
||||||
</fileset>
|
|
||||||
</copy>
|
|
||||||
<copy todir="${target}/root" filtering="false" >
|
|
||||||
<fileset dir="content">
|
|
||||||
<exclude name="*.jsp*"/>
|
|
||||||
<exclude name="*-INF/**"/>
|
|
||||||
</fileset>
|
|
||||||
</copy>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="war" depends="prepare, compile">
|
|
||||||
<war destfile="${target}/plantuml.war" webxml="content/WEB-INF/web.xml">
|
|
||||||
<classes dir="content/WEB-INF/classes" />
|
|
||||||
<fileset dir="${target}/root" />
|
|
||||||
<lib dir="content/WEB-INF/lib" />
|
|
||||||
</war>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="deploy" depends="main">
|
|
||||||
<copy file="${target}/plantuml.war" todir="${tomcat-home}/webapps" overwrite="true" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="test" depends="init">
|
|
||||||
<echo>
|
|
||||||
WARN - Test execution requires an running PlantUMLServer.
|
|
||||||
</echo>
|
|
||||||
<javac srcdir="test/src" destdir="${target}" debug="${debug}" classpathref="test-classpath" />
|
|
||||||
<junit showoutput="true" >
|
|
||||||
<classpath>
|
|
||||||
<path refid="test-classpath"/>
|
|
||||||
</classpath>
|
|
||||||
<formatter type="plain" usefile="false" />
|
|
||||||
<test name="net.sourceforge.plantuml.servlet.AllTests"/>
|
|
||||||
</junit>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
</project>
|
|
Binary file not shown.
Binary file not shown.
@ -1,68 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
|
|
||||||
<display-name>plantuml</display-name>
|
|
||||||
<servlet>
|
|
||||||
<servlet-name>plantumlservlet</servlet-name>
|
|
||||||
<servlet-class>net.sourceforge.plantuml.servlet.PlantUmlServlet</servlet-class>
|
|
||||||
</servlet>
|
|
||||||
<servlet>
|
|
||||||
<servlet-name>welcome</servlet-name>
|
|
||||||
<servlet-class>net.sourceforge.plantuml.servlet.Welcome</servlet-class>
|
|
||||||
</servlet>
|
|
||||||
<servlet>
|
|
||||||
<servlet-name>imgservlet</servlet-name>
|
|
||||||
<servlet-class>net.sourceforge.plantuml.servlet.ImgServlet</servlet-class>
|
|
||||||
</servlet>
|
|
||||||
<servlet>
|
|
||||||
<servlet-name>svgservlet</servlet-name>
|
|
||||||
<servlet-class>net.sourceforge.plantuml.servlet.SvgServlet</servlet-class>
|
|
||||||
</servlet>
|
|
||||||
<servlet>
|
|
||||||
<servlet-name>asciiservlet</servlet-name>
|
|
||||||
<servlet-class>net.sourceforge.plantuml.servlet.AsciiServlet</servlet-class>
|
|
||||||
</servlet>
|
|
||||||
<!-- Patterns of the servlet -->
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>welcome</servlet-name>
|
|
||||||
<url-pattern>/welcome</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>plantumlservlet</servlet-name>
|
|
||||||
<url-pattern>/uml/*</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>plantumlservlet</servlet-name>
|
|
||||||
<url-pattern>/form</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>imgservlet</servlet-name>
|
|
||||||
<url-pattern>/img/*</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>svgservlet</servlet-name>
|
|
||||||
<url-pattern>/svg/*</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>asciiservlet</servlet-name>
|
|
||||||
<url-pattern>/txt/*</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>plantumlservlet</servlet-name>
|
|
||||||
<url-pattern>/start/*</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>plantumlservlet</servlet-name>
|
|
||||||
<url-pattern>/proxy/*</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
<welcome-file-list>
|
|
||||||
<welcome-file>welcome</welcome-file>
|
|
||||||
</welcome-file-list>
|
|
||||||
<error-page>
|
|
||||||
<exception-type>java.lang.Throwable</exception-type>
|
|
||||||
<location>/error.jsp</location>
|
|
||||||
</error-page>
|
|
||||||
<error-page>
|
|
||||||
<error-code>500</error-code>
|
|
||||||
<location>/error.jsp</location>
|
|
||||||
</error-page>
|
|
||||||
</web-app>
|
|
90
pom.xml
Normal file
90
pom.xml
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.sourceforge.plantuml</groupId>
|
||||||
|
<artifactId>plantumlservlet</artifactId>
|
||||||
|
<version>1-SNAPSHOT</version>
|
||||||
|
<name>PlantUML Servlet</name>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
<build>
|
||||||
|
<finalName>plantuml</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-eclipse-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<wtpversion>1.5</wtpversion>
|
||||||
|
<wtpContextName>plantuml</wtpContextName>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.6</source>
|
||||||
|
<target>1.6</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<scanIntervalSeconds>5</scanIntervalSeconds>
|
||||||
|
<webApp>
|
||||||
|
<contextPath>/plantuml</contextPath>
|
||||||
|
</webApp>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<properties>
|
||||||
|
<jetty.version>8.0.4.v20111024</jetty.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sourceforge.plantuml</groupId>
|
||||||
|
<artifactId>plantuml</artifactId>
|
||||||
|
<version>7481</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>HTTPClient</groupId>
|
||||||
|
<artifactId>HTTPClient</artifactId>
|
||||||
|
<version>0.3-3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>3.8.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>httpunit</groupId>
|
||||||
|
<artifactId>httpunit</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>rhino</groupId>
|
||||||
|
<artifactId>js</artifactId>
|
||||||
|
<version>1.7R2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty.aggregate</groupId>
|
||||||
|
<artifactId>jetty-all</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
<artifactId>jsp-2.1-glassfish</artifactId>
|
||||||
|
<version>2.1.v20100127</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -53,6 +53,7 @@ import HTTPClient.ParseException;
|
|||||||
* See http://www.banapple.de/display/BANAPPLE/plantuml+user+macro
|
* See http://www.banapple.de/display/BANAPPLE/plantuml+user+macro
|
||||||
*
|
*
|
||||||
* Modified by Arnaud Roques
|
* Modified by Arnaud Roques
|
||||||
|
* Modified by Pablo Lalloni
|
||||||
* Packaged by Maxime Sinclair
|
* Packaged by Maxime Sinclair
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -60,10 +61,10 @@ import HTTPClient.ParseException;
|
|||||||
public class PlantUmlServlet extends HttpServlet {
|
public class PlantUmlServlet extends HttpServlet {
|
||||||
|
|
||||||
private static final Pattern startumlPattern = Pattern.compile("/\\w+/start/(.*)");
|
private static final Pattern startumlPattern = Pattern.compile("/\\w+/start/(.*)");
|
||||||
private static final Pattern proxyPattern = Pattern.compile("/\\w+/proxy/((\\d+)/)?(http://.*)");
|
private static final Pattern proxyPattern = Pattern.compile("/\\w+/proxy/((\\d+)/)?((\\w+)/)?(http://.*)");
|
||||||
private static final Pattern oldStartumlPattern = Pattern.compile("/\\w+/uml/startuml/(.*)");
|
private static final Pattern oldStartumlPattern = Pattern.compile("/\\w+/uml/startuml/(.*)");
|
||||||
private static final Pattern oldImagePattern = Pattern.compile("/\\w+/uml/image/(.*)");
|
private static final Pattern oldImagePattern = Pattern.compile("/\\w+/uml/image/(.*)");
|
||||||
private static final Pattern oldProxyPattern = Pattern.compile("/\\w+/uml/proxy/((\\d+)/)?(http://.*)");
|
private static final Pattern oldProxyPattern = Pattern.compile("/\\w+/uml/proxy/((\\d+)/)?((\\w+)/)?(http://.*)");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
@ -80,8 +81,9 @@ public class PlantUmlServlet extends HttpServlet {
|
|||||||
handleImage(response, source, uri);
|
handleImage(response, source, uri);
|
||||||
} else if (proxyMatcher.matches()) {
|
} else if (proxyMatcher.matches()) {
|
||||||
String num = proxyMatcher.group(2);
|
String num = proxyMatcher.group(2);
|
||||||
String source = proxyMatcher.group(3);
|
String format = proxyMatcher.group(4);
|
||||||
handleImageProxy(response, num, source, uri);
|
String source = proxyMatcher.group(5);
|
||||||
|
handleImageProxy(response, num, source, format, uri);
|
||||||
} else if (oldStartumlMatcher.matches()) {
|
} else if (oldStartumlMatcher.matches()) {
|
||||||
String source = oldStartumlMatcher.group(1);
|
String source = oldStartumlMatcher.group(1);
|
||||||
handleImage(response, source, uri);
|
handleImage(response, source, uri);
|
||||||
@ -90,8 +92,9 @@ public class PlantUmlServlet extends HttpServlet {
|
|||||||
handleImageDecompress(response, source, uri);
|
handleImageDecompress(response, source, uri);
|
||||||
} else if (oldProxyMatcher.matches()) {
|
} else if (oldProxyMatcher.matches()) {
|
||||||
String num = oldProxyMatcher.group(2);
|
String num = oldProxyMatcher.group(2);
|
||||||
String source = oldProxyMatcher.group(3);
|
String format = oldProxyMatcher.group(4);
|
||||||
handleImageProxy(response, num, source, uri);
|
String source = oldProxyMatcher.group(5);
|
||||||
|
handleImageProxy(response, num, source, format, uri);
|
||||||
} else {
|
} else {
|
||||||
doPost(request, response);
|
doPost(request, response);
|
||||||
}
|
}
|
||||||
@ -109,7 +112,7 @@ public class PlantUmlServlet extends HttpServlet {
|
|||||||
|
|
||||||
Transcoder transcoder = getTranscoder();
|
Transcoder transcoder = getTranscoder();
|
||||||
// the URL form has been submitted
|
// the URL form has been submitted
|
||||||
if ((url != null) && (!url.trim().isEmpty())) {
|
if (url != null && !url.trim().isEmpty()) {
|
||||||
// TODO Verify the url is correct
|
// TODO Verify the url is correct
|
||||||
Pattern p = Pattern.compile(".*/(.*)");
|
Pattern p = Pattern.compile(".*/(.*)");
|
||||||
Matcher m = p.matcher(url);
|
Matcher m = p.matcher(url);
|
||||||
@ -119,7 +122,7 @@ public class PlantUmlServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// the Text form has been submitted
|
// the Text form has been submitted
|
||||||
if ((text != null) && (!text.trim().isEmpty())) {
|
if (text != null && !text.trim().isEmpty()) {
|
||||||
encoded = transcoder.encode(text);
|
encoded = transcoder.encode(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,12 +161,16 @@ public class PlantUmlServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleImageProxy(HttpServletResponse response, String num,
|
private void handleImageProxy(HttpServletResponse response, String num,
|
||||||
String source, String uri) throws IOException {
|
String source, String format, String uri) throws IOException {
|
||||||
SourceStringReader reader = new SourceStringReader( getContent(source));
|
SourceStringReader reader = new SourceStringReader( getContent(source));
|
||||||
int n = num == null ? 0 : Integer.parseInt(num);
|
int n = num == null ? 0 : Integer.parseInt(num);
|
||||||
// Write the first image to "os"
|
// Write the requested image to "os"
|
||||||
|
if (format != null) {
|
||||||
|
reader.generateImage(response.getOutputStream(), n, new FileFormatOption(FileFormat.valueOf(format)));
|
||||||
|
} else {
|
||||||
reader.generateImage(response.getOutputStream(), n);
|
reader.generateImage(response.getOutputStream(), n);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void sendImage(HttpServletResponse response, String text, String uri)
|
private void sendImage(HttpServletResponse response, String text, String uri)
|
||||||
throws IOException {
|
throws IOException {
|
74
src/main/webapp/WEB-INF/web.xml
Normal file
74
src/main/webapp/WEB-INF/web.xml
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
|
||||||
|
<display-name>plantuml</display-name>
|
||||||
|
<context-param>
|
||||||
|
<param-name>org.eclipse.jetty.servlet.Default.welcomeServlets</param-name>
|
||||||
|
<param-value>exact</param-value>
|
||||||
|
</context-param>
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>plantumlservlet</servlet-name>
|
||||||
|
<servlet-class>net.sourceforge.plantuml.servlet.PlantUmlServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>welcome</servlet-name>
|
||||||
|
<servlet-class>net.sourceforge.plantuml.servlet.Welcome</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>imgservlet</servlet-name>
|
||||||
|
<servlet-class>net.sourceforge.plantuml.servlet.ImgServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>svgservlet</servlet-name>
|
||||||
|
<servlet-class>net.sourceforge.plantuml.servlet.SvgServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>asciiservlet</servlet-name>
|
||||||
|
<servlet-class>net.sourceforge.plantuml.servlet.AsciiServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<!-- Patterns of the servlet -->
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>welcome</servlet-name>
|
||||||
|
<url-pattern>/welcome</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>plantumlservlet</servlet-name>
|
||||||
|
<url-pattern>/uml/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>plantumlservlet</servlet-name>
|
||||||
|
<url-pattern>/form</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>imgservlet</servlet-name>
|
||||||
|
<url-pattern>/img/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>svgservlet</servlet-name>
|
||||||
|
<url-pattern>/svg/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>asciiservlet</servlet-name>
|
||||||
|
<url-pattern>/txt/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>plantumlservlet</servlet-name>
|
||||||
|
<url-pattern>/start/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>plantumlservlet</servlet-name>
|
||||||
|
<url-pattern>/proxy/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<error-page>
|
||||||
|
<exception-type>java.lang.Throwable</exception-type>
|
||||||
|
<location>/error.jsp</location>
|
||||||
|
</error-page>
|
||||||
|
<error-page>
|
||||||
|
<error-code>500</error-code>
|
||||||
|
<location>/error.jsp</location>
|
||||||
|
</error-page>
|
||||||
|
<welcome-file-list>
|
||||||
|
<welcome-file>welcome</welcome-file>
|
||||||
|
</welcome-file-list>
|
||||||
|
</web-app>
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,38 @@
|
|||||||
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.server.Connector;
|
||||||
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
|
||||||
|
public class ServerUtils {
|
||||||
|
|
||||||
|
Server server;
|
||||||
|
|
||||||
|
public ServerUtils(boolean start) throws Exception {
|
||||||
|
server = new Server(new InetSocketAddress("127.0.0.1", 0));
|
||||||
|
server.addBean(new WebAppContext(server, "src/main/webapp", "/plantuml"));
|
||||||
|
if (start) {
|
||||||
|
startServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerUtils() throws Exception {
|
||||||
|
this(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startServer() throws Exception {
|
||||||
|
server.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopServer() throws Exception {
|
||||||
|
server.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerUrl() {
|
||||||
|
Connector connector = server.getConnectors()[0];
|
||||||
|
return String.format("http://%s:%d/plantuml/", connector.getHost(), connector.getLocalPort());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
public class TestAsciiArt extends WebappTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies the generation of the ascii art for the Bob -> Alice sample
|
||||||
|
*/
|
||||||
|
public void testSimpleSequenceDiagram() throws Exception {
|
||||||
|
WebConversation conversation = new WebConversation();
|
||||||
|
WebRequest request = new GetMethodWebRequest(getServerUrl() + "txt/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000");
|
||||||
|
WebResponse response = conversation.getResource(request);
|
||||||
|
// Analyze response
|
||||||
|
// Verifies the Content-Type header
|
||||||
|
assertEquals("Response content type is not TEXT PLAIN", "text/plain", response.getContentType());
|
||||||
|
// Get the content and verify its size
|
||||||
|
String diagram = response.getText();
|
||||||
|
int diagramLen = diagram.length();
|
||||||
|
assertTrue(diagramLen > 200);
|
||||||
|
assertTrue(diagramLen < 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,12 @@
|
|||||||
package net.sourceforge.plantuml.servlet;
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import com.meterware.httpunit.GetMethodWebRequest;
|
||||||
import com.meterware.httpunit.*;
|
import com.meterware.httpunit.WebConversation;
|
||||||
|
import com.meterware.httpunit.WebForm;
|
||||||
|
import com.meterware.httpunit.WebRequest;
|
||||||
|
import com.meterware.httpunit.WebResponse;
|
||||||
|
|
||||||
public class TestForm extends TestCase {
|
public class TestForm extends WebappTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that the welcome page has exactly two form
|
* Verifies that the welcome page has exactly two form
|
||||||
@ -11,7 +14,7 @@ public class TestForm extends TestCase {
|
|||||||
*/
|
*/
|
||||||
public void testWelcomePage() throws Exception {
|
public void testWelcomePage() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl());
|
WebRequest request = new GetMethodWebRequest(getServerUrl());
|
||||||
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
||||||
// Analyze response
|
// Analyze response
|
||||||
WebForm forms[] = response.getForms();
|
WebForm forms[] = response.getForms();
|
||||||
@ -29,7 +32,7 @@ public class TestForm extends TestCase {
|
|||||||
public void testVersion() throws Exception {
|
public void testVersion() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
// Fill the form and submit it
|
// Fill the form and submit it
|
||||||
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl());
|
WebRequest request = new GetMethodWebRequest(getServerUrl());
|
||||||
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
||||||
WebForm formUMLText = response.getForms()[0];
|
WebForm formUMLText = response.getForms()[0];
|
||||||
formUMLText.setParameter("text", "version");
|
formUMLText.setParameter("text", "version");
|
||||||
@ -51,7 +54,7 @@ public class TestForm extends TestCase {
|
|||||||
public void testEmptyText() throws Exception {
|
public void testEmptyText() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
// Fill the form and submit it
|
// Fill the form and submit it
|
||||||
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl());
|
WebRequest request = new GetMethodWebRequest(getServerUrl());
|
||||||
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
||||||
WebForm formUMLText = response.getForms()[0];
|
WebForm formUMLText = response.getForms()[0];
|
||||||
formUMLText.setParameter("text", "");
|
formUMLText.setParameter("text", "");
|
||||||
@ -73,7 +76,7 @@ public class TestForm extends TestCase {
|
|||||||
public void testEmptyUrl() throws Exception {
|
public void testEmptyUrl() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
// Fill the form and submit it
|
// Fill the form and submit it
|
||||||
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl() );
|
WebRequest request = new GetMethodWebRequest(getServerUrl());
|
||||||
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
||||||
WebForm formUrl = response.getForms()[1];
|
WebForm formUrl = response.getForms()[1];
|
||||||
formUrl.setParameter("url", "");
|
formUrl.setParameter("url", "");
|
||||||
@ -95,7 +98,7 @@ public class TestForm extends TestCase {
|
|||||||
public void testDitaaText() throws Exception {
|
public void testDitaaText() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
// Fill the form and submit it
|
// Fill the form and submit it
|
||||||
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl() );
|
WebRequest request = new GetMethodWebRequest(getServerUrl());
|
||||||
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
WebResponse response = TestUtils.tryGetResponse(conversation, request );
|
||||||
WebForm formDitaaText = response.getForms()[0];
|
WebForm formDitaaText = response.getForms()[0];
|
||||||
formDitaaText.setParameter("text", "@startditaa \n*--> \n@endditaa");
|
formDitaaText.setParameter("text", "@startditaa \n*--> \n@endditaa");
|
@ -1,21 +1,23 @@
|
|||||||
package net.sourceforge.plantuml.servlet;
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import com.meterware.httpunit.*;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
|
|
||||||
public class TestImage extends TestCase {
|
import com.meterware.httpunit.GetMethodWebRequest;
|
||||||
|
import com.meterware.httpunit.WebConversation;
|
||||||
|
import com.meterware.httpunit.WebRequest;
|
||||||
|
import com.meterware.httpunit.WebResponse;
|
||||||
|
|
||||||
|
public class TestImage extends WebappTestCase {
|
||||||
/**
|
/**
|
||||||
* Verifies the generation of the version image from an encoded URL
|
* Verifies the generation of the version image from an encoded URL
|
||||||
*/
|
*/
|
||||||
public void testVersionImage() throws Exception {
|
public void testVersionImage() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl()+"img/AqijAixCpmC0");
|
WebRequest request = new GetMethodWebRequest(getServerUrl() + "img/AqijAixCpmC0");
|
||||||
WebResponse response = conversation.getResource( request);
|
WebResponse response = conversation.getResource( request);
|
||||||
// Analyze response
|
// Analyze response
|
||||||
// Verifies the Content-Type header
|
// Verifies the Content-Type header
|
||||||
@ -42,7 +44,7 @@ public class TestImage extends TestCase {
|
|||||||
public void testDiagramHttpHeader() throws Exception {
|
public void testDiagramHttpHeader() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
// Bob -> Alice : hello
|
// Bob -> Alice : hello
|
||||||
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl()+"img/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000");
|
WebRequest request = new GetMethodWebRequest(getServerUrl() + "img/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000");
|
||||||
WebResponse response = conversation.getResource( request);
|
WebResponse response = conversation.getResource( request);
|
||||||
// Analyze response
|
// Analyze response
|
||||||
// Verifies the Content-Type header
|
// Verifies the Content-Type header
|
@ -1,24 +1,27 @@
|
|||||||
package net.sourceforge.plantuml.servlet;
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import com.meterware.httpunit.*;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
public class TestProxy extends TestCase {
|
import com.meterware.httpunit.GetMethodWebRequest;
|
||||||
|
import com.meterware.httpunit.WebConversation;
|
||||||
|
import com.meterware.httpunit.WebForm;
|
||||||
|
import com.meterware.httpunit.WebRequest;
|
||||||
|
import com.meterware.httpunit.WebResponse;
|
||||||
|
|
||||||
|
public class TestProxy extends WebappTestCase {
|
||||||
/**
|
/**
|
||||||
* Verifies the proxified reception of the default Bob and Alice diagram
|
* Verifies the proxified reception of the default Bob and Alice diagram
|
||||||
*/
|
*/
|
||||||
public void testDefaultProxy() throws Exception {
|
public void testDefaultProxy() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl()+"proxy/"
|
WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/"
|
||||||
+TestUtils.getServerUrl()+"welcome");
|
+ getServerUrl() + "welcome");
|
||||||
WebResponse response = conversation.getResource( request);
|
WebResponse response = conversation.getResource( request);
|
||||||
// Analyze response
|
// Analyze response
|
||||||
// Verifies the Content-Type header
|
// 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 (~1533 bytes)
|
// Get the image and verify its size (~1600 bytes)
|
||||||
InputStream responseStream = response.getInputStream();
|
InputStream responseStream = response.getInputStream();
|
||||||
ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
|
||||||
byte[] buf = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
@ -31,7 +34,7 @@ public class TestProxy extends TestCase {
|
|||||||
byte[] inMemoryImage = imageStream.toByteArray();
|
byte[] inMemoryImage = imageStream.toByteArray();
|
||||||
int diagramLen = inMemoryImage.length;
|
int diagramLen = inMemoryImage.length;
|
||||||
assertTrue( diagramLen > 1500);
|
assertTrue( diagramLen > 1500);
|
||||||
assertTrue( diagramLen < 1600);
|
assertTrue( diagramLen < 1700);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +43,7 @@ public class TestProxy extends TestCase {
|
|||||||
public void testInvalidUrl() throws Exception {
|
public void testInvalidUrl() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
// Try to proxify an invalid address
|
// Try to proxify an invalid address
|
||||||
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl()+"proxy/invalidURL");
|
WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/invalidURL");
|
||||||
WebResponse response = conversation.getResource( request);
|
WebResponse response = conversation.getResource( request);
|
||||||
// Analyze response, it must be the empty form
|
// Analyze response, it must be the empty form
|
||||||
// Verifies the Content-Type header
|
// Verifies the Content-Type header
|
@ -1,19 +1,17 @@
|
|||||||
package net.sourceforge.plantuml.servlet;
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import com.meterware.httpunit.GetMethodWebRequest;
|
||||||
import com.meterware.httpunit.*;
|
import com.meterware.httpunit.WebConversation;
|
||||||
|
import com.meterware.httpunit.WebRequest;
|
||||||
|
import com.meterware.httpunit.WebResponse;
|
||||||
|
|
||||||
import java.util.Date;
|
public class TestSVG extends WebappTestCase {
|
||||||
import java.util.Locale;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
|
|
||||||
public class TestSVG extends TestCase {
|
|
||||||
/**
|
/**
|
||||||
* Verifies the generation of the SVG for the Bob -> Alice sample
|
* Verifies the generation of the SVG for the Bob -> Alice sample
|
||||||
*/
|
*/
|
||||||
public void testSimpleSequenceDiagram() throws Exception {
|
public void testSimpleSequenceDiagram() throws Exception {
|
||||||
WebConversation conversation = new WebConversation();
|
WebConversation conversation = new WebConversation();
|
||||||
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl()+"svg/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000");
|
WebRequest request = new GetMethodWebRequest(getServerUrl() + "svg/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000");
|
||||||
WebResponse response = conversation.getResource( request);
|
WebResponse response = conversation.getResource( request);
|
||||||
// Analyze response
|
// Analyze response
|
||||||
// Verifies the Content-Type header
|
// Verifies the Content-Type header
|
@ -0,0 +1,31 @@
|
|||||||
|
package net.sourceforge.plantuml.servlet;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public abstract class WebappTestCase extends TestCase {
|
||||||
|
|
||||||
|
private ServerUtils serverUtils;
|
||||||
|
|
||||||
|
public WebappTestCase() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WebappTestCase(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
serverUtils = new ServerUtils(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
serverUtils.stopServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getServerUrl() {
|
||||||
|
return serverUtils.getServerUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,28 +0,0 @@
|
|||||||
package net.sourceforge.plantuml.servlet;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import com.meterware.httpunit.*;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
|
|
||||||
public class TestAsciiArt extends TestCase {
|
|
||||||
/**
|
|
||||||
* Verifies the generation of the ascii art for the Bob -> Alice sample
|
|
||||||
*/
|
|
||||||
public void testSimpleSequenceDiagram() throws Exception {
|
|
||||||
WebConversation conversation = new WebConversation();
|
|
||||||
WebRequest request = new GetMethodWebRequest( TestUtils.getServerUrl()+"txt/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000");
|
|
||||||
WebResponse response = conversation.getResource( request);
|
|
||||||
// Analyze response
|
|
||||||
// Verifies the Content-Type header
|
|
||||||
assertEquals( "Response content type is not TEXT PLAIN", "text/plain", response.getContentType());
|
|
||||||
// Get the content and verify its size
|
|
||||||
String diagram = response.getText();
|
|
||||||
int diagramLen = diagram.length();
|
|
||||||
assertTrue( diagramLen > 200);
|
|
||||||
assertTrue( diagramLen < 250);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user