use of com.ginsberg.junit.exit.ExpectSystemExitWithStatus in project SchemaCrawler by schemacrawler.
the class SqliteCommandlineTest method testSqliteMainMissingDatabase.
@Test
@ExpectSystemExitWithStatus(1)
public void testSqliteMainMissingDatabase() throws Exception {
final Path sqliteDbFile = Paths.get(System.getProperty("java.io.tmpdir"), RandomStringUtils.randomAlphanumeric(12).toLowerCase() + ".db");
assertThat("SQLite database should exist before the test", sqliteDbFile.toFile(), not(anExistingFile()));
final Map<String, String> argsMap = new HashMap<>();
argsMap.put("--server", "sqlite");
argsMap.put("--database", sqliteDbFile.toString());
argsMap.put("--no-info", Boolean.TRUE.toString());
argsMap.put("--command", "list");
argsMap.put("--info-level", InfoLevel.minimum.name());
try {
Main.main(flattenCommandlineArgs(argsMap));
} catch (final SystemExitPreventedException e) {
assertThat("An empty SQLite database should not be created when SchemaCrawler connects", sqliteDbFile.toFile(), not(anExistingFile()));
final int exitCode = e.getStatusCode();
assertThat(exitCode, is(1));
}
}
use of com.ginsberg.junit.exit.ExpectSystemExitWithStatus in project SchemaCrawler by schemacrawler.
the class MetadataRetrievalStrategyTest method overrideMetadataRetrievalStrategyDataDictionary.
@Test
@ExpectSystemExitWithStatus(1)
public void overrideMetadataRetrievalStrategyDataDictionary(final TestContext testContext, final DatabaseConnectionInfo connectionInfo) throws Exception {
final SchemaTextDetailType schemaTextDetailType = SchemaTextDetailType.schema;
final InfoLevel infoLevel = InfoLevel.minimum;
final OutputFormat outputFormat = TextOutputFormat.text;
final Map<String, Object> config = new HashMap<>();
config.put("schemacrawler.schema.retrieval.strategy.tables", MetadataRetrievalStrategy.data_dictionary_all.name());
final Map<String, String> argsMap = new HashMap<>();
argsMap.put("--info-level", infoLevel.name());
// Check that System.err has an error, since the SQL for retrieving tables was not provided
try {
assertThat(outputOf(commandlineExecution(connectionInfo, schemaTextDetailType.name(), argsMap, config, outputFormat)), hasNoContent());
} catch (final SystemExitPreventedException e) {
// Continue execution
}
assertThat(outputOf(err), hasSameContentAs(classpathResource(METADATA_RETRIEVAL_STRATEGY_OUTPUT + testContext.testMethodName() + ".stderr.txt")));
}
use of com.ginsberg.junit.exit.ExpectSystemExitWithStatus in project SchemaCrawler by schemacrawler.
the class ShellCommandsTest method exit.
@Test
@ExpectSystemExitWithStatus(0)
public void exit(final TestContext testContext) {
new ExitCommand().run();
assertThat(outputOf(err), hasNoContent());
assertThat(outputOf(out), hasNoContent());
}
use of com.ginsberg.junit.exit.ExpectSystemExitWithStatus in project keycloak-config-cli by adorsys.
the class CommandLineImportFilesIT method testImportDirectory.
@Test
@ExpectSystemExitWithStatus(0)
void testImportDirectory() {
KeycloakConfigApplication.main(new String[] { "--keycloak.sslVerify=false", "--import.path=src/test/resources/import-files/cli/dir/" });
RealmRepresentation file1Realm = keycloakProvider.getInstance().realm("file1").toRepresentation();
assertThat(file1Realm.getRealm(), is("file1"));
assertThat(file1Realm.isEnabled(), is(true));
RealmRepresentation file2Realm = keycloakProvider.getInstance().realm("file2").toRepresentation();
assertThat(file2Realm.getRealm(), is("file2"));
assertThat(file2Realm.isEnabled(), is(true));
}
Aggregations