From d9f90a7dbced45e3e7e7a0d325619c7c669b26e8 Mon Sep 17 00:00:00 2001 From: Ryan McNally Date: Fri, 17 Mar 2023 15:41:13 +0000 Subject: [PATCH] Extended SQL message field type support (#292) * Extended SQL message field type support * Avoid DST pain * Avoiding chrome issue * https://www.selenium.dev/blog/2023/headless-is-going-away/ --- .gitattributes | 5 + doc/src/main/markdown/further.md | 4 +- .../test/flow/example/app/assrt/Browser.java | 4 +- .../example/app/model/ExampleSystemTest.java | 6 +- .../test/flow/msg/AbstractMessage.java | 6 +- .../test/flow/msg/AbstractMessageTest.java | 6 + .../mastercard/test/flow/msg/sql/Query.java | 4 +- .../mastercard/test/flow/msg/sql/Result.java | 3 +- .../test/flow/msg/sql/TypedKVP.java | 145 ++++++++++++++++-- .../test/flow/msg/sql/QueryTest.java | 104 +++++++++---- .../test/flow/msg/sql/ResultTest.java | 86 ++++++++--- .../test/flow/report/seq/Browser.java | 4 +- 12 files changed, 300 insertions(+), 77 deletions(-) diff --git a/.gitattributes b/.gitattributes index 62062e3bc0..eb7376445e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,8 @@ +# Configures git behaviour so everyone gets the same line-endings where it matters +# check what file extensions exist in the project with: +# find . -type f -name '*.*' | sed 's|.*\.||' | sort -u + +*.css text eol=lf *.html text eol=lf *.java text eol=lf *.js text eol=lf diff --git a/doc/src/main/markdown/further.md b/doc/src/main/markdown/further.md index f7aa13ba69..00fb96390f 100644 --- a/doc/src/main/markdown/further.md +++ b/doc/src/main/markdown/further.md @@ -245,12 +245,12 @@ Consider the following worked example: [flow.Unpredictable]: ../../../../api/src/main/java/com/mastercard/test/flow/Unpredictable.java -[AbstractMessage.masking(Unpredictable,UnaryOperator)]: ../../../../message/message-core/src/main/java/com/mastercard/test/flow/msg/AbstractMessage.java#L48-L55,48-55 +[AbstractMessage.masking(Unpredictable,UnaryOperator)]: ../../../../message/message-core/src/main/java/com/mastercard/test/flow/msg/AbstractMessage.java#L50-L57,50-57 [AbstractFlocessor.masking(Unpredictable...)]: ../../../../assert/assert-core/src/main/java/com/mastercard/test/flow/assrt/AbstractFlocessor.java#L202-L209,202-209 [mask.BenSys]: ../../test/java/com/mastercard/test/flow/doc/mask/BenSys.java [mask.DieSys]: ../../test/java/com/mastercard/test/flow/doc/mask/DieSys.java [mask.Unpredictables]: ../../test/java/com/mastercard/test/flow/doc/mask/Unpredictables.java -[AbstractMessage.masking(Unpredictable,UnaryOperator)]: ../../../../message/message-core/src/main/java/com/mastercard/test/flow/msg/AbstractMessage.java#L48-L55,48-55 +[AbstractMessage.masking(Unpredictable,UnaryOperator)]: ../../../../message/message-core/src/main/java/com/mastercard/test/flow/msg/AbstractMessage.java#L50-L57,50-57 [Rolling?d\+]: ../../test/java/com/mastercard/test/flow/doc/mask/Rolling.java#L30,30 [msg.Mask]: ../../../../message/message-core/src/main/java/com/mastercard/test/flow/msg/Mask.java [msg.Mask.andThen(Consumer)]: ../../../../message/message-core/src/main/java/com/mastercard/test/flow/msg/Mask.java#L290-L292,290-292 diff --git a/example/app-assert/src/main/java/com/mastercard/test/flow/example/app/assrt/Browser.java b/example/app-assert/src/main/java/com/mastercard/test/flow/example/app/assrt/Browser.java index 4a1554b8fe..2c7d639c22 100644 --- a/example/app-assert/src/main/java/com/mastercard/test/flow/example/app/assrt/Browser.java +++ b/example/app-assert/src/main/java/com/mastercard/test/flow/example/app/assrt/Browser.java @@ -72,7 +72,7 @@ public static WebDriver get() { WebDriverManager.chromedriver().setup(); ChromeOptions options = new ChromeOptions(); if( !SHOW ) { - options.addArguments( "--headless" ); + options.addArguments( "--headless=new" ); } // some oddness around browser locale changing with headful/less mode, possibly // related to https://bugs.chromium.org/p/chromium/issues/detail?id=755338 @@ -81,6 +81,8 @@ public static WebDriver get() { options.addArguments( "--lang=en_GB" ); options.addArguments( "--disable-gpu" ); options.addArguments( "--window-size=1400,800" ); + // https://github.com/SeleniumHQ/selenium/issues/11750 + options.addArguments( "--remote-allow-origins=*" ); // suppress most stdout noise. We still get a "ChromeDriver was started // successfully." line for some reason diff --git a/example/app-model/src/test/java/com/mastercard/test/flow/example/app/model/ExampleSystemTest.java b/example/app-model/src/test/java/com/mastercard/test/flow/example/app/model/ExampleSystemTest.java index 311ce6c7a9..32bef30a73 100644 --- a/example/app-model/src/test/java/com/mastercard/test/flow/example/app/model/ExampleSystemTest.java +++ b/example/app-model/src/test/java/com/mastercard/test/flow/example/app/model/ExampleSystemTest.java @@ -56,7 +56,7 @@ void messageHashes() { mh.expect( ExampleSystem.MODEL, "ALL MESSAGES", - "FD907B745292C2C0980111694D69A8E8 0122 21.3 KiB", + "720AC1156AFAE947D7B32D94483B5B16 0122 21.3 KiB", "REQUESTS --> USER", "00000000000000000000000000000000 0000 0 B", "RESPONSES <-- USER", @@ -86,9 +86,9 @@ void messageHashes() { "RESPONSES <-- STORE", "3DD66292776363BB0FC0E5F2443DDD7C 0006 1.1 KiB", "REQUESTS --> DB", - "A06D030C1A8192CFE446CD5893217196 0008 2.6 KiB", + "DFB253E31C3C812A60E039379CCFA64D 0008 2.5 KiB", "RESPONSES <-- DB", - "3F7C757B6981B4A5844357C399720641 0008 1.1 KiB", + "CF399FF557548CC74F579F5193CE2264 0008 1.1 KiB", "REQUESTS --> HISTOGRAM", "BF8DDDB8D319B876FADD333BCB149E4F 0009 1.1 KiB", "RESPONSES <-- HISTOGRAM", diff --git a/message/message-core/src/main/java/com/mastercard/test/flow/msg/AbstractMessage.java b/message/message-core/src/main/java/com/mastercard/test/flow/msg/AbstractMessage.java index f227f9f237..1d11b8c6e5 100644 --- a/message/message-core/src/main/java/com/mastercard/test/flow/msg/AbstractMessage.java +++ b/message/message-core/src/main/java/com/mastercard/test/flow/msg/AbstractMessage.java @@ -5,6 +5,8 @@ import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.BigInteger; +import java.sql.Date; +import java.sql.Time; import java.sql.Timestamp; import java.util.ArrayList; import java.util.HashMap; @@ -221,7 +223,9 @@ public static void registerDefensiveCopier( Class type, UnaryOperator } static { - registerDefensiveCopier( Timestamp.class, t -> new Timestamp( t.getTime() ) ); + registerDefensiveCopier( Date.class, d -> new Date( d.getTime() ) ); + registerDefensiveCopier( Time.class, t -> new Time( t.getTime() ) ); + registerDefensiveCopier( Timestamp.class, ts -> new Timestamp( ts.getTime() ) ); } /** diff --git a/message/message-core/src/test/java/com/mastercard/test/flow/msg/AbstractMessageTest.java b/message/message-core/src/test/java/com/mastercard/test/flow/msg/AbstractMessageTest.java index d6e187fffd..cc4c9f239a 100644 --- a/message/message-core/src/test/java/com/mastercard/test/flow/msg/AbstractMessageTest.java +++ b/message/message-core/src/test/java/com/mastercard/test/flow/msg/AbstractMessageTest.java @@ -8,6 +8,8 @@ import java.lang.reflect.Field; import java.math.BigDecimal; import java.math.BigInteger; +import java.sql.Date; +import java.sql.Time; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Collections; @@ -223,6 +225,8 @@ void validTypes() { msg.set( "bigdecimal", new BigDecimal( "1.234" ) ); msg.set( "biginteger", new BigInteger( "5678" ) ); msg.set( "uuid", new UUID( 12345L, 67890L ) ); + msg.set( "time", new Time( 1234567890L ) ); + msg.set( "date", new Date( 1234567890L ) ); msg.set( "timestamp", new Timestamp( 1234567890L ) ); msg.set( "null", null ); @@ -238,6 +242,8 @@ void validTypes() { assertEquals( new BigDecimal( "1.234" ), msg.get( "bigdecimal" ) ); assertEquals( new BigInteger( "5678" ), msg.get( "biginteger" ) ); assertEquals( new UUID( 12345L, 67890L ), msg.get( "uuid" ) ); + assertEquals( new Time( 1234567890L ), msg.get( "time" ) ); + assertEquals( new Date( 1234567890L ), msg.get( "date" ) ); assertEquals( new Timestamp( 1234567890L ), msg.get( "timestamp" ) ); assertEquals( null, msg.get( "null" ) ); assertEquals( null, msg.get( "no such field" ) ); diff --git a/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/Query.java b/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/Query.java index 4bac3256d2..eb92847caa 100644 --- a/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/Query.java +++ b/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/Query.java @@ -142,7 +142,7 @@ protected String asHuman() { */ private static String formatValue( Object value ) { if( value instanceof byte[] ) { - return "bytes: " + Base64.getEncoder().encodeToString( (byte[]) value ); + return Base64.getEncoder().encodeToString( (byte[]) value ); } return String.valueOf( value ); } @@ -166,7 +166,7 @@ static class TypedMap { private final List> pairs = new ArrayList<>(); /** - * @param m The values for sewrialisation + * @param m The values for serialisation */ TypedMap( Map m ) { m.forEach( ( k, v ) -> pairs.add( new TypedKVP<>( k, v ) ) ); diff --git a/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/Result.java b/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/Result.java index eac120cd0e..92ec2be62d 100644 --- a/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/Result.java +++ b/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/Result.java @@ -252,7 +252,7 @@ protected String asHuman() { */ private static String formatValue( Object value ) { if( value instanceof byte[] ) { - return "bytes: " + Base64.getEncoder().encodeToString( (byte[]) value ); + return Base64.getEncoder().encodeToString( (byte[]) value ); } return String.valueOf( value ); } @@ -284,7 +284,6 @@ public ResultSetStructure( } ResultSetStructure prepForSerialisation() { - rows.clear(); maps.stream() .map( row -> row.entrySet().stream() .map( e -> new TypedKVP<>( e.getKey(), e.getValue() ) ) diff --git a/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/TypedKVP.java b/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/TypedKVP.java index c681829dfc..7492bec73f 100644 --- a/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/TypedKVP.java +++ b/message/message-sql/src/main/java/com/mastercard/test/flow/msg/sql/TypedKVP.java @@ -1,44 +1,146 @@ package com.mastercard.test.flow.msg.sql; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Objects; +import java.util.stream.Stream; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; /** - * Preserves typing for byte arrays during jackson serialisation + * Preserves value typing during jackson serialisation * * @param The key type */ +@JsonInclude(Include.NON_NULL) class TypedKVP { - @JsonProperty("k") + @JsonProperty("key") private final K key; - @JsonProperty("v") + + @JsonProperty("bit") + private final Boolean bit; + + @JsonProperty("tinyint") + private final Byte tinyint; + + @JsonProperty("smallint") + private final Short smallint; + + @JsonProperty("integer") + private final Integer integer; + + @JsonProperty("bigint") + private final Long bigint; + + @JsonProperty("biggerint") + private final BigInteger biggerint; + + @JsonProperty("real") + private final Float real; + + @JsonProperty("double") + private final Double _double; + + @JsonProperty("decimal") + private final BigDecimal decimal; + + @JsonProperty("character") + private final Character character; + + @JsonProperty("varchar") + private final String varchar; + + @JsonProperty("blob") + private final byte[] blob; + + @JsonProperty("date") + private final Date date; + + @JsonProperty("time") + private final Time time; + + @JsonProperty("timestamp") + private final Timestamp timestamp; + + @JsonProperty("value") private final Object value; - @JsonProperty("b") - private final byte[] bytes; /** * @param key The pair key * @param value The pair value */ TypedKVP( K key, Object value ) { - this( key, - value instanceof byte[] ? null : value, - value instanceof byte[] ? (byte[]) value : null ); + this.key = key; + + bit = value instanceof Boolean ? (Boolean) value : null; + tinyint = value instanceof Byte ? (Byte) value : null; + smallint = value instanceof Short ? (Short) value : null; + integer = value instanceof Integer ? (Integer) value : null; + bigint = value instanceof Long ? (Long) value : null; + biggerint = value instanceof BigInteger ? (BigInteger) value : null; + real = value instanceof Float ? (Float) value : null; + _double = value instanceof Double ? (Double) value : null; + decimal = value instanceof BigDecimal ? (BigDecimal) value : null; + character = value instanceof Character ? (Character) value : null; + varchar = value instanceof String ? (String) value : null; + blob = value instanceof byte[] ? (byte[]) value : null; + date = value instanceof Date ? (Date) value : null; + time = value instanceof Time ? (Time) value : null; + timestamp = value instanceof Timestamp ? (Timestamp) value : null; + + this.value = Stream.of( + bit, tinyint, smallint, integer, bigint, biggerint, + real, _double, decimal, + character, varchar, + blob, + date, time, timestamp ) + .anyMatch( Objects::nonNull ) ? null : value; } /** * For jackson's benefit - * - * @param key The pair key - * @param value The non-bytey pair value - * @param bytes The bytey pair value */ + @SuppressWarnings("javadoc") TypedKVP( - @JsonProperty("k") K key, - @JsonProperty("v") Object value, - @JsonProperty("b") byte[] bytes ) { + @JsonProperty("key") K key, + @JsonProperty("bit") Boolean bit, + @JsonProperty("tinyint") Byte tinyint, + @JsonProperty("smallint") Short smallint, + @JsonProperty("integer") Integer integer, + @JsonProperty("bigint") Long bigint, + @JsonProperty("biggerint") BigInteger biggerint, + @JsonProperty("real") Float real, + @JsonProperty("double") Double _double, + @JsonProperty("decimal") BigDecimal decimal, + @JsonProperty("character") Character character, + @JsonProperty("varchar") String varchar, + @JsonProperty("blob") byte[] blob, + @JsonProperty("date") Date date, + @JsonProperty("time") Time time, + @JsonProperty("timestamp") Timestamp timestamp, + @JsonProperty("value") Object value ) { this.key = key; + this.bit = bit; + this.tinyint = tinyint; + this.smallint = smallint; + this.integer = integer; + this.bigint = bigint; + this.biggerint = biggerint; + this.real = real; + this._double = _double; + this.decimal = decimal; + this.character = character; + this.varchar = varchar; + this.blob = blob; + this.date = date; + this.time = time; + this.timestamp = timestamp; this.value = value; - this.bytes = bytes; } /** @@ -52,6 +154,15 @@ K key() { * @return The value */ Object value() { - return value != null ? value : bytes; + return Stream.of( + bit, tinyint, smallint, integer, bigint, biggerint, + real, _double, decimal, + character, varchar, + blob, + date, time, timestamp, + value ) + .filter( Objects::nonNull ) + .findFirst() + .orElse( null ); } } diff --git a/message/message-sql/src/test/java/com/mastercard/test/flow/msg/sql/QueryTest.java b/message/message-sql/src/test/java/com/mastercard/test/flow/msg/sql/QueryTest.java index 83a7cf4557..de983b5696 100644 --- a/message/message-sql/src/test/java/com/mastercard/test/flow/msg/sql/QueryTest.java +++ b/message/message-sql/src/test/java/com/mastercard/test/flow/msg/sql/QueryTest.java @@ -1,9 +1,15 @@ package com.mastercard.test.flow.msg.sql; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; @@ -180,6 +186,74 @@ void manyBinds() { + " 14 : 14", query.asHuman() ); } + /** + * Shows that types are preserved in the round-trip to byte content + */ + @Test + void types() { + + Query query = new Query( "SELECT 1" ) + .set( "0", true ) + .set( "1", (byte) 1 ) + .set( "2", (short) 2 ) + .set( "3", 3 ) + .set( "4", 4.0f ) + .set( "5", 5L ) + .set( "6", 6.0 ) + .set( "7", 'a' ) + .set( "8", "bcd" ) + .set( "9", new BigInteger( "9" ) ) + .set( "10", new BigDecimal( "10.0" ) ) + .set( "11", "bytes".getBytes( UTF_8 ) ) + .set( "12", Date.valueOf( "1970-01-02" ) ) + .set( "13", Time.valueOf( "03:04:06" ) ) + .set( "14", Timestamp.valueOf( "1970-01-02 03:04:07.0" ) ) + .set( "15", null ); + + assertEquals( "" + + "Query:\n" + + "SELECT\n" + + " 1\n" + + "Bind variables:\n" + + " 0 : true\n" + + " 1 : 1\n" + + " 2 : 2\n" + + " 3 : 3\n" + + " 4 : 4.0\n" + + " 5 : 5\n" + + " 6 : 6.0\n" + + " 7 : a\n" + + " 8 : bcd\n" + + " 9 : 9\n" + + " 10 : 10.0\n" + + " 11 : Ynl0ZXM=\n" + + " 12 : 1970-01-02\n" + + " 13 : 03:04:06\n" + + " 14 : 1970-01-02 03:04:07.0\n" + + " 15 : null", + query.assertable() ); + + Query parsed = new Query( "" ).peer( query.content() ); + + assertEquals( "SELECT 1", parsed.get( Query.SQL ) ); + assertEquals( true, parsed.get( "0" ) ); + assertEquals( (byte) 1, parsed.get( "1" ) ); + assertEquals( (short) 2, parsed.get( "2" ) ); + assertEquals( 3, parsed.get( "3" ) ); + assertEquals( 4.0f, parsed.get( "4" ) ); + assertEquals( 5L, parsed.get( "5" ) ); + assertEquals( 6.0, parsed.get( "6" ) ); + assertEquals( 'a', parsed.get( "7" ) ); + assertEquals( "bcd", parsed.get( "8" ) ); + assertEquals( new BigInteger( "9" ), parsed.get( "9" ) ); + assertEquals( new BigDecimal( "10.0" ), parsed.get( "10" ) ); + assertArrayEquals( "bytes".getBytes( UTF_8 ), (byte[]) parsed.get( "11" ) ); + assertEquals( Date.valueOf( "1970-01-02" ), parsed.get( "12" ) ); + assertEquals( Time.valueOf( "03:04:06" ), parsed.get( "13" ) ); + assertEquals( Timestamp.valueOf( "1970-01-02 03:04:07.0" ), parsed.get( "14" ) ); + assertEquals( null, parsed.get( "15" ) ); + } + /** * Exercises mask inheritance to peers */ @@ -225,34 +299,4 @@ protected Object validateValueType( String field, Object value ) { assertThrows( IllegalStateException.class, () -> query.content() ); } - /** - * Demonstrates custom encoding of byte array bind variables - */ - @Test - void bytes() { - Query query = new Query( "UPDATE table SET byte_column = ?" ) - .set( "1", "value".getBytes( UTF_8 ) ); - - assertEquals( "" - + "Query:\n" - + "UPDATE\n" - + " table\n" - + "SET\n" - + " byte_column = ?\n" - + "Bind variables:\n" - + " 1 : bytes: dmFsdWU=", - query.assertable() ); - - Query roundTrip = query.peer( query.content() ); - - assertEquals( "" - + "Query:\n" - + "UPDATE\n" - + " table\n" - + "SET\n" - + " byte_column = ?\n" - + "Bind variables:\n" - + " 1 : bytes: dmFsdWU=", - roundTrip.assertable() ); - } } diff --git a/message/message-sql/src/test/java/com/mastercard/test/flow/msg/sql/ResultTest.java b/message/message-sql/src/test/java/com/mastercard/test/flow/msg/sql/ResultTest.java index 576198251f..2caf12de1a 100644 --- a/message/message-sql/src/test/java/com/mastercard/test/flow/msg/sql/ResultTest.java +++ b/message/message-sql/src/test/java/com/mastercard/test/flow/msg/sql/ResultTest.java @@ -1,10 +1,16 @@ package com.mastercard.test.flow.msg.sql; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; import java.util.Arrays; import java.util.List; @@ -235,28 +241,72 @@ protected Object validateValueType( String field, Object value ) { } /** - * Demonstrates encoding of byte array result values + * Shows that types are preserved in the round-trip to byte content */ @Test - void bytes() { - Result res = new Result( "byte_column" ) - .set( "0:0", "value".getBytes( UTF_8 ) ); + void types() { + + Result result = new Result( + "bit", "tinyint", "smallint", "integer", "bigint", "biggerint", + "real", "double", "decimal", + "character", "varchar", + "blob", + "date", "time", "timestamp", + "value" ) + .set( "0:0", true ) + .set( "0:1", (byte) 1 ) + .set( "0:2", (short) 2 ) + .set( "0:3", 3 ) + .set( "0:4", 4L ) + .set( "0:5", new BigInteger( "5" ) ) + .set( "0:6", 6.0f ) + .set( "0:7", 7.0 ) + .set( "0:8", new BigDecimal( "8.0" ) ) + .set( "0:9", 'a' ) + .set( "0:10", "bcd" ) + .set( "0:11", "bytes".getBytes( UTF_8 ) ) + .set( "0:12", Date.valueOf( "1970-01-02" ) ) + .set( "0:13", Time.valueOf( "03:04:06" ) ) + .set( "0:14", Timestamp.valueOf( "1970-01-02 03:04:07.0" ) ) + .set( "0:15", null ); assertEquals( "" + " --- Row 0 ---\n" - + " byte_column : bytes: dmFsdWU=", - res.assertable() ); - - int originalByteCount = res.content().length; - - Result roundTrip = res.peer( res.content() ); - - assertEquals( "" - + " --- Row 0 ---\n" - + " byte_column : bytes: dmFsdWU=", - roundTrip.assertable() ); - - assertEquals( originalByteCount, roundTrip.content().length, - "serialisation does not affect wire format" ); + + " bit : true\n" + + " tinyint : 1\n" + + " smallint : 2\n" + + " integer : 3\n" + + " bigint : 4\n" + + " biggerint : 5\n" + + " real : 6.0\n" + + " double : 7.0\n" + + " decimal : 8.0\n" + + " character : a\n" + + " varchar : bcd\n" + + " blob : Ynl0ZXM=\n" + + " date : 1970-01-02\n" + + " time : 03:04:06\n" + + " timestamp : 1970-01-02 03:04:07.0\n" + + " value : null", + result.assertable() ); + + Result parsed = new Result().peer( result.content() ); + + assertEquals( true, parsed.get( "0:0" ) ); + assertEquals( (byte) 1, parsed.get( "0:1" ) ); + assertEquals( (short) 2, parsed.get( "0:2" ) ); + assertEquals( 3, parsed.get( "0:3" ) ); + assertEquals( 4L, parsed.get( "0:4" ) ); + assertEquals( new BigInteger( "5" ), parsed.get( "0:5" ) ); + assertEquals( 6.0f, parsed.get( "0:6" ) ); + assertEquals( 7.0, parsed.get( "0:7" ) ); + assertEquals( new BigDecimal( "8.0" ), parsed.get( "0:8" ) ); + assertEquals( 'a', parsed.get( "0:9" ) ); + assertEquals( "bcd", parsed.get( "0:10" ) ); + assertArrayEquals( "bytes".getBytes( UTF_8 ), (byte[]) parsed.get( "0:11" ) ); + assertEquals( Date.valueOf( "1970-01-02" ), parsed.get( "0:12" ) ); + assertEquals( Time.valueOf( "03:04:06" ), parsed.get( "0:13" ) ); + assertEquals( Timestamp.valueOf( "1970-01-02 03:04:07.0" ), parsed.get( "0:14" ) ); + assertEquals( null, parsed.get( "0:15" ) ); } } diff --git a/report/report-core/src/test/java/com/mastercard/test/flow/report/seq/Browser.java b/report/report-core/src/test/java/com/mastercard/test/flow/report/seq/Browser.java index af12b7f139..dae1312f5c 100644 --- a/report/report-core/src/test/java/com/mastercard/test/flow/report/seq/Browser.java +++ b/report/report-core/src/test/java/com/mastercard/test/flow/report/seq/Browser.java @@ -146,7 +146,7 @@ public WebDriver get() { WebDriverManager.chromedriver().setup(); ChromeOptions options = new ChromeOptions(); if( !SHOW ) { - options.addArguments( "--headless" ); + options.addArguments( "--headless=new" ); } // some oddness around browser locale changing with headful/less mode, possibly // related to https://bugs.chromium.org/p/chromium/issues/detail?id=755338 @@ -155,6 +155,8 @@ public WebDriver get() { options.addArguments( "--lang=en_GB" ); options.addArguments( "--disable-gpu" ); options.addArguments( "--window-size=1400,800" ); + // https://github.com/SeleniumHQ/selenium/issues/11750 + options.addArguments( "--remote-allow-origins=*" ); // suppress most stdout noise. We still get a "ChromeDriver was started // successfully." line for some reason