Skip to content

Commit 85e27ea

Browse files
author
liukang
committed
Merge branch 'master' into retry-kafka
2 parents 71658a7 + 6b90e16 commit 85e27ea

File tree

10 files changed

+229
-9
lines changed

10 files changed

+229
-9
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ subprojects {
794794
dependency "javax.annotation:javax.annotation-api:1.3.2"
795795
dependency "com.alibaba.fastjson2:fastjson2:2.0.52"
796796

797-
dependency "software.amazon.awssdk:s3:2.27.17"
797+
dependency "software.amazon.awssdk:s3:2.28.12"
798798
dependency "com.github.rholder:guava-retrying:2.0.0"
799799

800800
dependency "com.alibaba:druid-spring-boot-starter:1.2.23"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.eventmesh.common.stubs;
19+
20+
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
21+
import org.apache.eventmesh.common.protocol.http.header.Header;
22+
import org.apache.eventmesh.common.utils.HttpConvertsUtils;
23+
24+
import java.util.Map;
25+
26+
public class HeaderStub extends Header {
27+
28+
public String code;
29+
public String eventmeshenv;
30+
31+
@Override
32+
public Map<String, Object> toMap() {
33+
return new HttpConvertsUtils().httpMapConverts(this, new ProtocolKey(), new ProtocolKey.EventMeshInstanceKey());
34+
}
35+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.eventmesh.common.utils;
19+
20+
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
21+
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey.EventMeshInstanceKey;
22+
import org.apache.eventmesh.common.protocol.http.header.Header;
23+
import org.apache.eventmesh.common.stubs.HeaderStub;
24+
25+
import java.util.HashMap;
26+
import java.util.Map;
27+
28+
import org.junit.jupiter.api.Assertions;
29+
import org.junit.jupiter.api.Test;
30+
31+
class HttpConvertsUtilsTest {
32+
33+
private final HeaderStub headerStub = new HeaderStub();
34+
private final ProtocolKey mockedProtocolKey = new ProtocolKey();
35+
private final EventMeshInstanceKey mockedEventMeshProtocolKey = new EventMeshInstanceKey();
36+
37+
@Test
38+
void httpMapConverts() {
39+
Map<String, Object> httpMapConverts = new HttpConvertsUtils().httpMapConverts(headerStub, mockedProtocolKey);
40+
Assertions.assertEquals(httpMapConverts.get(headerStub.code), headerStub.code);
41+
}
42+
43+
@Test
44+
void testHttpMapConverts() {
45+
Map<String, Object> httpMapConverts = new HttpConvertsUtils().httpMapConverts(headerStub, mockedProtocolKey, mockedEventMeshProtocolKey);
46+
Assertions.assertEquals(httpMapConverts.get(headerStub.code), headerStub.code);
47+
Assertions.assertEquals(httpMapConverts.get(headerStub.eventmeshenv), headerStub.eventmeshenv);
48+
}
49+
50+
@Test
51+
void httpHeaderConverts() {
52+
HashMap<String, Object> headerParams = new HashMap<>();
53+
String code = "test";
54+
headerParams.put("code", code);
55+
Header header = new HttpConvertsUtils().httpHeaderConverts(headerStub, headerParams);
56+
Assertions.assertEquals(code, header.toMap().get("code"));
57+
}
58+
59+
@Test
60+
void testHttpHeaderConverts() {
61+
HashMap<String, Object> headerParams = new HashMap<>();
62+
String env = "test";
63+
headerParams.put("eventmeshenv", env);
64+
Header header = new HttpConvertsUtils().httpHeaderConverts(headerStub, headerParams, mockedEventMeshProtocolKey);
65+
Assertions.assertEquals(env, header.toMap().get("eventmeshenv"));
66+
}
67+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
19+
package org.apache.eventmesh.common.utils;
20+
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertThrows;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
25+
import java.util.concurrent.TimeUnit;
26+
27+
import org.junit.jupiter.api.Test;
28+
29+
class ThreadUtilsTest {
30+
31+
@Test
32+
void testRandomPauseBetweenMinAndMax() {
33+
34+
long min = 1000;
35+
long max = 5000;
36+
37+
long start = System.currentTimeMillis();
38+
ThreadUtils.randomPause(min, max, TimeUnit.MILLISECONDS);
39+
long end = System.currentTimeMillis();
40+
41+
long pause = end - start;
42+
43+
assertTrue(pause >= min && pause <= max, "Pause time should be between min and max");
44+
}
45+
46+
@Test
47+
void testRandomPauseWithInterruption() {
48+
49+
Thread.currentThread().interrupt();
50+
ThreadUtils.randomPause(1000, 2000, TimeUnit.MILLISECONDS);
51+
assertTrue(Thread.currentThread().isInterrupted());
52+
}
53+
54+
@Test
55+
void testDeprecatedSleep() {
56+
57+
ThreadUtils.sleep(1000);
58+
assertTrue(true, "Method should execute without any exception");
59+
}
60+
61+
@Test
62+
void testSleepWithTimeOutAndTimeUnit() throws InterruptedException {
63+
64+
ThreadUtils.sleepWithThrowException(5000, TimeUnit.MILLISECONDS);
65+
assertTrue(true, "Method should execute without any exception");
66+
}
67+
68+
@Test
69+
void testSleepWithNullTimeUnit() throws InterruptedException {
70+
71+
ThreadUtils.sleepWithThrowException(5000, null);
72+
assertTrue(true, "Method should not throw any exception with null TimeUnit");
73+
}
74+
75+
@Test
76+
void testSleepWithThrowExceptionInterruption() {
77+
Thread.currentThread().interrupt();
78+
79+
assertThrows(InterruptedException.class, () -> {
80+
ThreadUtils.sleepWithThrowException(5000, TimeUnit.MILLISECONDS);
81+
});
82+
}
83+
84+
@Test
85+
void testGetPIDWithRealProcessId() {
86+
87+
long pid = ThreadUtils.getPID();
88+
assertTrue(pid > 0);
89+
90+
long cashedPId = ThreadUtils.getPID();
91+
assertEquals(pid, cashedPId);
92+
}
93+
94+
@Test
95+
void testGetPIDWithMultiThread() throws InterruptedException {
96+
97+
final long[] pid1 = new long[1];
98+
final long[] pid2 = new long[1];
99+
100+
Thread thread1 = new Thread(() -> {
101+
pid1[0] = ThreadUtils.getPID();
102+
assertTrue(pid1[0] > 0);
103+
});
104+
105+
Thread thread2 = new Thread(() -> {
106+
pid2[0] = ThreadUtils.getPID();
107+
assertTrue(pid2[0] > 0);
108+
});
109+
110+
thread1.start();
111+
thread2.start();
112+
113+
thread1.join();
114+
thread2.join();
115+
116+
assertEquals(pid1[0], pid2[0]);
117+
}
118+
}

eventmesh-connectors/eventmesh-connector-http/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ dependencies {
2525
implementation 'dev.failsafe:failsafe:3.3.2'
2626

2727

28-
testImplementation 'org.apache.httpcomponents.client5:httpclient5:5.3.1'
29-
testImplementation 'org.apache.httpcomponents.client5:httpclient5-fluent:5.3.1'
28+
testImplementation 'org.apache.httpcomponents.client5:httpclient5:5.4'
29+
testImplementation 'org.apache.httpcomponents.client5:httpclient5-fluent:5.4'
3030
testImplementation 'org.mock-server:mockserver-netty:5.15.0'
3131
compileOnly 'org.projectlombok:lombok'
3232
annotationProcessor 'org.projectlombok:lombok'

eventmesh-connectors/eventmesh-connector-rabbitmq/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies {
2020
api project(":eventmesh-openconnect:eventmesh-openconnect-java")
2121
implementation project(":eventmesh-common")
2222
// rabbitmq
23-
implementation 'com.rabbitmq:amqp-client:5.21.0'
23+
implementation 'com.rabbitmq:amqp-client:5.22.0'
2424

2525
implementation 'io.cloudevents:cloudevents-json-jackson'
2626

eventmesh-connectors/eventmesh-connector-redis/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies {
1919
implementation project(":eventmesh-common")
2020
implementation project(":eventmesh-openconnect:eventmesh-openconnect-java")
2121

22-
implementation 'org.redisson:redisson:3.35.0'
22+
implementation 'org.redisson:redisson:3.36.0'
2323

2424
api 'io.cloudevents:cloudevents-json-jackson'
2525

eventmesh-storage-plugin/eventmesh-storage-rabbitmq/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ dependencies {
1919
implementation project(":eventmesh-storage-plugin:eventmesh-storage-api")
2020
implementation project(":eventmesh-common")
2121
// rabbitmq
22-
implementation 'com.rabbitmq:amqp-client:5.21.0'
22+
implementation 'com.rabbitmq:amqp-client:5.22.0'
2323

2424
testImplementation project(":eventmesh-storage-plugin:eventmesh-storage-api")
2525
testImplementation project(":eventmesh-common")
2626
// rabbitmq
27-
testImplementation 'com.rabbitmq:amqp-client:5.21.0'
27+
testImplementation 'com.rabbitmq:amqp-client:5.22.0'
2828

2929
implementation 'io.cloudevents:cloudevents-json-jackson'
3030
testImplementation 'io.cloudevents:cloudevents-json-jackson'

eventmesh-storage-plugin/eventmesh-storage-redis/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies {
2020
implementation project(":eventmesh-storage-plugin:eventmesh-storage-api")
2121

2222
// redisson
23-
implementation 'org.redisson:redisson:3.35.0'
23+
implementation 'org.redisson:redisson:3.36.0'
2424

2525
// netty
2626
implementation 'io.netty:netty-all'

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
plugins {
19-
id 'com.gradle.develocity' version '3.17.5'
19+
id 'com.gradle.develocity' version '3.18.1'
2020
id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.2'
2121
}
2222

0 commit comments

Comments
 (0)