001/* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014package de.softwareforge.testing.postgres.junit5; 015 016import static de.softwareforge.testing.postgres.junit5.Junit5ClassMemberTest.createTable; 017import static de.softwareforge.testing.postgres.junit5.Junit5ClassMemberTest.existsTable; 018import static org.junit.jupiter.api.Assertions.assertFalse; 019 020import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; 021import org.junit.jupiter.api.Order; 022import org.junit.jupiter.api.Test; 023import org.junit.jupiter.api.TestMethodOrder; 024import org.junit.jupiter.api.extension.RegisterExtension; 025 026@TestMethodOrder(OrderAnnotation.class) 027public class Junit5InstanceMemberTest { 028 029 @RegisterExtension 030 public EmbeddedPgExtension singleDatabase = SingleDatabaseBuilder.instanceWithDefaults().build(); 031 032 @RegisterExtension 033 public EmbeddedPgExtension multiDatabase = MultiDatabaseBuilder.instanceWithDefaults().build(); 034 035 @Test 036 @Order(1) 037 public void testTableCreation() throws Exception { 038 // create tables in a single and a multi database 039 // the extension creates a new database for each test 040 createTable(singleDatabase, "table1"); 041 createTable(multiDatabase, "table2"); 042 } 043 044 @Test 045 @Order(2) 046 public void testTableExists() throws Exception { 047 // neither database is shared across tests 048 assertFalse(existsTable(singleDatabase, "table1")); 049 assertFalse(existsTable(multiDatabase, "table2")); 050 } 051}