Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2016 Google LLC

This comment was marked as spam.

*
* 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.google.cloud.testing;

public interface SmokeTest {}

5 changes: 5 additions & 0 deletions google-cloud-dlp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2018 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
*
* https://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.google.cloud.dlp.v2beta1;

import com.google.privacy.dlp.v2beta1.ContentItem;
import com.google.privacy.dlp.v2beta1.InspectConfig;
import com.google.privacy.dlp.v2beta1.InspectContentResponse;
import com.google.privacy.dlp.v2beta1.Likelihood;
import com.google.cloud.testing.SmokeTest;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.junit.Test;
import org.junit.experimental.categories.Category;


@Category(SmokeTest.class)
@javax.annotation.Generated("by GAPIC")
public class DlpServiceSmokeTest {
@Test
public void run() {
main(null);
}

public static void main(String args[]) {
Logger.getLogger("").setLevel(Level.WARNING);
try {
executeNoCatch();
System.out.println("OK");
} catch (Exception e) {
System.err.println("Failed with exception:");
e.printStackTrace(System.err);
System.exit(1);
}
}

public static void executeNoCatch() throws Exception {
try (DlpServiceClient client = DlpServiceClient.create()) {
Likelihood minLikelihood = Likelihood.POSSIBLE;
InspectConfig inspectConfig =
InspectConfig.newBuilder().setMinLikelihood(minLikelihood).build();
String type = "text/plain";
String value = "my phone number is 215-512-1212";
ContentItem itemsElement = ContentItem.newBuilder().setType(type).setValue(value).build();
List<ContentItem> items = Arrays.asList(itemsElement);

InspectContentResponse response = client.inspectContent(inspectConfig, items);
System.out.println(
ReflectionToStringBuilder.toString(response, ToStringStyle.MULTI_LINE_STYLE));
}
}
}
10 changes: 10 additions & 0 deletions google-cloud-pubsub/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* Copyright 2018 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
*
* https://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.google.cloud.pubsub.v1;

import static com.google.cloud.pubsub.v1.TopicAdminClient.ListTopicsPagedResponse;

import com.google.common.base.Preconditions;
import com.google.pubsub.v1.ProjectName;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.google.cloud.testing.SmokeTest;
import org.junit.experimental.categories.Category;
import org.junit.Test;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;



@Category(SmokeTest.class)
@javax.annotation.Generated("by GAPIC")
public class TopicAdminSmokeTest {
@Test
public void run() {
Logger.getLogger("").setLevel(Level.WARNING);
try {
String projectId = getProjectId();
executeNoCatch(projectId);
System.out.println("OK");
} catch (Exception e) {
System.err.println("Failed with exception:");
e.printStackTrace(System.err);
System.exit(1);
}
}

public static void main(String args[]) {
Logger.getLogger("").setLevel(Level.WARNING);
try {
String projectId = getProjectId();
if (projectId == null) {
projectId = tryParseProjectIdFromCmdline(args);
}
executeNoCatch(projectId);
System.out.println("OK");
} catch (Exception e) {
System.err.println("Failed with exception:");
e.printStackTrace(System.err);
System.exit(1);
}
}

public static void executeNoCatch(String projectId) throws Exception {
Preconditions.checkArgument(projectId != null, "A project ID is required.");
try (TopicAdminClient client = TopicAdminClient.create()) {
ProjectName project = ProjectName.of(projectId);

ListTopicsPagedResponse pagedResponse = client.listTopics(project);
System.out.println(pagedResponse.toString());
}
}

private static String tryParseProjectIdFromCmdline(String args[]) {
try {
Options options = new Options();
options.addOption("h", "help", false, "show usage");
options.addOption(
Option.builder()
.longOpt("project_id")
.desc("Project id")
.hasArg()
.argName("PROJECT-ID")
.required(true)
.build());
CommandLine cl = (new DefaultParser()).parse(options, args);
if (cl.hasOption("help")) {
HelpFormatter formater = new HelpFormatter();
formater.printHelp("TopicAdminSmokeTest", options);
}
return cl.getOptionValue("project_id");
} catch (Exception e) {
System.err.println("Failed with exception:");
e.printStackTrace(System.err);
System.exit(1);
}
return "";
}

private static String getProjectId() {
final String PROJECT_ENV_NAME = "GOOGLE_CLOUD_PROJECT";
final String LEGACY_PROJECT_ENV_NAME = "GCLOUD_PROJECT";
String projectId = System.getProperty(PROJECT_ENV_NAME, System.getenv(PROJECT_ENV_NAME));
if (projectId == null) {
projectId =
System.getProperty(LEGACY_PROJECT_ENV_NAME, System.getenv(LEGACY_PROJECT_ENV_NAME));
}
return projectId;
}
}
57 changes: 50 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
Expand Down Expand Up @@ -355,6 +355,16 @@
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
Expand Down Expand Up @@ -429,12 +439,6 @@

<module>google-cloud-util</module>
<module>google-cloud</module>

<!--
Uncomment the following lines to include google app engine (GAE) testing apps in the build.
Each GAE app packages all its dependencies in a fat war (>20MB each).
-->
<!--<module>google-cloud-testing</module>-->
</modules>
<pluginRepositories>
<pluginRepository>
Expand Down Expand Up @@ -865,5 +869,44 @@
</plugins>
</build>
</profile>

<profile>
<!-- for smoke test -->
<id>smoke-test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/*SmokeTest.java</include>
</includes>
<excludes>
<exclude>**/*IT.java</exclude>
</excludes>
<groups>com.google.cloud.testing.SmokeTest</groups>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Disable unit tests -->
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>