From ce08eb02aa35df1553a7c152eec133c53867301f Mon Sep 17 00:00:00 2001 From: Vitaliy Pavlyuk Date: Thu, 4 Oct 2018 21:00:52 -0400 Subject: [PATCH] limited unit tests --- ...sponseHeaderGatewayFilterFactoryTests.java | 2 +- ...seHeaderGatewayFilterFactoryUnitTests.java | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/RewriteResponseHeaderGatewayFilterFactoryUnitTests.java diff --git a/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/RewriteResponseHeaderGatewayFilterFactoryTests.java b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/RewriteResponseHeaderGatewayFilterFactoryTests.java index ad4dde3e..e974a49c 100644 --- a/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/RewriteResponseHeaderGatewayFilterFactoryTests.java +++ b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/RewriteResponseHeaderGatewayFilterFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2017 the original author or authors. + * Copyright 2013-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/RewriteResponseHeaderGatewayFilterFactoryUnitTests.java b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/RewriteResponseHeaderGatewayFilterFactoryUnitTests.java new file mode 100644 index 00000000..7598e62f --- /dev/null +++ b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/filter/factory/RewriteResponseHeaderGatewayFilterFactoryUnitTests.java @@ -0,0 +1,45 @@ +/* + * Copyright 2013-2018 the original author or authors. + * + * 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.springframework.cloud.gateway.filter.factory; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class RewriteResponseHeaderGatewayFilterFactoryUnitTests { + + private RewriteResponseHeaderGatewayFilterFactory filterFactory; + + @Before + public void setUp() { + filterFactory = new RewriteResponseHeaderGatewayFilterFactory(); + } + + @Test + public void testRewriteDollarSlash() { + Assert.assertEquals("/bar/bar/42", filterFactory.rewrite( + "/foo/bar", "/foo/(?.*)", "/$\\{segment}/$\\{segment}/42")); + } + + @Test + public void testRewriteMultiple() { + Assert.assertEquals("/foo/cafe/wat/cafe", filterFactory.rewrite( + "/foo/bar/wat/bar", "bar", "cafe")); + } + +}