mirror of
https://github.com/octoleo/plantuml-server.git
synced 2024-12-22 08:48:54 +00:00
Project fully mavenized with functionality exceeding previous Ant build.xml implemented (except deployment to servlet container, which can be easily added).
Improved unit tests to be independent of externally running servlet container, now every test runs its own embedded jetty server (and stops it afterward). Removed all eclipse artifacts (.project, .classpath, .settings, etc.) and added to .gitignore to be independent of development environment (can be autogenerated by maven, or better yet use m2eclipse). Removed embedded dependency jars since they are handled automatically by maven.
This commit is contained in:
parent
4f80244a2b
commit
89c4d91b41
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
|
|
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.
56
pom.xml
Normal file
56
pom.xml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<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>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
<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.5</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>7.5.4.v20111024</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>
|
@ -24,7 +24,7 @@
|
|||||||
<!-- Patterns of the servlet -->
|
<!-- Patterns of the servlet -->
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>welcome</servlet-name>
|
<servlet-name>welcome</servlet-name>
|
||||||
<url-pattern>/welcome</url-pattern>
|
<url-pattern>/</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>plantumlservlet</servlet-name>
|
<servlet-name>plantumlservlet</servlet-name>
|
||||||
@ -54,9 +54,6 @@
|
|||||||
<servlet-name>plantumlservlet</servlet-name>
|
<servlet-name>plantumlservlet</servlet-name>
|
||||||
<url-pattern>/proxy/*</url-pattern>
|
<url-pattern>/proxy/*</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
<welcome-file-list>
|
|
||||||
<welcome-file>welcome</welcome-file>
|
|
||||||
</welcome-file-list>
|
|
||||||
<error-page>
|
<error-page>
|
||||||
<exception-type>java.lang.Throwable</exception-type>
|
<exception-type>java.lang.Throwable</exception-type>
|
||||||
<location>/error.jsp</location>
|
<location>/error.jsp</location>
|
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,19 +1,22 @@
|
|||||||
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 WebappTestCase {
|
||||||
|
|
||||||
public class TestForm extends TestCase {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that the welcome page has exactly two form
|
* Verifies that the welcome page has exactly two form
|
||||||
* with the Bob --> Alice sample
|
* with the Bob --> Alice sample
|
||||||
*/
|
*/
|
||||||
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();
|
||||||
assertEquals( 2, forms.length );
|
assertEquals( 2, forms.length );
|
||||||
assertEquals( "url", forms[1].getParameterNames()[0] );
|
assertEquals( "url", forms[1].getParameterNames()[0] );
|
||||||
@ -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", "");
|
||||||
@ -66,14 +69,14 @@ public class TestForm extends TestCase {
|
|||||||
// Ensure there is no image
|
// Ensure there is no image
|
||||||
assertEquals( 0, response.getImages().length);
|
assertEquals( 0, response.getImages().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that when the encoded URL is empty, no image is generated
|
* Verifies that when the encoded URL is empty, no image is generated
|
||||||
*/
|
*/
|
||||||
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", "");
|
||||||
@ -88,14 +91,14 @@ public class TestForm extends TestCase {
|
|||||||
// Ensure there is no image
|
// Ensure there is no image
|
||||||
assertEquals( 0, response.getImages().length);
|
assertEquals( 0, response.getImages().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that a ditaa diagram is generated
|
* Verifies that a ditaa diagram is generated
|
||||||
*/
|
*/
|
||||||
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,26 +1,28 @@
|
|||||||
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
|
||||||
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
|
// Get the image and verify its size
|
||||||
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];
|
||||||
@ -33,7 +35,7 @@ public class TestImage extends TestCase {
|
|||||||
byte[] inMemoryImage = imageStream.toByteArray();
|
byte[] inMemoryImage = imageStream.toByteArray();
|
||||||
int diagramLen = inMemoryImage.length;
|
int diagramLen = inMemoryImage.length;
|
||||||
assertTrue( diagramLen > 10000);
|
assertTrue( diagramLen > 10000);
|
||||||
assertTrue( diagramLen < 20000);
|
assertTrue( diagramLen < 20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,8 +43,8 @@ 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,19 +1,22 @@
|
|||||||
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
|
||||||
@ -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 < 1600);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,8 +42,8 @@ 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
|
||||||
@ -22,7 +20,7 @@ public class TestSVG extends TestCase {
|
|||||||
String diagram = response.getText();
|
String diagram = response.getText();
|
||||||
int diagramLen = diagram.length();
|
int diagramLen = diagram.length();
|
||||||
assertTrue( diagramLen > 1700);
|
assertTrue( diagramLen > 1700);
|
||||||
assertTrue( diagramLen < 1800);
|
assertTrue( diagramLen < 1800);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -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