├── .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 | [![CircleCI](https://circleci.com/gh/qamatic/mintleaf.svg?style=svg)](https://circleci.com/gh/qamatic/mintleaf) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.qamatic/mintleaf-core/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/org.qamatic/mintleaf-core) 2 | 3 | ![logo](https://github.com/qamatic/mintleaf/blob/master/doc/source/images/logosimple.png) 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 sourceTable); 52 | 53 | Table getTargetTable(); 54 | 55 | void setTargetTable(Table 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 rowValues = new ArrayList<>(); 20 | 21 | public InMemoryRow() { 22 | 23 | } 24 | 25 | public InMemoryRow(MetaDataCollection metaDataCollection) { 26 | this.metaDataCollection = metaDataCollection; 27 | } 28 | 29 | 30 | @Override 31 | public Object getValue(int columnIndex) throws MintleafException { 32 | return rowValues.get(columnIndex); 33 | } 34 | 35 | @Override 36 | public MetaDataCollection getMetaData() throws MintleafException { 37 | return this.metaDataCollection; 38 | } 39 | 40 | @Override 41 | public void setMetaData(MetaDataCollection metaDataCollection) { 42 | this.metaDataCollection = metaDataCollection; 43 | } 44 | 45 | 46 | @Override 47 | public void setValue(int columnIndex, Object value) { 48 | getValues().add(value);//override if you need differently 49 | } 50 | 51 | @Override 52 | public void setValue(int columnIndex, byte[] value, Charset charset) { 53 | setValue(columnIndex, new String(value, charset).trim()); 54 | } 55 | 56 | @Override 57 | public void setValues(byte[] byteRecord, Charset charset) { 58 | 59 | int bstart = 0; 60 | try { 61 | if (getMetaData() == null) { 62 | MintleafException.throwException("metadata must be set on the object before calling this method"); 63 | } 64 | for (int i = 0; i < getMetaData().getColumnCount(); i++) { 65 | Column c = getMetaData().getColumn(i); 66 | byte[] bytes = Arrays.copyOfRange(byteRecord, bstart, bstart + c.getColumnSize()); 67 | bstart += bytes.length; 68 | setValue(i, bytes, charset); 69 | } 70 | } catch (SQLException e) { 71 | MintleafException.throwException(e); 72 | } catch (MintleafException e) { 73 | MintleafException.throwException(e); 74 | } 75 | } 76 | 77 | public List getValues() { 78 | return rowValues; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/core/stdqueries/MSSqlQueries.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.stdqueries; 37 | 38 | import org.qamatic.mintleaf.ConnectionContext; 39 | 40 | /** 41 | * Created by qamatic on 3/6/16. 42 | */ 43 | public class MSSqlQueries extends StandardQueries { 44 | public MSSqlQueries(ConnectionContext connectionContext) { 45 | super(connectionContext); 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/core/stdqueries/MySqlQueries.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.stdqueries; 37 | 38 | import org.qamatic.mintleaf.ConnectionContext; 39 | 40 | /** 41 | * Created by qamatic on 3/6/16. 42 | */ 43 | public class MySqlQueries extends StandardQueries { 44 | public MySqlQueries(ConnectionContext connectionContext) { 45 | super(connectionContext); 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/core/stdqueries/PostgresQueries.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.stdqueries; 37 | 38 | import org.qamatic.mintleaf.ConnectionContext; 39 | 40 | /** 41 | * Created by qamatic on 3/6/16. 42 | */ 43 | public class PostgresQueries extends StandardQueries { 44 | public PostgresQueries(ConnectionContext connectionContext) { 45 | super(connectionContext); 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/data/CompareRowState.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.data; 37 | 38 | import org.qamatic.mintleaf.MetaDataCollection; 39 | import org.qamatic.mintleaf.MintleafException; 40 | 41 | /** 42 | * Created by qamatic on 3/5/16. 43 | */ 44 | public class CompareRowState { 45 | public int ColumnNumber = -1; 46 | public int RowNumber = -1; 47 | public int IsSurplusRow; 48 | public org.qamatic.mintleaf.Row Row; 49 | private MetaDataCollection metaDataCollection; 50 | 51 | @Override 52 | public String toString() { 53 | return String.format("RowNo:%d, ColumnNo:%d, Surplus:%d", RowNumber, ColumnNumber, IsSurplusRow); 54 | } 55 | 56 | public Object getValue() throws MintleafException { 57 | return Row.getValue(ColumnNumber); 58 | } 59 | 60 | public String asString() throws MintleafException { 61 | return getValue().toString(); 62 | } 63 | 64 | public MetaDataCollection getMetaData() { 65 | return metaDataCollection; 66 | } 67 | 68 | public void setMetaData(MetaDataCollection metaDataCollection) { 69 | this.metaDataCollection = metaDataCollection; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/data/ComparerListener.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.data; 37 | 38 | import org.qamatic.mintleaf.MintleafException; 39 | import org.qamatic.mintleaf.Table; 40 | 41 | /** 42 | * Created by qamatic on 3/4/16. 43 | */ 44 | public interface ComparerListener { 45 | 46 | default void OnBeginCompare(Table sourceTable, Table targetTable) throws MintleafException { 47 | 48 | } 49 | 50 | default void OnEndCompare(final CompareRowState sourceRow, final CompareRowState targetRow) throws MintleafException { 51 | 52 | } 53 | 54 | default void onBeforeRowCompare(final CompareRowState sourceRow, final CompareRowState targetRow) throws MintleafException { 55 | 56 | } 57 | 58 | default void onAfterRowCompare(final CompareRowState sourceRow, final CompareRowState targetRow) throws MintleafException { 59 | 60 | } 61 | 62 | default void OnRowCompare(final CompareRowState sourceRow, final CompareRowState targetRow) throws MintleafException { 63 | 64 | } 65 | 66 | 67 | void OnColumnCompare(final CompareColumnState sourceColumn, final CompareColumnState targetColumn) throws MintleafException; 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/readers/BinaryDataReader.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf.readers; 2 | 3 | import org.qamatic.mintleaf.MintleafException; 4 | import org.qamatic.mintleaf.MintleafReader; 5 | import org.qamatic.mintleaf.Row; 6 | import org.qamatic.mintleaf.core.BaseReader; 7 | import org.qamatic.mintleaf.core.BinaryDataIterable; 8 | 9 | import java.nio.charset.Charset; 10 | import java.util.Iterator; 11 | 12 | /** 13 | * Created by QAmatic Team on 4/11/17. 14 | */ 15 | public abstract class BinaryDataReader extends BaseReader implements MintleafReader { 16 | 17 | 18 | private BinaryDataIterable binaryDataIterable; 19 | 20 | public BinaryDataReader(BinaryDataIterable binaryDataIterable, Charset charset) { 21 | this.binaryDataIterable = binaryDataIterable; 22 | setCharset(charset); 23 | } 24 | 25 | public abstract Row createRowInstance(byte[] rowChunk); 26 | 27 | @Override 28 | public void read() throws MintleafException { 29 | Iterator iterator = this.binaryDataIterable.iterator(); 30 | int i = 0; 31 | while (iterator.hasNext()) { 32 | byte[] bytes = iterator.next(); 33 | Row row = createRowInstance(bytes); 34 | row.setValues(bytes, getCharset()); 35 | if (!readRow(i++, row)) { 36 | break; 37 | } 38 | } 39 | 40 | } 41 | 42 | public BinaryDataIterable getIterator() { 43 | return binaryDataIterable; 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/readers/CsvRowWrapper.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.readers; 37 | 38 | import org.apache.commons.csv.CSVRecord; 39 | import org.qamatic.mintleaf.MetaDataCollection; 40 | import org.qamatic.mintleaf.MintleafException; 41 | import org.qamatic.mintleaf.Row; 42 | 43 | /** 44 | * Created by QAmatic on 3/10/2017. 45 | */ 46 | public class CsvRowWrapper implements Row { 47 | 48 | 49 | private CSVRecord record; 50 | private MetaDataCollection metaDataCollection; 51 | 52 | public CsvRowWrapper() { 53 | 54 | } 55 | 56 | public CsvRowWrapper(CSVRecord record) { 57 | this.record = record; 58 | } 59 | 60 | public void setRecord(CSVRecord record) { 61 | this.record = record; 62 | } 63 | 64 | @Override 65 | public String getValue(int columnIndex) { 66 | return record.get(columnIndex); 67 | } 68 | 69 | @Override 70 | public String getValue(String columnName) { 71 | return record.get(columnName); 72 | } 73 | 74 | @Override 75 | public MetaDataCollection getMetaData() throws MintleafException { 76 | return this.metaDataCollection; 77 | } 78 | 79 | @Override 80 | public void setMetaData(MetaDataCollection metaDataCollection) { 81 | this.metaDataCollection = metaDataCollection; 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/readers/SqlFileExecute.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf.readers; 2 | 3 | import org.qamatic.mintleaf.ConnectionContext; 4 | import org.qamatic.mintleaf.Executable; 5 | import org.qamatic.mintleaf.MintleafException; 6 | 7 | public class SqlFileExecute extends SqlFileStreamReader implements Executable { 8 | public SqlFileExecute(ConnectionContext connectionContext, String filename) { 9 | super(filename); 10 | } 11 | 12 | public SqlFileExecute(ConnectionContext connectionContext, String filename, String delimiter) { 13 | super(filename); 14 | setDelimiter(delimiter); 15 | } 16 | 17 | @Override 18 | public Boolean execute() throws MintleafException { 19 | 20 | 21 | return true; 22 | } 23 | 24 | @Override 25 | public void close() { 26 | super.close(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/tools/BinaryFileImporter.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.tools; 37 | 38 | import org.qamatic.mintleaf.*; 39 | 40 | /** 41 | * Created by qamatic on 3/6/16. 42 | */ 43 | public class BinaryFileImporter extends SqlBatchInsertReadListener implements Executable { 44 | 45 | private static final MintleafLogger logger = MintleafLogger.getLogger(BinaryFileImporter.class); 46 | private MintleafReader importReader; 47 | private ConnectionContext targetDb; 48 | private String targetSqlTemplate; 49 | private ReadListener importReaderReadListener; 50 | 51 | public BinaryFileImporter(MintleafReader importReader, ConnectionContext targetDb, 52 | String targetSqlTemplate) { 53 | this.importReader = importReader; 54 | this.targetDb = targetDb; 55 | this.targetSqlTemplate = targetSqlTemplate; 56 | 57 | } 58 | 59 | @Override 60 | protected ConnectionContext getConnectionContext() { 61 | return targetDb; 62 | } 63 | 64 | @Override 65 | protected String getSql() { 66 | return this.targetSqlTemplate; 67 | } 68 | 69 | @Override 70 | public MintleafReader getReader() throws MintleafException { 71 | this.importReader.getPreProcessors().add(this); 72 | return this.importReader; 73 | } 74 | 75 | 76 | } 77 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/tools/CsvExportFlavour.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.tools; 37 | 38 | import org.apache.commons.csv.CSVFormat; 39 | import org.apache.commons.csv.CSVPrinter; 40 | import org.qamatic.mintleaf.MintleafException; 41 | 42 | import java.io.IOException; 43 | import java.io.Writer; 44 | import java.sql.ResultSet; 45 | import java.sql.SQLException; 46 | 47 | /** 48 | * Created by qamatic on 2/18/6/16. 49 | */ 50 | public class CsvExportFlavour implements ExportFlavour { 51 | 52 | private Writer writer; 53 | 54 | public CsvExportFlavour(Writer writer) { 55 | this.writer = writer; 56 | 57 | } 58 | 59 | @Override 60 | public void export(ResultSet resultSet) throws MintleafException { 61 | CSVPrinter printer = null; 62 | try { 63 | printer = new CSVPrinter(writer, CSVFormat.EXCEL.withHeader(resultSet)); 64 | printer.printRecords(resultSet); 65 | printer.close(); 66 | } catch (SQLException e) { 67 | throw new MintleafException(e); 68 | } catch (IOException e) { 69 | throw new MintleafException(e); 70 | 71 | } 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/tools/ExportFlavour.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.tools; 37 | 38 | import org.qamatic.mintleaf.MintleafException; 39 | 40 | import java.sql.ResultSet; 41 | 42 | /** 43 | * Created by qamatic on 2/18/6/16. 44 | */ 45 | public interface ExportFlavour extends AutoCloseable { 46 | 47 | void export(ResultSet resultSet) throws MintleafException; 48 | 49 | default void close() throws MintleafException { 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/main/java/org/qamatic/mintleaf/tools/FileFinder.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf.tools; 2 | 3 | import org.qamatic.mintleaf.MintleafLogger; 4 | 5 | import java.io.IOException; 6 | import java.nio.file.*; 7 | import java.nio.file.attribute.BasicFileAttributes; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by QAmatic Team on 4/8/17. 13 | */ 14 | public class FileFinder { 15 | private static final MintleafLogger logger = MintleafLogger.getLogger(FileFinder.class); 16 | 17 | private final PathMatcher matcher; 18 | private final String path; 19 | private final boolean regExMatch; 20 | 21 | public FileFinder(String path) { 22 | final String[] pathSplits = path.split("/"); 23 | regExMatch = path.contains("regex:"); 24 | final String wildCardName = regExMatch ? pathSplits[pathSplits.length - 1] : "glob:" + pathSplits[pathSplits.length - 1]; 25 | this.path = path.replaceAll("\\Q" + pathSplits[pathSplits.length - 1] + "\\E", ""); 26 | matcher = FileSystems.getDefault() 27 | .getPathMatcher(wildCardName); 28 | } 29 | 30 | public List list() { 31 | List files = new ArrayList<>(); 32 | try { 33 | Files.walkFileTree(Paths.get(this.path), new SimpleFileVisitor() { 34 | @Override 35 | public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { 36 | Path name = regExMatch ? file.toAbsolutePath() : file.getFileName(); 37 | if (name != null && matcher.matches(name)) { 38 | files.add(file.toAbsolutePath().toString()); 39 | } 40 | return FileVisitResult.CONTINUE; 41 | } 42 | }); 43 | } catch (IOException e) { 44 | logger.error(e); 45 | } 46 | return files; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/resources/internal-core-mintleaf-logs.sql: -------------------------------------------------------------------------------- 1 | -- 2 | 3 | drop table if exists mintleaf.mintleaf_logs 4 | 5 | -- 6 | 7 | CREATE TABLE if not exists mintleaf.mintleaf_logs 8 | ( 9 | 10 | id INT NOT NULL , 11 | version VARCHAR2 (60 CHAR) NOT NULL, 12 | change_sets VARCHAR2 (60 CHAR) NOT NULL, 13 | script_location VARCHAR2 (60 CHAR) NOT NULL, 14 | status NUMBER (5) NULL, 15 | last_error TEXT NULL, 16 | 17 | ) 18 | ; 19 | 20 | 21 | 22 | -- 23 | 24 | CREATE TABLE mintleaf.mintleaf_logs ( 25 | id SERIAL PRIMARY KEY, 26 | version VARCHAR(20) NOT NULL, 27 | change_sets VARCHAR(250) NOT NULL, 28 | script_location VARCHAR(120) NOT NULL, 29 | status SMALLINT DEFAULT 0 NULL, 30 | last_error TEXT NULL 31 | 32 | ); 33 | 34 | -- -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/ApacheBasicDataSource.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.apache.commons.dbcp.BasicDataSource; 39 | 40 | /** 41 | * Created by qamatic on 3/5/16. 42 | */ 43 | public class ApacheBasicDataSource extends BasicDataSource implements DriverSource { 44 | 45 | 46 | @Override 47 | public boolean isDebugEnabled() { 48 | return false; 49 | } 50 | 51 | @Override 52 | public void setDebugEnabled(boolean debug) { 53 | 54 | } 55 | 56 | @Override 57 | public void setProperty(String propName, String value) { 58 | 59 | } 60 | 61 | @Override 62 | public String getProperty(String propName) { 63 | return null; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/H2ExampleAssert.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/25/17. 40 | */ 41 | public interface H2ExampleAssert extends DbQueryExtension { 42 | String returnSomeValue(); 43 | } 44 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/H2MigrationTest.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.junit.Assert; 39 | import org.junit.Before; 40 | import org.junit.Test; 41 | import org.qamatic.mintleaf.core.ChangeSets; 42 | 43 | import java.io.IOException; 44 | import java.sql.SQLException; 45 | 46 | public class H2MigrationTest extends H2TestCase { 47 | 48 | @Before 49 | public void cleanDb() throws MintleafException { 50 | ChangeSets.migrate(testDb.getNewConnection(), "res:/testddl.sql", "create schema"); 51 | ChangeSets.migrate(testDb.getNewConnection(), "res:/internal-core-mintleaf-logs.sql", "delete-mintleaf-logs, h2-core-mintleaf-logs"); 52 | } 53 | 54 | @Test 55 | public void testMintleafLog() throws SQLException, IOException, MintleafException { 56 | Assert.assertTrue("MINTLEAF_LOGS table not found", testDbQueries.isTableExists("mintleaf.MINTLEAF_LOGS")); 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/H2TestCase.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.junit.BeforeClass; 39 | import org.qamatic.mintleaf.core.JdbcDriverSource; 40 | 41 | /** 42 | * Created by qamatic on 3/3/16. 43 | */ 44 | public class H2TestCase { 45 | protected static Database testDb; 46 | protected static DbQueryExtension testDbQueries; 47 | 48 | @BeforeClass 49 | public static void setupDb() { 50 | 51 | if (testDb != null) 52 | return; 53 | 54 | testDb = new Mintleaf.DatabaseBuilder(). 55 | withDriverSource(JdbcDriverSource.class). 56 | withUrl("jdbc:h2:./target/h2testdb;mv_store=false;"). 57 | build(); 58 | testDbQueries = testDb.getNewConnection().getDbQueries(); 59 | 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/Hey.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf; 2 | 3 | public class Hey { 4 | 5 | public static double square(double num) { 6 | return Math.pow(num, 2); 7 | } 8 | 9 | public static boolean contains(double num, double num1) { 10 | return true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/MyH2Queries.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.stdqueries.H2Queries; 39 | 40 | /** 41 | * Created by QAmatic Team on 3/25/17. 42 | */ 43 | public class MyH2Queries extends H2Queries implements H2ExampleAssert { 44 | 45 | public MyH2Queries(ConnectionContext connectionContext) { 46 | super(connectionContext); 47 | } 48 | 49 | @Override 50 | public String returnSomeValue() { 51 | return "test"; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/TestSuiteH2.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | /** 7 | * Created by QAmatic team on 3/26/17. 8 | */ 9 | @RunWith(Suite.class) 10 | @Suite.SuiteClasses({ 11 | // DbComparerTests.class, 12 | // DbQueriesTest.class, 13 | // ImportExportTests.class, 14 | // SingleLoadScriptTests.class, 15 | // ChangeSetsTest.class 16 | }) 17 | public class TestSuiteH2 { 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/TestSuiteOracle.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | /** 7 | * Created by QAmatic team on 3/26/17. 8 | */ 9 | @RunWith(Suite.class) 10 | @Suite.SuiteClasses({ 11 | // OraTransactionTest.class, 12 | // OraUtilityTest.class 13 | }) 14 | public class TestSuiteOracle { 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/core/Apple.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf.core; 2 | 3 | public class Apple { 4 | private String color; 5 | private Double weight; 6 | 7 | public Apple(String c, Double w) { 8 | this.color = c; 9 | this.weight = w; 10 | } 11 | 12 | @Override 13 | public String toString() { 14 | return "Apple{color:" + this.getColor() + ",weight:" + this.getWeight() + "}"; 15 | } 16 | 17 | public String getColor() { 18 | return color; 19 | } 20 | 21 | public void setColor(String color) { 22 | this.color = color; 23 | } 24 | 25 | public Double getWeight() { 26 | return weight; 27 | } 28 | 29 | public void setWeight(Double weight) { 30 | this.weight = weight; 31 | } 32 | } -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/core/CustomInMemoryRow.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf.core; 2 | 3 | 4 | import org.qamatic.mintleaf.core.rows.InMemoryRow; 5 | 6 | public class CustomInMemoryRow extends InMemoryRow { 7 | private int name; 8 | 9 | public int getName() { 10 | return name; 11 | } 12 | 13 | public void setName(int name) { 14 | this.name = name; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/mysql/MySqlDbQueriesTest.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf.mysql; 2 | 3 | import org.junit.Before; 4 | import org.junit.Ignore; 5 | import org.qamatic.mintleaf.ConnectionContext; 6 | import org.qamatic.mintleaf.Database; 7 | import org.qamatic.mintleaf.MintleafException; 8 | import org.qamatic.mintleaf.SqlResultSet; 9 | import org.qamatic.mintleaf.core.ChangeSets; 10 | 11 | import java.sql.SQLException; 12 | 13 | import static junit.framework.TestCase.assertEquals; 14 | 15 | /** 16 | * Created by QAmatic Team on 4/1/17. 17 | */ 18 | @Ignore 19 | public class MySqlDbQueriesTest extends MysqlTestCase { 20 | 21 | 22 | @Before 23 | public void setup() { 24 | initDb(); 25 | } 26 | 27 | 28 | @Ignore 29 | public void mysqlDepartmentQueryTest() throws MintleafException, SQLException { 30 | Database employeesDb = createDbContext("testuser1", "testpassword1"); 31 | try (ConnectionContext ctx = employeesDb.getNewConnection()) { 32 | ChangeSets.migrate(ctx, "res:/mysql/mysql-sample-db-employees.sql", "create employees sample database"); 33 | ChangeSets.migrate(ctx, "res:/mysql/mysql_load_departments.dump", "load departments"); 34 | } 35 | try (ConnectionContext ctx = employeesDb.getNewConnection()) { 36 | SqlResultSet resultSet = ctx.queryBuilder().withSql("Select count(*) from employees.departments").buildSelect(); 37 | assertEquals(9, resultSet.first().getInt(1)); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/mysql/MysqlTestCase.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.mysql; 37 | 38 | import org.qamatic.mintleaf.ApacheBasicDataSource; 39 | import org.qamatic.mintleaf.Database; 40 | import org.qamatic.mintleaf.Mintleaf; 41 | import org.qamatic.mintleaf.MintleafException; 42 | import org.qamatic.mintleaf.core.ChangeSets; 43 | 44 | /** 45 | * Created by qamatic on 3/4/16. 46 | */ 47 | public class MysqlTestCase { 48 | 49 | 50 | static { 51 | initDb(); 52 | } 53 | 54 | protected static void initDb() { 55 | Database sysDb = createDbContext(System.getenv("MYSQL_DB_ADMIN_USERNAME"), 56 | System.getenv("MYSQL_DB_ADMIN_PASSWORD")); 57 | try { 58 | ChangeSets.migrate(sysDb.getNewConnection(), "res:/mysql/mysql-db-setup.sql", "create database and users"); 59 | } catch (MintleafException e) { 60 | MintleafException.throwException(e.getMessage()); 61 | } 62 | } 63 | 64 | public static Database createDbContext(String userName, String password) { 65 | Database db = new Mintleaf.DatabaseBuilder(). 66 | withDriverSource(ApacheBasicDataSource.class). 67 | withUrl(System.getenv("MYSQL_DB_URL")). 68 | withUsername(userName). 69 | withPassword(password). 70 | build(); 71 | return db; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/oracle/OraTransactionTest.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.oracle; 37 | 38 | import org.junit.BeforeClass; 39 | import org.junit.Ignore; 40 | import org.junit.Test; 41 | import org.qamatic.mintleaf.ConnectionContext; 42 | import org.qamatic.mintleaf.Database; 43 | import org.qamatic.mintleaf.MintleafException; 44 | import org.qamatic.mintleaf.core.ChangeSets; 45 | 46 | import static org.junit.Assert.assertEquals; 47 | 48 | /** 49 | * Created by qamatic on 3/4/16. 50 | */ 51 | 52 | @Ignore 53 | public class OraTransactionTest extends OracleTestCase { 54 | 55 | private static Database hrdb1 = createOracleDbContext("HRDB1", "HRDB1"); 56 | 57 | @BeforeClass 58 | public static void migrate() throws MintleafException { 59 | ChangeSets.migrate(hrdb1.getNewConnection(), "res:/oracle/hrdb-changesets/hrdb-ddl.sql", "create countries"); 60 | } 61 | 62 | @Test 63 | public void testCountriesCount() throws MintleafException { 64 | ChangeSets.migrate(hrdb1.getNewConnection(), "res:/oracle/hrdb-changesets/hrdb-sampledata.sql", "seed data for countries"); 65 | try (ConnectionContext ctx = hrdb1.getNewConnection()) { 66 | assertEquals(12, ctx.getDbQueries().getCount("HRDB1.COUNTRIES")); 67 | } 68 | 69 | } 70 | 71 | 72 | } 73 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/oracle/OracleTestCase.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.oracle; 37 | 38 | import org.qamatic.mintleaf.ApacheBasicDataSource; 39 | import org.qamatic.mintleaf.Database; 40 | import org.qamatic.mintleaf.Mintleaf; 41 | import org.qamatic.mintleaf.MintleafException; 42 | import org.qamatic.mintleaf.core.ChangeSets; 43 | 44 | /** 45 | * Created by qamatic on 3/4/16. 46 | */ 47 | public class OracleTestCase { 48 | 49 | 50 | static { 51 | Database oraSysDb = createOracleDbContext(System.getenv("ORA_DB_ADMIN_USERNAME"), 52 | System.getenv("ORA_DB_ADMIN_PASSWORD")); 53 | try { 54 | ChangeSets.migrate(oraSysDb.getNewConnection(), "res:/oracle/hrdb-changesets/hrdb-schema-setup.sql", "create users"); 55 | } catch (MintleafException e) { 56 | MintleafException.throwException(e.getMessage()); 57 | } 58 | } 59 | 60 | public static Database createOracleDbContext(String userName, String password) { 61 | Database db = new Mintleaf.DatabaseBuilder(). 62 | withDriverSource(ApacheBasicDataSource.class). 63 | withUrl(System.getenv("ORA_DB_URL")). 64 | withUsername(userName). 65 | withPassword(password). 66 | build(); 67 | return db; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/postgres/PostgresTest.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf.postgres; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | import org.qamatic.mintleaf.ConnectionContext; 6 | import org.qamatic.mintleaf.Database; 7 | import org.qamatic.mintleaf.MintleafException; 8 | import org.qamatic.mintleaf.SqlResultSet; 9 | import org.qamatic.mintleaf.core.ChangeSets; 10 | 11 | import java.sql.SQLException; 12 | 13 | import static junit.framework.TestCase.assertEquals; 14 | 15 | public class PostgresTest extends PostgresTestCase { 16 | 17 | 18 | @Before 19 | public void setup() { 20 | initDb("northwind"); 21 | } 22 | 23 | @Test 24 | public void checkCategroiesCount() throws MintleafException, SQLException { 25 | Database employeesDb = createDbContext("northwind_user", "thewindisblowing", "northwind"); 26 | try (ConnectionContext ctx = employeesDb.getNewConnection()) { 27 | 28 | ChangeSets.migrate(ctx, "res:/postgres/postgres-northwind-db.sql", "create tables, load categories"); 29 | 30 | } 31 | try (ConnectionContext ctx = employeesDb.getNewConnection()) { 32 | SqlResultSet resultSet = ctx.queryBuilder().withSql("Select count(*) from categories").buildSelect(); 33 | assertEquals(7, resultSet.first().getInt(1)); 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /core/src/test/java/org/qamatic/mintleaf/postgres/PostgresTestCase.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.postgres; 37 | 38 | import org.qamatic.mintleaf.*; 39 | import org.qamatic.mintleaf.core.ChangeSets; 40 | 41 | /** 42 | * Created by qamatic on 3/4/16. 43 | */ 44 | public class PostgresTestCase { 45 | 46 | 47 | static { 48 | MintleafLogger.setLoggerType(ConsoleLogger.class, true); 49 | } 50 | 51 | protected static void initDb(String db) { 52 | Database sysDb = createDbContext(System.getenv("POSTGRES_DB_ADMIN_USERNAME"), 53 | System.getenv("POSTGRES_DB_ADMIN_PASSWORD"), "postgres"); 54 | try { 55 | ChangeSets.migrate(sysDb.getNewConnection(), String.format("res:/postgres/postgres-db-setup-%s.sql", db), "create northwind database"); 56 | } catch (MintleafException e) { 57 | MintleafException.throwException(e.getMessage()); 58 | } 59 | } 60 | 61 | public static Database createDbContext(String userName, String password, String dbName) { 62 | Database db = new Mintleaf.DatabaseBuilder(). 63 | withDriverSource(ApacheBasicDataSource.class). 64 | withUrl(System.getenv("POSTGRES_DB_URL") + dbName). 65 | withUsername(userName). 66 | withPassword(password). 67 | build(); 68 | return db; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /core/src/test/resources/EmptyPackage.sql: -------------------------------------------------------------------------------- 1 | -- empty package 2 | create or replace package EmptyPackage 3 | as 4 | 5 | end EmptyPackage; 6 | 7 | / 8 | show err 9 | 10 | create or replace 11 | package body EmptyPackage 12 | as 13 | 14 | end EmptyPackage; 15 | 16 | / 17 | 18 | -------------------------------------------------------------------------------- /core/src/test/resources/Testddl.sql: -------------------------------------------------------------------------------- 1 | -- 2 | 3 | create SCHEMA if not EXISTS mintleaf; 4 | 5 | -- 6 | 7 | 8 | 9 | CREATE TABLE mintleaf.TABLE1 10 | ( 11 | 12 | ID NUMBER (18) NOT NULL , 13 | NAME VARCHAR2 (60 CHAR) NOT NULL 14 | 15 | ) 16 | ; 17 | 18 | 19 | CREATE TABLE mintleaf.TABLE2 20 | ( 21 | ID NUMBER (18) NOT NULL , 22 | NAME VARCHAR2 (60 CHAR) NOT NULL 23 | ) 24 | ; 25 | 26 | 27 | -- 28 | 29 | drop table if EXISTS mintleaf.TABLE1; 30 | 31 | drop table if EXISTS mintleaf.TABLE2; 32 | 33 | 34 | -- 35 | drop schema if EXISTS mintleaf; -------------------------------------------------------------------------------- /core/src/test/resources/binary-import-changesets.sql: -------------------------------------------------------------------------------- 1 | -- 2 | DROP SCHEMA IF EXISTS BINARY_IMPDB; 3 | CREATE SCHEMA IF NOT EXISTS BINARY_IMPDB; 4 | 5 | CREATE TABLE IF NOT EXISTS BINARY_IMPDB.CITIES 6 | ( 7 | ID INT NOT NULL, 8 | CITY VARCHAR2(50), 9 | STATE VARCHAR2(50), 10 | COUNTRY VARCHAR2(50), 11 | CONSTRAINT PK_ID PRIMARY KEY (ID) 12 | ); 13 | 14 | 15 | -------------------------------------------------------------------------------- /core/src/test/resources/changesets/h2/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 | -------------------------------------------------------------------------------- /core/src/test/resources/changesets/h2/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 | -------------------------------------------------------------------------------- /core/src/test/resources/connection-prop-variable.sql: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | 4 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (${user_id}, '${user_name}'); 5 | 6 | 7 | -- 8 | 9 | INSERT INTO ${DEFAULT_SCHEMA}.USERS (USERID, USERNAME) VALUES ("33", 'senthil'); -------------------------------------------------------------------------------- /core/src/test/resources/example-changesets.sql: -------------------------------------------------------------------------------- 1 | -- 2 | DROP SCHEMA IF EXISTS HRDB; 3 | CREATE SCHEMA IF NOT EXISTS HRDB; 4 | 5 | CREATE TABLE IF NOT EXISTS HRDB.USERS 6 | ( 7 | USERID INT NOT NULL, 8 | USERNAME VARCHAR2(50), 9 | RATE NUMBER(12, 2), 10 | CREATE_TIME DATE NULL , 11 | CONSTRAINT PK_USERID PRIMARY KEY (USERID) 12 | ); 13 | 14 | -- 15 | 16 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (1, 'Aiden'); 17 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (2, 'Ethan, Allen'); 18 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (3, 'Liam'); 19 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (4, 'Noah'); 20 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (5, 'Jacob'); 21 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (6, 'Benjamin'); 22 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (7, 'qamatic'); 23 | 24 | -- 25 | DROP TABLE IF EXISTS HRDB.USERS_IMPORT_TABLE; 26 | 27 | CREATE TABLE IF NOT EXISTS HRDB.USERS_IMPORT_TABLE 28 | ( 29 | USERID INT NOT NULL, 30 | USERNAME VARCHAR2(50), 31 | RATE NUMBER(12, 2), 32 | CREATE_TIME DATE NULL, 33 | CONSTRAINT PK_USERID_IMPORT PRIMARY KEY (USERID) 34 | ); 35 | 36 | 37 | -- 38 | 39 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (1, 'Aiden'); 40 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (2, 'qamatic'); 41 | 42 | -------------------------------------------------------------------------------- /core/src/test/resources/filefinder/f1/file11.sql: -------------------------------------------------------------------------------- 1 | -- 2 | 3 | --*--preconditions 4 | 5 | IfExists(ABCDB.TABLE1) = true 6 | IfUsingClass(com.qamatic.assert, 1, PACKAGE) = true 7 | IfCount(SELECT count(*) FROM ABCDB.TABLE1) = 0 8 | IfProc( dberify, 1, 2 ) = S 9 | 10 | --*--rollback 11 | 12 | 13 | --*--tests 14 | 15 | assertSql(SELECT ID, NAME FROM USERS) = [2, SEN] 16 | 17 | 18 | -- 19 | 20 | --*-- 21 | 22 | 23 | --*-- 24 | 25 | -------------------------------------------------------------------------------- /core/src/test/resources/filefinder/f1/file12.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/core/src/test/resources/filefinder/f1/file12.sql -------------------------------------------------------------------------------- /core/src/test/resources/filefinder/f2/file21.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/core/src/test/resources/filefinder/f2/file21.sql -------------------------------------------------------------------------------- /core/src/test/resources/h2singlescript.sql: -------------------------------------------------------------------------------- 1 | -- 2 | 3 | DROP ALL OBJECTS; 4 | 5 | CREATE SCHEMA IF NOT EXISTS HRDB; 6 | 7 | CREATE TABLE IF NOT EXISTS HRDB.USERS 8 | (USERID INT NOT NULL , USERNAME VARCHAR2(50), RATE NUMBER(12,2), CREATE_TIME DATE DEFAULT sysdate, CONSTRAINT PK_USERID PRIMARY KEY (USERID )); 9 | 10 | -- rollback-changes 11 | -------------------------------------------------------------------------------- /core/src/test/resources/impexpfiles/asciifile.txt: -------------------------------------------------------------------------------- 1 | IT Italy 1 2 | JP Japan 3 3 | US United States of America 2 4 | CA Canada 2 5 | CN China 3 6 | IN India 3 7 | AU Australia 3 8 | ZW Zimbabwe 4 9 | SG Singapore 3 10 | UK United Kingdom 1 11 | FR France 1 12 | DE Germany 1 -------------------------------------------------------------------------------- /core/src/test/resources/impexpfiles/cp1047-1.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/core/src/test/resources/impexpfiles/cp1047-1.txt -------------------------------------------------------------------------------- /core/src/test/resources/migrationtests/h2testdb/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 | -------------------------------------------------------------------------------- /core/src/test/resources/migrationtests/h2testdb/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 | -------------------------------------------------------------------------------- /core/src/test/resources/multipart.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- empty package 3 | create or replace package EmptyPackage 4 | as 5 | 6 | end EmptyPackage; 7 | 8 | / 9 | 10 | -- 11 | 12 | create or replace 13 | package body EmptyPackage 14 | as 15 | 16 | end EmptyPackage; 17 | 18 | / 19 | 20 | -- 21 | 22 | 23 | 24 | 25 | CREATE TABLE TABLE1 26 | ( 27 | 28 | ID NUMBER (18) NOT NULL , 29 | NAME VARCHAR2 (60 CHAR) NOT NULL 30 | 31 | ) 32 | ; 33 | 34 | 35 | 36 | 37 | 38 | CREATE TABLE TABLE2 39 | ( 40 | ID NUMBER (18) NOT NULL , 41 | NAME VARCHAR2 (60 CHAR) NOT NULL 42 | ) 43 | ; 44 | 45 | -------------------------------------------------------------------------------- /core/src/test/resources/multipart2.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- empty package 3 | create or replace package EmptyPackage 4 | as 5 | 6 | end EmptyPackage; 7 | 8 | / 9 | 10 | -- 11 | 12 | create or replace 13 | package body EmptyPackage 14 | as 15 | 16 | end EmptyPackage; 17 | 18 | / 19 | 20 | -- 21 | 22 | 23 | 24 | 25 | CREATE TABLE TABLE1 26 | ( 27 | 28 | ID NUMBER (18) NOT NULL , 29 | NAME VARCHAR2 (60 CHAR) NOT NULL 30 | 31 | ) 32 | ; 33 | 34 | 35 | 36 | 37 | 38 | CREATE TABLE TABLE2 39 | ( 40 | ID NUMBER (18) NOT NULL , 41 | NAME VARCHAR2 (60 CHAR) NOT NULL 42 | ) 43 | ; 44 | 45 | -------------------------------------------------------------------------------- /core/src/test/resources/mysql/mysql-db-setup.sql: -------------------------------------------------------------------------------- 1 | -- MYSQL SETUP 2 | -- 3 | 4 | DROP USER IF EXISTS 'testuser1'; 5 | CREATE USER IF NOT EXISTS 'testuser1' IDENTIFIED BY 'testpassword1'; 6 | 7 | 8 | DROP DATABASE IF EXISTS employees; 9 | CREATE DATABASE IF NOT EXISTS employees; 10 | 11 | GRANT ALL ON employees.* TO 'testuser1'; 12 | FLUSH PRIVILEGES; 13 | -------------------------------------------------------------------------------- /core/src/test/resources/mysql/mysql_load_departments.dump: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | 4 | INSERT INTO `departments` VALUES 5 | ('d001','Marketing'), 6 | ('d002','Finance'), 7 | ('d003','Human Resources'), 8 | ('d004','Production'), 9 | ('d005','Development'), 10 | ('d006','Quality Management'), 11 | ('d007','Sales'), 12 | ('d008','Research'), 13 | ('d009','Customer Service'); 14 | -------------------------------------------------------------------------------- /core/src/test/resources/oracle/hrdb-changesets/hrdb-ddl-typeobjects.sql: -------------------------------------------------------------------------------- 1 | -- 2 | 3 | CREATE TYPE address_typ AS OBJECT ( 4 | street VARCHAR2(30), 5 | city VARCHAR2(20), 6 | state CHAR(2), 7 | postal_code VARCHAR2(6) ); 8 | / 9 | 10 | CREATE TYPE employee_typ AS OBJECT ( 11 | employee_id NUMBER(6), 12 | first_name VARCHAR2(20), 13 | last_name VARCHAR2(25), 14 | email VARCHAR2(25), 15 | phone_number VARCHAR2(20), 16 | hire_date DATE, 17 | job_id VARCHAR2(10), 18 | salary NUMBER(8,2), 19 | commission_pct NUMBER(2,2), 20 | manager_id NUMBER(6), 21 | department_id NUMBER(4), 22 | address address_typ, 23 | MAP MEMBER FUNCTION get_idno RETURN NUMBER, 24 | MEMBER PROCEDURE display_address ( SELF IN OUT NOCOPY employee_typ ) ); 25 | 26 | / 27 | 28 | CREATE TYPE BODY employee_typ AS 29 | MAP MEMBER FUNCTION get_idno RETURN NUMBER IS 30 | BEGIN 31 | RETURN employee_id; 32 | END; 33 | MEMBER PROCEDURE display_address ( SELF IN OUT NOCOPY employee_typ ) IS 34 | BEGIN 35 | DBMS_OUTPUT.PUT_LINE(first_name || ' ' || last_name); 36 | DBMS_OUTPUT.PUT_LINE(address.street); 37 | DBMS_OUTPUT.PUT_LINE(address.city || ', ' || address.state || ' ' || 38 | address.postal_code); 39 | END; 40 | END; 41 | / 42 | -------------------------------------------------------------------------------- /core/src/test/resources/oracle/hrdb-changesets/hrdb-ddl.sql: -------------------------------------------------------------------------------- 1 | -- 2 | 3 | CREATE TABLE COUNTRIES 4 | ( 5 | COUNTRY_ID CHAR(2 BYTE) NOT NULL, 6 | COUNTRY_NAME VARCHAR2(40 BYTE), 7 | REGION_ID NUMBER 8 | ) LOGGING; 9 | 10 | CREATE UNIQUE INDEX COUNTRY_C_ID_PKX ON COUNTRIES 11 | ( 12 | COUNTRY_ID ASC 13 | ); 14 | 15 | ALTER TABLE COUNTRIES 16 | ADD CONSTRAINT COUNTRY_C_ID_PK PRIMARY KEY (COUNTRY_ID); 17 | 18 | 19 | -------------------------------------------------------------------------------- /core/src/test/resources/oracle/hrdb-changesets/hrdb-proc-packages.sql: -------------------------------------------------------------------------------- 1 | -- 2 | 3 | 4 | create or replace package SomePackage 5 | as 6 | 7 | end SomePackage; 8 | 9 | / 10 | 11 | 12 | create or replace 13 | package body SomePackage 14 | as 15 | 16 | end SomePackage; 17 | 18 | / 19 | 20 | -------------------------------------------------------------------------------- /core/src/test/resources/oracle/hrdb-changesets/hrdb-sampledata.sql: -------------------------------------------------------------------------------- 1 | -- 2 | 3 | INSERT INTO countries VALUES ( 'IT','Italy',1); 4 | INSERT INTO countries VALUES ( 'JP','Japan',3); 5 | INSERT INTO countries VALUES ( 'US','United States of America',2); 6 | INSERT INTO countries VALUES ( 'CA','Canada',2); 7 | INSERT INTO countries VALUES ( 'CN','China',3); 8 | INSERT INTO countries VALUES ( 'IN','India',3); 9 | INSERT INTO countries VALUES ( 'AU','Australia',3); 10 | INSERT INTO countries VALUES ( 'ZW','Zimbabwe',4); 11 | INSERT INTO countries VALUES ( 'SG','Singapore',3); 12 | INSERT INTO countries VALUES ( 'UK','United Kingdom',1); 13 | INSERT INTO countries VALUES ( 'FR','France',1); 14 | INSERT INTO countries VALUES ( 'DE','Germany',1); 15 | -------------------------------------------------------------------------------- /core/src/test/resources/oracle/hrdb-changesets/hrdb-schema-setup.sql: -------------------------------------------------------------------------------- 1 | -- 2 | 3 | DECLARE 4 | 5 | PROCEDURE CREATE_TESTUSER( 6 | v_username VARCHAR, 7 | v_password VARCHAR ) 8 | IS 9 | CNT INT; 10 | BEGIN 11 | 12 | FOR REC IN (SELECT s.SID, s.SERIAL# FROM v$session s 13 | WHERE s.username = upper(v_username)) 14 | LOOP 15 | EXECUTE immediate 'alter system kill session ''' || rec.sid || ', ' || rec.serial# || '''' ; 16 | END LOOP; 17 | 18 | SELECT COUNT(*) INTO CNT FROM ALL_USERS WHERE USERNAME = UPPER(v_username); 19 | IF CNT = 1 THEN 20 | DBMS_OUTPUT.PUT_LINE ('DROP USER' || v_username); 21 | EXECUTE IMMEDIATE 'DROP USER '|| v_username || ' CASCADE'; 22 | END IF; 23 | 24 | 25 | DBMS_OUTPUT.PUT_LINE ( 'USER created: user= ' || v_username || ', ' 26 | || 'password = ' || v_password || '.' ); 27 | 28 | EXECUTE IMMEDIATE 'CREATE USER '||v_username||' IDENTIFIED BY '||v_password; 29 | 30 | EXECUTE IMMEDIATE 'GRANT CREATE SESSION TO '||v_username; 31 | EXECUTE immediate 'GRANT CONNECT, RESOURCE, CREATE TABLE, CREATE SESSION, CREATE SEQUENCE, CREATE VIEW, CREATE TRIGGER, ALTER SESSION, CREATE SYNONYM to ' || v_username; 32 | 33 | EXECUTE IMMEDIATE 'ALTER USER '||v_username||' quota unlimited on USERS'; 34 | 35 | END CREATE_TESTUSER; 36 | 37 | BEGIN 38 | EXECUTE IMMEDIATE 'alter session set "_ORACLE_SCRIPT"=true'; 39 | CREATE_TESTUSER('HRDB1', 'HRDB1'); 40 | CREATE_TESTUSER('HRDB2', 'HRDB2'); 41 | CREATE_TESTUSER('PAYROLL1', 'PAYROLL1'); 42 | END; 43 | 44 | / 45 | -------------------------------------------------------------------------------- /core/src/test/resources/oracle/payroll-changesets/payroll-ddl.sql: -------------------------------------------------------------------------------- 1 | -- 2 | 3 | CREATE TABLE COUNTRIES 4 | ( 5 | COUNTRY_ID CHAR(2 BYTE) NOT NULL, 6 | COUNTRY_NAME VARCHAR2(40 BYTE), 7 | REGION_ID NUMBER 8 | ) LOGGING; 9 | 10 | CREATE UNIQUE INDEX COUNTRY_C_ID_PKX ON COUNTRIES 11 | ( 12 | COUNTRY_ID ASC 13 | ); 14 | 15 | ALTER TABLE COUNTRIES 16 | ADD CONSTRAINT COUNTRY_C_ID_PK PRIMARY KEY (COUNTRY_ID); 17 | 18 | 19 | -- 20 | 21 | INSERT INTO countries VALUES ( 'IT','Italy',1); 22 | INSERT INTO countries VALUES ( 'JP','Japan',3); 23 | INSERT INTO countries VALUES ( 'US','United States of America',2); 24 | INSERT INTO countries VALUES ( 'CA','Canada',2); 25 | INSERT INTO countries VALUES ( 'CN','China',3); 26 | INSERT INTO countries VALUES ( 'IN','India',3); 27 | INSERT INTO countries VALUES ( 'AU','Australia',3); 28 | INSERT INTO countries VALUES ( 'ZW','Zimbabwe',4); 29 | INSERT INTO countries VALUES ( 'SG','Singapore',3); 30 | INSERT INTO countries VALUES ( 'UK','United Kingdom',1); 31 | INSERT INTO countries VALUES ( 'FR','France',1); 32 | INSERT INTO countries VALUES ( 'DE','Germany',1); 33 | 34 | 35 | -- 36 | 37 | 38 | CREATE OR REPLACE PROCEDURE add_country 39 | ( p_country_id COUNTRIES.COUNTRY_ID%type 40 | , p_country_name COUNTRIES.COUNTRY_NAME%type 41 | ) 42 | IS 43 | BEGIN 44 | INSERT INTO COUNTRIES (COUNTRY_ID, COUNTRY_NAME) 45 | VALUES(p_country_id, p_country_name); 46 | END add_country; 47 | 48 | / 49 | 50 | create or replace function sum_numbers (n1 in number,n2 in number) 51 | return number 52 | is 53 | 54 | t number(8); 55 | 56 | begin 57 | t :=n1+n2; 58 | return t; 59 | end; 60 | 61 | / -------------------------------------------------------------------------------- /core/src/test/resources/postgres/postgres-db-setup-northwind.sql: -------------------------------------------------------------------------------- 1 | -- https://github.com/pthom/northwind_psql 2 | -- 3 | 4 | DROP DATABASE IF EXISTS northwind; 5 | CREATE DATABASE northwind; 6 | 7 | 8 | 9 | DROP USER IF EXISTS northwind_user; 10 | create user northwind_user with password 'thewindisblowing'; 11 | grant all privileges on database northwind to northwind_user; 12 | 13 | -------------------------------------------------------------------------------- /core/src/test/resources/postgres/postgres-northwind-db.sql: -------------------------------------------------------------------------------- 1 | -- 2 | 3 | 4 | 5 | 6 | CREATE TABLE categories ( 7 | category_id smallint NOT NULL, 8 | category_name character varying(15) NOT NULL, 9 | description text, 10 | picture bytea 11 | ); 12 | 13 | 14 | 15 | -- 16 | 17 | INSERT INTO categories VALUES (1, 'Beverages', 'Soft drinks, coffees, teas, beers, and ales', '\x'); 18 | INSERT INTO categories VALUES (2, 'Condiments', 'Sweet and savory sauces, relishes, spreads, and seasonings', '\x'); 19 | INSERT INTO categories VALUES (3, 'Confections', 'Desserts, candies, and sweet breads', '\x'); 20 | INSERT INTO categories VALUES (4, 'Dairy Products', 'Cheeses', '\x'); 21 | INSERT INTO categories VALUES (5, 'Grains/Cereals', 'Breads, crackers, pasta, and cereal', '\x'); 22 | INSERT INTO categories VALUES (6, 'Organic Veg', 'Organic', '\x'); 23 | INSERT INTO categories VALUES (7, 'Produce', 'Dried fruit and bean curd', '\x'); 24 | 25 | 26 | 27 | 28 | -- 29 | 30 | DROP TABLE IF EXISTS books, authors, testing, images; 31 | 32 | CREATE TABLE IF NOT EXISTS authors ( 33 | id serial PRIMARY KEY, 34 | name VARCHAR(25) 35 | ); 36 | 37 | CREATE TABLE IF NOT EXISTS books ( 38 | id serial PRIMARY KEY, 39 | author_id INT references authors(id), title VARCHAR(100) 40 | ); 41 | 42 | 43 | INSERT INTO authors(id, name) VALUES(1, 'Jack London'); 44 | INSERT INTO authors(id, name) VALUES(2, 'Honore de Balzac'); 45 | INSERT INTO authors(id, name) VALUES(3, 'Lion Feuchtwanger'); 46 | INSERT INTO authors(id, name) VALUES(4, 'Emile Zola'); 47 | INSERT INTO authors(id, name) VALUES(5, 'Truman Capote'); 48 | 49 | INSERT INTO books(id, author_id, title) VALUES(1, 1, 'Call of the Wild'); 50 | INSERT INTO books(id, author_id, title) VALUES(2, 1, 'Martin Eden'); 51 | INSERT INTO books(id, author_id, title) VALUES(3, 2, 'Old Goriot'); 52 | INSERT INTO books(id, author_id, title) VALUES(4, 2, 'Cousin Bette'); 53 | INSERT INTO books(id, author_id, title) VALUES(5, 3, 'Jew Suess'); 54 | INSERT INTO books(id, author_id, title) VALUES(6, 4, 'Nana'); 55 | INSERT INTO books(id, author_id, title) VALUES(7, 4, 'The Belly of Paris'); 56 | INSERT INTO books(id, author_id, title) VALUES(8, 5, 'In Cold blood'); 57 | INSERT INTO books(id, author_id, title) VALUES(9, 5, 'Breakfast at Tiffany'); 58 | -------------------------------------------------------------------------------- /core/src/test/resources/test-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 36 | 37 | 38 | Database connections and Schema version configuration file 39 | 40 | abcdb 41 | ORACLE 42 | jdbc:oracle:thin:your-db-connection-url-here 43 | your-user-name 44 | your-password 45 | 46 | 47 | 48 | 49 | 50 | 51 | h2testdb 52 | H2 53 | jdbc:h2:file:./target/h2testdb1;mv_store=false; 54 | 55 | 56 | 57 | 1.0 58 | 59 | create schema, 60 | load seed data 61 | 62 | ./target/test-classes/migrationtests/h2testdb/1.0/*.sql 63 | 64 | 65 | -------------------------------------------------------------------------------- /core/src/test/resources/test_db.properties: -------------------------------------------------------------------------------- 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 | db.url=jdbc:oracle:thin:@hostname:1521 36 | db.username=SYS 37 | db.password=1234 38 | db.data.location=?/a_data_file0 39 | 40 | -------------------------------------------------------------------------------- /core/src/test/resources/users.csv: -------------------------------------------------------------------------------- 1 | USERID,USERNAME,RATE,CREATE_TIME 2 | 1,Aiden,,2017-03-03 3 | 2,"Ethan, Allen",,2017-03-03 4 | 3,Liam,,2017-03-03 5 | 4,Noah,,2017-03-03 6 | 5,Jacob,,2017-03-03 7 | 6,SM,,2017-03-03 8 | 7,qamatic,,2017-03-03 9 | -------------------------------------------------------------------------------- /core/src/test/resources/variable-changesets.sql: -------------------------------------------------------------------------------- 1 | 2 | 3 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (${user_id}, '${user_name}'); 4 | 5 | 6 | -------------------------------------------------------------------------------- /dbexamples/src/main/java/org/qamatic/mintleaf/excel/ExcelReader.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf.excel; 2 | 3 | import org.apache.poi.hssf.usermodel.HSSFSheet; 4 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 5 | import org.apache.poi.ss.usermodel.Cell; 6 | import org.apache.poi.ss.usermodel.Row; 7 | import org.qamatic.mintleaf.Column; 8 | import org.qamatic.mintleaf.ColumnMetaDataCollection; 9 | import org.qamatic.mintleaf.MetaDataCollection; 10 | import org.qamatic.mintleaf.MintleafException; 11 | import org.qamatic.mintleaf.core.BaseReader; 12 | 13 | import java.io.IOException; 14 | import java.io.InputStream; 15 | import java.util.Iterator; 16 | 17 | /** 18 | * Created by QAmatic Team on 4/25/17. 19 | */ 20 | public class ExcelReader extends BaseReader { 21 | 22 | private InputStream inputStream; 23 | private int activeWorkSheet; 24 | private int headerRowIndex; 25 | 26 | 27 | public ExcelReader(InputStream inputStream) { 28 | this.inputStream = inputStream; 29 | } 30 | 31 | public void setHeaderRow(int headerRowIndex) { 32 | this.headerRowIndex = headerRowIndex; 33 | } 34 | 35 | protected MetaDataCollection getMetaData(Row row) { 36 | ColumnMetaDataCollection metaDataCollection = new ColumnMetaDataCollection(); 37 | for (Cell cell : row) { 38 | metaDataCollection.add(new Column(cell.getStringCellValue(), cell.getCellType())); 39 | } 40 | return metaDataCollection; 41 | } 42 | 43 | @Override 44 | public void read() throws MintleafException { 45 | HSSFWorkbook workbook = null; 46 | try { 47 | workbook = new HSSFWorkbook(this.inputStream); 48 | HSSFSheet sheet = workbook.getSheetAt(getActiveWorkSheet()); 49 | Iterator rowIterator = sheet.iterator(); 50 | int i = 0; 51 | boolean headerRowFound = this.headerRowIndex == -1; 52 | MetaDataCollection metaDataCollection = null; 53 | while (rowIterator.hasNext()) { 54 | if ((!headerRowFound) && (i == this.headerRowIndex)) { 55 | headerRowFound = true; 56 | metaDataCollection = getMetaData(rowIterator.next()); 57 | continue; 58 | } 59 | if (!headerRowFound) { 60 | continue; 61 | } 62 | ExcelRow row = new ExcelRow(rowIterator.next()); 63 | 64 | row.setMetaData(metaDataCollection); 65 | if (!readRow(i++, row)) { 66 | break; 67 | } 68 | 69 | } 70 | 71 | 72 | } catch (IOException e) { 73 | throw new MintleafException(e); 74 | } 75 | } 76 | 77 | public int getActiveWorkSheet() { 78 | return activeWorkSheet; 79 | } 80 | 81 | public void setActiveWorkSheet(int activeWorkSheet) { 82 | this.activeWorkSheet = activeWorkSheet; 83 | } 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /dbexamples/src/main/java/org/qamatic/mintleaf/excel/ExcelRow.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf.excel; 2 | 3 | import org.qamatic.mintleaf.MetaDataCollection; 4 | import org.qamatic.mintleaf.MintleafException; 5 | import org.qamatic.mintleaf.Row; 6 | 7 | /** 8 | * Created by QAmatic Team on 4/25/17. 9 | */ 10 | public class ExcelRow implements Row { 11 | 12 | private MetaDataCollection metaDataCollection; 13 | private org.apache.poi.ss.usermodel.Row poiRow; 14 | 15 | public ExcelRow(org.apache.poi.ss.usermodel.Row poiRow) { 16 | this.poiRow = poiRow; 17 | } 18 | 19 | @Override 20 | public Object getValue(int columnIndex) throws MintleafException { 21 | return this.poiRow.getCell(columnIndex).getStringCellValue(); 22 | } 23 | 24 | @Override 25 | public MetaDataCollection getMetaData() throws MintleafException { 26 | return this.metaDataCollection; 27 | } 28 | 29 | @Override 30 | public void setMetaData(MetaDataCollection metaDataCollection) { 31 | this.metaDataCollection = metaDataCollection; 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /dbexamples/src/test/java/org/qamatic/mintleaf/dbexample/ApacheBasicDataSource.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.dbexample; 37 | 38 | import org.apache.commons.dbcp.BasicDataSource; 39 | import org.qamatic.mintleaf.DriverSource; 40 | 41 | /** 42 | * Created by qamatic on 3/5/17. 43 | */ 44 | public class ApacheBasicDataSource extends BasicDataSource implements DriverSource { 45 | 46 | @Override 47 | public boolean isDebugEnabled() { 48 | return false; 49 | } 50 | 51 | @Override 52 | public void setDebugEnabled(boolean debug) { 53 | 54 | } 55 | 56 | @Override 57 | public void setProperty(String propName, String value) { 58 | 59 | } 60 | 61 | @Override 62 | public String getProperty(String propName) { 63 | return null; 64 | } 65 | 66 | 67 | } 68 | -------------------------------------------------------------------------------- /dbexamples/src/test/java/org/qamatic/mintleaf/dbexample/excel/ExcelImportTest.java: -------------------------------------------------------------------------------- 1 | package org.qamatic.mintleaf.dbexample.excel; 2 | 3 | import org.junit.Test; 4 | import org.qamatic.mintleaf.*; 5 | import org.qamatic.mintleaf.excel.ExcelReader; 6 | import org.qamatic.mintleaf.excel.ExcelRow; 7 | 8 | import static junit.framework.TestCase.assertEquals; 9 | 10 | /** 11 | * Created by QAmatic Team on 4/25/17. 12 | */ 13 | public class ExcelImportTest { 14 | 15 | 16 | @Test 17 | public void importFromExcelToObjectListTest() throws MintleafException { 18 | 19 | MintleafReader importReader = new ExcelReader(org.qamatic.mintleaf.core.BaseReader.getInputStreamFromFile("res:/users.xls")); 20 | Executable importToList = new Mintleaf.AnyDataToListTransferBuilder<>(). 21 | withSource(importReader). 22 | build(); 23 | 24 | Table rows = (Table) importToList.execute(); 25 | assertEquals(7, rows.size()); 26 | assertEquals("qamatic", rows.getRow(6).getValue(1)); 27 | assertEquals("qamatic", rows.getRow(6).getValue("USERNAME")); 28 | } 29 | 30 | // @Test 31 | // public void importFromExcelToObjectListTestMatches() throws MintleafException { 32 | // 33 | // ImportReader importReader = new ExcelImportReader(BaseSqlReader.getInputStreamFromFile("res:/users.xls")); 34 | // Executable importToList = new Mintleaf.AnyDataToListTransferBuilder<>(). 35 | // withSource(importReader). 36 | // withMatchingCriteria(new MintleafReadListener() { 37 | // @Override 38 | // public Object eachRow(int rowNum, Row row) throws MintleafException { 39 | // return null; 40 | // } 41 | // 42 | // 43 | // }). 44 | // build(); 45 | // 46 | // Table rows = (Table) importToList.execute(); 47 | // assertEquals(7, rows.size()); 48 | // assertEquals("qamatic", rows.getRow(6).getValue(1)); 49 | // assertEquals("qamatic", rows.getRow(6).getValue("USERNAME")); 50 | // } 51 | } 52 | -------------------------------------------------------------------------------- /dbexamples/src/test/java/org/qamatic/mintleaf/dbexample/reportgenerator/TestResult.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.dbexample.reportgenerator; 37 | 38 | /** 39 | * Created by QAmatic Team on 3/11/17. 40 | */ 41 | public class TestResult { 42 | private String expected; 43 | private String actual; 44 | private String status; 45 | 46 | public String getExpected() { 47 | return expected; 48 | } 49 | 50 | public void setExpected(String expected) { 51 | this.expected = expected; 52 | } 53 | 54 | public String getActual() { 55 | return actual; 56 | } 57 | 58 | public void setActual(String actual) { 59 | this.actual = actual; 60 | } 61 | 62 | public String getStatus() { 63 | return status; 64 | } 65 | 66 | public void setStatus(String status) { 67 | this.status = status; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /dbexamples/src/test/resources/HR_30_PROCS.sql: -------------------------------------------------------------------------------- 1 | CREATE OR REPLACE TRIGGER SECURE_EMPLOYEES 2 | BEFORE INSERT OR UPDATE OR DELETE ON EMPLOYEES 3 | FOR EACH ROW 4 | BEGIN 5 | secure_dml; 6 | END secure_employees; 7 | / 8 | 9 | 10 | 11 | CREATE OR REPLACE TRIGGER UPDATE_JOB_HISTORY 12 | AFTER UPDATE OF JOB_ID, DEPARTMENT_ID ON EMPLOYEES 13 | FOR EACH ROW 14 | BEGIN 15 | add_job_history(:old.employee_id, :old.hire_date, sysdate, 16 | :old.job_id, :old.department_id); 17 | END; 18 | / 19 | 20 | 21 | 22 | 23 | CREATE OR REPLACE PROCEDURE add_job_history 24 | ( p_emp_id job_history.employee_id%type 25 | , p_start_date job_history.start_date%type 26 | , p_end_date job_history.end_date%type 27 | , p_job_id job_history.job_id%type 28 | , p_department_id job_history.department_id%type 29 | ) 30 | IS 31 | BEGIN 32 | INSERT INTO job_history (employee_id, start_date, end_date, 33 | job_id, department_id) 34 | VALUES(p_emp_id, p_start_date, p_end_date, p_job_id, p_department_id); 35 | END add_job_history; 36 | / 37 | 38 | 39 | CREATE OR REPLACE PROCEDURE secure_dml 40 | IS 41 | BEGIN 42 | IF TO_CHAR (SYSDATE, 'HH24:MI') NOT BETWEEN '08:00' AND '18:00' 43 | OR TO_CHAR (SYSDATE, 'DY') IN ('SAT', 'SUN') THEN 44 | RAISE_APPLICATION_ERROR (-20205, 45 | 'You may only make changes during normal office hours'); 46 | END IF; 47 | END secure_dml; 48 | / 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -- Oracle SQL Developer Data Modeler Summary Report: 60 | -- 61 | -- CREATE TABLE 7 62 | -- CREATE INDEX 18 63 | -- ALTER TABLE 20 64 | -- CREATE VIEW 1 65 | -- CREATE PACKAGE 0 66 | -- CREATE PACKAGE BODY 0 67 | -- CREATE PROCEDURE 2 68 | -- CREATE FUNCTION 0 69 | -- CREATE TRIGGER 2 70 | -- CREATE STRUCTURED TYPE 0 71 | -- CREATE COLLECTION TYPE 0 72 | -- CREATE CLUSTER 0 73 | -- CREATE CONTEXT 0 74 | -- CREATE DATABASE 0 75 | -- CREATE DIMENSION 0 76 | -- CREATE DIRECTORY 0 77 | -- CREATE DISK GROUP 0 78 | -- CREATE ROLE 0 79 | -- CREATE ROLLBACK SEGMENT 0 80 | -- CREATE SEQUENCE 3 81 | -- CREATE MATERIALIZED VIEW 0 82 | -- CREATE SYNONYM 0 83 | -- CREATE TABLESPACE 0 84 | -- CREATE USER 1 85 | -- 86 | -- DROP TABLESPACE 0 87 | -- DROP DATABASE 0 88 | -- 89 | -- ERRORS 0 90 | -- WARNINGS 0 91 | -------------------------------------------------------------------------------- /dbexamples/src/test/resources/database-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 38 | 39 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /dbexamples/src/test/resources/h2-changesets/v1/schema-v1.sql: -------------------------------------------------------------------------------- 1 | -- 2 | DROP SCHEMA IF EXISTS HRDB; 3 | CREATE SCHEMA IF NOT EXISTS HRDB; 4 | 5 | CREATE TABLE IF NOT EXISTS HRDB.USERS 6 | ( 7 | USERID INT NOT NULL, 8 | USERNAME VARCHAR2(50), 9 | RATE NUMBER(12, 2), 10 | CREATE_TIME DATE DEFAULT sysdate, 11 | CONSTRAINT PK_USERID PRIMARY KEY (USERID) 12 | ); 13 | 14 | 15 | 16 | -- 17 | 18 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (1, 'qamatic'); 19 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (2, 'Ethan, Allen'); 20 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (3, 'Maruth'); 21 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (4, 'Ka'); 22 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (5, 'Keb'); 23 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (6, 'Benjamin'); 24 | INSERT INTO HRDB.USERS (USERID, USERNAME) VALUES (7, 'Rob'); 25 | 26 | -- 27 | DROP TABLE IF EXISTS HRDB.USERS_IMPORT_TABLE; 28 | 29 | CREATE TABLE IF NOT EXISTS HRDB.USERS_IMPORT_TABLE 30 | ( 31 | USERID INT NOT NULL, 32 | USERNAME VARCHAR2(50), 33 | RATE NUMBER(12, 2), 34 | CREATE_TIME DATE DEFAULT sysdate, 35 | CONSTRAINT PK_USERID_IMPORT PRIMARY KEY (USERID) 36 | ); -------------------------------------------------------------------------------- /dbexamples/src/test/resources/print-templates/compare-result-template.html: -------------------------------------------------------------------------------- 1 | 35 | 36 | 37 | 38 | Mintleaf examples - Data comparision result 39 | 40 | 41 |
42 |

Hello world

43 |

amazing

44 |
45 | 46 | -------------------------------------------------------------------------------- /dbexamples/src/test/resources/users.csv: -------------------------------------------------------------------------------- 1 | USERID,USERNAME,RATE,CREATE_TIME 2 | 1,Aiden,,2017-03-10 3 | 2,"Ethan, Allen",,2017-03-10 4 | 3,Liam,,2017-03-10 5 | 4,Noah,,2017-03-10 6 | 5,Jacob,,2017-03-10 7 | 6,SM,,2017-03-10 8 | 7,qamatic,,2017-03-10 9 | -------------------------------------------------------------------------------- /dbexamples/src/test/resources/users.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/dbexamples/src/test/resources/users.xls -------------------------------------------------------------------------------- /doc/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Version 1.5.0 4 | 5 | *February 23, 2017* 6 | 7 | - Add [multiple tabs per programming language](https://github.com/lord/slate/wiki/Multiple-language-tabs-per-programming-language) feature 8 | - Upgrade Middleman to add Ruby 1.4.0 compatibility 9 | - Switch default code highlighting color scheme to better highlight JSON 10 | - Various small typo and bug fixes 11 | 12 | ## Version 1.4.0 13 | 14 | *November 24, 2016* 15 | 16 | - Upgrade Middleman and Rouge gems, should hopefully solve a number of bugs 17 | - Update some links in README 18 | - Fix broken Vagrant startup script 19 | - Fix some problems with deploy.sh help message 20 | - Fix bug with language tabs not hiding properly if no error 21 | - Add `!default` to SASS variables 22 | - Fix bug with logo margin 23 | - Bump tested Ruby versions in .travis.yml 24 | 25 | ## Version 1.3.3 26 | 27 | *June 11, 2016* 28 | 29 | Documentation and example changes. 30 | 31 | ## Version 1.3.2 32 | 33 | *February 3, 2016* 34 | 35 | A small bugfix for slightly incorrect background colors on code samples in some cases. 36 | 37 | ## Version 1.3.1 38 | 39 | *January 31, 2016* 40 | 41 | A small bugfix for incorrect whitespace in code blocks. 42 | 43 | ## Version 1.3 44 | 45 | *January 27, 2016* 46 | 47 | We've upgraded Middleman and a number of other dependencies, which should fix quite a few bugs. 48 | 49 | Instead of `rake build` and `rake deploy`, you should now run `bundle exec middleman build --clean` to build your server, and `./deploy.sh` to deploy it to Github Pages. 50 | 51 | ## Version 1.2 52 | 53 | *June 20, 2015* 54 | 55 | **Fixes:** 56 | 57 | - Remove crash on invalid languages 58 | - Update Tocify to scroll to the highlighted header in the Table of Contents 59 | - Fix variable leak and update search algorithms 60 | - Update Python examples to be valid Python 61 | - Update gems 62 | - More misc. bugfixes of Javascript errors 63 | - Add Dockerfile 64 | - Remove unused gems 65 | - Optimize images, fonts, and generated asset files 66 | - Add chinese font support 67 | - Remove RedCarpet header ID patch 68 | - Update language tabs to not disturb existing query strings 69 | 70 | ## Version 1.1 71 | 72 | *July 27, 2014* 73 | 74 | **Fixes:** 75 | 76 | - Finally, a fix for the redcarpet upgrade bug 77 | 78 | ## Version 1.0 79 | 80 | *July 2, 2014* 81 | 82 | [View Issues](https://github.com/tripit/slate/issues?milestone=1&state=closed) 83 | 84 | **Features:** 85 | 86 | - Responsive designs for phones and tablets 87 | - Started tagging versions 88 | 89 | **Fixes:** 90 | 91 | - Fixed 'unrecognized expression' error 92 | - Fixed #undefined hash bug 93 | - Fixed bug where the current language tab would be unselected 94 | - Fixed bug where tocify wouldn't highlight the current section while searching 95 | - Fixed bug where ids of header tags would have special characters that caused problems 96 | - Updated layout so that pages with disabled search wouldn't load search.js 97 | - Cleaned up Javascript 98 | -------------------------------------------------------------------------------- /doc/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Middleman 4 | gem 'middleman', '~>4.2.1' 5 | gem 'middleman-syntax', '~> 3.0.0' 6 | gem 'middleman-autoprefixer', '~> 2.7.0' 7 | gem "middleman-sprockets", "~> 4.1.0" 8 | gem 'rouge', '~> 2.0.5' 9 | gem 'redcarpet', '~> 3.4.0' 10 | -------------------------------------------------------------------------------- /doc/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008-2013 Concur Technologies, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | not use this file except in compliance with the License. You may obtain 5 | a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | License for the specific language governing permissions and limitations 13 | under the License. -------------------------------------------------------------------------------- /doc/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure(2) do |config| 2 | config.vm.box = "ubuntu/trusty64" 3 | config.vm.network :forwarded_port, guest: 4567, host: 4567 4 | 5 | config.vm.provision "bootstrap", 6 | type: "shell", 7 | inline: <<-SHELL 8 | sudo apt-get update 9 | sudo apt-get install -yq ruby2.0 ruby2.0-dev pkg-config build-essential nodejs git libxml2-dev libxslt-dev 10 | sudo apt-get autoremove -yq 11 | gem2.0 install --no-ri --no-rdoc bundler 12 | SHELL 13 | 14 | # add the local user git config to the vm 15 | config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig" 16 | 17 | config.vm.provision "install", 18 | type: "shell", 19 | privileged: false, 20 | inline: <<-SHELL 21 | echo "==============================================" 22 | echo "Installing app dependencies" 23 | cd /vagrant 24 | bundle config build.nokogiri --use-system-libraries 25 | bundle install 26 | SHELL 27 | 28 | config.vm.provision "run", 29 | type: "shell", 30 | privileged: false, 31 | run: "always", 32 | inline: <<-SHELL 33 | echo "==============================================" 34 | echo "Starting up middleman at http://localhost:4567" 35 | echo "If it does not come up, check the ~/middleman.log file for any error messages" 36 | cd /vagrant 37 | bundle exec middleman server --force-polling --latency=1 &> ~/middleman.log & 38 | SHELL 39 | end 40 | -------------------------------------------------------------------------------- /doc/config.rb: -------------------------------------------------------------------------------- 1 | # Markdown 2 | set :markdown_engine, :redcarpet 3 | set :markdown, 4 | fenced_code_blocks: true, 5 | smartypants: true, 6 | disable_indented_code_blocks: true, 7 | prettify: true, 8 | tables: true, 9 | with_toc_data: true, 10 | no_intra_emphasis: true 11 | 12 | # Assets 13 | set :css_dir, 'stylesheets' 14 | set :js_dir, 'javascripts' 15 | set :images_dir, 'images' 16 | set :fonts_dir, 'fonts' 17 | 18 | # Activate the syntax highlighter 19 | activate :syntax 20 | ready do 21 | require './lib/multilang.rb' 22 | end 23 | 24 | activate :sprockets 25 | 26 | activate :autoprefixer do |config| 27 | config.browsers = ['last 2 version', 'Firefox ESR'] 28 | config.cascade = false 29 | config.inline = true 30 | end 31 | 32 | # Github pages require relative links 33 | activate :relative_assets 34 | set :relative_links, true 35 | 36 | # Build Configuration 37 | configure :build do 38 | # If you're having trouble with Middleman hanging, commenting 39 | # out the following two lines has been known to help 40 | activate :minify_css 41 | activate :minify_javascript 42 | # activate :relative_assets 43 | # activate :asset_hash 44 | # activate :gzip 45 | end 46 | 47 | # Deploy Configuration 48 | # If you want Middleman to listen on a different port, you can set that below 49 | set :port, 4567 50 | -------------------------------------------------------------------------------- /doc/lib/multilang.rb: -------------------------------------------------------------------------------- 1 | module Multilang 2 | def block_code(code, full_lang_name) 3 | parts = full_lang_name.split('--') 4 | rouge_lang_name = parts[0] || "" 5 | super(code, rouge_lang_name).sub("highlight #{rouge_lang_name}") do |match| 6 | match + " tab-" + full_lang_name 7 | end 8 | end 9 | end 10 | 11 | require 'middleman-core/renderers/redcarpet' 12 | Middleman::Renderers::MiddlemanRedcarpetHTML.send :include, Multilang 13 | -------------------------------------------------------------------------------- /doc/logo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/logo.psd -------------------------------------------------------------------------------- /doc/logo1.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/logo1.psd -------------------------------------------------------------------------------- /doc/logosimple.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/logosimple.psd -------------------------------------------------------------------------------- /doc/source/fonts/slate.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/source/fonts/slate.eot -------------------------------------------------------------------------------- /doc/source/fonts/slate.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/source/fonts/slate.ttf -------------------------------------------------------------------------------- /doc/source/fonts/slate.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/source/fonts/slate.woff -------------------------------------------------------------------------------- /doc/source/fonts/slate.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/source/fonts/slate.woff2 -------------------------------------------------------------------------------- /doc/source/images/basicflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/source/images/basicflow.png -------------------------------------------------------------------------------- /doc/source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/source/images/logo.png -------------------------------------------------------------------------------- /doc/source/images/logosimple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/source/images/logosimple.png -------------------------------------------------------------------------------- /doc/source/images/mintleaf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/source/images/mintleaf.png -------------------------------------------------------------------------------- /doc/source/images/navbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/source/images/navbar.png -------------------------------------------------------------------------------- /doc/source/images/overall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/source/images/overall.png -------------------------------------------------------------------------------- /doc/source/includes/_errors.md: -------------------------------------------------------------------------------- 1 | # Errors 2 | 3 | 4 | 5 | The Kittn API uses the following error codes: 6 | 7 | 8 | Error Code | Meaning 9 | ---------- | ------- 10 | 400 | Bad Request -- Your request sucks 11 | 401 | Unauthorized -- Your API key is wrong 12 | 403 | Forbidden -- The kitten requested is hidden for administrators only 13 | 404 | Not Found -- The specified kitten could not be found 14 | 405 | Method Not Allowed -- You tried to access a kitten with an invalid method 15 | 406 | Not Acceptable -- You requested a format that isn't json 16 | 410 | Gone -- The kitten requested has been removed from our servers 17 | 418 | I'm a teapot 18 | 429 | Too Many Requests -- You're requesting too many kittens! Slow down! 19 | 500 | Internal Server Error -- We had a problem with our server. Try again later. 20 | 503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. 21 | -------------------------------------------------------------------------------- /doc/source/javascripts/all.js: -------------------------------------------------------------------------------- 1 | //= require ./lib/_energize 2 | //= require ./app/_lang 3 | //= require ./app/_search 4 | //= require ./app/_toc 5 | -------------------------------------------------------------------------------- /doc/source/javascripts/all_nosearch.js: -------------------------------------------------------------------------------- 1 | //= require ./lib/_energize 2 | //= require ./app/_lang 3 | //= require ./app/_toc 4 | -------------------------------------------------------------------------------- /doc/source/javascripts/app/_search.js: -------------------------------------------------------------------------------- 1 | //= require ../lib/_lunr 2 | //= require ../lib/_jquery 3 | //= require ../lib/_jquery.highlight 4 | (function () { 5 | 'use strict'; 6 | 7 | var content, searchResults; 8 | var highlightOpts = { element: 'span', className: 'search-highlight' }; 9 | 10 | var index = new lunr.Index(); 11 | 12 | index.ref('id'); 13 | index.field('title', { boost: 10 }); 14 | index.field('body'); 15 | index.pipeline.add(lunr.trimmer, lunr.stopWordFilter); 16 | 17 | $(populate); 18 | $(bind); 19 | 20 | function populate() { 21 | $('h1, h2').each(function() { 22 | var title = $(this); 23 | var body = title.nextUntil('h1, h2'); 24 | index.add({ 25 | id: title.prop('id'), 26 | title: title.text(), 27 | body: body.text() 28 | }); 29 | }); 30 | } 31 | 32 | function bind() { 33 | content = $('.content'); 34 | searchResults = $('.search-results'); 35 | 36 | $('#input-search').on('keyup', search); 37 | } 38 | 39 | function search(event) { 40 | unhighlight(); 41 | searchResults.addClass('visible'); 42 | 43 | // ESC clears the field 44 | if (event.keyCode === 27) this.value = ''; 45 | 46 | if (this.value) { 47 | var results = index.search(this.value).filter(function(r) { 48 | return r.score > 0.0001; 49 | }); 50 | 51 | if (results.length) { 52 | searchResults.empty(); 53 | $.each(results, function (index, result) { 54 | var elem = document.getElementById(result.ref); 55 | searchResults.append("
  • " + $(elem).text() + "
  • "); 56 | }); 57 | highlight.call(this); 58 | } else { 59 | searchResults.html('
  • '); 60 | $('.search-results li').text('No Results Found for "' + this.value + '"'); 61 | } 62 | } else { 63 | unhighlight(); 64 | searchResults.removeClass('visible'); 65 | } 66 | } 67 | 68 | function highlight() { 69 | if (this.value) content.highlight(this.value, highlightOpts); 70 | } 71 | 72 | function unhighlight() { 73 | content.unhighlight(highlightOpts); 74 | } 75 | })(); 76 | -------------------------------------------------------------------------------- /doc/source/javascripts/app/_toc.js: -------------------------------------------------------------------------------- 1 | //= require ../lib/_jquery 2 | //= require ../lib/_jquery_ui 3 | //= require ../lib/_jquery.tocify 4 | //= require ../lib/_imagesloaded.min 5 | (function (global) { 6 | 'use strict'; 7 | 8 | var closeToc = function() { 9 | $(".tocify-wrapper").removeClass('open'); 10 | $("#nav-button").removeClass('open'); 11 | }; 12 | 13 | var makeToc = function() { 14 | global.toc = $("#toc").tocify({ 15 | selectors: 'h1, h2, h3', 16 | extendPage: false, 17 | theme: 'none', 18 | smoothScroll: false, 19 | showEffectSpeed: 0, 20 | hideEffectSpeed: 180, 21 | ignoreSelector: '.toc-ignore', 22 | highlightOffset: 60, 23 | scrollTo: -1, 24 | scrollHistory: true, 25 | hashGenerator: function (text, element) { 26 | return element.prop('id'); 27 | } 28 | }).data('toc-tocify'); 29 | 30 | $("#nav-button").click(function() { 31 | $(".tocify-wrapper").toggleClass('open'); 32 | $("#nav-button").toggleClass('open'); 33 | return false; 34 | }); 35 | 36 | $(".page-wrapper").click(closeToc); 37 | $(".tocify-item").click(closeToc); 38 | }; 39 | 40 | // Hack to make already open sections to start opened, 41 | // instead of displaying an ugly animation 42 | function animate() { 43 | setTimeout(function() { 44 | toc.setOption('showEffectSpeed', 180); 45 | }, 50); 46 | } 47 | 48 | $(function() { 49 | makeToc(); 50 | animate(); 51 | setupLanguages($('body').data('languages')); 52 | $('.content').imagesLoaded( function() { 53 | global.toc.calculateHeights(); 54 | }); 55 | }); 56 | })(window); 57 | 58 | -------------------------------------------------------------------------------- /doc/source/stylesheets/_icon-font.scss: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'slate'; 3 | src:font-url('slate.eot?-syv14m'); 4 | src:font-url('slate.eot?#iefix-syv14m') format('embedded-opentype'), 5 | font-url('slate.woff2?-syv14m') format('woff2'), 6 | font-url('slate.woff?-syv14m') format('woff'), 7 | font-url('slate.ttf?-syv14m') format('truetype'), 8 | font-url('slate.svg?-syv14m#slate') format('svg'); 9 | font-weight: normal; 10 | font-style: normal; 11 | } 12 | 13 | %icon { 14 | font-family: 'slate'; 15 | speak: none; 16 | font-style: normal; 17 | font-weight: normal; 18 | font-variant: normal; 19 | text-transform: none; 20 | line-height: 1; 21 | } 22 | 23 | %icon-exclamation-sign { 24 | @extend %icon; 25 | content: "\e600"; 26 | } 27 | %icon-info-sign { 28 | @extend %icon; 29 | content: "\e602"; 30 | } 31 | %icon-ok-sign { 32 | @extend %icon; 33 | content: "\e606"; 34 | } 35 | %icon-search { 36 | @extend %icon; 37 | content: "\e607"; 38 | } 39 | -------------------------------------------------------------------------------- /doc/www/css/gradients.css: -------------------------------------------------------------------------------- 1 | /* Gradients */ 2 | .heaven-0 { background: #00000A; } 3 | .heaven-1 { background: linear-gradient(to bottom, #020214 85%,#191922 100%); } 4 | .heaven-2 { background: linear-gradient(to bottom, #020214 60%,#20202D 100%); } 5 | .heaven-3 { background: linear-gradient(to bottom, #020214 10%,#303054 100%); } 6 | .heaven-4 { background: linear-gradient(to bottom, #20202D 0%,#505070 100%); } 7 | .heaven-5 { background: linear-gradient(to bottom, #404050 0%,#7070AA 80%,#8C78AA 100%); } 8 | .heaven-6 { background: linear-gradient(to bottom, #4A4A69 0%,#7878B4 50%,#C878A0 100%); } 9 | .heaven-7 { background: linear-gradient(to bottom, #7878BE 0%,#8282BE 60%,#E6B4D2 100%); } 10 | .heaven-8 { background: linear-gradient(to bottom, #82AADC 0%,#F0B4B4 100%); } 11 | .heaven-9 { background: linear-gradient(to bottom, #96C8FA 1%,#AAE6FF 70%,#B4B4F0 100%); } 12 | .heaven-10 { background: linear-gradient(to bottom, #B4E6FF 0%,#96DCFF 100%); } 13 | .heaven-11 { background: linear-gradient(to bottom, #9BDCFF 0%,#64D2FA 100%); } 14 | .heaven-12 { background: linear-gradient(to bottom, #96DCFF 0%,#37A0D2 100%); } 15 | .heaven-13 { background: linear-gradient(to bottom, #5ABEE6 0%,#236EAA 100%); } 16 | .heaven-14 { background: linear-gradient(to bottom, #2D91BE 0%,#1E508C 100%); } 17 | .heaven-15 { background: linear-gradient(to bottom, #2473ab 0%,#1E508C 70%,#5A7882 100%); } 18 | .heaven-16 { background: linear-gradient(to bottom, #1E508C 0%,#285A8C 50%,#A0AA6E 100%); } 19 | .heaven-17 { background: linear-gradient(to bottom, #1E508C 0%,#738C7D 50%,#EBD25A 100%); } 20 | .heaven-18 { background: linear-gradient(to bottom, #143C78 0%,#5A6E73 30%,#E1C85A 70%,#B4643C 100%); } 21 | .heaven-19 { background: linear-gradient(to bottom, #143C50 0%,#505046 30%,#C8782D 60%,#BC460F 80%, #320F05 100%); } 22 | .heaven-20 { background: linear-gradient(to bottom, #051928 0%,#051928 30%,#8C3C14 80%,#230F05 100%); } 23 | .heaven-21 { background: linear-gradient(to bottom, #000A0F 30%,#5A230A 80%,#280A05 100%); } 24 | .heaven-22 { background: linear-gradient(to bottom, #0A0500 50%,#4B1E05 100%); } 25 | .heaven-23 { background: linear-gradient(to bottom, #00000A 80%,#140A00 100%); } 26 | .heaven-24 { background: #00000A; } 27 | -------------------------------------------------------------------------------- /doc/www/img/logosimple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/doc/www/img/logosimple.png -------------------------------------------------------------------------------- /doc/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Mintleaf - Database Migration and Testing Simplified 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
    15 | 22 |
    23 | 24 |
    25 | 26 |
    27 | 28 |

    Database Migration and Testing Simplified

    29 | 30 |
      31 |
    • Database Migration
    • 32 |
    • Compare Data between database tables/csv/spreadsheets/list of objects/any custom data sources
    • 33 |
    • Data export/import: database table to CSV, CSV to database table and, between database tables
    • 34 |
    • Unit testing: write automated tests and run them on migrated database schemas, objects, data integrity 35 | checks during CI/CD. 36 |
    • 37 |
    • Seamless Test life cycle management such as creation of test data, test data setup, test data teardown, 38 | schema and any database objects using changesets 39 |
    • 40 |
    • Extensibility framework offers you the power of customizations - custom data wrappers, custom 41 | import/export, custom comparer implementation, and report generation and so on.. 42 |
    • 43 |
    • Low memory overhead, high performance on large datasets for data exports, imports, and data compare 44 | scenarios 45 |
    • 46 |
    • Nothing more but to use Plain old SQL that you know of
    • 47 |
    48 |
    49 |
    50 |
    51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /doc/www/js/set-background.js: -------------------------------------------------------------------------------- 1 | var idx = Math.floor((new Date().getHours())); 2 | var body = document.getElementsByTagName("body")[0]; 3 | body.className = "heaven-" + idx; 4 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.3' 2 | 3 | services: 4 | 5 | mysql-dev: 6 | image: mysql:8.0.2 7 | environment: 8 | MYSQL_ROOT_PASSWORD: password 9 | MYSQL_PASSWORD: password 10 | MYSQL_DATABASE: mysqldb 11 | ports: 12 | - "3308:3306" 13 | volumes: 14 | - "./data/mysqldata:/var/lib/mysql:rw" 15 | 16 | pgdb: 17 | image: postgres 18 | ports: 19 | - "5432:5432" 20 | environment: 21 | POSTGRES_USER: root 22 | POSTGRES_PASSWORD: password 23 | POSTGRES_DB: pgdb 24 | 25 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/docs/.nojekyll -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | [![CircleCI](https://circleci.com/gh/qamatic/mintleaf.svg?style=svg)](https://circleci.com/gh/qamatic/mintleaf) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.qamatic/mintleaf-core/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/org.qamatic/mintleaf-core) 2 | 3 | ![logo](https://github.com/qamatic/mintleaf/blob/master/doc/source/images/logosimple.png) 4 | Welcome to the Mintleaf! Mintleaf is a light weight framework tool helps you to advance your database developement on continuous integration / continuous delivery model as easy as possible. 5 | 6 | - Database Migration 7 | - Ability to write automated tests and run them on migrated database schemas, objects, data integrity checks during CI/CD 8 | - Seamless Test life cycle management such as setup, teardown mock data, schema and database objects using changesets 9 | - Create mock data or transfer/copy data between databases for your tests 10 | - Nothing more but to use Plain old SQL that you know of 11 | 12 | ## Documentation 13 | 14 | - [Documentation](https://qamatic.github.io/mintleaf/) 15 | - [API Reference](https://qamatic.github.io/mintleaf/apidocs) 16 | 17 | ## Maven 18 | 19 | org.qamatic 20 | mintleaf-core 21 | 1.8.27 22 | 23 | 24 | ## Download binaries 25 | 26 | Command line tools: 27 | 28 | - [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) 29 | - [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) 30 | 31 | 32 | ## Run in Docker 33 | 34 | 35 | ## License 36 | 37 | The MIT License (MIT) 38 | 39 | Copyright (c) 2010-2017 QAMatic Team 40 | 41 | Permission is hereby granted, free of charge, to any person obtaining a copy 42 | of this software and associated documentation files (the "Software"), to deal 43 | in the Software without restriction, including without limitation the rights 44 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 45 | copies of the Software, and to permit persons to whom the Software is 46 | furnished to do so, subject to the following conditions: 47 | 48 | The above copyright notice and this permission notice shall be included in all 49 | copies or substantial portions of the Software. 50 | 51 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 52 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 53 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 54 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 55 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 56 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 57 | SOFTWARE. 58 | 59 | -------------------------------------------------------------------------------- /docs/_sidebar.md: -------------------------------------------------------------------------------- 1 | 2 | - [Getting started](guide.md) 3 | 4 | - [API Documentation](https://apidocs) 5 | - [getmintleaf.org](http://getmintleaf.org) 6 | - [Source @ github](https://github.com/qamatic/mintleaf) 7 | 8 | -------------------------------------------------------------------------------- /docs/images/basicflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/docs/images/basicflow.png -------------------------------------------------------------------------------- /docs/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/docs/images/logo.png -------------------------------------------------------------------------------- /docs/images/logosimple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/docs/images/logosimple.png -------------------------------------------------------------------------------- /docs/images/mintleaf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/docs/images/mintleaf.png -------------------------------------------------------------------------------- /docs/images/navbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/docs/images/navbar.png -------------------------------------------------------------------------------- /docs/images/overall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/docs/images/overall.png -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Document 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 |
    16 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /libs/ojdbc6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qamatic/mintleaf/658785693ed9a6044f1e5884180800ea9033fc8e/libs/ojdbc6.jar -------------------------------------------------------------------------------- /libs/readme.txt: -------------------------------------------------------------------------------- 1 | please download odbc6.jar from oracle downloads and place it here 2 | or modify pom.xml if you have your own repo having this artifact 3 | 4 | run: mvn -P install-drivers initialize 5 | -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | # 2 | # /* 3 | # * 4 | # * * 30 | # * 31 | # * 32 | # */ 33 | # 34 | # must be unique in a given SonarQube instance 35 | sonar.projectKey=org.qamatic 36 | # this is the name displayed in the SonarQube UI 37 | sonar.projectName=Mintleaf Database Framework 38 | sonar.projectVersion=1.0 39 | # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. 40 | # Since SonarQube 4.2, this property is optional if sonar.modules is set. 41 | # If not set, SonarQube starts looking for source code from the directory containing 42 | # the sonar-project.properties file. 43 | sonar.sources=. 44 | # Encoding of the source code. Default is default system encoding 45 | sonar.sourceEncoding=UTF-8 46 | 47 | -------------------------------------------------------------------------------- /startlocaldb.sh: -------------------------------------------------------------------------------- 1 | export MYSQL_DB_ADMIN_USERNAME=root 2 | export MYSQL_DB_ADMIN_PASSWORD=password 3 | export MYSQL_DB_URL=jdbc:mysql://localhost:3306 4 | 5 | export POSTGRES_DB_ADMIN_USERNAME=root 6 | export POSTGRES_DB_ADMIN_PASSWORD=password 7 | export POSTGRES_DB_URL=jdbc:postgresql://localhost:5432/ 8 | 9 | mkdir -p ./data/mysqldata 10 | docker-compose up -d 11 | echo $POSTGRES_DB_URL 12 | while ! curl http://localhost:5432/ 2>&1 | grep '52' 13 | do 14 | sleep 20s 15 | done --------------------------------------------------------------------------------