Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import org.apache.servicecomb.foundation.common.utils.BeanUtils;
import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import com.netflix.config.DynamicPropertyFactory;

Expand All @@ -31,7 +31,7 @@
public class DynamicConfigurationIT {
private static Vertx vertx = null;

@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
vertx = Vertx.vertx();
vertx.deployVerticle(new SimApolloServer());
Expand All @@ -40,7 +40,7 @@ public static void setUp() throws Exception {
BeanUtils.init();
}

@AfterClass
@AfterAll
public static void tearDown() {
vertx.close();
}
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/it-consumer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
</dependency>
</dependencies>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public void print() {
sb.append(String.format("%s, %s\n"
+ "%s\n",
failure.getParents(),
failure.getTestHeader(),
failure.getTrace()));
failure.getDisplayName(),
failure.getStacktrace()));
}
sb.append(String.format("\nrun count:%d, failed count: %d, totalTime: %s.\n",
ITJUnitUtils.getRunCount(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Stack;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
Expand All @@ -32,17 +34,22 @@
import org.apache.servicecomb.it.Consumers;
import org.apache.servicecomb.it.extend.engine.GateRestTemplate;
import org.apache.servicecomb.it.extend.engine.ITSCBRestTemplate;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
import org.junit.platform.engine.TestExecutionResult;
import org.junit.platform.engine.discovery.ClassSelector;
import org.junit.platform.engine.discovery.DiscoverySelectors;
import org.junit.platform.launcher.Launcher;
import org.junit.platform.launcher.LauncherDiscoveryRequest;
import org.junit.platform.launcher.TestExecutionListener;
import org.junit.platform.launcher.TestIdentifier;
import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
import org.junit.platform.launcher.core.LauncherFactory;

import com.google.common.reflect.ClassPath;

public final class ITJUnitUtils {
private static final ClassLoader classLoader = JvmUtils.findClassLoader();

private static final JUnitCore jUnitCore = new JUnitCore();
private static final Launcher launcher;

private static final Stack<String> parents = new Stack<>();

Expand All @@ -63,12 +70,18 @@ public static void setProducerName(String producerName) {
}

static {
jUnitCore.addListener(new RunListener() {
launcher = LauncherFactory.create();
launcher.registerTestExecutionListeners(new TestExecutionListener() {
@Override
public void testFailure(Failure failure) {
SCBFailure scbFailure = new SCBFailure(failure.getDescription(), failure.getException());
failures.add(scbFailure);
System.out.println(scbFailure);
public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult result) {
if (result.getStatus() == TestExecutionResult.Status.FAILED) {
Optional<Throwable> throwable = result.getThrowable();
SCBFailure scbFailure = throwable.map(value -> new SCBFailure(testIdentifier.getDisplayName(), value))
.orElseGet(() -> new SCBFailure(testIdentifier.getDisplayName(),
new RuntimeException("no exception was thrown but the test failed.")));
failures.add(scbFailure);
System.out.println(scbFailure);
}
}
});
}
Expand Down Expand Up @@ -131,8 +144,16 @@ public static void runFromPackage(String packageName) throws Throwable {

public static void run(Class<?>... classes) throws Throwable {
initClasses(classes);
Result result = jUnitCore.run(classes);
runCount.addAndGet(result.getRunCount());

List<ClassSelector> selectors = Arrays.stream(classes).map(DiscoverySelectors::selectClass)
.collect(Collectors.toList());
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request().selectors(selectors).build();
launcher.execute(request, new TestExecutionListener() {
@Override
public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
runCount.addAndGet(1);
}
});
}

public static void initClasses(Class<?>... classes) throws Throwable {
Expand Down Expand Up @@ -201,6 +222,7 @@ public static void runWithTransports(List<String> transports, Class<?>... classe
* 3.run the case
* 4.after finished the debug, remove code of ITJUnitUtils.initForDebug
* </pre>
*
* @param producerName
* @param transport
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,42 @@
*/
package org.apache.servicecomb.it.junit;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;

import org.junit.runner.Description;
import org.junit.runner.notification.Failure;

public class SCBFailure extends Failure {
private static final long serialVersionUID = 6467681668616080232L;
public class SCBFailure {

private final List<String> parents;

public SCBFailure(Description description, Throwable thrownException) {
super(description, thrownException);
private final String displayName;

private final Throwable exception;

public SCBFailure(String displayName, Throwable thrownException) {
this.displayName = displayName;
exception = thrownException;

parents = ITJUnitUtils.cloneParents();
}

public List<String> getParents() {
return parents;
}

public String getDisplayName() {
return displayName;
}

public String getStacktrace() {
StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter);
exception.printStackTrace(writer);
return stringWriter.toString();
}

@Override
public String toString() {
return "" + displayName + ":" + exception.getMessage();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.servicecomb.core.definition.SchemaMeta;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import io.swagger.models.Operation;
import io.swagger.models.Swagger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.List;

import org.apache.servicecomb.it.Consumers;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;

public class TestMyService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.apache.servicecomb.it.Consumers;
import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.apache.servicecomb.it.Consumers;
import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.concurrent.atomic.AtomicLong;

import org.apache.servicecomb.it.Consumers;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.http.ResponseEntity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.servicecomb.core.definition.OperationMeta;
import org.apache.servicecomb.core.definition.SchemaMeta;
import org.apache.servicecomb.swagger.SwaggerUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import io.swagger.models.ModelImpl;
import io.swagger.models.parameters.BodyParameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.servicecomb.provider.springmvc.reference.async.CseAsyncRestTemplate;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.http.ResponseEntity;
import org.springframework.util.concurrent.ListenableFuture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.apache.servicecomb.it.testcase;

import org.apache.servicecomb.it.Consumers;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;

public class TestChangeTransport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.servicecomb.it.extend.engine.ITSCBRestTemplate;
import org.apache.servicecomb.it.junit.ITJUnitUtils;
import org.apache.servicecomb.it.schema.DynamicColor;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Map;

import org.apache.servicecomb.it.extend.engine.GateRestTemplate;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.apache.servicecomb.it.Consumers;
import org.apache.servicecomb.swagger.SwaggerUtils;
import org.apache.servicecomb.swagger.generator.SwaggerGenerator;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import io.swagger.models.Swagger;
import org.junit.jupiter.api.Assertions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import org.apache.servicecomb.it.Consumers;
import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.apache.servicecomb.foundation.vertx.http.ReadStreamPart;
import org.apache.servicecomb.it.Consumers;
import org.apache.servicecomb.it.testcase.support.DownloadSchemaIntf;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.io.IOException;

import org.apache.servicecomb.it.extend.engine.GateRestTemplate;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import okhttp3.OkHttpClient;
import okhttp3.Request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
package org.apache.servicecomb.it.testcase;

import org.apache.servicecomb.it.extend.engine.GateRestTemplate;
import org.junit.Test;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import org.springframework.web.client.HttpClientErrorException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.servicecomb.it.extend.engine.GateRestTemplate;
import org.apache.servicecomb.it.schema.Generic;
import org.apache.servicecomb.it.schema.User;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;

public class TestGenericEdge {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.apache.servicecomb.core.SCBEngine;
import org.apache.servicecomb.core.definition.MicroserviceMeta;
import org.apache.servicecomb.core.definition.SchemaMeta;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;

public class TestIgnoreMethod {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.servicecomb.core.definition.MicroserviceMeta;
import org.apache.servicecomb.core.definition.OperationMeta;
import org.apache.servicecomb.core.definition.SchemaMeta;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;

public class TestIgnoreStaticMethod {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import org.apache.servicecomb.it.Consumers;
import org.apache.servicecomb.it.schema.PersonViewModel;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;

public class TestJsonView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.concurrent.ExecutionException;

import org.apache.servicecomb.it.Consumers;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.springframework.http.ResponseEntity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.servicecomb.foundation.test.scaffolding.model.Media;
import org.apache.servicecomb.it.Consumers;
import org.apache.servicecomb.it.junit.ITJUnitUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;

public class TestParamCodec {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.servicecomb.foundation.test.scaffolding.model.Media;
import org.apache.servicecomb.it.extend.engine.GateRestTemplate;
import org.apache.servicecomb.it.junit.ITJUnitUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Loading