Java Code Examples for org.springframework.jdbc.datasource.embedded.EmbeddedDatabase#shutdown()

The following examples show how to use org.springframework.jdbc.datasource.embedded.EmbeddedDatabase#shutdown() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetaDataExtractorTest.java    From celerio with Apache License 2.0 6 votes vote down vote up
@Test
public void noTable() throws ClassNotFoundException, SQLException, JAXBException, IOException {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    EmbeddedDatabase embeddedDatabase = builder.setType(EmbeddedDatabaseType.H2).build();

    Metadata meta = extractor.extract(embeddedDatabase.getConnection());

    assertThat(countTables(meta)).isZero();
    assertThat(countColumns(meta)).isZero();
    assertThat(countPrimaryKeys(meta)).isZero();
    assertThat(countImportedKeys(meta)).isZero();
    assertThat(countIndexes(meta)).isZero();
    assertThat(countEnums(meta)).isZero();

    embeddedDatabase.shutdown();
}
 
Example 2
Source File: MetaDataExtractorTest.java    From celerio with Apache License 2.0 6 votes vote down vote up
@Test
public void outputIsSameAsInput() throws ClassNotFoundException, SQLException, XmlMappingException, IOException {
    EmbeddedDatabase embeddedDatabase = createMinimalEmbeddedDatabase(ALL_RELATIONS_SCRIPT);

    Metadata meta = extractor.extract(embeddedDatabase.getConnection());


    assertThat(countTables(meta)).isEqualTo(18);
    assertThat(countColumns(meta)).isEqualTo(49);
    assertThat(countPrimaryKeys(meta)).isEqualTo(18);
    assertThat(countIndexes(meta)).isEqualTo(21);
    assertThat(countEnums(meta)).isEqualTo(3);

    File tempFile = File.createTempFile(getClass().getName(), ".xml");
    tempFile.deleteOnExit();
    loader.write(meta, tempFile);

    Metadata loadedMeta = loader.load(tempFile);
    assertThat(countTables(meta)).isEqualTo(countTables(loadedMeta));
    assertThat(countColumns(meta)).isEqualTo(countColumns(loadedMeta));
    assertThat(countPrimaryKeys(meta)).isEqualTo(countPrimaryKeys(loadedMeta));
    assertThat(countIndexes(meta)).isEqualTo(countIndexes(loadedMeta));
    assertThat(countEnums(meta)).isEqualTo(countEnums(loadedMeta));

    embeddedDatabase.shutdown();
}
 
Example 3
Source File: MetaDataExtractorTest.java    From celerio with Apache License 2.0 5 votes vote down vote up
@Test
public void minimal() throws ClassNotFoundException, SQLException, JAXBException, IOException {
    EmbeddedDatabase embeddedDatabase = createMinimalEmbeddedDatabase(MINIMAL_SCRIPT);
    Metadata meta = extractor.extract(embeddedDatabase.getConnection());

    assertThat(countTables(meta)).isEqualTo(6);
    assertThat(countColumns(meta)).isEqualTo(29);
    assertThat(countPrimaryKeys(meta)).isEqualTo(9);
    assertThat(countImportedKeys(meta)).isEqualTo(4);
    assertThat(countIndexes(meta)).isEqualTo(13);
    assertThat(countEnums(meta)).isZero();

    embeddedDatabase.shutdown();
}