Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

Commit

Permalink
Changes to configure our filters correctly, and numerous other test f…
Browse files Browse the repository at this point in the history
…ixes. Only 7 REST tests are not passing.
  • Loading branch information
snoopdave committed Sep 3, 2015
1 parent 0578d98 commit eb2aa6f
Show file tree
Hide file tree
Showing 51 changed files with 628 additions and 516 deletions.
2 changes: 1 addition & 1 deletion stack/pom.xml
Expand Up @@ -114,7 +114,7 @@
<shiro-version>1.2.4</shiro-version> <shiro-version>1.2.4</shiro-version>
<slf4j-version>1.6.1</slf4j-version> <slf4j-version>1.6.1</slf4j-version>
<snakeyaml-version>1.9</snakeyaml-version> <snakeyaml-version>1.9</snakeyaml-version>
<tomcat-version>7.0.59</tomcat-version> <tomcat-version>7.0.64</tomcat-version>
<antlr.version>3.4</antlr.version> <antlr.version>3.4</antlr.version>
<tika.version>1.4</tika.version> <tika.version>1.4</tika.version>
<mockito.version>1.10.8</mockito.version> <mockito.version>1.10.8</mockito.version>
Expand Down
120 changes: 44 additions & 76 deletions stack/rest/pom.xml
Expand Up @@ -39,26 +39,28 @@
<!-- profile that arquillian uses when it builds/starts tomcat --> <!-- profile that arquillian uses when it builds/starts tomcat -->
<profiles> <profiles>


<!--<profile>--> <!--
<!--<id>arquillian-tomcat</id>--> <profile>
<!--<activation>--> <id>arquillian-tomcat</id>
<!--<activeByDefault>true</activeByDefault>--> <activation>
<!--</activation>--> <activeByDefault>true</activeByDefault>
<!--<dependencies>--> </activation>
<!--<dependency>--> <dependencies>
<!--<groupId>org.jboss.arquillian.container</groupId>--> <dependency>
<!--<artifactId>arquillian-tomcat-remote-7</artifactId>--> <groupId>org.jboss.arquillian.container</groupId>
<!--<version>1.0.0.CR7</version>--> <artifactId>arquillian-tomcat-remote-7</artifactId>
<!--<scope>test</scope>--> <version>1.0.0.CR7</version>
<!--</dependency>--> <scope>test</scope>
<!--<dependency>--> </dependency>
<!--<groupId>org.eu.ingwar.tools</groupId>--> <dependency>
<!--<artifactId>arquillian-suite-extension</artifactId>--> <groupId>org.eu.ingwar.tools</groupId>
<!--<version>1.1.1</version>--> <artifactId>arquillian-suite-extension</artifactId>
<!--<scope>test</scope>--> <version>1.1.1</version>
<!--</dependency>--> <scope>test</scope>
<!--</dependencies>--> </dependency>
<!--</profile>--> </dependencies>
</profile>
-->


</profiles> </profiles>


Expand Down Expand Up @@ -103,7 +105,7 @@
<threadCount>${usergrid.rest.threads}</threadCount> <threadCount>${usergrid.rest.threads}</threadCount>
<useSystemClassLoader>false</useSystemClassLoader> <useSystemClassLoader>false</useSystemClassLoader>
<reuseForks>true</reuseForks> <reuseForks>true</reuseForks>
<argLine>-Dwebapp.directory=${basedir}/src/main/webapp -Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar ${ug.argline} <argLine>-Dwebapp.directory=${basedir}/src/main/webapp -Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar -Djava.util.logging.config.file=${basedir}/src/test/resources/logging.properties ${ug.argline}
</argLine> </argLine>
<includes> <includes>
<include>**/*IT.java</include> <include>**/*IT.java</include>
Expand All @@ -128,6 +130,7 @@
<version>2.6</version> <version>2.6</version>
</plugin> </plugin>


<!-- TODO: do we need this?
<plugin> <plugin>
<groupId>org.jasig.mojo.jspc</groupId> <groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-maven-plugin</artifactId> <artifactId>jspc-maven-plugin</artifactId>
Expand All @@ -144,14 +147,7 @@
</goals> </goals>
</execution> </execution>
</executions> </executions>
<dependencies> </plugin> -->
<dependency>
<groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-compiler-tomcat6</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</plugin>


<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -213,11 +209,11 @@
</exclusions> </exclusions>
</dependency> </dependency>


<!--<dependency>--> <!-- <dependency>
<!--<groupId>org.apache.usergrid</groupId>--> <groupId>org.apache.usergrid</groupId>
<!--<artifactId>usergrid-mongo-emulator</artifactId>--> <artifactId>usergrid-mongo-emulator</artifactId>
<!--<version>${project.version}</version>--> <version>${project.version}</version>
<!--</dependency>--> </dependency> -->


