I am using otj-pg-embedded for the first time and would like to incorporate it into our test framework. Details are as follows
Following is the maven dependency :
<dependency>
<groupId>com.opentable.components</groupId>
<artifactId>otj-pg-embedded</artifactId>
<version>0.12.5</version>
<scope>test</scope>
</dependency>
And the code is :
EmbeddedPostgres pg = EmbeddedPostgres.start();
Connection connection = pg.getPostgresDatabase().getConnection();
Statement s = connection.createStatement();
ResultSet rs = s.executeQuery("SELECT 1");
assertEquals(1, rs.getInt(1));
But it fails with java.lang.IllegalStateException on line 1 of the code.
Stack trace is :
initdb: invalid locale settings; check LANG and LC_* environment variables
java.lang.IllegalStateException: Process [/var/folders/rj/3jd5_2n16g37lv1v550g9cqw0000gp/T/embedded-pg/PG-b210101549c90a94dbbada389b65c5d2/bin/initdb, -A, trust, -U, postgres, -D, /var/folders/rj/3jd5_2n16g37lv1v550g9cqw0000gp/T/epg2729813194709143982, -E, UTF-8] failed
at com.opentable.db.postgres.embedded.EmbeddedPostgres.system(EmbeddedPostgres.java:593)
at com.opentable.db.postgres.embedded.EmbeddedPostgres.initdb(EmbeddedPostgres.java:230)
at com.opentable.db.postgres.embedded.EmbeddedPostgres.<init>(EmbeddedPostgres.java:148)
at com.opentable.db.postgres.embedded.EmbeddedPostgres$Builder.start(EmbeddedPostgres.java:580)
at com.opentable.db.postgres.embedded.EmbeddedPostgres.start(EmbeddedPostgres.java:480)
Is there anything that I am missing to configure here? Any help would be appreciated.
By looking at this line in the stack trace
initdb: invalid locale settings; check LANG and LC_* environment variables
,
It seems you need to set env variables for locale as described here: https://github.com/zonkyio/embedded-postgres/issues/11.
export LC_CTYPE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With