update all dependencies (maven artifacts)

- PDF dependency was missing in the pom file the JDK8
  * We should think about creating a parent pom - in that case all plantuml dependencies could be in the parent pom and we would only the mantain one pom file.
    (It is also possible to drop the Java 8 support.)
  * Why do we not have any PDF tests?
- add rule to ignore version update hint with `-dev` followed by a dot and date (e.g. `0.37.0-dev.20230308`)
- migration from JUnit4 to JUnit5
This commit is contained in:
Florian
2023-05-05 17:50:02 +02:00
committed by PlantUML
parent e6566b58bd
commit e5d11fb89a
20 changed files with 435 additions and 359 deletions

View File

@@ -4,6 +4,9 @@ import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import net.sourceforge.plantuml.servlet.utils.WebappTestCase;
@@ -12,59 +15,61 @@ public class TestOldProxy extends WebappTestCase {
/**
* Verifies the proxified reception of the default Bob and Alice diagram
*/
@Test
public void testDefaultProxy() throws IOException {
final URL url = new URL(getServerUrl() + "/proxy/" + getTestDiagramUrl());
final HttpURLConnection conn = (HttpURLConnection)url.openConnection();
// Analyze response
// Verifies HTTP status code and the Content-Type
assertEquals("Bad HTTP status received", 200, conn.getResponseCode());
assertEquals(
"Response content type is not PNG",
Assertions.assertEquals(200, conn.getResponseCode(), "Bad HTTP status received");
Assertions.assertEquals(
"image/png",
conn.getContentType().toLowerCase()
conn.getContentType().toLowerCase(),
"Response content type is not PNG"
);
// Get the image and verify its size (~2000 bytes)
byte[] inMemoryImage = getContentAsBytes(conn);
int diagramLen = inMemoryImage.length;
assertTrue(diagramLen > 2000);
assertTrue(diagramLen < 3000);
Assertions.assertTrue(diagramLen > 2000);
Assertions.assertTrue(diagramLen < 3000);
}
/**
* Verifies the proxified reception of the default Bob and Alice diagram in a specific format (SVG)
*/
@Test
public void testProxyWithFormat() throws IOException {
final URL url = new URL(getServerUrl() + "/proxy/svg/" + getTestDiagramUrl());
final HttpURLConnection conn = (HttpURLConnection)url.openConnection();
// Analyze response
// Verifies HTTP status code and the Content-Type
assertEquals("Bad HTTP status received", 200, conn.getResponseCode());
assertEquals(
"Response content type is not SVG",
Assertions.assertEquals(200, conn.getResponseCode(), "Bad HTTP status received");
Assertions.assertEquals(
"image/svg+xml",
conn.getContentType().toLowerCase()
conn.getContentType().toLowerCase(),
"Response content type is not SVG"
);
// Get the content and verify its size
String diagram = getContentText(conn);
int diagramLen = diagram.length();
assertTrue(diagramLen > 1000);
assertTrue(diagramLen < 3000);
Assertions.assertTrue(diagramLen > 1000);
Assertions.assertTrue(diagramLen < 3000);
}
/**
* Verifies that the HTTP header of a diagram incites the browser to cache it.
*/
@Test
public void testInvalidUrl() throws IOException {
final URL url = new URL(getServerUrl() + "/proxy/invalidURL");
final HttpURLConnection conn = (HttpURLConnection)url.openConnection();
// Analyze response
// Check if status code is 400
assertEquals(
"Bad HTTP status received",
400,
conn.getResponseCode()
);
Assertions.assertEquals(400, conn.getResponseCode(), "Bad HTTP status received");
// Check error message
assertTrue(
"Response is not malformed URL",
getContentText(conn.getErrorStream()).contains("URL malformed.")
Assertions.assertTrue(
getContentText(conn.getErrorStream()).contains("URL malformed."),
"Response is not malformed URL"
);
}