Skip to content

Commit

Permalink
Fixed Interceptor test failure & warning while building the msf4j cor…
Browse files Browse the repository at this point in the history
…e bundle
  • Loading branch information
afkham authored and WSO2 Builder committed Jul 21, 2016
1 parent 963822e commit 07816d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,11 @@

<properties>
<bundle.activator>org.wso2.msf4j.internal.MicroservicesServerActivator</bundle.activator>
<private.package>org.wso2.msf4j.internal.*,</private.package>
<private.package>org.wso2.msf4j.internal.*</private.package>
<export.package>
!org.wso2.msf4j.internal.*,
!org.wso2.msf4j.delegates.*,
org.wso2.msf4j.*;version="${msf4j.version}",
!org.wso2.msf4j.internal.*,
!org.wso2.msf4j.delegates.*
</export.package>
<import.package>
org.apache.commons.io.*;version="${commons-io.version.range}",
Expand Down
18 changes: 10 additions & 8 deletions core/src/test/java/org/wso2/msf4j/interceptor/TestInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,32 @@
import org.wso2.msf4j.Response;
import org.wso2.msf4j.ServiceMethodInfo;

import java.util.concurrent.atomic.AtomicInteger;

/**
* Interceptor used in test.
*/
public class TestInterceptor implements Interceptor {
private volatile int numPreCalls = 0;
private volatile int numPostCalls = 0;
private volatile AtomicInteger numPreCalls = new AtomicInteger(0);
private volatile AtomicInteger numPostCalls = new AtomicInteger(0);

public int getNumPreCalls() {
return numPreCalls;
return numPreCalls.get();
}

public int getNumPostCalls() {
return numPostCalls;
return numPostCalls.get();
}

public void reset() {
numPreCalls = 0;
numPostCalls = 0;
numPreCalls.set(0);
numPostCalls.set(0);
}

@Override
public boolean preCall(Request request, Response responder, ServiceMethodInfo serviceMethodInfo)
throws Exception {
++numPreCalls;
numPreCalls.incrementAndGet();

String header = request.getHeader("X-Request-Type");
if (header != null && header.equals("Reject")) {
Expand All @@ -61,7 +63,7 @@ public boolean preCall(Request request, Response responder, ServiceMethodInfo se

@Override
public void postCall(Request request, int status, ServiceMethodInfo serviceMethodInfo) {
++numPostCalls;
numPostCalls.incrementAndGet();
String header = request.getHeader("X-Request-Type");
if (header != null && header.equals("PostException")) {
throw new IllegalArgumentException("PostException");
Expand Down

0 comments on commit 07816d3

Please sign in to comment.