diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index a9c2d2bca0..1f66eb7d95 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -372,6 +372,12 @@ jobs:
mvn clean verify -P '!showcase,enable-integration-tests,loggingTestBase,disabledLogging' \
--batch-mode \
--no-transfer-progress
+ - name: Showcase integration tests - Protobuf 3 compatibility with third party library Tensorflow
+ working-directory: java-showcase
+ run: |
+ mvn clean verify -P 'enable-integration-tests,protobuf3,showcase' \
+ --batch-mode \
+ --no-transfer-progress
showcase-clirr:
if: ${{ github.base_ref != '' }} # Only execute on pull_request trigger event
diff --git a/java-showcase/gapic-showcase/pom.xml b/java-showcase/gapic-showcase/pom.xml
index a9e4de22fe..feeead440b 100644
--- a/java-showcase/gapic-showcase/pom.xml
+++ b/java-showcase/gapic-showcase/pom.xml
@@ -201,6 +201,14 @@
test
+
+
+ org.tensorflow
+ tensorflow-core-platform
+ 1.1.0
+ test
+
+
io.opentelemetry
@@ -361,6 +369,25 @@
+
+ protobuf3
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ **/com/google/showcase/v1beta1/it/logging/*.java
+
+
+ **/com/google/showcase/v1beta1/it/ITProtobuf3Compatibility.java
+
+
+
+
+
+
diff --git a/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITProtobuf3Compatibility.java b/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITProtobuf3Compatibility.java
new file mode 100644
index 0000000000..04582fe7fe
--- /dev/null
+++ b/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITProtobuf3Compatibility.java
@@ -0,0 +1,67 @@
+package com.google.showcase.v1beta1.it;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import org.junit.jupiter.api.Test;
+import org.tensorflow.Graph;
+import org.tensorflow.Session;
+import org.tensorflow.op.Ops;
+import org.tensorflow.op.core.Constant;
+import org.tensorflow.op.math.Add;
+import org.tensorflow.proto.GraphDef;
+import org.tensorflow.types.TInt32;
+
+/**
+ * Tensorflow depends on protobuf 3.x gen code and runtime, we test it in showcase module to prove
+ * that it works with protobuf 4.33+ gen code and runtime that comes with client libraries.
+ */
+class ITProtobuf3Compatibility {
+
+ @Test
+ void testTensorflow_helloWorldExample() {
+ try (Graph graph = new Graph()) {
+ // Hello world example for "10 + 32" operation.
+ Ops tf = Ops.create(graph);
+
+ int expectedValue1 = 10;
+ int expectedValue2 = 32;
+ int expectedSum = 42;
+
+ String name1 = "constant1";
+ String name2 = "constant2";
+
+ Constant constant1 = tf.withName(name1).constant(expectedValue1);
+ Constant constant2 = tf.withName(name2).constant(expectedValue2);
+
+ Add sum = tf.math.add(constant1, constant2);
+
+ try (Session s = new Session(graph)) {
+ try (TInt32 result = (TInt32) s.runner().fetch(sum).run().get(0)) {
+ int actualResult = result.getInt();
+ assertThat(actualResult).isEqualTo(expectedSum);
+ }
+ }
+
+ // GraphDef is a protobuf gen code.
+ GraphDef graphDef = graph.toGraphDef();
+
+ // Inspect the protobuf gen code
+ Integer actual1 = getValueFromGraphDefByName(graphDef, name1);
+ Integer actual2 = getValueFromGraphDefByName(graphDef, name2);
+
+ assertThat(actual1).isEqualTo(expectedValue1);
+ assertThat(actual2).isEqualTo(expectedValue2);
+ }
+ }
+
+ private static Integer getValueFromGraphDefByName(GraphDef graphDef, String name1) {
+ return graphDef.getNodeList().stream()
+ .filter(nodeDef -> nodeDef.getName().equals(name1))
+ .findFirst()
+ .get()
+ .getAttrOrThrow("value")
+ .getTensor()
+ .getIntValList()
+ .get(0);
+ }
+}
diff --git a/java-showcase/pom.xml b/java-showcase/pom.xml
index 303c69e575..bda530a2b3 100644
--- a/java-showcase/pom.xml
+++ b/java-showcase/pom.xml
@@ -79,6 +79,7 @@
**/com/google/showcase/v1beta1/it/logging/*.java
+ **/com/google/showcase/v1beta1/it/ITProtobuf3Compatibility.java
@@ -120,6 +121,7 @@
**/com/google/showcase/v1beta1/it/logging/*.java
+ **/com/google/showcase/v1beta1/it/ITProtobuf3Compatibility.java