@Override public DbEnvironment getEnvironment() { return delegate.getEnvironment(); }
@Override public DbEnvironment getEnvironment() { return delegate.getEnvironment(); }
@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(); }
.setViews(views) .buildContext(); dbDeployerAppContext.setupAndCleanAndDeploy().getEnvironment();
@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); }
@Test public void testDeploy() throws Exception { getAppContext.valueOf(1) .setupEnvInfra() .cleanEnvironment() .deploy() ; // ensuring that we can modify DbDeployerAppContext dbDeployerAppContext = getAppContext.valueOf(2); dbDeployerAppContext .setupEnvInfra() .deploy(); JdbcHelper jdbc = new JdbcHelper(); Connection conn = ds.getConnection(); try { List<Map<String, Object>> results = jdbc.queryForList(conn, "select * from " + dbDeployerAppContext.getEnvironment().getPhysicalSchema("schema1") + ".TABLE_A order by a_id"); assertEquals(3, results.size()); this.validateResults(results.get(0), 2, 3, "fasdfasd", "2013-02-02 11:11:11.65432", 9); this.validateResults(results.get(1), 3, 4, "ABC", null, 9); this.validateResults(results.get(2), 4, 2, "ABC", "2012-01-01 12:12:12", null); } finally { DbUtils.closeQuietly(conn); } }
@Test public void testDeploy() throws Exception { getAppContext.valueOf(1) .setupEnvInfra() .cleanEnvironment() .deploy() ; // ensuring that we can modify DbDeployerAppContext dbDeployerAppContext = getAppContext.valueOf(2); dbDeployerAppContext .setupEnvInfra() .deploy(); JdbcHelper jdbc = new JdbcHelper(); Connection conn = ds.getConnection(); try { List<Map<String, Object>> results = jdbc.queryForList(conn, "select * from " + dbDeployerAppContext.getEnvironment().getPhysicalSchema("schema1") + ".TABLE_A order by a_id"); assertEquals(3, results.size()); this.validateResults(results.get(0), 2, 3, "fasdfasd", "2013-02-02 11:11:11.65432", 9); this.validateResults(results.get(1), 3, 4, "ABC", null, 9); this.validateResults(results.get(2), 4, 2, "ABC", "2012-01-01 12:12:12", null); } finally { DbUtils.closeQuietly(conn); } }
@Test public void testDeploy() throws Exception { getAppContext.valueOf(1) .setupEnvInfra() .cleanEnvironment() .deploy(); // ensuring that we can modify DbDeployerAppContext dbDeployerAppContext = getAppContext.valueOf(2); dbDeployerAppContext .cleanEnvironment() .setupEnvInfra() .deploy(); JdbcHelper jdbc = new JdbcHelper(); Connection conn = ds.getConnection(); try { List<Map<String, Object>> results = jdbc.queryForList(conn, "select * from " + dbDeployerAppContext.getEnvironment().getPhysicalSchema("schema1") + ".TABLE_A order by a_id"); assertEquals(3, results.size()); this.validateResults(results.get(0), 2, 3, "fasdfasd", "2013-02-02 11:11:11.65432", 9); this.validateResults(results.get(1), 3, 4, "ABC", null, 9); this.validateResults(results.get(2), 4, 2, "ABC", "2012-01-01 12:12:12", null); } finally { DbUtils.closeQuietly(conn); } }
@Test public void testDeploy() throws Exception { getAppContext.valueOf(1) .setupEnvInfra() .setupEnvInfra() .cleanEnvironment() .deploy(); // ensuring that we can modify DbDeployerAppContext dbDeployerAppContext = getAppContext.valueOf(2); dbDeployerAppContext .cleanEnvironment() .setupEnvInfra() .deploy(); JdbcHelper jdbc = new JdbcHelper(); Connection conn = ds.getConnection(); try { List<Map<String, Object>> results = jdbc.queryForList(conn, "select * from " + dbDeployerAppContext.getEnvironment().getPhysicalSchema("schema1") + ".TABLE_A order by a_id"); assertEquals(3, results.size()); this.validateResults(results.get(0), 2, 3, "fasdfasd", "2013-02-02 11:11:11.65432", 9); this.validateResults(results.get(1), 3, 4, "ABC", null, 9); this.validateResults(results.get(2), 4, 2, "ABC", "2012-01-01 12:12:12", null); } finally { DbUtils.closeQuietly(conn); } }
@Test public void testDeploy() throws Exception { getAppContext.valueOf(1) .setupEnvInfra() .setupEnvInfra() .cleanEnvironment() .deploy(); // ensuring that we can modify DbDeployerAppContext dbDeployerAppContext = getAppContext.valueOf(2); dbDeployerAppContext .cleanEnvironment() .setupEnvInfra() .deploy(); JdbcHelper jdbc = new JdbcHelper(); Connection conn = ds.getConnection(); try { List<Map<String, Object>> results = jdbc.queryForList(conn, "select * from " + dbDeployerAppContext.getEnvironment().getPhysicalSchema("schema1") + ".TABLE_A order by a_id"); assertEquals(3, results.size()); this.validateResults(results.get(0), 2, 3, "fasdfasd", "2013-02-02 11:11:11.65432", 9); this.validateResults(results.get(1), 3, 4, "ABC", null, 9); this.validateResults(results.get(2), 4, 2, "ABC", "2012-01-01 12:12:12", null); } finally { DbUtils.closeQuietly(conn); } }
@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()); }
@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); }
.deploy() .setupAndCleanAndDeploy() .getEnvironment();
.cleanAndDeploy() .setupAndCleanAndDeploy() .getEnvironment();
.cleanAndDeploy() .setupAndCleanAndDeploy() .getEnvironment();
.deploy() .setupAndCleanAndDeploy() .getEnvironment();