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 21:39:01 UTC

[incubator-baremaps] branch server-refactoring updated (5b31edb7 -> d5d5b51f)

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

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


    omit 5b31edb7 Add test case for ClassPathResource
     new d5d5b51f Add test case for ClassPathResource

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5b31edb7)
            \
             N -- N -- N   refs/heads/server-refactoring (d5d5b51f)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../main/java/org/apache/baremaps/server/ClassPathResource.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)


[incubator-baremaps] 01/01: Add test case for ClassPathResource

Posted by bc...@apache.org.
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

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

    Add test case for ClassPathResource
---
 .../apache/baremaps/server/ClassPathResource.java  |  7 ++--
 .../server/ClassPathResourceIntegrationTest.java   | 48 ++++++++++++++++++++++
 2 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/baremaps-server/src/main/java/org/apache/baremaps/server/ClassPathResource.java b/baremaps-server/src/main/java/org/apache/baremaps/server/ClassPathResource.java
index daf6408e..b46ba1f7 100644
--- a/baremaps-server/src/main/java/org/apache/baremaps/server/ClassPathResource.java
+++ b/baremaps-server/src/main/java/org/apache/baremaps/server/ClassPathResource.java
@@ -19,13 +19,14 @@ import javax.inject.Named;
 import javax.inject.Singleton;
 import javax.ws.rs.GET;
 import javax.ws.rs.PathParam;
+import javax.ws.rs.Path;
 import javax.ws.rs.core.Response;
 
 /**
  * Serves static resources from the class path.
  */
 @Singleton
-@javax.ws.rs.Path("/")
+@Path("/")
 public class ClassPathResource {
 
   private final String directory;
@@ -53,9 +54,9 @@ public class ClassPathResource {
    * @return the response
    */
   @GET
-  @javax.ws.rs.Path("{path:.*}")
+  @Path("{path:.*}")
   public Response get(@PathParam("path") String path) {
-    if (path.equals("") || path.endsWith("/")) {
+    if (path.isEmpty() || path.endsWith("/")) {
       path += index;
     }
     path = String.format("%s/%s", directory, path);
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..e1abee85
--- /dev/null
+++ b/baremaps-server/src/test/java/org/apache/baremaps/server/ClassPathResourceIntegrationTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.baremaps.server;
+
+import static org.junit.Assert.assertTrue;
+
+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;
+
+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>"));
+  }
+}