Skip to content

Commit 7fc4ff4

Browse files
committed
fix it & apply spotless
1 parent 1a914b0 commit 7fc4ff4

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

messaging-wrappers/aliyun-mns-sdk/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ tasks {
3131
jvmArgs("-Dotel.logs.exporter=logging")
3232
}
3333
}
34+
35+
configurations.testRuntimeClasspath {
36+
resolutionStrategy {
37+
force("ch.qos.logback:logback-classic:1.2.12")
38+
force("org.slf4j:slf4j-api:1.7.35")
39+
}
40+
}

messaging-wrappers/aliyun-mns-sdk/src/test/java/io/opentelemetry/contrib/messaging/wrappers/mns/AliyunMnsSdkTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
99
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME;
1010
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_MESSAGE_BODY_SIZE;
11+
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_MESSAGE_ENVELOPE_SIZE;
1112
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_OPERATION;
1213
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_SYSTEM;
1314
import static org.assertj.core.api.Assertions.assertThat;
@@ -30,6 +31,7 @@
3031
import io.opentelemetry.contrib.messaging.wrappers.mns.semconv.MnsProcessRequest;
3132
import io.opentelemetry.contrib.messaging.wrappers.testing.AbstractBaseTest;
3233
import java.nio.charset.StandardCharsets;
34+
import org.apache.commons.codec.binary.Base64;
3335
import org.junit.jupiter.api.BeforeAll;
3436
import org.junit.jupiter.api.Test;
3537
import org.junit.jupiter.api.TestInstance;
@@ -140,11 +142,15 @@ public void assertTraces() {
140142
.hasKind(SpanKind.CONSUMER)
141143
.hasParent(trace.getSpan(0))
142144
.hasAttributesSatisfyingExactly(
143-
equalTo(MESSAGING_SYSTEM, "guava-eventbus"),
145+
equalTo(MESSAGING_SYSTEM, "smq"),
144146
equalTo(MESSAGING_DESTINATION_NAME, QUEUE),
145147
equalTo(
146148
MESSAGING_MESSAGE_BODY_SIZE,
147149
MESSAGE_BODY.getBytes(StandardCharsets.UTF_8).length),
150+
equalTo(
151+
MESSAGING_MESSAGE_ENVELOPE_SIZE,
152+
Base64.encodeBase64(MESSAGE_BODY.getBytes(StandardCharsets.UTF_8))
153+
.length),
148154
equalTo(MESSAGING_OPERATION, "process")),
149155
span ->
150156
span.hasName("process child")

messaging-wrappers/aliyun-mns-sdk/src/test/java/io/opentelemetry/contrib/messaging/wrappers/mns/broker/SmqMockedBroker.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,22 @@
4949
import org.springframework.web.bind.annotation.RequestParam;
5050

5151
@SpringBootApplication
52-
@SuppressWarnings({"JavaUtilDate", "LockNotBeforeTry", "SystemOut"})
52+
@SuppressWarnings({
53+
"JavaUtilDate",
54+
"LockNotBeforeTry",
55+
"SystemOut",
56+
"PrivateConstructorForUtilityClass"
57+
})
5358
public class SmqMockedBroker {
5459

5560
public static void main(String[] args) {
56-
System.out.println(System.getProperty("java.class.path"));
5761
SpringApplication.run(SmqMockedBroker.class, args);
5862
}
5963

6064
@Controller
6165
@Scope("singleton")
6266
public static class BrokerController {
63-
67+
6468
Lock queuesLock = new ReentrantLock();
6569

6670
Map<String, Deque<Message>> queues = new HashMap<>();
@@ -225,7 +229,4 @@ public ResponseEntity<Void> serveDeleteMessage(
225229
.build();
226230
}
227231
}
228-
229-
private SmqMockedBroker() {
230-
}
231232
}

messaging-wrappers/aliyun-mns-sdk/src/test/java/io/opentelemetry/contrib/messaging/wrappers/mns/broker/SmqUtils.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ public static String generateRandomMessageId() {
4141
}
4242

4343
public static String generateRandomRequestId() {
44-
return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 24).toUpperCase(Locale.ROOT);
44+
return UUID.randomUUID()
45+
.toString()
46+
.replaceAll("-", "")
47+
.substring(0, 24)
48+
.toUpperCase(Locale.ROOT);
4549
}
4650

4751
public static ErrorMessage createErrorMessage(String requestId) {
@@ -68,6 +72,5 @@ private static String bytesToHex(byte[] bytes) {
6872
return sb.toString();
6973
}
7074

71-
private SmqUtils() {
72-
}
75+
private SmqUtils() {}
7376
}

0 commit comments

Comments
 (0)