<!-- Apache Dependencies --> <!-- Apache Dependencies -->


Expand All @@ -226,7 +222,7 @@
<artifactId>commons-collections</artifactId> <artifactId>commons-collections</artifactId>
</dependency> </dependency>


<!-- SUN, Javax Package, and Other Com Dependencies --> <!-- Java EE and Jersey dependencies -->


<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
Expand All @@ -241,12 +237,10 @@


<dependency> <dependency>
<groupId>org.glassfish.jersey.containers</groupId> <groupId>org.glassfish.jersey.containers</groupId>
<!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" -->
<artifactId>jersey-container-servlet</artifactId> <artifactId>jersey-container-servlet</artifactId>
<version>2.21</version> <version>2.21</version>
</dependency> </dependency>


<!-- Required only when you are using JAX-RS Client -->
<dependency> <dependency>
<groupId>org.glassfish.jersey.core</groupId> <groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId> <artifactId>jersey-client</artifactId>
Expand All @@ -259,7 +253,6 @@
<version>2.21</version> <version>2.21</version>
</dependency> </dependency>


<!-- support for JSP and Viewable -->
<dependency> <dependency>
<groupId>org.glassfish.jersey.ext</groupId> <groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-mvc-jsp</artifactId> <artifactId>jersey-mvc-jsp</artifactId>
Expand All @@ -269,7 +262,7 @@
<dependency> <dependency>
<groupId>org.glassfish.jersey.media</groupId> <groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId> <artifactId>jersey-media-multipart</artifactId>
<version>2.7</version> <version>2.21</version>
</dependency> </dependency>


<dependency> <dependency>
Expand All @@ -278,42 +271,24 @@
<version>2.21</version> <version>2.21</version>
</dependency> </dependency>


<!--<dependency>--> <dependency>
<!--<groupId>com.sun.jersey.contribs</groupId>--> <groupId>org.glassfish.jersey.ext</groupId>
<!--<artifactId>jersey-multipart</artifactId>--> <artifactId>jersey-spring3</artifactId>
<!--</dependency>--> <version>2.21</version>
</dependency>


<!--<dependency>--> <!-- Jackson, Spring, and other dependencies -->
<!--<groupId>com.sun.jersey</groupId>-->
<!--<artifactId>jersey-json</artifactId>-->
<!--</dependency>-->


<dependency> <dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId> <groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId> <artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency> </dependency>


<!--<dependency>-->
<!--<groupId>com.sun.jersey</groupId>-->
<!--<artifactId>jersey-client</artifactId>-->
<!--</dependency>-->

<dependency> <dependency>
<groupId>com.google.code.maven-play-plugin.net.tanesha.recaptcha4j</groupId> <groupId>com.google.code.maven-play-plugin.net.tanesha.recaptcha4j</groupId>
<artifactId>recaptcha4j</artifactId> <artifactId>recaptcha4j</artifactId>
</dependency> </dependency>


<!--<dependency>-->
<!--<groupId>com.sun.jersey</groupId>-->
<!--<artifactId>jersey-server</artifactId>-->
<!--</dependency>-->

<!--<dependency>-->
<!--<groupId>com.sun.jersey.contribs</groupId>-->
<!--<artifactId>jersey-spring</artifactId>-->
<!--</dependency>-->

<!-- Codehaus, Spring, and Other Org Dependencies -->


<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
Expand Down Expand Up @@ -415,24 +390,17 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>


<!-- use the in-memory test setup. Just depend on the maven jetty plugin to launch jetty -->
<dependency> <dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId> <groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-inmemory</artifactId> <artifactId>jersey-test-framework-provider-external</artifactId>
<version>2.21</version> <version>2.21</version>
</dependency> </dependency>


<!--<dependency>--> <dependency>
<!--<groupId>com.sun.jersey.jersey-test-framework</groupId>--> <groupId>org.glassfish.jersey.test-framework</groupId>
<!--<artifactId>jersey-test-framework-external</artifactId>--> <artifactId>jersey-test-framework-core</artifactId>
<!--<scope>test</scope>--> <version>2.21</version>
<!--</dependency>--> </dependency>

<!--<dependency>-->
<!--<groupId>com.sun.jersey.jersey-test-framework</groupId>-->
<!--<artifactId>jersey-test-framework-core</artifactId>-->
<!--<scope>test</scope>-->
<!--</dependency>-->


