You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by bc...@apache.org on 2023/06/18 09:04:55 UTC

[incubator-baremaps] branch server-refactoring updated: Add test case for ClassPathResource

This is an automated email from the ASF dual-hosted git repository.

bchapuis pushed a commit to branch server-refactoring
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git


The following commit(s) were added to refs/heads/server-refactoring by this push:
     new fd231b75 Add test case for ClassPathResource
fd231b75 is described below

commit fd231b754adf3aa860a5e9b30a95dff94b399fc2
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Sun Jun 18 11:04:47 2023 +0200

    Add test case for ClassPathResource
---
 .../server/ClassPathResourceIntegrationTest.java   | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/baremaps-server/src/test/java/org/apache/baremaps/server/ClassPathResourceIntegrationTest.java b/baremaps-server/src/test/java/org/apache/baremaps/server/ClassPathResourceIntegrationTest.java
new file mode 100644
index 00000000..fa0b00b4
--- /dev/null
+++ b/baremaps-server/src/test/java/org/apache/baremaps/server/ClassPathResourceIntegrationTest.java
@@ -0,0 +1,34 @@
+package org.apache.baremaps.server;
+
+import org.glassfish.jersey.internal.inject.AbstractBinder;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.TestProperties;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class ClassPathResourceIntegrationTest extends JerseyTest {
+
+    @Override
+    protected ResourceConfig configure() {
+        enable(TestProperties.LOG_TRAFFIC);
+        enable(TestProperties.DUMP_ENTITY);
+        return new ResourceConfig()
+                .register(ClassPathResource.class)
+                .register(new AbstractBinder() {
+                    @Override
+                    protected void configure() {
+                        bind("assets").to(String.class).named("directory");
+                        bind("viewer.html").to(String.class).named("index");
+                    }
+                });
+    }
+
+    @Test
+    public void testAssetsDirectory() {
+        assertTrue(target().path("").request().get(String.class).contains("<title>Baremaps</title>"));
+        assertTrue(target().path("viewer.html").request().get(String.class).contains("<title>Baremaps</title>"));
+        assertTrue(target().path("server.html").request().get(String.class).contains("<title>Baremaps</title>"));
+    }
+}
\ No newline at end of file