Skip to content

Commit

Permalink
[#8965] Remove SharedClass annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Jun 28, 2022
1 parent 5d7f1b3 commit aeb088b
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 505 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@

import org.tinylog.TaggedLogger;

import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -137,27 +133,15 @@ private class ExecuteSharedThreadRunnable implements Runnable {
private volatile Throwable throwable;
@Override
public void run() {
Class<?> testClazz = null;
try {
testClazz = loadClass();
Class<?> testClazz = loadClass();

logger.debug("Execute testClazz:{} cl:{}", testClazz.getName(), testClazz.getClassLoader());

sharedTestLifeCycleWrapper = SharedTestLifeCycleWrapper.newVersionTestLifeCycleWrapper(testClazz);
if (sharedTestLifeCycleWrapper != null) {
sharedTestLifeCycleWrapper.beforeAll();
}

runBeforeSharedClass(testClazz);
Map<String, Object> result = getProperties(testClazz);
if (result.size() > 0) {
// bind parameter
for (Map.Entry<String, Object> entry : result.entrySet()) {
if (entry.getValue() != null) {
properties.put(entry.getKey(), entry.getValue());
}
}
}
} catch (Throwable th) {
logger.warn("{} testclass error", testClazzName, th);
throwable = th;
Expand All @@ -166,7 +150,6 @@ public void run() {
}

awaitAfterStart();
runAfterSharedClass(testClazz);
if (sharedTestLifeCycleWrapper != null) {
sharedTestLifeCycleWrapper.afterAll();
}
Expand All @@ -182,36 +165,4 @@ private Class<?> loadClass() {
}
}

private void runBeforeSharedClass(final Class<?> testClazz) {
try {
MethodFilter beforeSharedMethodFilter = MethodUtils.createBeforeSharedMethodFilter();
List<Method> beforeSharedMethods = MethodUtils.getMethod(testClazz, beforeSharedMethodFilter);
MethodUtils.invokeStaticAndNoParametersMethod(beforeSharedMethods);
} catch (Exception e) {
logger.error(e, "execute beforeSharedClass failed. testClazz:{}", testClazzName);
}
}

private Map<String, Object> getProperties(final Class<?> testClazz) {
try {
return MethodUtils.invokeGetMethod(testClazz);
} catch (Exception e) {
logger.error(e, "invokeGetMethod execute failed. message:{}", e.getMessage());
}

return Collections.emptyMap();
}

private void runAfterSharedClass(final Class<?> testClazz) {
try {
MethodFilter afterSharedMethodFilter = MethodUtils.createAfterSharedMethodFilter();
List<Method> afterSharedMethods = MethodUtils.getMethod(testClazz, afterSharedMethodFilter);
MethodUtils.invokeStaticAndNoParametersMethod(afterSharedMethods);
} catch (Exception e) {
logger.error(e, "execute afterSharedClass failed. testClazz:{}", testClazzName);
}

}


}

This file was deleted.

Loading

0 comments on commit aeb088b

Please sign in to comment.