<dependency> <dependency>
<groupId>org.apache.usergrid</groupId> <groupId>org.apache.usergrid</groupId>
Expand Down
Expand Up @@ -59,7 +59,7 @@ public class ContentTypeFilter implements Filter {


/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig) * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/ */
@Override @Override
Expand All @@ -70,7 +70,7 @@ public void init( FilterConfig filterConfig ) throws ServletException {


/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
* javax.servlet.ServletResponse, javax.servlet.FilterChain) * javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/ */
Expand Down Expand Up @@ -98,7 +98,7 @@ public void doFilter( ServletRequest request, ServletResponse response, FilterCh


/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see javax.servlet.Filter#destroy() * @see javax.servlet.Filter#destroy()
*/ */
@Override @Override
Expand Down Expand Up @@ -153,12 +153,10 @@ private void adapt() throws IOException {
// nothing to read, check if it's a put or a post. If so set the // nothing to read, check if it's a put or a post. If so set the
// content type to json to create an empty json request // content type to json to create an empty json request
if ( initial == -1 ) { if ( initial == -1 ) {
if ( ( HttpMethod.POST.equals( method ) || HttpMethod.PUT.equals( method ) ) && !MediaType if ( ( HttpMethod.POST.equals( method ) || HttpMethod.PUT.equals( method ) )
.APPLICATION_FORM_URLENCODED.equals( getContentType() ) ) { && !MediaType.APPLICATION_FORM_URLENCODED.equals( getContentType() ) ) {

logger.debug("Setting content type to application/json " +
logger.debug( "for POST or PUT with no content at path '{}'", path );
"Setting content type to application/json for POST or PUT with no content at path '{}'",
path );


setHeader( HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON ); setHeader( HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON );
setHeader( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON ); setHeader( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON );
Expand All @@ -170,9 +168,11 @@ private void adapt() throws IOException {
char firstChar = ( char ) initial; char firstChar = ( char ) initial;


// its json, make it so // its json, make it so
if ( firstChar == '{' || firstChar == '[' ) { if ( firstChar == '{' || firstChar == '['
logger.debug( "Setting content type to application/json for POST or PUT with json content at path '{}'", && !MediaType.APPLICATION_JSON.equals( getContentType() )) {
path );
logger.debug( "Setting content type to application/json " +
"for POST or PUT with json content at path '{}'", path );


setHeader( HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON ); setHeader( HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON );
setHeader( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON ); setHeader( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON );
Expand All @@ -193,7 +193,7 @@ public void setHeader( String name, String value ) {


/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* javax.servlet.http.HttpServletRequestWrapper#getHeader(java.lang. * javax.servlet.http.HttpServletRequestWrapper#getHeader(java.lang.
* String) * String)
Expand All @@ -212,7 +212,7 @@ public String getHeader( String name ) {


/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* javax.servlet.http.HttpServletRequestWrapper#getHeaders(java.lang * javax.servlet.http.HttpServletRequestWrapper#getHeaders(java.lang
* .String) * .String)
Expand All @@ -238,7 +238,7 @@ public Enumeration getHeaders( String name ) {


/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see javax.servlet.http.HttpServletRequestWrapper#getHeaderNames() * @see javax.servlet.http.HttpServletRequestWrapper#getHeaderNames()
*/ */
@Override @Override
Expand All @@ -257,7 +257,7 @@ public Enumeration getHeaderNames() {


/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see javax.servlet.ServletRequestWrapper#getInputStream() * @see javax.servlet.ServletRequestWrapper#getInputStream()
*/ */
@Override @Override
Expand All @@ -268,7 +268,7 @@ public ServletInputStream getInputStream() throws IOException {


/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see javax.servlet.ServletRequestWrapper#getReader() * @see javax.servlet.ServletRequestWrapper#getReader()
*/ */
@Override @Override
Expand Down
Expand Up @@ -21,15 +21,19 @@
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter; import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import java.io.IOException; import java.io.IOException;


import static org.apache.commons.lang.StringUtils.isNotBlank; import static org.apache.commons.lang.StringUtils.isNotBlank;




@Resource
@PreMatching
@Component @Component
public class JSONPCallbackFilter implements ContainerRequestFilter { public class JSONPCallbackFilter implements ContainerRequestFilter {


Expand Down
Expand Up @@ -32,11 +32,9 @@
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.*;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import java.io.FilterInputStream; import java.io.FilterInputStream;
import java.io.IOException; import java.io.IOException;
Expand All @@ -49,6 +47,8 @@




// TODO: Metering for Jersey 2 // TODO: Metering for Jersey 2
@Resource
@PreMatching
@Component @Component
public class MeteringFilter implements ContainerRequestFilter, ContainerResponseFilter { public class MeteringFilter implements ContainerRequestFilter, ContainerResponseFilter {


Expand Down
Expand Up @@ -26,11 +26,9 @@
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.*;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;




Expand All @@ -39,6 +37,8 @@
* *
* @author zznate * @author zznate
*/ */
@Resource
@PreMatching
@Component @Component
public class TracingFilter implements ContainerRequestFilter, ContainerResponseFilter { public class TracingFilter implements ContainerRequestFilter, ContainerResponseFilter {


Expand Down

0 comments on commit eb2aa6f

Please sign in to comment.