fixed issue apiman-1227 related to a trailing / being left out in the gateway
MODIFY
common/util/src/main/java/io/apiman/common/util/ApimanPathUtils.java
common/util/src/main/java/io/apiman/common/util/ApimanPathUtils.java
@@ -69,6 +69,8 @@ public class ApimanPathUtils {
resource.append('/');
}
info.resource = resource.toString();
+ } else if (pathInfo.endsWith("/")) {
+ info.resource = "/";
}
}
}

ADD
common/util/src/test/java/io/apiman/common/util/ApimanPathUtilsTest.java
+/*
+ * Copyright 2016 JBoss Inc
+ *
+ * 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 io.apiman.common.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import io.apiman.common.util.ApimanPathUtils.ApiRequestPathInfo;
+
+public class ApimanPathUtilsTest {
+
+ @Test
+ public void testParseApiRequestPath() {
+ ApiRequestPathInfo path = ApimanPathUtils.parseApiRequestPath(null, "application/json", "/OrgId/ApiId/VER/path/to/thing");
+ Assert.assertEquals("OrgId", path.orgId);
+ Assert.assertEquals("ApiId", path.apiId);
+ Assert.assertEquals("VER", path.apiVersion);
+ Assert.assertEquals("/path/to/thing", path.resource);
+
+ path = ApimanPathUtils.parseApiRequestPath(null, "application/json", "/OrgId/ApiId/VER");
+ Assert.assertEquals("OrgId", path.orgId);
+ Assert.assertEquals("ApiId", path.apiId);
+ Assert.assertEquals("VER", path.apiVersion);
+ Assert.assertEquals(null, path.resource);
+
+ path = ApimanPathUtils.parseApiRequestPath(null, "application/json", "/OrgId/ApiId/VER/");
+ Assert.assertEquals("OrgId", path.orgId);
+ Assert.assertEquals("ApiId", path.apiId);
+ Assert.assertEquals("VER", path.apiVersion);
+ Assert.assertEquals("/", path.resource);
+
+ path = ApimanPathUtils.parseApiRequestPath("VER", "application/json", "/OrgId/ApiId/path/to/thing");
+ Assert.assertEquals("OrgId", path.orgId);
+ Assert.assertEquals("ApiId", path.apiId);
+ Assert.assertEquals("VER", path.apiVersion);
+ Assert.assertEquals("/path/to/thing", path.resource);
+
+ path = ApimanPathUtils.parseApiRequestPath("VER", "application/json", "/OrgId/ApiId");
+ Assert.assertEquals("OrgId", path.orgId);
+ Assert.assertEquals("ApiId", path.apiId);
+ Assert.assertEquals("VER", path.apiVersion);
+ Assert.assertEquals(null, path.resource);
+
+ }
+
+}

ADD
gateway/test/src/test/java/io/apiman/gateway/test/SimpleEcho1227Test.java
+/*
+ * Copyright 2014 JBoss Inc
+ *
+ * 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 io.apiman.gateway.test;
+
+import io.apiman.gateway.test.junit.GatewayRestTestPlan;
+import io.apiman.gateway.test.junit.GatewayRestTester;
+
+import org.junit.runner.RunWith;
+
+/**
+ * Make sure the gateway and test echo server are working.
+ *
+ * @author eric.wittmann@redhat.com
+ */
+@RunWith(GatewayRestTester.class)
+@GatewayRestTestPlan("test-plans/simple/simple-echo-1227-testPlan.xml")
+public class SimpleEcho1227Test {
+
+}

ADD
gateway/test/src/test/resources/test-plan-data/simple/simple-echo-1227/001-publish-api.resttest
+PUT /apis admin/admin
+Content-Type: application/json
+
+{
+ "organizationId" : "SimpleEcho1227Test",
+ "apiId" : "echo",
+ "version" : "1.0",
+ "publicAPI" : true,
+ "endpointType" : "REST",
+ "endpoint" : "${apiman-gateway-test.endpoints.echo}/endpoint/with-trailing-slash/",
+ "apiPolicies" : [ ]
+}
+----
+204

ADD
gateway/test/src/test/resources/test-plan-data/simple/simple-echo-1227/002-echo.resttest
+GET /SimpleEcho1227Test/echo/1.0/ admin/admin
+Accept: application/json
+
+----
+200
+Content-Type: application/json
+
+{
+ "method" : "GET",
+ "resource" : "/endpoint/with-trailing-slash/",
+ "uri" : "/endpoint/with-trailing-slash/",
+ "headers" : {
+ }
+}

ADD
gateway/test/src/test/resources/test-plan-data/simple/simple-echo-1227/003-echo-2.resttest
+GET /SimpleEcho1227Test/echo/1.0 admin/admin
+Accept: application/json
+
+----
+200
+Content-Type: application/json
+
+{
+ "method" : "GET",
+ "resource" : "/endpoint/with-trailing-slash",
+ "uri" : "/endpoint/with-trailing-slash",
+ "headers" : {
+ }
+}

ADD
gateway/test/src/test/resources/test-plan-data/simple/simple-echo-1227/004-echo-3.resttest
+GET /SimpleEcho1227Test/echo/1.0/some/resource admin/admin
+Accept: application/json
+
+----
+200
+Content-Type: application/json
+
+{
+ "method" : "GET",
+ "resource" : "/endpoint/with-trailing-slash/some/resource",
+ "uri" : "/endpoint/with-trailing-slash/some/resource",
+ "headers" : {
+ }
+}

ADD
gateway/test/src/test/resources/test-plan-data/simple/simple-echo-1227/005-echo-4.resttest
+GET /SimpleEcho1227Test/echo/1.0/some/resource/ admin/admin
+Accept: application/json
+
+----
+200
+Content-Type: application/json
+
+{
+ "method" : "GET",
+ "resource" : "/endpoint/with-trailing-slash/some/resource/",
+ "uri" : "/endpoint/with-trailing-slash/some/resource/",
+ "headers" : {
+ }
+}

ADD
gateway/test/src/test/resources/test-plans/simple/simple-echo-1227-testPlan.xml
+<?xml version="1.0" encoding="UTF-8"?>
+<testPlan xmlns="urn:io.apiman.test:2014:02:testPlan">
+
+ <!-- Reproducer for APIMAN-1227 -->
+
+ <testGroup name="setup" endpoint="api">
+ <test name="Publish Api">test-plan-data/simple/simple-echo-1227/001-publish-api.resttest</test>
+ </testGroup>
+
+ <testGroup name="test">
+ <test name="Echo 1">test-plan-data/simple/simple-echo-1227/002-echo.resttest</test>
+ <test name="Echo 2">test-plan-data/simple/simple-echo-1227/003-echo-2.resttest</test>
+ <test name="Echo 3">test-plan-data/simple/simple-echo-1227/004-echo-3.resttest</test>
+ <test name="Echo 4">test-plan-data/simple/simple-echo-1227/005-echo-4.resttest</test>
+ </testGroup>
+</testPlan>

fixed issue apiman-1227 related to a trailing / being left out in the gateway