Skip to content

Commit ac5a4a1

Browse files
authored
Merge pull request #62 from PgBulkInsert/github-actions
template based maven build
2 parents cebdade + 34d81d4 commit ac5a4a1

5 files changed

Lines changed: 58 additions & 22 deletions

File tree

.github/workflows/maven.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: Java CI with Maven
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
services:
18+
postgres:
19+
image: postgres
20+
env:
21+
POSTGRES_PASSWORD: password
22+
TZ: UTC
23+
options: >-
24+
--health-cmd pg_isready
25+
--health-interval 10s
26+
--health-timeout 5s
27+
--health-retries 5
28+
ports:
29+
- 5432:5432
30+
31+
steps:
32+
- uses: actions/checkout@v2
33+
- name: Set up JDK 1.8
34+
uses: actions/setup-java@v1
35+
with:
36+
java-version: 1.8
37+
- name: Build with Maven
38+
run: mvn -B package --file pom.xml
39+
working-directory: ./PgBulkInsert

PgBulkInsert/pgbulkinsert-core/src/test/java/de/bytefish/pgbulkinsert/test/pgsql/handlers/RangeTypesTest.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
import java.sql.ResultSet;
1515
import java.sql.SQLException;
1616
import java.sql.Statement;
17-
import java.time.LocalDate;
18-
import java.time.LocalDateTime;
19-
import java.time.ZoneId;
20-
import java.time.ZonedDateTime;
17+
import java.time.*;
2118
import java.util.ArrayList;
2219
import java.util.List;
2320

