File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
src/test/java/io/opentelemetry/proto Expand file tree Collapse file tree 2 files changed +46
-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+
20+ isValidClass ("io.opentelemetry.proto.trace.v1.Span" );
21+ isValidClass ("io.opentelemetry.proto.metrics.v1.Metric" );
22+ isValidClass ("io.opentelemetry.proto.logs.v1.LogRecord" );
23+ }
24+
25+ private static void isValidClass (String fqcn ) {
26+ Class <?> clazz = null ;
27+ try {
28+ clazz = Class .forName (fqcn );
29+ } catch (ClassNotFoundException e ) {
30+ fail (e .getMessage ());
31+ }
32+ Field [] declaredFields = clazz .getDeclaredFields ();
33+ Class <?>[] declaredClasses = clazz .getDeclaredClasses ();
34+ boolean hasFieldsOrInnerClasses =
35+ (declaredFields != null && declaredFields .length > 0 )
36+ || (declaredClasses != null && declaredClasses .length > 0 );
37+ assertThat (hasFieldsOrInnerClasses ).withFailMessage (() -> fqcn + " is empty" ).isTrue ();
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments