├── .circleci
└── config.yml
├── .gitignore
├── .travis.yml
├── Dockerfile
├── LICENSE
├── README.md
├── clean.sh
├── cmd
├── pom.xml
└── src
│ ├── main
│ ├── assembly
│ │ ├── LICENSE.txt
│ │ ├── distro-assembly.xml
│ │ ├── examples
│ │ │ └── migration
│ │ │ │ └── h2
│ │ │ │ ├── changesets
│ │ │ │ └── 1.0
│ │ │ │ │ ├── ddl.sql
│ │ │ │ │ └── seed-data.sql
│ │ │ │ └── h2-config.xml
│ │ ├── files.xml
│ │ ├── mintleaf
│ │ └── mintleaf.cmd
│ └── java
│ │ └── org
│ │ └── qamatic
│ │ └── mintleaf
│ │ └── MainCli.java
│ └── test
│ ├── java
│ └── org
│ │ └── qamatic
│ │ └── mintleaf
│ │ └── MigrationConfigTest.java
│ └── resources
│ ├── test-config-future.yml
│ └── test-config.xml
├── core
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── qamatic
│ │ │ └── mintleaf
│ │ │ ├── CallableParameterGets.java
│ │ │ ├── CallableParameterSets.java
│ │ │ ├── ChangeSet.java
│ │ │ ├── ChangeSetReader.java
│ │ │ ├── Column.java
│ │ │ ├── ColumnMatcher.java
│ │ │ ├── ColumnMetaDataCollection.java
│ │ │ ├── ConnectionContext.java
│ │ │ ├── ConsoleLogger.java
│ │ │ ├── DataComparer.java
│ │ │ ├── DataImporter.java
│ │ │ ├── Database.java
│ │ │ ├── DbQueryExtension.java
│ │ │ ├── DbSettings.java
│ │ │ ├── DbType.java
│ │ │ ├── DriverSource.java
│ │ │ ├── Executable.java
│ │ │ ├── ExecutionResultListener.java
│ │ │ ├── MetaDataCollection.java
│ │ │ ├── Mintleaf.java
│ │ │ ├── MintleafCliTask.java
│ │ │ ├── MintleafConfiguration.java
│ │ │ ├── MintleafException.java
│ │ │ ├── MintleafLogger.java
│ │ │ ├── MintleafReader.java
│ │ │ ├── NoLogger.java
│ │ │ ├── ParameterBinding.java
│ │ │ ├── ParameterGets.java
│ │ │ ├── ParameterSets.java
│ │ │ ├── ReadListener.java
│ │ │ ├── ResultSetMetaDataCollection.java
│ │ │ ├── Row.java
│ │ │ ├── RowMatchListener.java
│ │ │ ├── SqlResultSet.java
│ │ │ ├── SqlScript.java
│ │ │ ├── Table.java
│ │ │ ├── TaskOptions.java
│ │ │ ├── cli
│ │ │ └── MigrationTask.java
│ │ │ ├── configuration
│ │ │ ├── ConnectionProperties.java
│ │ │ ├── DbConnectionInfo.java
│ │ │ ├── MintleafXmlConfiguration.java
│ │ │ ├── Property.java
│ │ │ ├── SchemaVersionInfo.java
│ │ │ └── SchemaVersions.java
│ │ │ ├── core
│ │ │ ├── ArgPatternHandler.java
│ │ │ ├── BaseReader.java
│ │ │ ├── BaseSqlScript.java
│ │ │ ├── BasicDatabase.java
│ │ │ ├── BinaryDataIterable.java
│ │ │ ├── BindingParameterSets.java
│ │ │ ├── CallableBindingParameterSets.java
│ │ │ ├── ChangeSets.java
│ │ │ ├── CommandExecutor.java
│ │ │ ├── DbConnectionContext.java
│ │ │ ├── ExecuteQuery.java
│ │ │ ├── FixedLengthRecordFile.java
│ │ │ ├── FluentJdbc.java
│ │ │ ├── JdbcDriverSource.java
│ │ │ ├── SelectQuery.java
│ │ │ ├── SqlChangeSets.java
│ │ │ ├── SqlScriptFile.java
│ │ │ ├── StoredProcedure.java
│ │ │ ├── rows
│ │ │ │ ├── InMemoryRow.java
│ │ │ │ └── ResultSetRow.java
│ │ │ ├── stdqueries
│ │ │ │ ├── H2Queries.java
│ │ │ │ ├── MSSqlQueries.java
│ │ │ │ ├── MySqlQueries.java
│ │ │ │ ├── OracleQueries.java
│ │ │ │ ├── PostgresQueries.java
│ │ │ │ └── StandardQueries.java
│ │ │ └── tables
│ │ │ │ ├── InMemoryTable.java
│ │ │ │ └── SqlQueryTable.java
│ │ │ ├── data
│ │ │ ├── CompareColumnState.java
│ │ │ ├── CompareRowState.java
│ │ │ ├── ComparerListener.java
│ │ │ ├── OrderedColumnMatcher.java
│ │ │ ├── OrderedListComparator.java
│ │ │ └── SelectedColumnMatcher.java
│ │ │ ├── readers
│ │ │ ├── BinaryDataReader.java
│ │ │ ├── CsvReader.java
│ │ │ ├── CsvRowWrapper.java
│ │ │ ├── CsvTable.java
│ │ │ ├── DbResultSetReader.java
│ │ │ ├── MultiChangeSetFileReader.java
│ │ │ ├── SqlChangeSetFileReader.java
│ │ │ ├── SqlFileExecute.java
│ │ │ ├── SqlFileStreamReader.java
│ │ │ ├── SqlStringReader.java
│ │ │ └── TextStreamReader.java
│ │ │ └── tools
│ │ │ ├── BinaryFileImporter.java
│ │ │ ├── CsvExportFlavour.java
│ │ │ ├── CsvExporter.java
│ │ │ ├── CsvImporter.java
│ │ │ ├── DbImporter.java
│ │ │ ├── ExportFlavour.java
│ │ │ ├── FileFinder.java
│ │ │ ├── SqlBatchInsertReadListener.java
│ │ │ └── SqlTemplateBasedReadListener.java
│ └── resources
│ │ └── internal-core-mintleaf-logs.sql
│ └── test
│ ├── java
│ └── org
│ │ └── qamatic
│ │ └── mintleaf
│ │ ├── ApacheBasicDataSource.java
│ │ ├── H2ExampleAssert.java
│ │ ├── H2MigrationTest.java
│ │ ├── H2TestCase.java
│ │ ├── Hey.java
│ │ ├── ImportExportTest.java
│ │ ├── ListComparerTest.java
│ │ ├── LoggerTest.java
│ │ ├── MigrationTest.java
│ │ ├── MultiPartTest.java
│ │ ├── MyH2Queries.java
│ │ ├── ParameterTest.java
│ │ ├── SelectedMatchTest.java
│ │ ├── SingleLoadScriptTest.java
│ │ ├── SqlFileStreamReaderTest.java
│ │ ├── SqlMultiPartlFileReaderTest.java
│ │ ├── SqlStringReaderTest.java
│ │ ├── TestSuiteH2.java
│ │ ├── TestSuiteOracle.java
│ │ ├── User.java
│ │ ├── UtilTest.java
│ │ ├── core
│ │ ├── Apple.java
│ │ ├── BaseReaderTest.java
│ │ ├── BinaryImportTest.java
│ │ ├── ChangeSetsTest.java
│ │ ├── CityRecord.java
│ │ ├── ColumnTest.java
│ │ ├── ConnectionParameterTest.java
│ │ ├── CsvVsListComparerTest.java
│ │ ├── CsvWrapperTest.java
│ │ ├── CustomInMemoryRow.java
│ │ ├── DbComparerTest.java
│ │ └── DbQueriesTest.java
│ │ ├── mysql
│ │ ├── MySqlDbQueriesTest.java
│ │ └── MysqlTestCase.java
│ │ ├── oracle
│ │ ├── OraStoredProcTest.java
│ │ ├── OraTransactionTest.java
│ │ ├── OraUtilityTest.java
│ │ └── OracleTestCase.java
│ │ └── postgres
│ │ ├── PostgresTest.java
│ │ └── PostgresTestCase.java
│ └── resources
│ ├── EmptyPackage.sql
│ ├── Testddl.sql
│ ├── binary-import-changesets.sql
│ ├── changesets
│ └── h2
│ │ └── 1.0
│ │ ├── ddl.sql
│ │ └── seed-data.sql
│ ├── connection-prop-variable.sql
│ ├── example-changesets.sql
│ ├── filefinder
│ ├── f1
│ │ ├── file11.sql
│ │ └── file12.sql
│ └── f2
│ │ └── file21.sql
│ ├── h2singlescript.sql
│ ├── impexpfiles
│ ├── asciifile.txt
│ └── cp1047-1.txt
│ ├── migrationtests
│ └── h2testdb
│ │ └── 1.0
│ │ ├── ddl.sql
│ │ └── seed-data.sql
│ ├── multipart.sql
│ ├── multipart2.sql
│ ├── mysql
│ ├── mysql-db-setup.sql
│ ├── mysql-sample-db-employees.sql
│ └── mysql_load_departments.dump
│ ├── oracle
│ ├── hrdb-changesets
│ │ ├── hrdb-ddl-typeobjects.sql
│ │ ├── hrdb-ddl.sql
│ │ ├── hrdb-proc-packages.sql
│ │ ├── hrdb-sampledata.sql
│ │ └── hrdb-schema-setup.sql
│ └── payroll-changesets
│ │ └── payroll-ddl.sql
│ ├── postgres
│ ├── postgres-db-setup-northwind.sql
│ └── postgres-northwind-db.sql
│ ├── test-config.xml
│ ├── test_db.properties
│ ├── users.csv
│ └── variable-changesets.sql
├── dbexamples
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── org
│ │ └── qamatic
│ │ └── mintleaf
│ │ └── excel
│ │ ├── ExcelReader.java
│ │ └── ExcelRow.java
│ └── test
│ ├── java
│ └── org
│ │ └── qamatic
│ │ └── mintleaf
│ │ └── dbexample
│ │ ├── ApacheBasicDataSource.java
│ │ ├── compare
│ │ ├── CsvVsListComparerTests.java
│ │ ├── ListOfObjectsComparerTests.java
│ │ └── User.java
│ │ ├── excel
│ │ └── ExcelImportTest.java
│ │ ├── migrate
│ │ └── H2ChangeSetsExampleTest.java
│ │ └── reportgenerator
│ │ ├── ComparisonResultReportGenerator.java
│ │ └── TestResult.java
│ └── resources
│ ├── HR_30_DDL.sql
│ ├── HR_30_PROCS.sql
│ ├── database-config.xml
│ ├── h2-changesets
│ └── v1
│ │ ├── hrdb-sampledata.sql
│ │ └── schema-v1.sql
│ ├── print-templates
│ └── compare-result-template.html
│ ├── users.csv
│ └── users.xls
├── doc
├── CHANGELOG.md
├── Gemfile
├── Gemfile.lock
├── LICENSE
├── Vagrantfile
├── basicflow.gliffy
├── config.rb
├── dbcompare.gliffy
├── deploy.sh
├── font-selection.json
├── lib
│ └── multilang.rb
├── logo.psd
├── logo1.psd
├── logosimple.psd
├── mintleaf.gliffy
├── overall.gliffy
├── source
│ ├── fonts
│ │ ├── slate.eot
│ │ ├── slate.svg
│ │ ├── slate.ttf
│ │ ├── slate.woff
│ │ └── slate.woff2
│ ├── images
│ │ ├── basicflow.png
│ │ ├── logo.png
│ │ ├── logosimple.png
│ │ ├── mintleaf.png
│ │ ├── navbar.png
│ │ └── overall.png
│ ├── includes
│ │ └── _errors.md
│ ├── index.html.md
│ ├── javascripts
│ │ ├── all.js
│ │ ├── all_nosearch.js
│ │ ├── app
│ │ │ ├── _lang.js
│ │ │ ├── _search.js
│ │ │ └── _toc.js
│ │ └── lib
│ │ │ ├── _energize.js
│ │ │ ├── _imagesloaded.min.js
│ │ │ ├── _jquery.highlight.js
│ │ │ ├── _jquery.js
│ │ │ ├── _jquery.tocify.js
│ │ │ ├── _jquery_ui.js
│ │ │ └── _lunr.js
│ ├── layouts
│ │ └── layout.erb
│ └── stylesheets
│ │ ├── _icon-font.scss
│ │ ├── _normalize.scss
│ │ ├── _variables.scss
│ │ ├── print.css.scss
│ │ └── screen.css.scss
└── www
│ ├── css
│ ├── gradients.css
│ └── styles.css
│ ├── img
│ └── logosimple.png
│ ├── index.html
│ └── js
│ └── set-background.js
├── docker-compose.yml
├── docs
├── .nojekyll
├── README.md
├── _sidebar.md
├── guide.md
├── images
│ ├── basicflow.png
│ ├── logo.png
│ ├── logosimple.png
│ ├── mintleaf.png
│ ├── navbar.png
│ └── overall.png
└── index.html
├── libs
├── ojdbc6.jar
└── readme.txt
├── pom.xml
├── sonar-project.properties
└── startlocaldb.sh
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | # Java Maven CircleCI 2.0 configuration file
2 | #
3 | # Check https://circleci.com/docs/2.0/language-java/ for more details
4 | #
5 | version: 2
6 | executorType: machine
7 | jobs:
8 | build:
9 | docker:
10 | machine:
11 | image: ubuntu-1604:201903-01 # pins image to specific version
12 |
13 | working_directory: ~/repo
14 |
15 | environment:
16 | # Customize the JVM maximum heap limit
17 | MAVEN_OPTS: -Xmx3200m
18 | POSTGRES_DB_ADMIN_USERNAME: root
19 | POSTGRES_DB_ADMIN_PASSWORD: password
20 | POSTGRES_DB_URL: jdbc:postgresql://localhost:5432/
21 |
22 | steps:
23 | - checkout
24 | - run: ./startlocaldb.sh
25 |
26 | # run tests!
27 | - run: mvn initialize -P install-drivers
28 | - run: mvn clean test
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 | data
3 |
4 | # Mobile Tools for Java (J2ME)
5 | .mtj.tmp/
6 |
7 | # Package Files #
8 | *.jar
9 | *.war
10 | *.ear
11 | *.h2.db
12 | .idea
13 | *.iml
14 | libs/*.jar
15 |
16 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
17 | hs_err_pid*
18 |
19 | plsql/src/test/resources/test_sysdba.properties
20 | plsql/src/test/resources/test_schema.properties
21 |
22 | *.iml
23 |
24 | doc/build/*
25 |
26 | .idea
27 |
28 | target
29 |
30 | dependency-redu*
31 |
32 | *report.html
33 |
34 | Archive.zip
35 | mem
36 | .fossa.yml
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | sudo: false # optional
3 |
4 | addons:
5 | apt:
6 | packages:
7 | - oracle-java8-installer
8 |
9 | jdk: oraclejdk8
10 |
11 |
12 | install:
13 | - mvn initialize -P install-drivers
14 |
15 | script:
16 | - mvn install
17 | - mvn cobertura:cobertura
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM maven:3.6.2-jdk-8-slim AS build
2 | COPY . /home/app
3 | COPY pom.xml /home/app
4 | RUN mvn -f /home/app/pom.xml -P install-drivers initialize
5 | RUN mvn -f /home/app/pom.xml clean test
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2010-2015 QAMatic
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://circleci.com/gh/qamatic/mintleaf) [](https://maven-badges.herokuapp.com/maven-central/org.qamatic/mintleaf-core)
2 |
3 | 
4 | Welcome to the Mintleaf! Mintleaf is a light weight framework tool helps you to advance your database developement for ETL Jobs, continuous integration / continuous delivery model as easy as possible.
5 |
6 | - Database Migration
7 | - ETL jobs to transfer data between different sources.
8 | - Data pipelines
9 | - Ability to write automated tests and run them on migrated database schemas, objects, data integrity checks during CI/CD
10 | - Seamless Test life cycle management such as setup, teardown mock data, schema and database objects using changesets
11 | - Create mock data or transfer/copy data between databases for your tests
12 | - Nothing more but to use Plain old SQL that you know of
13 |
14 | ## Documentation
15 |
16 | - [Documentation](https://qamatic.github.io/mintleaf/)
17 | - [API Reference](https://qamatic.github.io/mintleaf/apidocs)
18 |
19 | ## Maven
20 |
21 | org.qamatic
22 | mintleaf-core
23 | 1.8.27
24 |
25 |
26 | ## Download binaries
27 |
28 | Command line tools:
29 |
30 | - [Windows: mintleaf-cmd-1.8.27-rel.zip](http://search.maven.org/remotecontent?filepath=org/qamatic/mintleaf-cmd/1.8.27/mintleaf-cmd-1.8.27-rel.zip)
31 | - [Mac/Linux: mintleaf-cmd-1.8.27-rel.tar.gz](http://search.maven.org/remotecontent?filepath=org/qamatic/mintleaf-cmd/1.8.27/mintleaf-cmd-1.8.27-rel.tar.gz)
32 |
33 |
34 | ## Run in Docker
35 |
36 |
37 | ## License
38 |
39 | The MIT License (MIT)
40 |
41 | Copyright (c) 2010-2017 QAMatic Team
42 |
43 | Permission is hereby granted, free of charge, to any person obtaining a copy
44 | of this software and associated documentation files (the "Software"), to deal
45 | in the Software without restriction, including without limitation the rights
46 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
47 | copies of the Software, and to permit persons to whom the Software is
48 | furnished to do so, subject to the following conditions:
49 |
50 | The above copyright notice and this permission notice shall be included in all
51 | copies or substantial portions of the Software.
52 |
53 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
54 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
55 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
56 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
57 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
58 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
59 | SOFTWARE.
60 |
61 |
--------------------------------------------------------------------------------
/clean.sh:
--------------------------------------------------------------------------------
1 | git checkout core/pom.xml
2 | git checkout pom.xml
3 | git checkout dbexamples/pom.xml
4 | git checkout cmd/pom.xml
5 |
--------------------------------------------------------------------------------
/cmd/src/main/assembly/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2010-2017 QAMatic Team
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/cmd/src/main/assembly/distro-assembly.xml:
--------------------------------------------------------------------------------
1 |
6 | rel
7 | false
8 |
9 | tar.gz
10 | zip
11 |
12 | mintleaf-${project.version}
13 |
14 | src/main/assembly/files.xml
15 |
16 |
--------------------------------------------------------------------------------
/cmd/src/main/assembly/examples/migration/h2/changesets/1.0/ddl.sql:
--------------------------------------------------------------------------------
1 | --
2 |
3 | DROP SCHEMA IF EXISTS BILLING;
4 | CREATE SCHEMA IF NOT EXISTS BILLING;
5 |
6 | CREATE TABLE IF NOT EXISTS BILLING.USERS
7 | (
8 | USERID INT NOT NULL,
9 | USERNAME VARCHAR2(50),
10 | RATE NUMBER(12, 2),
11 | CREATE_TIME DATE DEFAULT sysdate,
12 | CONSTRAINT PK_USERID PRIMARY KEY (USERID)
13 | );
14 |
--------------------------------------------------------------------------------
/cmd/src/main/assembly/examples/migration/h2/changesets/1.0/seed-data.sql:
--------------------------------------------------------------------------------
1 |
2 |
3 | --
4 |
5 | INSERT INTO BILLING.USERS (USERID, USERNAME) VALUES (1, 'Aiden');
6 | INSERT INTO BILLING.USERS (USERID, USERNAME) VALUES (2, 'Ethan, Allen');
7 | INSERT INTO BILLING.USERS (USERID, USERNAME) VALUES (3, 'Liam');
8 | INSERT INTO BILLING.USERS (USERID, USERNAME) VALUES (4, 'Noah');
9 | INSERT INTO BILLING.USERS (USERID, USERNAME) VALUES (5, 'Jacob');
10 | INSERT INTO BILLING.USERS (USERID, USERNAME) VALUES (6, 'Benjamin');
11 | INSERT INTO BILLING.USERS (USERID, USERNAME) VALUES (7, 'qamatic');
12 |
--------------------------------------------------------------------------------
/cmd/src/main/assembly/examples/migration/h2/h2-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Database connections and Schema version configuration file
6 |
7 | h2testdb
8 | H2
9 | jdbc:h2:file:./target/h2testdb1;mv_store=false;
10 |
11 |
12 | h2testdb
13 | H2
14 | jdbc:h2:file:./target/h2testdb1;mv_store=false;
15 |
16 |
17 |
18 | 1.0
19 |
20 | create schema,
21 | load seed data
22 |
23 | changesets/1.0/*.sql
24 |
25 |
26 | 2.0
27 |
28 | create schema,
29 | load seed data
30 |
31 | changesets/1.0/*.sql
32 |
33 |
34 |
--------------------------------------------------------------------------------
/cmd/src/main/assembly/files.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 | src/main/assembly
8 |
9 |
10 | LICENSE.txt
11 |
12 | 644
13 | true
14 |
15 |
16 | src/main/assembly
17 | bin
18 |
19 | mintleaf.cmd
20 |
21 | 644
22 | true
23 |
24 |
25 | src/main/assembly
26 | bin
27 |
28 | mintleaf
29 |
30 | 744
31 | unix
32 | true
33 |
34 |
35 | src/main/assembly/examples
36 | examples
37 | 644
38 | unix
39 |
40 |
41 |
42 |
43 |
44 | bin
45 |
46 | org.qamatic:mintleaf-cmd*
47 |
48 |
49 |
50 | lib
51 |
52 | org.qamatic:mintleaf*
53 | com.beust:jcommander*
54 | org.apache.commons:common*
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/cmd/src/main/assembly/mintleaf:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | DIR="$(dirname $([ -L $0 ] && readlink -f $0 || echo $0))"
3 | java -cp "$DIR/../lib/*:$DIR/*" org.qamatic.mintleaf.MainCli "$@"
--------------------------------------------------------------------------------
/cmd/src/main/assembly/mintleaf.cmd:
--------------------------------------------------------------------------------
1 | java -cp "../lib/*;*" org.qamatic.mintleaf.MainCli %*
--------------------------------------------------------------------------------
/cmd/src/test/resources/test-config-future.yml:
--------------------------------------------------------------------------------
1 | databases:
2 | - id: abcdb
3 | properties:
4 | poolSize: '100'
5 | type: H2
6 | url: ''
7 | mintleaf:
8 | description: 'Database and Schema version configuration file'
9 | file version: '1.0'
10 | schemaVersions:
11 | - changeSets:
12 | - create schema
13 | - load seed data
14 | scriptLocation: ./path/*.sql
15 | version: '1.0'
--------------------------------------------------------------------------------
/cmd/src/test/resources/test-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Database connections and Schema version configuration file
6 |
7 | h2testdb
8 | H2
9 | jdbc:h2:file:./target/h2testdb1;mv_store=false;
10 |
11 |
12 |
13 | 1.0
14 |
15 | create schema,
16 | load seed data
17 |
18 | ./target/test-classes/migrationtests/h2testdb/1.0/*.sql
19 |
20 |
21 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/CallableParameterSets.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf;
2 |
3 | import java.sql.SQLType;
4 |
5 | /**
6 | * Created by QAmatic Team on 4/2/17.
7 | */
8 | public interface CallableParameterSets extends ParameterSets {
9 | void registerOutParameter(int parameterIndex, int sqlType) throws MintleafException;
10 |
11 | void registerOutParameter(int parameterIndex, int sqlType, int scale) throws MintleafException;
12 |
13 | void registerOutParameter(int parameterIndex, int sqlType, String typeName) throws MintleafException;
14 |
15 | void registerOutParameter(int parameterIndex, SQLType sqlType) throws MintleafException;
16 |
17 | void registerOutParameter(int parameterIndex, SQLType sqlType, int scale) throws MintleafException;
18 |
19 | void registerOutParameter(int parameterIndex, SQLType sqlType, String typeName) throws MintleafException;
20 |
21 | void registerOutParameter(String parameterName, int sqlType) throws MintleafException;
22 |
23 | void registerOutParameter(String parameterName, int sqlType, int scale) throws MintleafException;
24 |
25 | void registerOutParameter(String parameterName, int sqlType, String typeName) throws MintleafException;
26 |
27 | void registerOutParameter(String parameterName, SQLType sqlType) throws MintleafException;
28 |
29 | void registerOutParameter(String parameterName, SQLType sqlType, int scale) throws MintleafException;
30 |
31 | void registerOutParameter(String parameterName, SQLType sqlType, String typeName) throws MintleafException;
32 | }
33 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/ChangeSetReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | import java.util.HashMap;
39 |
40 | public interface ChangeSetReader extends MintleafReader {
41 | ChangeSet getChangeSet(String changeSetId);
42 |
43 | HashMap getChangeSets();
44 | }
45 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/ColumnMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 |
39 | import org.qamatic.mintleaf.data.CompareRowState;
40 | import org.qamatic.mintleaf.data.ComparerListener;
41 |
42 | /**
43 | * Created by qamatic on 2/18/6/16.
44 | */
45 | public interface ColumnMatcher {
46 |
47 |
48 | void match(CompareRowState leftRowState, CompareRowState rightRowState, final ComparerListener listener) throws MintleafException;
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/ConsoleLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | /**
39 | * Created by qamatic on 2/16/16.
40 | */
41 | public class ConsoleLogger extends MintleafLogger {
42 |
43 | private Class> clazz;
44 |
45 | public ConsoleLogger(Class> clazz) {
46 |
47 | this.clazz = clazz;
48 | }
49 |
50 | @Override
51 | public void error(Throwable e) {
52 | System.out.println(e.getMessage());
53 | }
54 |
55 | @Override
56 | public void error(String message, Throwable e) {
57 | System.out.println(String.format("[%s] : %s", this.clazz.getName(), message));
58 | System.out.println(e.getMessage());
59 | }
60 |
61 | @Override
62 | public void debug(String message) {
63 | System.out.println(message);
64 | }
65 |
66 | @Override
67 | public void info(String message) {
68 | System.out.println(String.format("[%s] : %s", this.clazz.getName(), message));
69 | }
70 |
71 | @Override
72 | public void error(String message) {
73 | System.out.println(String.format("[%s] : %s", this.clazz.getName(), message));
74 | }
75 |
76 | @Override
77 | public void warn(String message) {
78 | System.out.println(message);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/DataComparer.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | import org.qamatic.mintleaf.data.ComparerListener;
39 |
40 | /**
41 | * Created by qamatic on 3/5/16.
42 | */
43 | public interface DataComparer extends Executable {
44 |
45 | void setComparerListener(ComparerListener comparerListener);
46 |
47 | void setColumnMatcher(ColumnMatcher columnMatcher);
48 |
49 | Table getSourceTable();
50 |
51 | void setSourceTable(Table extends Row> sourceTable);
52 |
53 | Table getTargetTable();
54 |
55 | void setTargetTable(Table extends Row> targetTable);
56 | }
57 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/DataImporter.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | /**
39 | * Created by qamatic on 3/6/16.
40 | */
41 | public interface DataImporter {
42 | void importNow() throws MintleafException;
43 | }
44 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/Database.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | import org.qamatic.mintleaf.core.DbConnectionContext;
39 |
40 | /**
41 | * Created by qamatic on 12/6/15.
42 | */
43 | public interface Database {
44 |
45 |
46 | DriverSource getDriverSource();
47 |
48 | default ConnectionContext getNewConnection() {
49 | return getNewConnection(true);
50 | }
51 |
52 | default ConnectionContext getNewConnection(boolean autoCloseable) {
53 | return new DbConnectionContext(getDriverSource(), autoCloseable);
54 | }
55 |
56 |
57 | default DbType getSupportedDbType() {
58 | return DbType.getDbType(getDriverSource().getUrl());
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/DbSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | public interface DbSettings {
39 | static String PROP_USERNAME = "user";
40 | static String PROP_PASSWORD = "password";
41 | static String PROP_URL = "url";
42 | static String PROP_DRIVER_CLASSNAME = "driverClassName";
43 | static String PROP_ENABLE_DEBUG = "debug";
44 | static String PROP_DATA_LOCATION = "dataLocation";
45 |
46 | String getUrl();
47 |
48 | void setUrl(String url);
49 |
50 | String getUsername();
51 |
52 | void setUsername(String userName);
53 |
54 | String getPassword();
55 |
56 | void setPassword(String password);
57 |
58 | boolean isDebugEnabled();
59 |
60 | void setDebugEnabled(boolean debug);
61 |
62 | String getDriverClassName();
63 |
64 | void setDriverClassName(String driverClassName);
65 |
66 | void setProperty(String propName, String value);
67 |
68 | String getProperty(String propName);
69 | }
70 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/DbType.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | /**
39 | * Created by qamatic on 1/5/16.
40 | */
41 | public enum DbType {
42 | H2("H2 Database", "jdbc:h2:"),
43 | MYSQL("MySQL database", "jdbc:mysql:"),
44 | POSTGRESQL("Postgres database", "jdbc:postgresql:"),
45 | ORACLE("Oracle database", "jdbc:oracle:"),
46 | MSSQL("Microsoft SQL Server database", "jdbc:sqlserver:");
47 |
48 | private final String name;
49 | private String jdbcUrlPrefix;
50 |
51 | private DbType(String name, String jdbcUrlPrefix) {
52 | this.name = name;
53 | this.jdbcUrlPrefix = jdbcUrlPrefix;
54 | }
55 |
56 | public static DbType getDbType(String url) {
57 | url = url.toLowerCase();
58 | for (DbType dt : DbType.values()) {
59 | if (url.contains(dt.jdbcUrlPrefix)) {
60 | return dt;
61 | }
62 | }
63 | return null;
64 | }
65 |
66 | public String getName() {
67 | return name;
68 | }
69 |
70 | public String getJdbcUrlPrefix() {
71 | return this.jdbcUrlPrefix;
72 | }
73 |
74 | public String getLogName(){
75 | return String.format("%s-core-mintleaf-logs", this.toString().toLowerCase());
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/DriverSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | import javax.sql.DataSource;
39 | import java.io.PrintWriter;
40 | import java.sql.SQLException;
41 | import java.sql.SQLFeatureNotSupportedException;
42 | import java.util.logging.Logger;
43 |
44 | /**
45 | * Created by qamatic on 3/5/16.
46 | */
47 | public interface DriverSource extends DataSource, DbSettings {
48 |
49 |
50 | @Override
51 | default PrintWriter getLogWriter() throws SQLException {
52 | return null;
53 | }
54 |
55 | @Override
56 | default void setLogWriter(PrintWriter out) throws SQLException {
57 |
58 | }
59 |
60 | @Override
61 | default int getLoginTimeout() throws SQLException {
62 | return 0;
63 | }
64 |
65 | @Override
66 | default void setLoginTimeout(int seconds) throws SQLException {
67 |
68 | }
69 |
70 | @Override
71 | default Logger getParentLogger() throws SQLFeatureNotSupportedException {
72 | return null;
73 | }
74 |
75 | @Override
76 | default T unwrap(Class iface) throws SQLException {
77 | return null;
78 | }
79 |
80 | @Override
81 | default boolean isWrapperFor(Class> iface) throws SQLException {
82 | return false;
83 | }
84 |
85 |
86 | default String getInfo() {
87 | return toString();
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/Executable.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | /**
39 | * Created by QAmatic Team on 7/19/16.
40 | */
41 | public interface Executable extends AutoCloseable {
42 |
43 | default void close() throws MintleafException {
44 |
45 | }
46 |
47 | V execute() throws MintleafException;
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/ExecutionResultListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | /**
39 | * Created by QAmatic Team on 3/24/17.
40 | */
41 | public interface ExecutionResultListener {
42 | void onAfterExecuteSql(ParameterGets result) throws MintleafException;
43 |
44 | public interface Callable {
45 | void onAfterExecuteSql(CallableParameterGets result) throws MintleafException;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/MetaDataCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | import java.sql.ResultSetMetaData;
39 | import java.sql.SQLException;
40 |
41 | /**
42 | * Created by qamatic on 3/5/16.
43 | */
44 | public interface MetaDataCollection extends ResultSetMetaData {
45 |
46 | default T unwrap(Class iface) throws SQLException {
47 | return null;
48 | }
49 |
50 |
51 | default boolean isWrapperFor(Class> iface) throws SQLException {
52 | return false;
53 | }
54 |
55 | int getIndex(String columnName);
56 |
57 | Column findColumn(String columnName);
58 |
59 | Column getColumn(int index);
60 |
61 | default String getColumnNameByIndex(int column) throws MintleafException {
62 | try {
63 | return getColumnName(column);
64 | } catch (SQLException e) {
65 | throw new MintleafException(e);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/MintleafCliTask.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf;
2 |
3 | /**
4 | * Created by QAmatic Team on 4/8/17.
5 | */
6 | public interface MintleafCliTask extends AutoCloseable {
7 | int execute() throws MintleafException;
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/MintleafConfiguration.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf;
2 |
3 | import org.qamatic.mintleaf.configuration.DbConnectionInfo;
4 | import org.qamatic.mintleaf.configuration.SchemaVersionInfo;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Created by QAmatic Team on 4/8/17.
10 | */
11 | public interface MintleafConfiguration {
12 |
13 | String getConfigVersion();
14 |
15 | String getDescription();
16 |
17 | DbConnectionInfo getDbConnectionInfo(String databaseId);
18 |
19 | SchemaVersionInfo getSchemaVersionInfo(String versionId);
20 |
21 | List getDatabases();
22 |
23 | List getSchemas();
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/MintleafException.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | /**
39 | * Created by qamatic on 2/16/16.
40 | */
41 | public class MintleafException extends Exception {
42 |
43 | public MintleafException(String message) {
44 | super(message);
45 | }
46 |
47 | public MintleafException(String message, Throwable cause) {
48 | super(message, cause);
49 | }
50 |
51 | public MintleafException(Throwable cause) {
52 | super(cause);
53 | }
54 |
55 | public MintleafException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
56 | super(message, cause, enableSuppression, writableStackTrace);
57 | }
58 |
59 | @SuppressWarnings("unchecked")
60 | private static void throwException(Throwable exception, Object dummy) throws T {
61 | throw (T) exception;
62 | }
63 |
64 | public static void throwException(Throwable exception) {
65 | MintleafException.throwException(exception, null);
66 | }
67 |
68 | public static void throwException(String message) {
69 | MintleafException.throwException(new MintleafException(message), null);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/NoLogger.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf;
2 |
3 | /**
4 | * Created by QAmatic Team on 4/8/17.
5 | */
6 | public class NoLogger extends MintleafLogger {
7 |
8 | private Class> clazz;
9 |
10 | public NoLogger(Class> clazz) {
11 |
12 | this.clazz = clazz;
13 | }
14 |
15 | @Override
16 | public void error(Throwable e) {
17 |
18 | }
19 |
20 | @Override
21 | public void error(String message, Throwable e) {
22 |
23 | }
24 |
25 | @Override
26 | public void debug(String message) {
27 |
28 | }
29 |
30 | @Override
31 | public void info(String message) {
32 |
33 | }
34 |
35 | @Override
36 | public void error(String message) {
37 |
38 | }
39 |
40 | @Override
41 | public void warn(String message) {
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/ParameterBinding.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | /**
39 | * Created by QAmatic Team on 3/18/17.
40 | */
41 | public interface ParameterBinding {
42 |
43 | void bindParameters(ParameterSets parameterSets) throws MintleafException;
44 |
45 | public interface Callable {
46 |
47 | void bindParameters(CallableParameterSets parameterSets) throws MintleafException;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/ParameterGets.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf;
2 |
3 | import java.sql.ParameterMetaData;
4 | import java.sql.ResultSet;
5 | import java.sql.SQLWarning;
6 |
7 | /**
8 | * Created by QAmatic Team on 4/2/17.
9 | */
10 | public interface ParameterGets {
11 | ParameterMetaData getParameterMetaData() throws MintleafException;
12 |
13 | boolean isBatch();
14 |
15 | int getFetchDirection() throws MintleafException;
16 |
17 | int getFetchSize() throws MintleafException;
18 |
19 | ResultSet getGeneratedKeys() throws MintleafException;
20 |
21 | long getLargeMaxRows() throws MintleafException;
22 |
23 | long getLargeUpdateCount() throws MintleafException;
24 |
25 | int getMaxFieldSize() throws MintleafException;
26 |
27 | int getMaxRows() throws MintleafException;
28 |
29 | boolean getMoreResults() throws MintleafException;
30 |
31 | boolean getMoreResults(int current) throws MintleafException;
32 |
33 | int getQueryTimeout() throws MintleafException;
34 |
35 | ResultSet getResultSet() throws MintleafException;
36 |
37 | int getResultSetConcurrency() throws MintleafException;
38 |
39 | int getResultSetHoldability() throws MintleafException;
40 |
41 | int getResultSetType() throws MintleafException;
42 |
43 | int getUpdateCount() throws MintleafException;
44 |
45 | SQLWarning getWarnings() throws MintleafException;
46 |
47 | boolean isClosed() throws MintleafException;
48 |
49 | boolean isCloseOnCompletion() throws MintleafException;
50 |
51 | boolean isPoolable() throws MintleafException;
52 | }
53 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/ReadListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | /**
39 | * Created by qamatic on 3/3/16.
40 | */
41 | public interface ReadListener {
42 | void eachRow(int rowNum, Row row) throws MintleafException;
43 | }
44 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/RowMatchListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | /**
39 | * Created by qamatic on 3/3/16.
40 | */
41 | public interface RowMatchListener extends ReadListener {
42 |
43 | default boolean matches(Row row) {
44 | return true;
45 | }
46 |
47 | default boolean canContinueRead(Row row) {
48 | return true;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/SqlResultSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | import java.sql.ResultSet;
39 |
40 | /**
41 | * Created by QAmatic Team on 3/16/17.
42 | */
43 | public interface SqlResultSet extends AutoCloseable {
44 | ResultSet getResultSet() throws MintleafException;
45 |
46 | void close() throws MintleafException;
47 |
48 | ResultSet first() throws MintleafException;
49 |
50 | void iterate(RowMatchListener listener) throws MintleafException, MintleafException;
51 |
52 | Table asRowListWrapper() throws MintleafException;
53 | }
54 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/SqlScript.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | /**
39 | * Created by qamatic on 7/16/16.
40 | */
41 | public interface SqlScript extends AutoCloseable {
42 |
43 | void apply() throws MintleafException;
44 |
45 | default void close() throws MintleafException {
46 |
47 | }
48 |
49 | MintleafReader getReader();
50 |
51 | ConnectionContext getConnectionContext();
52 | }
53 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/Table.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf;
37 |
38 | /**
39 | * Created by qamatic on 3/4/16.
40 | */
41 | public interface Table extends Iterable {
42 |
43 | T getRow(int index) throws MintleafException;
44 |
45 | boolean isEmpty();
46 |
47 | void clear();
48 |
49 | int size();
50 |
51 | MetaDataCollection getMetaData() throws MintleafException;
52 |
53 | default boolean add(T t) {
54 | MintleafException.throwException("unimplemented");
55 | return false;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/TaskOptions.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf;
2 |
3 | import java.util.HashMap;
4 |
5 | /**
6 | * Created by QAmatic Team on 4/8/17.
7 | */
8 | public class TaskOptions {
9 | private HashMap taskOptions = new HashMap<>();
10 |
11 | public void addOption(String optionKey, Object optionValue) {
12 | taskOptions.put(optionKey, optionValue);
13 | }
14 |
15 | public int asInt(String optionKey) {
16 | return (int) taskOptions.get(optionKey);
17 | }
18 |
19 | public String asString(String optionKey) {
20 | return (String) taskOptions.get(optionKey);
21 | }
22 |
23 | public Object asObject(String optionKey) {
24 | return taskOptions.get(optionKey);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/cli/MigrationTask.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf.cli;
2 |
3 | import org.qamatic.mintleaf.*;
4 | import org.qamatic.mintleaf.configuration.SchemaVersionInfo;
5 | import org.qamatic.mintleaf.core.SqlChangeSets;
6 | import org.qamatic.mintleaf.readers.MultiChangeSetFileReader;
7 |
8 | /**
9 | * Created by QAmatic team on 4/8/17.
10 | */
11 | public class MigrationTask implements MintleafCliTask {
12 | private static final MintleafLogger logger = MintleafLogger.getLogger(MigrationTask.class);
13 |
14 | private ConnectionContext connectionContext;
15 | private SchemaVersionInfo schemaVersionInfo;
16 | private TaskOptions options;
17 |
18 | public MigrationTask(ConnectionContext connectionContext, SchemaVersionInfo schemaVersionInfo, TaskOptions options) {
19 | this.connectionContext = connectionContext;
20 |
21 | this.schemaVersionInfo = schemaVersionInfo;
22 | this.options = options;
23 | }
24 |
25 | @Override
26 | public int execute() throws MintleafException {
27 |
28 | SqlChangeSets changeSets = new SqlChangeSets(this.connectionContext,
29 | new MultiChangeSetFileReader(this.schemaVersionInfo.getScriptLocationAsList()),
30 | this.schemaVersionInfo.getChangeSetsAsList());
31 | changeSets.apply();
32 |
33 | return 0;
34 | }
35 |
36 | @Override
37 | public void close() throws Exception {
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/configuration/ConnectionProperties.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf.configuration;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlElement;
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * Created by QAmatic Team on 3/28/17.
11 | */
12 | @XmlAccessorType(XmlAccessType.FIELD)
13 | public class ConnectionProperties {
14 |
15 | @XmlElement(name = "add")
16 | private List items = new ArrayList<>();
17 |
18 | public List getItems() {
19 | return items;
20 | }
21 |
22 | public void setItems(List connectionProperties) {
23 | this.items = connectionProperties;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/configuration/Property.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf.configuration;
2 |
3 | import javax.xml.bind.annotation.XmlAttribute;
4 |
5 | /**
6 | * Created by QAmatic Team on 3/28/17.
7 | */
8 | public class Property {
9 |
10 | @XmlAttribute
11 | private String key;
12 | @XmlAttribute
13 | private String value;
14 |
15 | public Property() {
16 |
17 | }
18 |
19 | public Property(String key, String value) {
20 |
21 | this.key = key;
22 | this.value = value;
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/configuration/SchemaVersions.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf.configuration;
37 |
38 | import java.util.ArrayList;
39 | import java.util.List;
40 |
41 | /**
42 | * Created by qamatic on 3/6/16.
43 | */
44 |
45 | public class SchemaVersions {
46 | private List version = new ArrayList<>();
47 |
48 | public List getVersion() {
49 | return version;
50 | }
51 |
52 | public void setVersion(List version) {
53 | this.version = version;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/core/ArgPatternHandler.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf.core;
2 |
3 | import org.qamatic.mintleaf.MintleafLogger;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 | import java.util.regex.Matcher;
8 | import java.util.regex.Pattern;
9 |
10 | /**
11 | * Created by QAmatic Team on 3/30/17.
12 | */
13 | public class ArgPatternHandler {
14 |
15 | private static final MintleafLogger logger = MintleafLogger.getLogger(ArgPatternHandler.class);
16 |
17 | private final static Pattern p = Pattern.compile("\\$\\{(.+?)\\}", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
18 | private String text;
19 | private Map userProperties;
20 | private boolean bDone;
21 |
22 | public ArgPatternHandler(String text) {
23 | this.text = text;
24 | }
25 |
26 | public Map getUserProperties() {
27 | if (userProperties == null) {
28 | userProperties = new HashMap<>();
29 | }
30 | return userProperties;
31 | }
32 |
33 | public ArgPatternHandler withUserProperties(Map userProperties) {
34 | this.userProperties = userProperties;
35 | return this;
36 | }
37 |
38 | public String getText() {
39 | if (!bDone) {
40 | bDone = true;
41 | relacewithUserVars();
42 | relacewithVMArgs();
43 | relacewithSystemArgs();
44 | }
45 | return this.text;
46 | }
47 |
48 | private void relacewithSystemArgs() {
49 | Matcher m = p.matcher(this.text);
50 | StringBuffer sb = new StringBuffer();
51 | while (m.find()) {
52 | if (System.getenv(m.group(1)) != null) {
53 | m.appendReplacement(sb, System.getenv(m.group(1)));
54 | }
55 | }
56 | m.appendTail(sb);
57 | this.text = sb.toString();
58 | }
59 |
60 | private void relacewithVMArgs() {
61 | Matcher m = p.matcher(this.text);
62 | StringBuffer sb = new StringBuffer();
63 | while (m.find()) {
64 | if (System.getProperty(m.group(1)) != null) {
65 | m.appendReplacement(sb, System.getProperty(m.group(1)));
66 | }
67 | }
68 | m.appendTail(sb);
69 | this.text = sb.toString();
70 | }
71 |
72 | private void relacewithUserVars() {
73 | Matcher m = p.matcher(this.text);
74 | StringBuffer sb = new StringBuffer();
75 | while (m.find()) {
76 | if (getUserProperties().containsKey(m.group(1))) {
77 | m.appendReplacement(sb, String.valueOf(getUserProperties().get(m.group(1))));
78 | }
79 | }
80 | m.appendTail(sb);
81 | this.text = sb.toString();
82 | }
83 |
84 | @Override
85 | public String toString() {
86 | return getText();
87 | }
88 |
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/core/BaseSqlScript.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf.core;
37 |
38 |
39 | import org.qamatic.mintleaf.*;
40 |
41 | public abstract class BaseSqlScript implements SqlScript {
42 |
43 | private final static MintleafLogger logger = MintleafLogger.getLogger(BaseSqlScript.class);
44 | protected ConnectionContext connectionContext;
45 |
46 | public BaseSqlScript(ConnectionContext connectionContext) {
47 | this.connectionContext = connectionContext;
48 | }
49 |
50 | public ConnectionContext getConnectionContext() {
51 | return connectionContext;
52 | }
53 |
54 | @Override
55 | public void apply() throws MintleafException {
56 | MintleafReader reader = getReader();
57 | execute(reader);
58 | close();
59 | }
60 |
61 |
62 | protected void execute(MintleafReader reader) throws MintleafException {
63 | prepareListeners(reader);
64 | reader.read();
65 | }
66 |
67 |
68 | protected void prepareListeners(MintleafReader reader) throws MintleafException {
69 | reader.getPreProcessors().add(new CommandExecutor(connectionContext));
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/core/BinaryDataIterable.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf.core;
2 |
3 | import org.qamatic.mintleaf.MintleafException;
4 |
5 | /**
6 | * Created by QAmatic Team on 4/17/17.
7 | */
8 | public interface BinaryDataIterable extends Iterable, AutoCloseable {
9 | long getCurrentPos() throws MintleafException;
10 |
11 | BinaryDataIterable recordAt(int recordNumber) throws MintleafException;
12 |
13 | BinaryDataIterable recordSize(int recordSize) throws MintleafException;
14 |
15 | BinaryDataIterable reset() throws MintleafException;
16 |
17 | BinaryDataIterable reset(long bytesPos) throws MintleafException;
18 |
19 | default void close() {
20 |
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/core/CommandExecutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf.core;
37 |
38 | import org.qamatic.mintleaf.*;
39 |
40 | public class CommandExecutor implements ReadListener {
41 |
42 | private static final MintleafLogger logger = MintleafLogger.getLogger(CommandExecutor.class);
43 | protected final ConnectionContext connectionContext;
44 |
45 | public CommandExecutor(ConnectionContext connectionContext) {
46 | this.connectionContext = connectionContext;
47 | }
48 |
49 | @Override
50 | public void eachRow(int rowNum, Row row) throws MintleafException {
51 | ChangeSet changeSet = (ChangeSet) row;
52 | ExecuteQuery query = new ExecuteQuery(connectionContext, changeSet.getChangeSetSource(), null);
53 | try {
54 | logger.info(String.format("Executing Query: %s \n--\n", changeSet.getChangeSetSource()));
55 | query.execute();
56 | } catch (Exception e) {
57 |
58 | final String message = "error executing query: \n" + this.connectionContext.toString();
59 | logger.error(message, e);
60 | throw new MintleafException("error executing query: ", e);
61 | } finally {
62 | query.close();
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/core/SqlScriptFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * *
4 | * * *
5 | * * * ~
6 | * * * ~ The MIT License (MIT)
7 | * * * ~
8 | * * * ~ Copyright (c) 2010-2017 QAMatic Team
9 | * * * ~
10 | * * * ~ Permission is hereby granted, free of charge, to any person obtaining a copy
11 | * * * ~ of this software and associated documentation files (the "Software"), to deal
12 | * * * ~ in the Software without restriction, including without limitation the rights
13 | * * * ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | * * * ~ copies of the Software, and to permit persons to whom the Software is
15 | * * * ~ furnished to do so, subject to the following conditions:
16 | * * * ~
17 | * * * ~ The above copyright notice and this permission notice shall be included in all
18 | * * * ~ copies or substantial portions of the Software.
19 | * * * ~
20 | * * * ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | * * * ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | * * * ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | * * * ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | * * * ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | * * * ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | * * * ~ SOFTWARE.
27 | * * * ~
28 | * * * ~
29 | * * *
30 | * *
31 | * *
32 | *
33 | * /
34 | */
35 |
36 | package org.qamatic.mintleaf.core;
37 |
38 | import org.qamatic.mintleaf.ConnectionContext;
39 | import org.qamatic.mintleaf.MintleafLogger;
40 | import org.qamatic.mintleaf.MintleafReader;
41 | import org.qamatic.mintleaf.readers.SqlFileStreamReader;
42 |
43 | import java.io.InputStream;
44 |
45 | /**
46 | * Created by qamatic on 7/18/16.
47 | */
48 | public class SqlScriptFile extends BaseSqlScript {
49 |
50 | private final static MintleafLogger logger = MintleafLogger.getLogger(SqlScriptFile.class);
51 | private final String filename;
52 | private final String delimiter;
53 | private MintleafReader reader;
54 |
55 | public SqlScriptFile(ConnectionContext connectionContext, String filename, String delimiter) {
56 | super(connectionContext);
57 | this.filename = filename;
58 | this.delimiter = delimiter;
59 | }
60 |
61 | @Override
62 | public MintleafReader getReader() {
63 | if (this.reader == null) {
64 | InputStream stream = BaseReader.getInputStreamFromFile(this.filename);
65 | this.reader = new SqlFileStreamReader(stream);
66 | ((SqlFileStreamReader)this.reader).setDelimiter(this.delimiter);
67 | }
68 | return this.reader;
69 | }
70 |
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/core/src/main/java/org/qamatic/mintleaf/core/rows/InMemoryRow.java:
--------------------------------------------------------------------------------
1 | package org.qamatic.mintleaf.core.rows;
2 |
3 | import org.qamatic.mintleaf.Column;
4 | import org.qamatic.mintleaf.MetaDataCollection;
5 | import org.qamatic.mintleaf.MintleafException;
6 | import org.qamatic.mintleaf.Row;
7 |
8 | import java.nio.charset.Charset;
9 | import java.sql.SQLException;
10 | import java.util.ArrayList;
11 | import java.util.Arrays;
12 | import java.util.List;
13 |
14 | /**
15 | * Created by QAmatic Team on 4/16/17.
16 | */
17 | public class InMemoryRow implements Row {
18 | private MetaDataCollection metaDataCollection;
19 | private List