@@ -265,8 +262,8 @@ public void test_SaveTsTzRange_Inclusive_Bounds() throws SQLException {
265262
// Range to insert:
266263
RangeEntity entity0 = new RangeEntity();
267264

268-
ZonedDateTime lower = ZonedDateTime.of(2020, 1, 1, 0, 0, 0 ,0, ZoneId.of("GMT"));
269-
ZonedDateTime upper = ZonedDateTime.of(2020, 3, 1, 0, 0, 0 ,0, ZoneId.of("GMT"));
265+
ZonedDateTime lower = ZonedDateTime.of(2020, 1, 1, 0, 0, 0 ,0, ZoneOffset.UTC);
266+
ZonedDateTime upper = ZonedDateTime.of(2020, 3, 1, 0, 0, 0 ,0, ZoneOffset.UTC);
270267

271268
entity0.timeTzRange = new Range<>(lower, upper);
272269

@@ -283,7 +280,7 @@ public void test_SaveTsTzRange_Inclusive_Bounds() throws SQLException {
283280
while (rs.next()) {
284281
PGobject v0 = (PGobject) rs.getObject("col_tstzrange");
285282

286-
Assert.assertEquals("[\"2020-01-01 01:00:00+01\",\"2020-03-01 01:00:00+01\"]", v0.getValue());
283+
Assert.assertEquals("[\"2020-01-01 00:00:00+00\",\"2020-03-01 00:00:00+00\"]", v0.getValue());
287284
}
288285
}
289286

@@ -296,7 +293,7 @@ public void test_SaveTsTzRange_UpperBound_Null() throws SQLException {
296293
// Range to insert:
297294
RangeEntity entity0 = new RangeEntity();
298295

299-
ZonedDateTime lower = ZonedDateTime.of(2020, 1, 1, 0, 0, 0 ,0, ZoneId.of("GMT"));
296+
ZonedDateTime lower = ZonedDateTime.of(2020, 1, 1, 0, 0, 0 ,0, ZoneOffset.UTC);
300297
ZonedDateTime upper = null;
301298

302299
entity0.timeTzRange = new Range<>(lower, upper);
@@ -314,7 +311,7 @@ public void test_SaveTsTzRange_UpperBound_Null() throws SQLException {
314311
while (rs.next()) {
315312
PGobject v0 = (PGobject) rs.getObject("col_tstzrange");
316313

317-
Assert.assertEquals("[\"2020-01-01 01:00:00+01\",)", v0.getValue());
314+
Assert.assertEquals("[\"2020-01-01 00:00:00+00\",)", v0.getValue());
318315
}
319316
}
320317

@@ -328,7 +325,7 @@ public void test_SaveTsTzRange_LowerBound_Null() throws SQLException {
328325
RangeEntity entity0 = new RangeEntity();
329326

330327
ZonedDateTime lower = null;
331-
ZonedDateTime upper = ZonedDateTime.of(2020, 1, 1, 0, 0, 0 ,0, ZoneId.of("GMT"));
328+
ZonedDateTime upper = ZonedDateTime.of(2020, 1, 1, 0, 0, 0 ,0, ZoneOffset.UTC);
332329

333330
entity0.timeTzRange = new Range<>(lower, upper);
334331

@@ -345,7 +342,7 @@ public void test_SaveTsTzRange_LowerBound_Null() throws SQLException {
345342
while (rs.next()) {
346343
PGobject v0 = (PGobject) rs.getObject("col_tstzrange");
347344

348-
Assert.assertEquals("(,\"2020-01-01 01:00:00+01\"]", v0.getValue());
345+
Assert.assertEquals("(,\"2020-01-01 00:00:00+00\"]", v0.getValue());
349346
}
350347
}
351348

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
db.url=jdbc:postgresql://127.0.0.1:5432/sampledb
2-
db.user=philipp
3-
db.password=test_pwd
1+
db.url=jdbc:postgresql://localhost:5432/postgres
2+
db.user=postgres
3+
db.password=password
44
db.schema=public

PgBulkInsert/pgbulkinsert-jpa/src/test/java/de/bytefish/pgbulkinsert/test/jpa/JpaMappingTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public enum SampleEntityTypeEnum {
3434
}
3535

3636
@Entity
37-
@Table(name = "unit_test", schema = "sample")
37+
@Table(name = "unit_test", schema = "public")
3838
public class SampleEntity {
3939

4040
@Id
@@ -242,7 +242,7 @@ private List<SampleEntity> getSampleEntityList(int num) {
242242

243243
private boolean createTable() throws SQLException {
244244

245-
String sqlStatement = "CREATE TABLE sample.unit_test" +
245+
String sqlStatement = "CREATE TABLE public.unit_test" +
246246
" (\n" +
247247
" id int8,\n" +
248248
" int_field int4,\n" +
@@ -259,7 +259,7 @@ private boolean createTable() throws SQLException {
259259
}
260260

261261
private ResultSet getAll() throws SQLException {
262-
String sqlStatement = "SELECT * FROM sample.unit_test";
262+
String sqlStatement = "SELECT * FROM public.unit_test";
263263

264264
Statement statement = connection.createStatement();
265265

@@ -270,7 +270,7 @@ private int getRowCount() throws SQLException {
270270

271271
Statement s = connection.createStatement();
272272

273-
ResultSet r = s.executeQuery(String.format("SELECT COUNT(*) AS rowcount FROM sample.unit_test"));
273+
ResultSet r = s.executeQuery(String.format("SELECT COUNT(*) AS rowcount FROM public.unit_test"));
274274
r.next();
275275
int count = r.getInt("rowcount");
276276
r.close();

PgBulkInsert/pgbulkinsert-jpa/src/test/java/de/bytefish/pgbulkinsert/test/jpa/annotations/PostgresDataTypeTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class PostgresDataTypeTests extends TransactionalTestBase {
2020

2121
@Entity
22-
@Table(name = "unit_test", schema = "sample")
22+
@Table(name = "unit_test", schema = "public")
2323
public class SampleEntity {
2424

2525
@Id
@@ -82,7 +82,7 @@ public void writeShortAsIntValueTest() throws SQLException {
8282

8383
private boolean createTable() throws SQLException {
8484

85-
String sqlStatement = "CREATE TABLE sample.unit_test" +
85+
String sqlStatement = "CREATE TABLE public.unit_test" +
8686
" (\n" +
8787
" id int8,\n" +
8888
" int_field int4\n" +
@@ -94,7 +94,7 @@ private boolean createTable() throws SQLException {
9494
}
9595

9696
private ResultSet getAll() throws SQLException {
97-
String sqlStatement = "SELECT * FROM sample.unit_test";
97+
String sqlStatement = "SELECT * FROM public.unit_test";
9898

9999
Statement statement = connection.createStatement();
100100

@@ -105,7 +105,7 @@ private int getRowCount() throws SQLException {
105105

106106
Statement s = connection.createStatement();
107107

108-
ResultSet r = s.executeQuery(String.format("SELECT COUNT(*) AS rowcount FROM sample.unit_test"));
108+
ResultSet r = s.executeQuery(String.format("SELECT COUNT(*) AS rowcount FROM public.unit_test"));
109109
r.next();
110110
int count = r.getInt("rowcount");
111111
r.close();

0 commit comments

Comments
 (0)