Skip to content

Commit 6041e31

Browse files
author
Jerjou Cheng
committed
Add Quickstart test.
1 parent 5a55784 commit 6041e31

File tree

2 files changed

+73
-4
lines changed

2 files changed

+73
-4
lines changed

kms/pom.xml

+2-4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262

6363
<properties>
6464
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
65+
<maven.compiler.source>1.7</maven.compiler.source>
66+
<maven.compiler.target>1.7</maven.compiler.target>
6567
</properties>
6668

6769
<build>
@@ -71,10 +73,6 @@
7173
<groupId>org.apache.maven.plugins</groupId>
7274
<artifactId>maven-compiler-plugin</artifactId>
7375
<version>3.2</version>
74-
<configuration>
75-
<source>5</source>
76-
<target>5</target>
77-
</configuration>
7876
</plugin>
7977
<plugin>
8078
<artifactId>maven-assembly-plugin</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2017 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
15+
package com.example;
16+
17+
import static com.google.common.truth.Truth.assertThat;
18+
19+
import org.junit.AfterClass;
20+
import org.junit.Before;
21+
import org.junit.BeforeClass;
22+
import org.junit.Test;
23+
import org.junit.runner.RunWith;
24+
import org.junit.runners.JUnit4;
25+
26+
import java.io.ByteArrayOutputStream;
27+
import java.io.PrintStream;
28+
29+
/**
30+
* Integration (system) tests for {@link Quickstart}.
31+
*/
32+
@RunWith(JUnit4.class)
33+
@SuppressWarnings("checkstyle:abbreviationaswordinname")
34+
public class QuickstartIT {
35+
36+
private ByteArrayOutputStream bout;
37+
private PrintStream out;
38+
39+
@BeforeClass
40+
public static void setUpClass() throws Exception {
41+
SnippetsIT.setUpClass();
42+
ByteArrayOutputStream bout = new ByteArrayOutputStream();
43+
PrintStream out = new PrintStream(bout);
44+
System.setOut(out);
45+
}
46+
47+
/**
48+
* Destroys all the keys created during this test run.
49+
*/
50+
@AfterClass
51+
public static void tearDownClass() throws Exception {
52+
SnippetsIT.tearDownClass();
53+
}
54+
55+
@Before
56+
public void setUp() throws Exception {
57+
bout = new ByteArrayOutputStream();
58+
out = new PrintStream(bout);
59+
System.setOut(out);
60+
61+
Snippets.createCryptoKeyVersion(
62+
SnippetsIT.PROJECT_ID, SnippetsIT.KEY_RING_ID, SnippetsIT.CRYPTO_KEY_ID);
63+
}
64+
65+
@Test
66+
public void listKeyRings_printsKeyRing() throws Exception {
67+
Quickstart.main(SnippetsIT.PROJECT_ID);
68+
69+
assertThat(bout.toString()).contains(String.format("keyRings/%s", SnippetsIT.KEY_RING_ID));
70+
}
71+
}

0 commit comments

Comments
 (0)