fix issue that test compile failed
This commit is contained in:
parent
4dd76f06b5
commit
24010d134b
|
|
@ -2,41 +2,53 @@ package com.a.eye.skywalking.api.plugin.assist;
|
|||
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.assist.NoConcurrencyAccessObject;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class NoConcurrencyAccessObjectTest {
|
||||
|
||||
@Mock
|
||||
private InstanceMethodInvokeContext invokeContext;
|
||||
|
||||
@Test
|
||||
public void testEntraExitCounter() {
|
||||
NoConcurrencyAccessObject object = new NoConcurrencyAccessObject();
|
||||
final EnhancedClassInstanceContext context = new EnhancedClassInstanceContext();
|
||||
object.whenEnter(context, new Runnable() {
|
||||
NoConcurrencyAccessObject first = new NoConcurrencyAccessObject(){
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
protected void enter(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
|
||||
context.set("firstEntrance", true);
|
||||
}
|
||||
});
|
||||
object.whenEnter(context, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
context.set("secondEntrance", true);
|
||||
}
|
||||
});
|
||||
object.whenExist(context, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@Override protected void exit() {
|
||||
context.set("firstExit", true);
|
||||
}
|
||||
});
|
||||
object.whenExist(context, new Runnable() {
|
||||
};
|
||||
|
||||
NoConcurrencyAccessObject second = new NoConcurrencyAccessObject(){
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
protected void enter(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
|
||||
context.set("secondEntrance", true);
|
||||
}
|
||||
|
||||
@Override protected void exit() {
|
||||
context.set("lastEntrance", true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
first.whenEnter(context, invokeContext);
|
||||
second.whenEnter(context, invokeContext);
|
||||
first.whenExist(context);
|
||||
second.whenExist(context);
|
||||
|
||||
Assert.assertTrue(!context.isContain("secondEntrance"));
|
||||
Assert.assertTrue(!context.isContain("firstExit"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue