Comments (9)
Hi @Gaibhne ! Thanks for reporting. I will look into it. Should not be to hard to implement.
from embedded-db-junit.
The reason this happens to me a lot is because I am adjusting legacy unit tests to not use the production (!) database and my typical work flow is to export the production DB with a tool like mysqldump or phpMyAdmin and then use that to seed the unit test database, but since MySQL and Postgre are not quite compatible with H2, oftentimes the SQL needs some cleanup before it is accepted by H2 and thus embedded-db-junit.
from embedded-db-junit.
Added logging for exception that is catched during initialization. As this library relies on SLF4J, remember to have a SLF4J runtime available in "test" scope to be able to read the actual log output
from embedded-db-junit.
@Gaibhne : just released the changes to Maven central as v. 0.9,. It should be widely available pretty soon. Thank you for reporting back!
from embedded-db-junit.
Even after adding the SLF dependencies to my project, the following does not produce any helpful output:
@Rule
public EmbeddedDatabaseRule rule = EmbeddedDatabaseRule.builder().withMode("MySQL")
.withInitialSqlFromResource("classpath:mock-data.sql").build();
@Test
public void bla() {
rule.getConnectionJdbcUrl();
assertTrue(true);
}
Am I not using it correctly ? All I get are variations of "Malformed database URL, failed to parse the main URL sections", which is obviously not the correct error.
from embedded-db-junit.
@Gaibhne: what version of the H2 database driver are you using?
from embedded-db-junit.
Yours:
[INFO] +- org.zapodot:embedded-db-junit:jar:1.0-RC1:compile
[INFO] | +- com.h2database:h2:jar:1.4.194:compile
Here is my complete dependency tree:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ InternalProject ---
[INFO] some.internal.project:InternalProject:jar:0.2.2
[INFO] +- junit:junit:jar:4.12:compile
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] +- com.github.stefanbirkner:system-rules:jar:1.16.1:test
[INFO] | \- (junit:junit:jar:4.11:test - omitted for conflict with 4.12)
[INFO] +- some.other.internal.project:MiscProject:jar:0.2:compile
[INFO] +- some.internal.project:InternalLogger:jar:0.1.2:compile
[INFO] | +- org.apache.logging.log4j:log4j-api:jar:2.4.1:compile
[INFO] | +- org.apache.logging.log4j:log4j-core:jar:2.4.1:compile
[INFO] | | \- (org.apache.logging.log4j:log4j-api:jar:2.4.1:compile - omitted for duplicate)
[INFO] | \- (some.other.internal.project:MiscProject:jar:0.1:compile - omitted for conflict with 0.2)
[INFO] +- org.apache.commons:commons-configuration2:jar:2.1:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- commons-io:commons-io:jar:2.5:compile
[INFO] +- com.squareup.retrofit2:retrofit:jar:2.1.0:compile
[INFO] | \- com.squareup.okhttp3:okhttp:jar:3.3.0:compile
[INFO] | \- com.squareup.okio:okio:jar:1.8.0:compile
[INFO] +- com.squareup.retrofit2:converter-gson:jar:2.1.0:compile
[INFO] | +- (com.squareup.retrofit2:retrofit:jar:2.1.0:compile - omitted for duplicate)
[INFO] | \- com.google.code.gson:gson:jar:2.7:compile
[INFO] +- com.squareup.okhttp3:logging-interceptor:jar:3.3.0:compile
[INFO] | \- (com.squareup.okhttp3:okhttp:jar:3.3.0:compile - omitted for duplicate)
[INFO] +- org.projectlombok:lombok:jar:1.16.12:provided
[INFO] +- com.beust:jcommander:jar:1.64:compile
[INFO] +- some.internal.project.commons:internal-java-commons:jar:1.6.8:compile
[INFO] | +- some.internal.project:InternalDBCore:jar:1.1.1:compile
[INFO] | | +- org.apache.commons:commons-dbcp2:jar:2.1.1:compile
[INFO] | | | +- (org.apache.commons:commons-pool2:jar:2.4.2:compile - omitted for duplicate)
[INFO] | | | \- (commons-logging:commons-logging:jar:1.2:compile - omitted for duplicate)
[INFO] | | +- (org.apache.commons:commons-lang3:jar:3.5:compile - omitted for conflict with 3.3.2)
[INFO] | | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] | | | +- (commons-logging:commons-logging:jar:1.2:compile - omitted for duplicate)
[INFO] | | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | | +- mysql:mysql-connector-java:jar:6.0.5:compile
[INFO] | | +- (some.internal.project:InternalLogger:jar:0.1:compile - omitted for conflict with 0.1.2)
[INFO] | | +- (some.other.internal.project:MiscProject:jar:0.2:compile - omitted for duplicate)
[INFO] | | +- (org.apache.commons:commons-configuration2:jar:2.1:compile - omitted for duplicate)
[INFO] | | \- org.apache.commons:commons-pool2:jar:2.4.2:compile
[INFO] | +- (some.other.internal.project:MiscProject:jar:0.2:compile - omitted for duplicate)
[INFO] | +- (some.internal.project:InternalLogger:jar:0.1:compile - omitted for conflict with 0.1.2)
[INFO] | +- javax.mail:mail:jar:1.5.0-b01:compile
[INFO] | | \- javax.activation:activation:jar:1.1:compile
[INFO] | +- com.google.code.findbugs:jsr305:jar:3.0.1:compile
[INFO] | +- (org.slf4j:slf4j-simple:jar:1.7.21:compile - omitted for duplicate)
[INFO] | +- com.squareup:javapoet:jar:1.8.0:compile
[INFO] | +- (com.google.code.gson:gson:jar:2.7:compile - omitted for duplicate)
[INFO] | +- (com.squareup.okhttp3:okhttp:jar:3.3.0:compile - omitted for duplicate)
[INFO] | +- (com.squareup.retrofit2:retrofit:jar:2.1.0:compile - omitted for duplicate)
[INFO] | +- (com.squareup.retrofit2:converter-gson:jar:2.1.0:compile - omitted for duplicate)
[INFO] | \- (com.squareup.okhttp3:logging-interceptor:jar:3.3.0:compile - omitted for duplicate)
[INFO] +- com.google.guava:guava:jar:21.0:compile
[INFO] +- io.rest-assured:json-schema-validator:jar:3.0.2:compile
[INFO] | +- com.github.fge:json-schema-validator:jar:2.2.6:compile
[INFO] | | +- (com.google.code.findbugs:jsr305:jar:3.0.0:compile - omitted for conflict with 3.0.1)
[INFO] | | +- joda-time:joda-time:jar:2.3:compile
[INFO] | | +- com.googlecode.libphonenumber:libphonenumber:jar:6.2:compile
[INFO] | | +- com.github.fge:json-schema-core:jar:1.2.5:compile
[INFO] | | | +- com.github.fge:uri-template:jar:0.9:compile
[INFO] | | | | +- com.github.fge:msg-simple:jar:1.1:compile
[INFO] | | | | | +- com.github.fge:btf:jar:1.2:compile
[INFO] | | | | | | \- (com.google.code.findbugs:jsr305:jar:2.0.1:compile - omitted for conflict with 3.0.1)
[INFO] | | | | | \- (com.google.code.findbugs:jsr305:jar:2.0.1:compile - omitted for conflict with 3.0.1)
[INFO] | | | | +- (com.google.guava:guava:jar:16.0.1:compile - omitted for conflict with 21.0)
[INFO] | | | | \- (com.google.code.findbugs:jsr305:jar:2.0.1:compile - omitted for conflict with 3.0.1)
[INFO] | | | +- com.github.fge:jackson-coreutils:jar:1.8:compile
[INFO] | | | | +- (com.github.fge:msg-simple:jar:1.1:compile - omitted for duplicate)
[INFO] | | | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.3:compile
[INFO] | | | | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.3:compile
[INFO] | | | | | \- com.fasterxml.jackson.core:jackson-core:jar:2.2.3:compile
[INFO] | | | | +- (com.google.guava:guava:jar:16.0.1:compile - omitted for conflict with 21.0)
[INFO] | | | | \- (com.google.code.findbugs:jsr305:jar:2.0.1:compile - omitted for conflict with 3.0.1)
[INFO] | | | +- org.mozilla:rhino:jar:1.7R4:compile
[INFO] | | | \- (com.google.code.findbugs:jsr305:jar:2.0.1:compile - omitted for conflict with 3.0.1)
[INFO] | | \- net.sf.jopt-simple:jopt-simple:jar:4.6:compile
[INFO] | \- (org.hamcrest:hamcrest-core:jar:1.3:compile - omitted for duplicate)
[INFO] +- org.zapodot:embedded-db-junit:jar:1.0-RC1:compile
[INFO] | +- (junit:junit:jar:4.12:compile - omitted for duplicate)
[INFO] | +- com.h2database:h2:jar:1.4.194:compile
[INFO] | +- net.bytebuddy:byte-buddy:jar:1.5.6:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.24:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.7.21:compile
[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.21:compile - omitted for conflict with 1.7.24)
[INFO] +- org.jdbi:jdbi3:jar:3.0.0-beta1:compile
[INFO] | +- org.antlr:antlr-runtime:jar:3.4:compile
[INFO] | | +- org.antlr:stringtemplate:jar:3.2.1:compile
[INFO] | | | \- (antlr:antlr:jar:2.7.7:compile - omitted for duplicate)
[INFO] | | \- antlr:antlr:jar:2.7.7:compile
[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.21:compile - omitted for conflict with 1.7.24)
[INFO] | +- com.google.code.findbugs:annotations:jar:3.0.1:compile
[INFO] | | +- net.jcip:jcip-annotations:jar:1.0:compile
[INFO] | | \- (com.google.code.findbugs:jsr305:jar:3.0.1:compile - omitted for duplicate)
[INFO] | +- (com.google.guava:guava:jar:21.0:compile - omitted for duplicate)
[INFO] | \- net.jodah:expiringmap:jar:0.5.6:compile
[INFO] \- org.jdbi:jdbi3-sqlobject:jar:3.0.0-beta1:compile
[INFO] +- (org.jdbi:jdbi3:jar:3.0.0-beta1:compile - omitted for duplicate)
[INFO] +- (com.google.code.findbugs:annotations:jar:3.0.1:compile - omitted for duplicate)
[INFO] \- org.assertj:assertj-core:jar:3.5.2:compile
from embedded-db-junit.
@Gaibhne thank you for posting your dependency graph. I still haven't got the time to write a test to find out what is happening in your case.
However: the library is using the H2 database driver's ability to add init scripts in the JDBC URL (see http://h2database.com/html/features.html#execute_sql_on_connection) and I guess that is why you are seeing the MalformedUrlException. Have you checked that you are using the correct path to the SQL file?
Having said that I will try to create a test of some sort to try to reproduce the error.
from embedded-db-junit.
Yes, my configuration in general is fine, as I am already using db-unit in my unit tests, and sometimes when I add something to the SQL files, they stop working. As soon as I remove the offending pieces (like "Engine=InnoDB") it works again. But since I get no feedback on what is wrong exactly, I sometimes have to try around a lot until I figure out what is causing the issue.
from embedded-db-junit.
Related Issues (20)
- Add support for JUnit 5 HOT 1
- Move baseline to Java 8 HOT 1
- Update bytebuddy to v.1.7.9
- @EmbeddedDatabase does not work during maven build HOT 2
- Support for alternative DB drivers HOT 4
- Support multiple .withInitialSql() / .withInitialSqlFromResource() HOT 6
- Move the CompatibilityMode enum to upper level
- DepShield encountered errors while building your project HOT 1
- [DepShield] (CVSS 5.5) Vulnerability due to usage of junit:junit:4.13
- [DepShield] (CVSS 7.5) Vulnerability due to usage of org.yaml:snakeyaml:1.25
- [DepShield] (CVSS 5.5) Vulnerability due to usage of junit:junit:4.13.1
- DepShield encountered errors while building your project
- Make possible to use with Weld rule HOT 1
- Upgrade Liquibase to 4.4.0 HOT 4
- Update to the latest dependent libraries HOT 1
- [DepShield] (CVSS 8.8) Vulnerability due to usage of com.h2database:h2:1.4.197
- [DepShield] (CVSS 9.1) Vulnerability due to usage of com.h2database:h2:1.4.200
- Support for loading from multiple SQL scripts is broken HOT 3
- DepShield Deprecation Notice
- Add InitializationPlugin for Flyway
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embedded-db-junit.