mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-17 18:02:05 +01:00
Add test for PGPainlessCLI main class
This commit is contained in:
parent
82536eaa77
commit
af6fe0aaf7
1 changed files with 50 additions and 0 deletions
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2021 Paul Schaub.
|
||||
*
|
||||
* 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 org.pgpainless.sop;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MainClassTest {
|
||||
|
||||
private static OutputStream originalSout;
|
||||
|
||||
@BeforeAll
|
||||
public static void saveOriginalSout() {
|
||||
originalSout = System.out;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMainByVersionCommand() {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
System.setOut(new PrintStream(out));
|
||||
PGPainlessCLI.main(new String[] {"version"});
|
||||
String version = out.toString();
|
||||
assertTrue(version.startsWith("PGPainlessCLI"));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void restoreOriginalSout() {
|
||||
System.setOut(new PrintStream(originalSout));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue