diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 51a6eed..5292fcd 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Changed + +- Change base package from `de.zalando` to `org.zalando` +- Update `postgresql` ([CVE-2020-13692](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-13692)) +- Update `guava` ([CVE-2020-8908](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-8908)) +- Update `spring` ([CVE-2020-5421](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-5421)) + ## [2.0.0] - 2017-08-04 ### Added diff --git a/pom.xml b/pom.xml index 9f02fb9..801cf42 100644 --- a/pom.xml +++ b/pom.xml @@ -61,7 +61,7 @@ UTF-8 1.8 1.8 - 5.2.5.RELEASE + 5.2.12.RELEASE 42.2.14 @@ -115,7 +115,7 @@ com.google.guava guava - 28.0-jre + 30.1-jre javax.persistence @@ -133,7 +133,7 @@ junit junit test - 4.12 + 4.13.1 org.springframework @@ -198,7 +198,7 @@ org.owasp dependency-check-maven - 5.0.0 + 6.0.5 diff --git a/src/test/java/org/zalando/typemapper/core/fieldMapper/DoubleFieldMapperTest.java b/src/test/java/org/zalando/typemapper/core/fieldMapper/DoubleFieldMapperTest.java index 6665f2c..311a5c1 100644 --- a/src/test/java/org/zalando/typemapper/core/fieldMapper/DoubleFieldMapperTest.java +++ b/src/test/java/org/zalando/typemapper/core/fieldMapper/DoubleFieldMapperTest.java @@ -2,8 +2,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.nullValue; - -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Before; import org.junit.Test; @@ -13,7 +12,7 @@ public class DoubleFieldMapperTest { private DoubleFieldMapper doubleFieldMapper; @Before - public void setUp() throws Exception { + public void setUp() { doubleFieldMapper = new DoubleFieldMapper(); } diff --git a/src/test/java/org/zalando/typemapper/core/fieldMapper/FloatFieldMapperTest.java b/src/test/java/org/zalando/typemapper/core/fieldMapper/FloatFieldMapperTest.java index 98d53a6..ad41915 100644 --- a/src/test/java/org/zalando/typemapper/core/fieldMapper/FloatFieldMapperTest.java +++ b/src/test/java/org/zalando/typemapper/core/fieldMapper/FloatFieldMapperTest.java @@ -2,8 +2,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.nullValue; - -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Before; import org.junit.Test; @@ -18,7 +17,7 @@ public void setUp() { } @Test - public void testShoulMapNullStringToNull() { + public void testShouldMapNullStringToNull() { assertThat(floatFieldMapper.mapField(null, Float.class), nullValue()); } diff --git a/src/test/java/org/zalando/typemapper/postgres/HStoreTest.java b/src/test/java/org/zalando/typemapper/postgres/HStoreTest.java index ff8209e..8d3bf35 100644 --- a/src/test/java/org/zalando/typemapper/postgres/HStoreTest.java +++ b/src/test/java/org/zalando/typemapper/postgres/HStoreTest.java @@ -2,9 +2,9 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.util.Map; diff --git a/src/test/java/org/zalando/typemapper/postgres/PgSerializerTest.java b/src/test/java/org/zalando/typemapper/postgres/PgSerializerTest.java index 5d47207..7c8a490 100644 --- a/src/test/java/org/zalando/typemapper/postgres/PgSerializerTest.java +++ b/src/test/java/org/zalando/typemapper/postgres/PgSerializerTest.java @@ -13,11 +13,14 @@ import java.util.Date; import java.util.regex.Pattern; + import static org.zalando.typemapper.postgres.PgArray.ARRAY; import static org.zalando.typemapper.postgres.PgRow.ROW; + + import static org.cthul.matchers.CthulMatchers.matchesPattern; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; @RunWith(Parameterized.class) public class PgSerializerTest { diff --git a/src/test/java/org/zalando/typemapper/postgres/PgSerializerToDatabaseTestIT.java b/src/test/java/org/zalando/typemapper/postgres/PgSerializerToDatabaseTestIT.java index 4bcf4ec..ece01ff 100644 --- a/src/test/java/org/zalando/typemapper/postgres/PgSerializerToDatabaseTestIT.java +++ b/src/test/java/org/zalando/typemapper/postgres/PgSerializerToDatabaseTestIT.java @@ -12,6 +12,8 @@ import org.zalando.typemapper.namedresult.results.InheritedClassWithPrimitives; import org.zalando.typemapper.namedresult.results.InheritedClassWithPrimitivesDeprecated; import org.zalando.typemapper.namedresult.transformer.Hans; + + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -26,10 +28,13 @@ import java.sql.Types; import java.util.*; + import static org.zalando.typemapper.postgres.PgArray.ARRAY; import static org.zalando.typemapper.postgres.PgRow.ROW; + + import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; @RunWith(Parameterized.class) @@ -68,7 +73,7 @@ public void createJdbcTemplate() { * @Parameters. */ public PgSerializerToDatabaseTestIT(final Object objectToSerialize, final String expectedString, - final Integer expectedSQLType) { + final Integer expectedSQLType) { this.objectToSerialize = objectToSerialize; this.expectedString = expectedString; this.expectedSQLType = expectedSQLType; @@ -89,127 +94,132 @@ private static Map createSimpleMap(final String key, final Strin @Parameters public static Collection generateData() throws SQLException { return Arrays.asList( - new Object[][] { - /* 23 */ - {PgTypeHelper.asPGobject(new InheritedClassWithPrimitivesDeprecated(1L, "1", 12)), "(1,12,1)", Types.OTHER}, - - /* 0 */ - {1, "1", Types.INTEGER}, - - /* 1 */ - {69, "69", Types.INTEGER}, - - /* 2 */ - {true, "true", Types.BOOLEAN}, - - /* 3 */ - {ARRAY(1, 2, 3, 4).asJdbcArray("int4"), "{1,2,3,4}", Types.ARRAY}, - - /* 4 */ - {ARRAY(null, 2, 3, 4).asJdbcArray("int4"), "{NULL,2,3,4}", Types.ARRAY}, - - /* 5 */ - {ARRAY("a", "b").asJdbcArray("text"), "{a,b}", Types.ARRAY}, - - /* 6 */ - { - ARRAY("first element", "second \"quoted\" element").asJdbcArray("text"), - "{\"first element\",\"second \\\"quoted\\\" element\"}", Types.ARRAY - }, - - /* 7 */ - {ROW(1, 2).asPGobject("int_duplet"), "(1,2)", Types.OTHER}, - - /* 8 */ - { - ROW(1, 2, ARRAY("a", "b")).asPGobject("int_duplet_with_text_array"), "(1,2,\"{a,b}\")", - Types.OTHER - }, - - /* 9 */ - { - ROW("a", "b", new int[] {1, 2, 3, 4}).asPGobject("text_duplet_with_int_array"), - "(a,b,\"{1,2,3,4}\")", Types.OTHER - }, - - /* 10 */ - { - ROW("a", null, ARRAY(ROW(1, 10), ROW(2, 20), null)).asPGobject( - "text_duplet_with_int_duplet_array"), "(a,,\"{\"\"(1,10)\"\",\"\"(2,20)\"\",NULL}\")", - Types.OTHER - }, - - /* 11 */ - { - ROW("a", null, ARRAY(ROW(1, 11), ROW(2, 22), null)).asPGobject( - "text_duplet_with_int_duplet_array"), "(a,,\"{\"\"(1,11)\"\",\"\"(2,22)\"\",NULL}\")", - Types.OTHER - }, - - /* 12 */ - { - ROW(1, new ClassWithPrimitives(1, 2L, 'c')).asPGobject("int_with_additional_type"), - "(1,\"(c,1,2)\")", Types.OTHER - }, - - /* 13 */ - { - ROW(1, - new ClassWithPrimitives[] { - new ClassWithPrimitives(1, 100L, 'a'), new ClassWithPrimitives(2, 200L, 'b') - }).asPGobject("int_with_additional_type_array"), - "(1,\"{\"\"(a,1,100)\"\",\"\"(b,2,200)\"\"}\")", Types.OTHER - }, - - /* 14 */ - {PgTypeHelper.asPGobject(new ClassWithPrimitives(1, 100L, 'a')), "(a,1,100)", Types.OTHER}, - - /* 15 */ - { - PgTypeHelper.asPGobject(new ClassWithPrimitivesAndMap(1, 2, 'a', createSimpleMap("b", "c"))), - "(1,2,a,\"\"\"b\"\"=>\"\"c\"\"\")", Types.OTHER - }, - - /* 16 */ - { - PgTypeHelper.asPGobject(new ClassWithEnum(Enumeration.VALUE_1, Enumeration.VALUE_2)), - "(VALUE_1,VALUE_2)", Types.OTHER - }, - - /* 17 */ - { - PgTypeHelper.asPGobject( - new ClassWithSimpleTransformers(GenderCode.MALE, GenderCode.MALE, GenderCode.MALE, "path", - "listElement1", "listElement2", "listElement3")), - "(path,homme,0,MALE,listElement1#listElement2#listElement3)", Types.OTHER - }, - - /* 18 */ - { - PgTypeHelper.asPGobject( - new ClassWithPredefinedTransformer( - new Hans("This is a complex object using an implicit transformer."))), - "(\"This is a complex object using an implicit transformer.\",{})", Types.OTHER - }, - - /* 19 */ - { - PgTypeHelper.asPGobject( - new ClassWithPredefinedTransformer( - new Hans("This is a complex object using an implicit transformer."), - new Hans("list element 1"), new Hans("list element 2"))), - "(\"This is a complex object using an implicit transformer.\",\"{\"\"list element 1\"\",\"\"list element 2\"\"}\")", - Types.OTHER - }, - - /* 20 */ - {new Date(1354338366000L), "2012-12-01 06:06:06+01", Types.TIMESTAMP}, - - /* 21 */ - {new Date(1349064366000L), "2012-10-01 06:06:06+02", Types.TIMESTAMP}, - - /* 22 */ - {PgTypeHelper.asPGobject(new InheritedClassWithPrimitives(1L, "1", 12)), "(1,12,1)", Types.OTHER}, + new Object[][]{ + /* 23 */ + {PgTypeHelper.asPGobject( + new InheritedClassWithPrimitivesDeprecated(1L, "1", 12)), "(1,12,1)", Types.OTHER}, + + /* 0 */ + {1, "1", Types.INTEGER}, + + /* 1 */ + {69, "69", Types.INTEGER}, + + /* 2 */ + {true, "true", Types.BOOLEAN}, + + /* 3 */ + {ARRAY(1, 2, 3, 4).asJdbcArray("int4"), "{1,2,3,4}", Types.ARRAY}, + + /* 4 */ + {ARRAY(null, 2, 3, 4).asJdbcArray("int4"), "{NULL,2,3,4}", Types.ARRAY}, + + /* 5 */ + {ARRAY("a", "b").asJdbcArray("text"), "{a,b}", Types.ARRAY}, + + /* 6 */ + { + ARRAY("first element", "second \"quoted\" element").asJdbcArray("text"), + "{\"first element\",\"second \\\"quoted\\\" element\"}", Types.ARRAY + }, + + /* 7 */ + {ROW(1, 2).asPGobject("int_duplet"), "(1,2)", Types.OTHER}, + + /* 8 */ + { + ROW(1, 2, ARRAY("a", "b")).asPGobject("int_duplet_with_text_array"), "(1,2,\"{a,b}\")", + Types.OTHER + }, + + /* 9 */ + { + ROW("a", "b", new int[]{1, 2, 3, 4}).asPGobject("text_duplet_with_int_array"), + "(a,b,\"{1,2,3,4}\")", Types.OTHER + }, + + /* 10 */ + { + ROW("a", null, ARRAY(ROW(1, 10), ROW(2, 20), null)).asPGobject( + "text_duplet_with_int_duplet_array"), "(a,,\"{\"\"(1,10)\"\",\"\"(2,20)\"\",NULL}\")", + Types.OTHER + }, + + /* 11 */ + { + ROW("a", null, ARRAY(ROW(1, 11), ROW(2, 22), null)).asPGobject( + "text_duplet_with_int_duplet_array"), "(a,,\"{\"\"(1,11)\"\",\"\"(2,22)\"\",NULL}\")", + Types.OTHER + }, + + /* 12 */ + { + ROW(1, new ClassWithPrimitives(1, 2L, 'c')).asPGobject("int_with_additional_type"), + "(1,\"(c,1,2)\")", Types.OTHER + }, + + /* 13 */ + { + ROW(1, + new ClassWithPrimitives[]{ + new ClassWithPrimitives(1, 100L, 'a'), new ClassWithPrimitives(2, 200L, + 'b') + }).asPGobject("int_with_additional_type_array"), + "(1,\"{\"\"(a,1,100)\"\",\"\"(b,2,200)\"\"}\")", Types.OTHER + }, + + /* 14 */ + {PgTypeHelper.asPGobject(new ClassWithPrimitives(1, 100L, 'a')), "(a,1,100)", Types.OTHER}, + + /* 15 */ + { + PgTypeHelper.asPGobject( + new ClassWithPrimitivesAndMap(1, 2, 'a', createSimpleMap("b", "c"))), + "(1,2,a,\"\"\"b\"\"=>\"\"c\"\"\")", Types.OTHER + }, + + /* 16 */ + { + PgTypeHelper.asPGobject(new ClassWithEnum(Enumeration.VALUE_1, Enumeration.VALUE_2)), + "(VALUE_1,VALUE_2)", Types.OTHER + }, + + /* 17 */ + { + PgTypeHelper.asPGobject( + new ClassWithSimpleTransformers(GenderCode.MALE, GenderCode.MALE, + GenderCode.MALE, "path", + "listElement1", "listElement2", "listElement3")), + "(path,homme,0,MALE,listElement1#listElement2#listElement3)", Types.OTHER + }, + + /* 18 */ + { + PgTypeHelper.asPGobject( + new ClassWithPredefinedTransformer( + new Hans("This is a complex object using an implicit transformer."))), + "(\"This is a complex object using an implicit transformer.\",{})", Types.OTHER + }, + + /* 19 */ + { + PgTypeHelper.asPGobject( + new ClassWithPredefinedTransformer( + new Hans("This is a complex object using an implicit transformer."), + new Hans("list element 1"), new Hans("list element 2"))), + "(\"This is a complex object using an implicit transformer.\",\"{\"\"list element 1\"\",\"\"list element 2\"\"}\")", + Types.OTHER + }, + + /* 20 */ + {new Date(1354338366000L), "2012-12-01 06:06:06+01", Types.TIMESTAMP}, + + /* 21 */ + {new Date(1349064366000L), "2012-10-01 06:06:06+02", Types.TIMESTAMP}, + + /* 22 */ + {PgTypeHelper.asPGobject( + new InheritedClassWithPrimitives(1L, "1", 12)), "(1,12,1)", Types.OTHER}, }); } @@ -235,7 +245,7 @@ public void createNeededTypes() throws SQLException { // type with gender code execute("CREATE TYPE gender_enum_type AS ENUM ('MALE', 'FEMALE');"); execute( - "CREATE TYPE tmp.class_with_simple_transformers AS (file_column text, gender_as_code text, gender_as_int integer, gender_as_name gender_enum_type, string_list_with_separtion_char text);"); + "CREATE TYPE tmp.class_with_simple_transformers AS (file_column text, gender_as_code text, gender_as_int integer, gender_as_name gender_enum_type, string_list_with_separtion_char text);"); execute("CREATE TYPE tmp.inherited_class_with_primitives AS (l bigint, cc text, i int);"); execute("CREATE TYPE tmp.inherited_class_with_primitives_deprecated AS (l bigint, cc text, i int);"); @@ -256,8 +266,8 @@ public void dropUsedTypes() throws SQLException { @Test public void passingParametersToQueryTest() { - assertThat(template.queryForObject("SELECT (?)::text", new Object[] {this.objectToSerialize}, - new int[] {this.expectedSQLType}, String.class), is(this.expectedString)); + assertThat(template.queryForObject("SELECT (?)::TEXT", new Object[]{this.objectToSerialize}, + new int[]{this.expectedSQLType}, String.class), is(this.expectedString)); } } //J+