Skip to content

Commit

Permalink
delete never thrown exception
Browse files Browse the repository at this point in the history
  • Loading branch information
erdengk committed Feb 27, 2023
1 parent a70cc27 commit c15e0f3
Show file tree
Hide file tree
Showing 81 changed files with 364 additions and 365 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void testBuildInvokerChainForLocalReference() {
urlWithoutFilter = urlWithoutFilter.setScopeModel(ApplicationModel.defaultModel());
AbstractInvoker<DemoService> invokerWithoutFilter = new AbstractInvoker<DemoService>(DemoService.class, urlWithoutFilter) {
@Override
protected Result doInvoke(Invocation invocation) throws Throwable {
protected Result doInvoke(Invocation invocation) {
return null;
}
};
Expand All @@ -58,7 +58,7 @@ protected Result doInvoke(Invocation invocation) throws Throwable {
urlWithFilter = urlWithFilter.setScopeModel(ApplicationModel.defaultModel());
AbstractInvoker<DemoService> invokerWithFilter = new AbstractInvoker<DemoService>(DemoService.class, urlWithFilter) {
@Override
protected Result doInvoke(Invocation invocation) throws Throwable {
protected Result doInvoke(Invocation invocation) {
return null;
}
};
Expand Down Expand Up @@ -93,7 +93,7 @@ protected Result doInvoke(Invocation invocation) throws Throwable {
urlWithFilter = urlWithFilter.setScopeModel(ApplicationModel.defaultModel());
AbstractInvoker<DemoService> invokerWithFilter = new AbstractInvoker<DemoService>(DemoService.class, urlWithFilter) {
@Override
protected Result doInvoke(Invocation invocation) throws Throwable {
protected Result doInvoke(Invocation invocation) {
return null;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ protected Result doInvoke(Invocation invocation, List invokers, LoadBalance load
}

@Test
void testSelect_Invokersize0() throws Exception {
void testSelect_Invokersize0() {
LoadBalance l = cluster.initLoadBalance(invokers, invocation);
Assertions.assertNotNull(l,"cluster.initLoadBalance returns null!");
{
Expand Down Expand Up @@ -228,7 +228,7 @@ protected Result doInvoke(Invocation invocation, List invokers, LoadBalance load
}

@Test
void testSelect_Invokersize1() throws Exception {
void testSelect_Invokersize1() {
invokers.clear();
invokers.add(invoker1);
LoadBalance l = cluster.initLoadBalance(invokers, invocation);
Expand All @@ -238,7 +238,7 @@ void testSelect_Invokersize1() throws Exception {
}

@Test
void testSelect_Invokersize2AndselectNotNull() throws Exception {
void testSelect_Invokersize2AndselectNotNull() {
invokers.clear();
invokers.add(invoker2);
invokers.add(invoker4);
Expand Down Expand Up @@ -412,7 +412,7 @@ void testSelectAgainAndCheckAvailable() {
}


public void testSelect_multiInvokers(String lbname) throws Exception {
public void testSelect_multiInvokers(String lbname) {

int min = 100, max = 500;
Double d = (Math.random() * (max - min + 1) + min);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void setup() {
}

@Test
void testMergeUrl() throws Exception {
void testMergeUrl() {
URL providerURL = URL.valueOf("dubbo://localhost:55555");
providerURL = providerURL.setPath("path")
.setUsername("username")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void setup() {
}

@Test
void testMergeUrl() throws Exception {
void testMergeUrl() {
URL providerURL = URL.valueOf("dubbo://localhost:55555");
providerURL = providerURL.setPath("path")
.setUsername("username")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class MixinTest {

@Test
void testMain() throws Exception {
void testMain() {
Mixin mixin = Mixin.mixin(new Class[]{I1.class, I2.class, I3.class}, new Class[]{C1.class, C2.class});
Object o = mixin.newInstance(new Object[]{new C1(), new C2()});
assertTrue(o instanceof I1);
Expand Down Expand Up @@ -69,4 +69,4 @@ public void setMixinInstance(Object mi) {
System.out.println("setMixinInstance:" + mi);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testCompileJavaClass0() throws Exception {
}

@Test
void testCompileJavaClass1() throws Exception {
void testCompileJavaClass1() {
Assertions.assertThrows(IllegalStateException.class, () -> {
JavassistCompiler compiler = new JavassistCompiler();
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithSyntax0(), JavassistCompiler.class.getClassLoader());
Expand All @@ -82,4 +82,4 @@ void testCompileJavaClassWithExtends() throws Exception {
Method sayHello = instance.getClass().getMethod("sayHello");
Assertions.assertEquals("Hello world3!", sayHello.invoke(instance));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void test_compileJavaClass() throws Exception {
}

@Test
void test_compileJavaClass0() throws Exception {
void test_compileJavaClass0() {
Assertions.assertThrows(IllegalStateException.class, () -> {
JdkCompiler compiler = new JdkCompiler();
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithoutPackage(), JdkCompiler.class.getClassLoader());
Expand All @@ -44,7 +44,7 @@ void test_compileJavaClass0() throws Exception {
}

@Test
void test_compileJavaClass1() throws Exception {
void test_compileJavaClass1() {
Assertions.assertThrows(IllegalStateException.class, () -> {
JdkCompiler compiler = new JdkCompiler();
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithSyntax(), JdkCompiler.class.getClassLoader());
Expand All @@ -64,7 +64,7 @@ void test_compileJavaClass_java8() throws Exception {
}

@Test
void test_compileJavaClass0_java8() throws Exception {
void test_compileJavaClass0_java8() {
Assertions.assertThrows(IllegalStateException.class, () -> {
JdkCompiler compiler = new JdkCompiler("1.8");
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithoutPackage(), JdkCompiler.class.getClassLoader());
Expand All @@ -75,7 +75,7 @@ void test_compileJavaClass0_java8() throws Exception {
}

@Test
void test_compileJavaClass1_java8() throws Exception {
void test_compileJavaClass1_java8() {
Assertions.assertThrows(IllegalStateException.class, () -> {
JdkCompiler compiler = new JdkCompiler("1.8");
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithSyntax(), JdkCompiler.class.getClassLoader());
Expand All @@ -84,4 +84,4 @@ void test_compileJavaClass1_java8() throws Exception {
Assertions.assertEquals("Hello world!", sayHello.invoke(instance));
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ class AbstractDynamicConfigurationTest {
public void init() {
configuration = new AbstractDynamicConfiguration(null) {
@Override
protected String doGetConfig(String key, String group) throws Exception {
protected String doGetConfig(String key, String group) {
return null;
}

@Override
protected void doClose() throws Exception {
protected void doClose() {

}

@Override
protected boolean doRemoveConfig(String key, String group) throws Exception {
protected boolean doRemoveConfig(String key, String group) {
return false;
}
};
Expand Down Expand Up @@ -93,17 +93,17 @@ void testConstructor() {
AbstractDynamicConfiguration configuration = new AbstractDynamicConfiguration(url) {

@Override
protected String doGetConfig(String key, String group) throws Exception {
protected String doGetConfig(String key, String group) {
return null;
}

@Override
protected void doClose() throws Exception {
protected void doClose() {

}

@Override
protected boolean doRemoveConfig(String key, String group) throws Exception {
protected boolean doRemoveConfig(String key, String group) {
return false;
}
};
Expand Down Expand Up @@ -202,4 +202,4 @@ void testRemoveConfigAndDoRemoveConfig() throws Exception {
assertEquals(configuration.removeConfig(key, group), configuration.doRemoveConfig(key, group));
assertFalse(configuration.removeConfig(key, group));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BytesTest {
private byte[] bytes2 = {3, 12, 14, 41, 12, 2, 3, 12, 4, 67};

@Test
void testMain() throws Exception {
void testMain() {
short s = (short) 0xabcd;
assertThat(s, is(Bytes.bytes2short(Bytes.short2bytes(s))));

Expand Down Expand Up @@ -86,7 +86,7 @@ void testSmallLength() {
}

@Test
void testBase64S2b2sFailCaseLog() throws Exception {
void testBase64S2b2sFailCaseLog() {
String s1 = Bytes.bytes2base64(bytes1);
byte[] out1 = Bytes.base642bytes(s1);
assertThat(bytes1, is(out1));
Expand Down Expand Up @@ -161,4 +161,4 @@ private byte[] long2bytes(long x) {
bb[7] = (byte) (x >> 0);
return bb;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class GlobalResourcesRepositoryTest {

@Test
void test() throws NoSuchFieldException {
void test() {
GlobalResourcesRepository repository = GlobalResourcesRepository.getInstance();

ExecutorService globalExecutorService = GlobalResourcesRepository.getGlobalExecutorService();
Expand Down Expand Up @@ -74,4 +74,4 @@ public boolean isDestroyed() {
return destroyed;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class LoadStatusCheckerTest {
private static Logger logger = LoggerFactory.getLogger(LoadStatusCheckerTest.class);

@Test
void test() throws Exception {
void test() {
LoadStatusChecker statusChecker = new LoadStatusChecker();
Status status = statusChecker.check();
assertThat(status, notNullValue());
logger.info("load status level: " + status.getLevel());
logger.info("load status message: " + status.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class MemoryStatusCheckerTest {
private static final Logger logger = LoggerFactory.getLogger(MemoryStatusCheckerTest.class);

@Test
void test() throws Exception {
void test() {
MemoryStatusChecker statusChecker = new MemoryStatusChecker();
Status status = statusChecker.check();
assertThat(status.getLevel(), anyOf(is(OK), is(WARN)));
logger.info("memory status level: " + status.getLevel());
logger.info("memory status message: " + status.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void setup() {
}

@Test
void testInternalThreadLocal() throws InterruptedException {
void testInternalThreadLocal() {
final AtomicInteger index = new AtomicInteger(0);

final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>() {
Expand All @@ -71,7 +71,7 @@ protected Integer initialValue() {
}

@Test
void testRemoveAll() throws InterruptedException {
void testRemoveAll() {
final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>();
internalThreadLocal.set(1);
Assertions.assertEquals(1, (int)internalThreadLocal.get(), "set failed");
Expand All @@ -86,7 +86,7 @@ void testRemoveAll() throws InterruptedException {
}

@Test
void testSize() throws InterruptedException {
void testSize() {
final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>();
internalThreadLocal.set(1);
Assertions.assertEquals(1, InternalThreadLocal.size(), "size method is wrong!");
Expand Down Expand Up @@ -120,7 +120,7 @@ void testOnRemove() {
final Integer[] valueToRemove = {null};
final InternalThreadLocal<Integer> internalThreadLocal = new InternalThreadLocal<Integer>() {
@Override
protected void onRemoval(Integer value) throws Exception {
protected void onRemoval(Integer value) {
//value calculate
valueToRemove[0] = value + 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class MemoryLimitedLinkedBlockingQueueTest {
@Test
void test() throws Exception {
void test() {
ByteBuddyAgent.install();
final Instrumentation instrumentation = ByteBuddyAgent.getInstrumentation();
MemoryLimitedLinkedBlockingQueue<Runnable> queue = new MemoryLimitedLinkedBlockingQueue<>(1, instrumentation);
Expand All @@ -38,4 +38,4 @@ void test() throws Exception {
queue.setMemoryLimit(Integer.MAX_VALUE);
assertThat(queue.offer(() -> System.out.println("add success")), is(true));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

class MemorySafeLinkedBlockingQueueTest {
@Test
void test() throws Exception {
void test() {
ByteBuddyAgent.install();
final Instrumentation instrumentation = ByteBuddyAgent.getInstrumentation();
final long objectSize = instrumentation.getObjectSize((Runnable) () -> {
Expand All @@ -49,7 +49,7 @@ void test() throws Exception {
}

@Test
void testCustomReject() throws Exception {
void testCustomReject() {
MemorySafeLinkedBlockingQueue<Runnable> queue = new MemorySafeLinkedBlockingQueue<>(Integer.MAX_VALUE);
queue.setRejector(new AbortPolicy<>());
assertThrows(RejectException.class, () -> queue.offer(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@

class AbortPolicyWithReportTest {
@Test
void jStackDumpTest() throws InterruptedException {
void jStackDumpTest() {
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue=");
AtomicReference<FileOutputStream> fileOutputStream = new AtomicReference<>();

AbortPolicyWithReport abortPolicyWithReport = new AbortPolicyWithReport("Test", url) {
@Override
protected void jstack(FileOutputStream jStackStream) throws Exception {
protected void jstack(FileOutputStream jStackStream) {
fileOutputStream.set(jStackStream);
}
};
Expand All @@ -59,7 +59,7 @@ protected void jstack(FileOutputStream jStackStream) throws Exception {
}

@Test
void jStackDumpTest_dumpDirectoryNotExists_cannotBeCreatedTakeUserHome() throws InterruptedException {
void jStackDumpTest_dumpDirectoryNotExists_cannotBeCreatedTakeUserHome() {
final String dumpDirectory = dumpDirectoryCannotBeCreated();

URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory="
Expand All @@ -81,7 +81,7 @@ private String dumpDirectoryCannotBeCreated() {
}

@Test
void jStackDumpTest_dumpDirectoryNotExists_canBeCreated() throws InterruptedException {
void jStackDumpTest_dumpDirectoryNotExists_canBeCreated() {
final String dumpDirectory = UUID.randomUUID().toString();

URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ void getExecutor1() throws Exception {
}

@Test
void getExecutor2() throws Exception {
void getExecutor2() {
URL url = URL.valueOf("dubbo://10.20.130.230:20880/context/path?" + QUEUES_KEY + "=1");
ThreadPool threadPool = new CachedThreadPool();
ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor(url);
assertThat(executor.getQueue(), Matchers.<BlockingQueue<Runnable>>instanceOf(LinkedBlockingQueue.class));
}
}
}
Loading

0 comments on commit c15e0f3

Please sign in to comment.