|
| 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.After; |
| 20 | +import org.junit.Before; |
| 21 | +import org.junit.Test; |
| 22 | +import org.junit.runner.RunWith; |
| 23 | +import org.junit.runners.JUnit4; |
| 24 | + |
| 25 | +import java.io.ByteArrayOutputStream; |
| 26 | +import java.io.PrintStream; |
| 27 | + |
| 28 | +/** |
| 29 | + * Integration (system) tests for {@link Quickstart}. |
| 30 | + */ |
| 31 | +@RunWith(JUnit4.class) |
| 32 | +@SuppressWarnings("checkstyle:abbreviationaswordinname") |
| 33 | +public class QuickstartIT { |
| 34 | + |
| 35 | + private ByteArrayOutputStream bout; |
| 36 | + private PrintStream out; |
| 37 | + |
| 38 | + @Before |
| 39 | + public void setUp() throws Exception { |
| 40 | + bout = new ByteArrayOutputStream(); |
| 41 | + out = new PrintStream(bout); |
| 42 | + System.setOut(out); |
| 43 | + } |
| 44 | + |
| 45 | + @After |
| 46 | + public void tearDown() { |
| 47 | + System.setOut(null); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + public void main_printsKeyrings() throws Exception { |
| 52 | + Quickstart.main("foo"); |
| 53 | + String stdout = bout.toString(); |
| 54 | + |
| 55 | + assertThat(stdout).contains("jerjou"); |
| 56 | + } |
| 57 | +} |
0 commit comments