Skip to content

Commit

Permalink
#907 ControllerFilters are only applied once during an AppIntegration…
Browse files Browse the repository at this point in the history
…Spec run

(cherry picked from commit c430d45)
  • Loading branch information
ipolevoy committed Sep 30, 2019
1 parent 76330d9 commit 0616ab2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions activeweb-testing/src/test/java/app/filters/HelloFilter.java
@@ -0,0 +1,12 @@
package app.filters;

import org.javalite.activeweb.controller_filters.ControllerFilterAdapter;
import org.javalite.activeweb.controller_filters.HttpSupportFilter;

public class HelloFilter extends HttpSupportFilter{

@Override
public void before() {
respond("hello");
}
}
Expand Up @@ -2,9 +2,12 @@

import app.controllers.AbcPersonController;
import app.controllers.XyzController;
import app.filters.HelloFilter;
import org.javalite.activeweb.controller_filters.HeadersLogFilter;
import org.junit.Test;

import java.util.List;

/**
* @author igor on 7/1/17.
*/
Expand All @@ -31,4 +34,12 @@ public void shouldResetGlobalFilter(){
//should match any random controller, since this is a global filter.
the(fm.matches(new Route(new XyzController(), "", HttpMethod.GET))).shouldBeTrue();
}

@Test
public void shouldInvokeFilter(){
resetFilters();
addFilter(new HelloFilter());
controller("format").get("index"); // any controller will do, since filter will respond first
the(responseContent()).shouldEqual("hello");
}
}

0 comments on commit 0616ab2

Please sign in to comment.