From 315cbb5c95eca208e40734a2ed16562907777e8b Mon Sep 17 00:00:00 2001 From: Praful Makani Date: Fri, 17 Jul 2020 11:39:27 +0530 Subject: [PATCH] docs(samples): modified code and remove deps --- samples/install-without-bom/pom.xml | 6 -- samples/snapshot/pom.xml | 6 -- samples/snippets/pom.xml | 6 -- .../com/example/bigquery/AuthUserFlowIT.java | 75 ----------------- .../com/example/bigquery/AuthUserQueryIT.java | 80 ------------------- 5 files changed, 173 deletions(-) delete mode 100644 samples/snippets/src/test/java/com/example/bigquery/AuthUserFlowIT.java delete mode 100644 samples/snippets/src/test/java/com/example/bigquery/AuthUserQueryIT.java diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index f96093eb4..52cae17a2 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -72,12 +72,6 @@ 1.0.1 test - - com.google.cloud - google-cloud-nio - 0.121.2 - test - diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 22f2e5a0e..31c5bcc22 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -70,12 +70,6 @@ 1.0.1 test - - com.google.cloud - google-cloud-nio - 0.121.2 - test - diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index fcb16b573..632f01667 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -82,12 +82,6 @@ 1.0.1 test - - com.google.cloud - google-cloud-nio - 0.121.2 - test - diff --git a/samples/snippets/src/test/java/com/example/bigquery/AuthUserFlowIT.java b/samples/snippets/src/test/java/com/example/bigquery/AuthUserFlowIT.java deleted file mode 100644 index abdc867c2..000000000 --- a/samples/snippets/src/test/java/com/example/bigquery/AuthUserFlowIT.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.bigquery; - -import static com.google.common.truth.Truth.assertThat; -import static junit.framework.TestCase.assertNotNull; - -import com.google.cloud.storage.contrib.nio.CloudStorageFileSystem; -import com.google.common.collect.ImmutableList; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.nio.file.Path; -import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class AuthUserFlowIT { - - private ByteArrayOutputStream bout; - private PrintStream out; - - private static final String GCS_BUCKET = System.getenv("GCS_BUCKET"); - - private static String requireEnvVar(String varName) { - String value = System.getenv(varName); - assertNotNull( - "Environment variable " + varName + " is required to perform these tests.", - System.getenv(varName)); - return value; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GCS_BUCKET"); - } - - @Before - public void setUp() { - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - System.setOut(out); - } - - @After - public void tearDown() { - System.setOut(null); - } - - @Test - public void testAuthUserFlow() throws IOException { - try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket(GCS_BUCKET)) { - Path credentialsPath = fs.getPath("client_secret.json"); - List scopes = ImmutableList.of("https://www.googleapis.com/auth/bigquery"); - AuthUserFlow.authUserFlow(credentialsPath, scopes); - } - assertThat(bout.toString()).contains("Success! Dataset ID"); - } -} diff --git a/samples/snippets/src/test/java/com/example/bigquery/AuthUserQueryIT.java b/samples/snippets/src/test/java/com/example/bigquery/AuthUserQueryIT.java deleted file mode 100644 index 30c77451e..000000000 --- a/samples/snippets/src/test/java/com/example/bigquery/AuthUserQueryIT.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.bigquery; - -import static com.google.common.truth.Truth.assertThat; -import static junit.framework.TestCase.assertNotNull; - -import com.google.cloud.storage.contrib.nio.CloudStorageFileSystem; -import com.google.common.collect.ImmutableList; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.nio.file.Path; -import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class AuthUserQueryIT { - - private ByteArrayOutputStream bout; - private PrintStream out; - - private static final String GCS_BUCKET = System.getenv("GCS_BUCKET"); - - private static String requireEnvVar(String varName) { - String value = System.getenv(varName); - assertNotNull( - "Environment variable " + varName + " is required to perform these tests.", - System.getenv(varName)); - return value; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GCS_BUCKET"); - } - - @Before - public void setUp() { - bout = new ByteArrayOutputStream(); - out = new PrintStream(bout); - System.setOut(out); - } - - @After - public void tearDown() { - System.setOut(null); - } - - @Test - public void testAuthUserQuery() throws IOException { - try (CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket(GCS_BUCKET)) { - Path credentialsPath = fs.getPath("client_secret.json"); - List scopes = ImmutableList.of("https://www.googleapis.com/auth/bigquery"); - String query = - "SELECT name, SUM(number) as total" - + " FROM `bigquery-public-data.usa_names.usa_1910_current`" - + " WHERE name = 'William'" - + " GROUP BY name;"; - AuthUserQuery.authUserQuery(credentialsPath, scopes, query); - } - assertThat(bout.toString()).contains("Query performed successfully."); - } -}