File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
src/test/java/io/opentelemetry/proto Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ dependencies {
44
44
compileOnly(" io.grpc:grpc-api:$grpcVersion " )
45
45
compileOnly(" io.grpc:grpc-protobuf:$grpcVersion " )
46
46
compileOnly(" io.grpc:grpc-stub:$grpcVersion " )
47
+
48
+ testImplementation(" org.junit.jupiter:junit-jupiter:5.11.4" )
49
+ testImplementation(" org.assertj:assertj-core:3.27.3" )
47
50
}
48
51
49
52
protobuf {
@@ -76,6 +79,10 @@ var protoVersion = if (properties.contains(
76
79
val protoArchive = file(" $buildDir /archives/opentelemetry-proto-$protoVersion .zip" )
77
80
78
81
tasks {
82
+ test {
83
+ useJUnitPlatform()
84
+ }
85
+
79
86
val downloadProtoArchive by registering(Download ::class ) {
80
87
onlyIf { ! protoArchive.exists() }
81
88
src(" https://github.com/open-telemetry/opentelemetry-proto/archive/v$protoVersion .zip" )
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ package io .opentelemetry .proto ;
7
+
8
+ import static org .assertj .core .api .Assertions .assertThat ;
9
+ import static org .assertj .core .api .Assertions .fail ;
10
+
11
+ import java .lang .reflect .Field ;
12
+ import org .junit .jupiter .api .Test ;
13
+
14
+ /** A placeholder test which verifies that the generated classes compile and can load. */
15
+ public class AvailabilityTest {
16
+
17
+ @ Test
18
+ void available () {
19
+ isValidClass ("io.opentelemetry.proto.trace.v1.Span" );
20
+ isValidClass ("io.opentelemetry.proto.metrics.v1.Metric" );
21
+ isValidClass ("io.opentelemetry.proto.logs.v1.LogRecord" );
22
+ }
23
+
24
+ private static void isValidClass (String fqcn ) {
25
+ Class <?> clazz = null ;
26
+ try {
27
+ clazz = Class .forName (fqcn );
28
+ } catch (ClassNotFoundException e ) {
29
+ fail (e .getMessage ());
30
+ }
31
+ Field [] declaredFields = clazz .getDeclaredFields ();
32
+ Class <?>[] declaredClasses = clazz .getDeclaredClasses ();
33
+ boolean hasFieldsOrInnerClasses =
34
+ (declaredFields != null && declaredFields .length > 0 )
35
+ || (declaredClasses != null && declaredClasses .length > 0 );
36
+ assertThat (hasFieldsOrInnerClasses ).withFailMessage (() -> fqcn + " is empty" ).isTrue ();
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments