Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
hanahmily committed Feb 28, 2018
1 parent d5ce8fd commit 19c58e0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ before_install:

install:
- jdk_switcher use oraclejdk8
- mvn clean install --quiet jacoco:report coveralls:report -X
- mvn clean install --quiet jacoco:report coveralls:report
- mvn clean javadoc:javadoc -Dmaven.test.skip=true --quiet

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.skywalking.apm.webapp.tools;

import com.netflix.zuul.context.RequestContext;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.PRE_DECORATION_FILTER_ORDER;

public class RewritePathFilterTest {

private RewritePathFilter filter;

@Before
public void init() {
filter = new RewritePathFilter("/graphql");
}

@Test
public void filterOrder() {
assertThat(filter.filterOrder(), is(PRE_DECORATION_FILTER_ORDER + 1));
}

@Test
public void filterType() {
assertThat(filter.filterType(), is("pre"));
}

@Test
public void shouldFilter() {
assertFalse(filter.shouldFilter());
RequestContext.getCurrentContext().set("requestURI");
assertTrue(filter.shouldFilter());
}

@Test
public void run() {
filter.run();
assertThat(RequestContext.getCurrentContext().get("requestURI"), is("/graphql"));
}
}

0 comments on commit 19c58e0

Please sign in to comment.