From 214eaae3bab8dec1bb6141fea9cd09b67d0b2590 Mon Sep 17 00:00:00 2001 From: Chengyuan Zhang Date: Fri, 27 Sep 2019 11:10:47 -0700 Subject: [PATCH] android-interop-testing: remove settings for using GET via setting MethodDescriptor to safe (#6203) * Removed client interceptor that sets safe in method descriptor. * Removed useGet checkbox in UI. --- .../android/integrationtest/InteropTask.java | 14 ++------- .../integrationtest/TesterActivity.java | 30 +------------------ .../src/main/res/layout/activity_tester.xml | 5 ---- .../app/src/main/res/values/strings.xml | 1 - 4 files changed, 3 insertions(+), 47 deletions(-) diff --git a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/InteropTask.java b/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/InteropTask.java index d1d181df28..caeafb723d 100644 --- a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/InteropTask.java +++ b/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/InteropTask.java @@ -18,13 +18,11 @@ package io.grpc.android.integrationtest; import android.os.AsyncTask; import android.util.Log; -import io.grpc.ClientInterceptor; import io.grpc.ManagedChannel; import io.grpc.testing.integration.AbstractInteropTest; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.ref.WeakReference; -import java.util.List; import org.junit.AssumptionViolatedException; /** AsyncTask for interop test cases. */ @@ -44,11 +42,10 @@ final class InteropTask extends AsyncTask { InteropTask( Listener listener, ManagedChannel channel, - List interceptors, String testCase) { this.listenerReference = new WeakReference(listener); this.testCase = testCase; - this.tester = new Tester(channel, interceptors); + this.tester = new Tester(channel); } @Override @@ -149,11 +146,9 @@ final class InteropTask extends AsyncTask { private static class Tester extends AbstractInteropTest { private final ManagedChannel channel; - private final List interceptors; - private Tester(ManagedChannel channel, List interceptors) { + private Tester(ManagedChannel channel) { this.channel = channel; - this.interceptors = interceptors; } @Override @@ -161,11 +156,6 @@ final class InteropTask extends AsyncTask { return channel; } - @Override - protected ClientInterceptor[] getAdditionalInterceptors() { - return interceptors.toArray(new ClientInterceptor[0]); - } - @Override protected boolean metricsExpected() { return false; diff --git a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/TesterActivity.java b/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/TesterActivity.java index e365f048e5..4081439f23 100644 --- a/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/TesterActivity.java +++ b/android-interop-testing/app/src/main/java/io/grpc/android/integrationtest/TesterActivity.java @@ -29,16 +29,8 @@ import android.widget.CheckBox; import android.widget.EditText; import android.widget.TextView; import com.google.android.gms.security.ProviderInstaller; -import io.grpc.CallOptions; -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.ClientInterceptor; -import io.grpc.ClientInterceptors.CheckedForwardingClientCall; import io.grpc.ManagedChannel; -import io.grpc.Metadata; -import io.grpc.MethodDescriptor; import java.io.InputStream; -import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -50,7 +42,6 @@ public class TesterActivity extends AppCompatActivity private EditText hostEdit; private EditText portEdit; private TextView resultText; - private CheckBox getCheckBox; private CheckBox testCertCheckBox; @Override @@ -67,7 +58,6 @@ public class TesterActivity extends AppCompatActivity hostEdit = (EditText) findViewById(R.id.host_edit_text); portEdit = (EditText) findViewById(R.id.port_edit_text); resultText = (TextView) findViewById(R.id.grpc_response_text); - getCheckBox = (CheckBox) findViewById(R.id.get_checkbox); testCertCheckBox = (CheckBox) findViewById(R.id.test_cert_checkbox); ProviderInstaller.installIfNeededAsync(this, this); @@ -129,11 +119,7 @@ public class TesterActivity extends AppCompatActivity ManagedChannel channel = TesterOkHttpChannelBuilder.build(host, port, serverHostOverride, true, testCert); - List interceptors = new ArrayList<>(); - if (getCheckBox.isChecked()) { - interceptors.add(new SafeMethodChannelInterceptor()); - } - new InteropTask(this, channel, interceptors, testCase).execute(); + new InteropTask(this, channel, testCase).execute(); } @Override @@ -149,18 +135,4 @@ public class TesterActivity extends AppCompatActivity Log.w(LOG_TAG, "Failed installing security provider, error code: " + errorCode); enableButtons(true); } - - private static final class SafeMethodChannelInterceptor implements ClientInterceptor { - @Override - public ClientCall interceptCall( - MethodDescriptor method, CallOptions callOptions, Channel next) { - return new CheckedForwardingClientCall( - next.newCall(method.toBuilder().setSafe(true).build(), callOptions)) { - @Override - public void checkedStart(Listener responseListener, Metadata headers) { - delegate().start(responseListener, headers); - } - }; - } - } } diff --git a/android-interop-testing/app/src/main/res/layout/activity_tester.xml b/android-interop-testing/app/src/main/res/layout/activity_tester.xml index 1fd55dd835..f133933022 100644 --- a/android-interop-testing/app/src/main/res/layout/activity_tester.xml +++ b/android-interop-testing/app/src/main/res/layout/activity_tester.xml @@ -33,11 +33,6 @@ android:layout_height="wrap_content" android:orientation="horizontal" > - gRPC Integration Test - Use GET