@Override public DataSource getDataSource() { return delegate.getDataSource(); }
@Override public DataSource getDataSource() { return delegate.getDataSource(); }
@Before public void setup() throws SQLException { DbDeployerAppContext dbDeployerAppContext = DbEnvironmentFactory.getInstance().readOneFromSourcePath("./src/test/resources/scenariotests/initusecase/step1") .buildAppContext("abc", "abc"); this.jdbc = new JdbcHelper(); this.conn = dbDeployerAppContext.getDataSource().getConnection(); // clean up from previous tests if not shut down cleanly jdbc.update(conn, "DROP ALL objects DELETE files"); }
this.conn = dbDeployerAppContext.getDataSource().getConnection(); List<Map<String, Object>> results = this.jdbc .queryForList(conn, "select STRING_FIELD from bogusSchema.TABLE_C c where c.STRING_FIELD = ''");
this.conn = dbDeployerAppContext.getDataSource().getConnection(); List<Map<String, Object>> results = this.jdbc .queryForList(conn, "select STRING_FIELD from bogusSchema.TABLE_C c where c.STRING_FIELD = ''");
@Before public void setup() throws Exception { DbDeployerAppContext context = getAppContext.valueOf(1); context.setupEnvInfra(); this.logicalSchema1 = context.getEnvironment().getSchemas().getFirst().getName(); // pick one from the environment at random as our logical schema so that we can test the retrieval logic this.logicalSchema2 = "MYSCHEMA2"; // this is just for testing in this DAO, no need to tie to the actual logical schema this.testSchema = context.getEnvironment().getPhysicalSchema(this.logicalSchema1); this.platform = context.getEnvironment().getPlatform(); this.conn = context.getDataSource().getConnection(); this.jdbcHelper = ((AbstractSqlExecutor) context.getSqlExecutor()).createJdbcHelper(context.getDataSource()); this.artifactDeployerDao = (SameSchemaChangeAuditDao) ((DbDeployerAppContextImpl) context).getArtifactDeployerDao(); this.deployExecutionDao = (SameSchemaDeployExecutionDao) context.getDeployExecutionDao(); }
@Test public void testCrossDbJoin() throws Exception { Set<String> tables = new HashSet<String>(); Set<String> views = new HashSet<String>(); tables.add("TABLE_C"); tables.add("PRODUCT"); // run it twice to ensure that we can drop the schema DbDeployerAppContext dbDeployerAppContext = new UnitTestDbBuilder() .setReferenceEnvName("test") .setDbServer("crossDbJoin") .setSourcePath("platforms/h2/step1") .setDbPlatform(new H2DbPlatform()) .setTables(tables) .setViews(views) .buildContext(); dbDeployerAppContext.setupAndCleanAndDeploy().getEnvironment(); this.setupVerification(dbDeployerAppContext); int result; this.conn = dbDeployerAppContext.getDataSource().getConnection(); result = this.jdbc .queryForInt(conn, "select count(p.*) from bogusSchema.TABLE_C a, SCHEMA2.PRODUCT p where a.PRODUCT_ID = p.PRODUCT_ID "); assertEquals(3, result); }
@Test public void testCrossDbJoin() throws Exception { Set<String> tables = new HashSet<String>(); Set<String> views = new HashSet<String>(); tables.add("TABLE_C"); tables.add("PRODUCT"); // run it twice to ensure that we can drop the schema DbDeployerAppContext dbDeployerAppContext = new UnitTestDbBuilder() .setReferenceEnvName("test") .setDbServer("crossDbJoin") .setSourcePath("platforms/h2/step1") .setDbPlatform(new H2DbPlatform()) .setTables(tables) .setViews(views) .buildContext(); dbDeployerAppContext.setupAndCleanAndDeploy().getEnvironment(); this.setupVerification(dbDeployerAppContext); int result; this.conn = dbDeployerAppContext.getDataSource().getConnection(); result = this.jdbc .queryForInt(conn, "select count(p.*) from bogusSchema.TABLE_C a, SCHEMA2.PRODUCT p where a.PRODUCT_ID = p.PRODUCT_ID "); assertEquals(3, result); }
this.conn = context.getDataSource().getConnection(); result = this.jdbc.queryForInt(conn, "select count(*) from bogusSchema.TABLE_A"); assertEquals(4, result); dbMetadataManager.setDataSource(context.getDataSource());
this.conn = context.getDataSource().getConnection(); result = this.jdbc.queryForInt(conn, "select count(*) from bogusSchema.TABLE_A"); assertEquals(4, result); dbMetadataManager.setDataSource(context.getDataSource());
@Test public void testAseDeploy() throws Exception { DbDeployerAppContext step1Context = getAppContext.valueOf(1); step1Context .setupEnvInfra() .cleanEnvironment() .deploy(); String physicalSchemaStr = step1Context.getEnvironment().getPlatform().getSchemaPrefix(step1Context.getEnvironment().getPhysicalSchema("oats")); this.validateStep1(step1Context.getDataSource(), physicalSchemaStr, new JdbcHelper()); DbDeployerAppContext step2Context = getAppContext.valueOf(2); step2Context .setupEnvInfra() .deploy(); this.validateStep2(step2Context.getDataSource(), physicalSchemaStr, new JdbcHelper()); }
this.conn = context.getDataSource().getConnection();
@Test public void testUnitTestDeploy() throws SQLException { DbDeployerAppContext context = UnitTestDbBuilder.newBuilder() .setEnvName("test2") .setDbPlatform(new HsqlDbPlatform()) .setSourcePath("platforms/hsql") .setDbServer("HsqlCustomName") .buildContext(); context.setupEnvInfra(); // run it twice to ensure that we can drop the schema context.cleanAndDeploy(); context.cleanAndDeploy(); DbEnvironment env = context.getEnvironment(); System.out.println("Created env at " + env.getJdbcUrl()); int result; this.setup(); Connection conn = context.getDataSource().getConnection(); try { result = this.jdbc.queryForInt(conn, "select count(*) from SCHEMA1.TABLE_A"); assertEquals(3, result); result = this.jdbc.queryForInt(conn, "select count(*) from SCHEMA1.VIEW1"); assertEquals(3, result); } finally { DbUtils.closeQuietly(conn); } } }
@Test public void testUnitTestDeploy() throws SQLException { DbDeployerAppContext context = UnitTestDbBuilder.newBuilder() .setEnvName("test2") .setDbPlatform(new HsqlDbPlatform()) .setSourcePath("platforms/hsql") .setDbServer("HsqlCustomName") .buildContext(); context.setupEnvInfra(); // run it twice to ensure that we can drop the schema context.cleanAndDeploy(); context.cleanAndDeploy(); DbEnvironment env = context.getEnvironment(); System.out.println("Created env at " + env.getJdbcUrl()); int result; this.setup(); Connection conn = context.getDataSource().getConnection(); try { result = this.jdbc.queryForInt(conn, "select count(*) from SCHEMA1.TABLE_A"); assertEquals(3, result); result = this.jdbc.queryForInt(conn, "select count(*) from SCHEMA1.VIEW1"); assertEquals(3, result); } finally { DbUtils.closeQuietly(conn); } } }
@Test public void testUnitTestDeploy() throws Exception { DbDeployerAppContext builder = new UnitTestDbBuilder() .setReferenceEnvName("test") .setSourcePath("./src/test/resources/platforms/h2/step1") .setDbPlatform(new H2DbPlatform()) .setDbServer("MYCUSTOMDB") .buildContext(); builder.setupEnvInfra(); builder.cleanAndDeploy(); DbDeployerAppContext context = builder.cleanAndDeploy();// run it twice to ensure clean ability DbEnvironment env = builder.getEnvironment(); this.setupVerification(builder); int result; this.conn = context.getDataSource().getConnection(); result = this.jdbc.queryForInt(conn, "select count(*) from bogusSchema.TABLE_A"); assertEquals(4, result); result = this.jdbc.queryForInt(conn, "select count(*) from bogusSchema.VIEW1"); assertEquals(4, result); }
@Test public void testUnitTestDeploy() throws Exception { DbDeployerAppContext builder = new UnitTestDbBuilder() .setReferenceEnvName("test") .setSourcePath("./src/test/resources/platforms/h2/step1") .setDbPlatform(new H2DbPlatform()) .setDbServer("MYCUSTOMDB") .buildContext(); builder.setupEnvInfra(); builder.cleanAndDeploy(); DbDeployerAppContext context = builder.cleanAndDeploy();// run it twice to ensure clean ability DbEnvironment env = builder.getEnvironment(); this.setupVerification(builder); int result; this.conn = context.getDataSource().getConnection(); result = this.jdbc.queryForInt(conn, "select count(*) from bogusSchema.TABLE_A"); assertEquals(4, result); result = this.jdbc.queryForInt(conn, "select count(*) from bogusSchema.VIEW1"); assertEquals(4, result); }
Connection conn = context.getDataSource().getConnection(); try { result = this.jdbc.queryForInt(conn, "select count(*) from SCHEMA1.TABLE_A");
Connection conn = context.getDataSource().getConnection(); try { result = this.jdbc.queryForInt(conn, "select count(*) from SCHEMA1.TABLE_A");
@Test public void testUnitTestWithFile() throws Exception { DataSource ds = JdbcDataSourceFactory.createFromJdbcUrl(org.h2.Driver.class, H2JdbcDataSourceFactory.getUrl("fileTest", true), new Credential("sa", "")); this.jdbc = new JdbcHelper(); // run it twice to ensure that we can drop the schema DbDeployerAppContext builder = new UnitTestDbBuilder() .setEnvName("unittest-file") .setDbServer("fileTest") .setSourcePath("platforms/h2/step1") .setDbPlatform(new H2DbPlatform()) .setPersistToFile(true) .buildContext(); builder.setupEnvInfra(); builder.setupEnvInfra(); builder.setupEnvInfra(); builder.cleanAndDeploy(); DbDeployerAppContext dbDeployerAppContext = builder.cleanAndDeploy(); int result; this.conn = dbDeployerAppContext.getDataSource().getConnection(); result = this.jdbc.queryForInt(conn, "select count(*) from bogusSchema.TABLE_A"); assertEquals(4, result); result = this.jdbc.queryForInt(conn, "select count(*) from bogusSchema.VIEW1"); assertEquals(4, result); } }
@Test public void testUnitTestWithFile() throws Exception { DataSource ds = JdbcDataSourceFactory.createFromJdbcUrl(org.h2.Driver.class, H2JdbcDataSourceFactory.getUrl("fileTest", true), new Credential("sa", "")); this.jdbc = new JdbcHelper(); // run it twice to ensure that we can drop the schema DbDeployerAppContext builder = new UnitTestDbBuilder() .setEnvName("unittest-file") .setDbServer("fileTest") .setSourcePath("platforms/h2/step1") .setDbPlatform(new H2DbPlatform()) .setPersistToFile(true) .buildContext(); builder.setupEnvInfra(); builder.setupEnvInfra(); builder.setupEnvInfra(); builder.cleanAndDeploy(); DbDeployerAppContext dbDeployerAppContext = builder.cleanAndDeploy(); int result; this.conn = dbDeployerAppContext.getDataSource().getConnection(); result = this.jdbc.queryForInt(conn, "select count(*) from bogusSchema.TABLE_A"); assertEquals(4, result); result = this.jdbc.queryForInt(conn, "select count(*) from bogusSchema.VIEW1"); assertEquals(4, result); } }