You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/03/22 09:16:40 UTC
[incubator-servicecomb-java-chassis] 05/05: Review comments
fix:Fault-Injection handler
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git
commit a7ea310ad268e07f504bd31ab2fb44f1b7f361fc
Author: maheshrajus <ma...@huawei.com>
AuthorDate: Thu Mar 22 13:14:58 2018 +0530
Review comments fix:Fault-Injection handler
---
handlers/handler-fault-injection/pom.xml | 55 ++++++++++---------
.../servicecomb/faultinjection/AbortFault.java | 17 +++---
.../servicecomb/faultinjection/BeanHolder.java | 47 ----------------
.../servicecomb/faultinjection/DelayFault.java | 14 +++--
.../apache/servicecomb/faultinjection/Fault.java | 2 +-
.../servicecomb/faultinjection/FaultExecutor.java | 9 +---
.../faultinjection/FaultInjectionHandler.java | 18 ++-----
.../faultinjection/FaultInjectionUtil.java | 9 ++--
.../servicecomb/faultinjection/FaultResponse.java | 63 ----------------------
.../org.apache.servicecomb.faultinjection.Fault | 19 +++++++
.../main/resources/META-INF/spring/cse.bean.xml | 31 -----------
.../faultinjection/TestFaultInjectConfig.java | 18 +------
.../faultinjection/TestFaultInjectUtil.java | 12 -----
13 files changed, 73 insertions(+), 241 deletions(-)
diff --git a/handlers/handler-fault-injection/pom.xml b/handlers/handler-fault-injection/pom.xml
index 3fda7b4..de176d4 100755
--- a/handlers/handler-fault-injection/pom.xml
+++ b/handlers/handler-fault-injection/pom.xml
@@ -16,29 +16,34 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>handlers</artifactId>
- <version>1.0.0-m2-SNAPSHOT</version>
- </parent>
- <artifactId>handler-fault-injection</artifactId>
- <name>Java Chassis::Handlers::Fault Injection</name>
- <dependencies>
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>java-chassis-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>handlers</artifactId>
+ <version>1.0.0-m2-SNAPSHOT</version>
+ </parent>
+ <artifactId>handler-fault-injection</artifactId>
+ <name>Java Chassis::Handlers::Fault Injection</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>foundation-test-scaffolding</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/AbortFault.java b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/AbortFault.java
index f53eef3..1135aa6 100644
--- a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/AbortFault.java
+++ b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/AbortFault.java
@@ -20,11 +20,10 @@ package org.apache.servicecomb.faultinjection;
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.swagger.invocation.AsyncResponse;
import org.apache.servicecomb.swagger.invocation.exception.CommonExceptionData;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-@Component
public class AbortFault extends AbstractFault {
private static final Logger LOGGER = LoggerFactory.getLogger(AbortFault.class);
@@ -36,12 +35,12 @@ public class AbortFault extends AbstractFault {
if (abortPercent == FaultInjectionConst.FAULT_INJECTION_DEFAULT_VALUE) {
LOGGER.debug("Fault injection: Abort percentage is not configured");
- asynResponse.success(new FaultResponse());
+ asynResponse.success("success");
return;
}
// check fault abort condition.
- boolean isAbort = FaultInjectionUtil.checkFaultInjectionDelayAndAbort(faultParam.getReqCount(), abortPercent);
+ boolean isAbort = FaultInjectionUtil.isFaultNeedToInject(faultParam.getReqCount(), abortPercent);
if (isAbort) {
// get the config values related to abort percentage.
int errorCode = FaultInjectionUtil.getFaultInjectionConfig(invocation,
@@ -49,22 +48,20 @@ public class AbortFault extends AbstractFault {
if (errorCode == FaultInjectionConst.FAULT_INJECTION_DEFAULT_VALUE) {
LOGGER.debug("Fault injection: Abort error code is not configured");
- asynResponse.success(new FaultResponse());
+ asynResponse.success("success");
return;
}
// if request need to be abort then return failure with given error code
CommonExceptionData errorData = new CommonExceptionData("aborted by fault inject");
-
- FaultResponse response = new FaultResponse(FaultInjectionConst.FAULT_INJECTION_ERROR, errorCode, errorData);
- asynResponse.success(response);
+ asynResponse.consumerFail(new InvocationException(errorCode, "aborted by fault inject", errorData));
return;
}
- asynResponse.success(new FaultResponse());
+ asynResponse.success("success");
}
@Override
- public int getPriority() {
+ public int getOrder() {
return 200;
}
}
diff --git a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/BeanHolder.java b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/BeanHolder.java
deleted file mode 100644
index 756ad4b..0000000
--- a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/BeanHolder.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.servicecomb.faultinjection;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import javax.inject.Inject;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class BeanHolder {
-
- @Inject
- private List<Fault> faultInjectionFeatureList = Collections.emptyList();
-
- public void init() {
- //sort the fault injection feature list based on priority.
- Collections.sort(faultInjectionFeatureList, new Comparator<Fault>() {
-
- @Override
- public int compare(Fault o1, Fault o2) {
- return Integer.compare(o1.getPriority(), o2.getPriority());
- }
- });
-
- FaultInjectionHandler.getFaultFeature().addAll(faultInjectionFeatureList);
-
- }
-}
diff --git a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/DelayFault.java b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/DelayFault.java
index 3f5edb9..ecbb2e1 100644
--- a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/DelayFault.java
+++ b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/DelayFault.java
@@ -21,17 +21,15 @@ import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.swagger.invocation.AsyncResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
-@Component
public class DelayFault extends AbstractFault {
private static final Logger LOGGER = LoggerFactory.getLogger(DelayFault.class);
@Override
- public int getPriority() {
+ public int getOrder() {
return 100;
}
@@ -42,12 +40,12 @@ public class DelayFault extends AbstractFault {
if (delayPercent == FaultInjectionConst.FAULT_INJECTION_DEFAULT_VALUE) {
LOGGER.debug("Fault injection: delay percentage is not configured");
- asynResponse.success(new FaultResponse());
+ asynResponse.success("success");
return;
}
// check fault delay condition.
- boolean isDelay = FaultInjectionUtil.checkFaultInjectionDelayAndAbort(faultParam.getReqCount(), delayPercent);
+ boolean isDelay = FaultInjectionUtil.isFaultNeedToInject(faultParam.getReqCount(), delayPercent);
if (isDelay) {
LOGGER.debug("Fault injection: delay is added for the request by fault inject handler");
long delay = FaultInjectionUtil.getFaultInjectionConfig(invocation,
@@ -55,7 +53,7 @@ public class DelayFault extends AbstractFault {
if (delay == FaultInjectionConst.FAULT_INJECTION_DEFAULT_VALUE) {
LOGGER.debug("Fault injection: delay is not configured");
- asynResponse.success(new FaultResponse());
+ asynResponse.success("success");
return;
}
@@ -64,7 +62,7 @@ public class DelayFault extends AbstractFault {
vertx.setTimer(delay, new Handler<Long>() {
@Override
public void handle(Long timeID) {
- asynResponse.success(new FaultResponse());
+ asynResponse.success("success");
}
});
} else {
@@ -73,7 +71,7 @@ public class DelayFault extends AbstractFault {
} catch (InterruptedException e) {
LOGGER.info("Interrupted exception is received");
}
- asynResponse.success(new FaultResponse());
+ asynResponse.success("success");
}
}
}
diff --git a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/Fault.java b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/Fault.java
index 6f50c62..ddc4229 100644
--- a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/Fault.java
+++ b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/Fault.java
@@ -22,7 +22,7 @@ import org.apache.servicecomb.swagger.invocation.AsyncResponse;
public interface Fault {
- int getPriority();
+ int getOrder();
void injectFault(Invocation invocation, FaultParam faultAttributes, AsyncResponse asynResponse);
}
diff --git a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultExecutor.java b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultExecutor.java
index c5a0e9b..9a20f64 100644
--- a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultExecutor.java
+++ b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultExecutor.java
@@ -48,7 +48,7 @@ public class FaultExecutor {
private void next(AsyncResponse asyncResponse) {
if (handlerIndex >= faultInjectList.size()) {
- asyncResponse.complete(Response.succResp(new FaultResponse()));
+ asyncResponse.complete(Response.succResp("success"));
return;
}
@@ -58,12 +58,7 @@ public class FaultExecutor {
if (response.isFailed()) {
asyncResponse.complete(response);
} else {
- FaultResponse r = response.getResult();
- if (r.getStatusCode() == FaultInjectionConst.FAULT_INJECTION_ERROR) {
- asyncResponse.complete(response);
- } else {
- FaultExecutor.this.next(asyncResponse);
- }
+ FaultExecutor.this.next(asyncResponse);
}
});
}
diff --git a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultInjectionHandler.java b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultInjectionHandler.java
index 204049c..8c29246 100755
--- a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultInjectionHandler.java
+++ b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultInjectionHandler.java
@@ -17,14 +17,13 @@
package org.apache.servicecomb.faultinjection;
-import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.servicecomb.core.Handler;
import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
import org.apache.servicecomb.swagger.invocation.AsyncResponse;
-import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
import io.vertx.core.Context;
import io.vertx.core.Vertx;
@@ -37,27 +36,21 @@ import io.vertx.core.Vertx;
public class FaultInjectionHandler implements Handler {
- private static List<Fault> faultInjectionFeatureList = new ArrayList<>();
+ private List<Fault> faultInjectionFeatureList = SPIServiceUtils.getSortedService(Fault.class);
//added only for unit testing
public void setFaultFeature(List<Fault> faultFeature) {
faultInjectionFeatureList = faultFeature;
}
- public static List<Fault> getFaultFeature() {
- return faultInjectionFeatureList;
- }
-
@Override
public void handle(Invocation invocation, AsyncResponse asyncResp) throws Exception {
// prepare the key and lookup for request count.
String key = invocation.getTransport().getName() + invocation.getMicroserviceQualifiedName();
AtomicLong reqCount = FaultInjectionUtil.getOperMetTotalReq(key);
- long reqCountCurrent = reqCount.get();
-
// increment the request count here after checking the delay/abort condition.
- reqCount.incrementAndGet();
+ long reqCountCurrent = reqCount.getAndIncrement();
FaultParam param = new FaultParam(reqCountCurrent);
Context currentContext = Vertx.currentContext();
@@ -71,11 +64,6 @@ public class FaultInjectionHandler implements Handler {
if (response.isFailed()) {
asyncResp.complete(response);
} else {
- FaultResponse r = response.getResult();
- if (r.getStatusCode() == FaultInjectionConst.FAULT_INJECTION_ERROR) {
- asyncResp.consumerFail(new InvocationException(r.getErrorCode(), "", r.getErrorData()));
- return;
- }
invocation.next(asyncResp);
}
} catch (Exception e) {
diff --git a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultInjectionUtil.java b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultInjectionUtil.java
index 18dba50..05e85ae 100755
--- a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultInjectionUtil.java
+++ b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultInjectionUtil.java
@@ -142,9 +142,9 @@ public class FaultInjectionUtil {
* @param reqCount
* @param percentage
* @param key
- * @return true/false
+ * @return true: delay/abort is needed. false: delay/abort is not needed.
*/
- public static boolean checkFaultInjectionDelayAndAbort(long reqCount, int percentage) {
+ public static boolean isFaultNeedToInject(long reqCount, int percentage) {
/*
* Example: delay/abort percentage configured is 10% and Get the count(suppose
* if it is 10th request) from map and calculate resultNew(10th request) and
@@ -160,9 +160,6 @@ public class FaultInjectionUtil {
long resultOld = ((reqCount - 1) * percentage) / 100;
// if both are not matching then delay/abort should be added.
- if (resultNew != resultOld) {
- return true;
- }
- return false;
+ return (resultNew != resultOld);
}
}
diff --git a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultResponse.java b/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultResponse.java
deleted file mode 100644
index ee59d71..0000000
--- a/handlers/handler-fault-injection/src/main/java/org/apache/servicecomb/faultinjection/FaultResponse.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.servicecomb.faultinjection;
-
-/**
- * Fault response which contains status of fault injection.
- */
-public class FaultResponse {
- private int statusCode;
-
- private int errorCode;
-
- private Object errorData;
-
- FaultResponse(int statusCode, int errorCode, Object errorData) {
- this.statusCode = statusCode;
- this.errorCode = errorCode;
- this.errorData = errorData;
- }
-
- FaultResponse() {
- }
-
- public int getStatusCode() {
- return statusCode;
- }
-
- public void setStatusCode(int statusCode) {
- this.statusCode = statusCode;
- }
-
- public int getErrorCode() {
- return errorCode;
- }
-
- public void setErrorCode(int errorCode) {
- this.errorCode = errorCode;
- }
-
- public Object getErrorData() {
- return errorData;
- }
-
- public void setErrorData(Object errorData) {
- this.errorData = errorData;
- }
-
-}
diff --git a/handlers/handler-fault-injection/src/main/resources/META-INF/services/org.apache.servicecomb.faultinjection.Fault b/handlers/handler-fault-injection/src/main/resources/META-INF/services/org.apache.servicecomb.faultinjection.Fault
new file mode 100644
index 0000000..1da13d5
--- /dev/null
+++ b/handlers/handler-fault-injection/src/main/resources/META-INF/services/org.apache.servicecomb.faultinjection.Fault
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+
+org.apache.servicecomb.faultinjection.DelayFault
+org.apache.servicecomb.faultinjection.AbortFault
diff --git a/handlers/handler-fault-injection/src/main/resources/META-INF/spring/cse.bean.xml b/handlers/handler-fault-injection/src/main/resources/META-INF/spring/cse.bean.xml
deleted file mode 100755
index b8f5c57..0000000
--- a/handlers/handler-fault-injection/src/main/resources/META-INF/spring/cse.bean.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
- <beans xmlns = "http://www.springframework.org/schema/beans"
- xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context = "http://www.springframework.org/schema/context"
- xsi:schemaLocation = "http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.0.xsd">
-
- <context:annotation-config />
- <!-- <context:spring-configured /> -->
- <context:component-scan base-package="org.apache.servicecomb.faultinjection" />
- <bean class="org.apache.servicecomb.faultinjection.BeanHolder" init-method="init"/>
-</beans>
diff --git a/handlers/handler-fault-injection/src/test/java/org/apache/servicecomb/faultinjection/TestFaultInjectConfig.java b/handlers/handler-fault-injection/src/test/java/org/apache/servicecomb/faultinjection/TestFaultInjectConfig.java
index 4c2a08e..a9ea092 100644
--- a/handlers/handler-fault-injection/src/test/java/org/apache/servicecomb/faultinjection/TestFaultInjectConfig.java
+++ b/handlers/handler-fault-injection/src/test/java/org/apache/servicecomb/faultinjection/TestFaultInjectConfig.java
@@ -36,8 +36,6 @@ public class TestFaultInjectConfig {
FaultParam faultParam;
- FaultResponse faultResp;
-
AbortFault abortFault;
DelayFault delayFault;
@@ -48,7 +46,6 @@ public class TestFaultInjectConfig {
faultConst = new FaultInjectionConst();
faultUtil = new FaultInjectionUtil();
faultParam = new FaultParam(10);
- faultResp = new FaultResponse();
abortFault = new AbortFault();
delayFault = new DelayFault();
}
@@ -85,19 +82,8 @@ public class TestFaultInjectConfig {
}
@Test
- public void testFaultResponse() {
- Object obj = new Object();
- faultResp.setErrorCode(100);
- faultResp.setErrorData(obj);
- faultResp.setStatusCode(123);
- assertEquals(123, faultResp.getStatusCode());
- assertEquals(100, faultResp.getErrorCode());
- assertEquals(obj, faultResp.getErrorData());
- }
-
- @Test
public void testFaultPriority() {
- assertEquals(200, abortFault.getPriority());
- assertEquals(100, delayFault.getPriority());
+ assertEquals(200, abortFault.getOrder());
+ assertEquals(100, delayFault.getOrder());
}
}
diff --git a/handlers/handler-fault-injection/src/test/java/org/apache/servicecomb/faultinjection/TestFaultInjectUtil.java b/handlers/handler-fault-injection/src/test/java/org/apache/servicecomb/faultinjection/TestFaultInjectUtil.java
index 46b428e..ec619a7 100644
--- a/handlers/handler-fault-injection/src/test/java/org/apache/servicecomb/faultinjection/TestFaultInjectUtil.java
+++ b/handlers/handler-fault-injection/src/test/java/org/apache/servicecomb/faultinjection/TestFaultInjectUtil.java
@@ -17,10 +17,7 @@
package org.apache.servicecomb.faultinjection;
-import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
@@ -52,15 +49,6 @@ public class TestFaultInjectUtil {
@Test
public void testFaultInjectUtil() throws Exception {
- BeanHolder beanHolder = new BeanHolder();
- List<Fault> faultInjectionFeatureList = Arrays.asList(delayFault, abortFault);
- Field field = beanHolder.getClass().getDeclaredField("faultInjectionFeatureList");
- field.setAccessible(true);
- field.set(beanHolder, faultInjectionFeatureList);
- Mockito.when(delayFault.getPriority()).thenReturn(1);
- Mockito.when(abortFault.getPriority()).thenReturn(10);
-
- beanHolder.init();
AtomicLong count1 = FaultInjectionUtil.getOperMetTotalReq("test");
Assert.assertEquals(1, count1.get());
count1.incrementAndGet();
--
To stop receiving notification emails like this one, please contact
liubao@apache.org.