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 {
4444 compileOnly(" io.grpc:grpc-api:$grpcVersion " )
4545 compileOnly(" io.grpc:grpc-protobuf:$grpcVersion " )
4646 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" )
4750}
4851
4952protobuf {
@@ -76,6 +79,10 @@ var protoVersion = if (properties.contains(
7679val protoArchive = file(" $buildDir /archives/opentelemetry-proto-$protoVersion .zip" )
7780
7881tasks {
82+ test {
83+ useJUnitPlatform()
84+ }
85+
7986 val downloadProtoArchive by registering(Download ::class ) {
8087 onlyIf { ! protoArchive.exists() }
8188 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