kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 9d5641e1175428708e75588a676243b0ae8a992c1aae46497390fa4c8e72cd40 |
|---|---|
| Author | Alexandre Dutra <alexdut@gmail.com> · 2015-11-09 09:42 +01:00 |
| Committer | Alexandre Dutra <alexdut@gmail.com> · 2015-11-09 09:42 +01:00 |
| Parents | 1d6480b23c6f, b9d0634700a6 |
6 files changed
modified changelog/README.md +1 −1
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | - [improvement] Improve error handling for when a non-type 1 UUID is given to bind() on a timeuuid column (JAVA-965) |
| 8 | 8 | - [improvement] Pass the authenticator name from the server to the auth provider (JAVA-885) |
| 9 | 9 | - [improvement] Raise an exception when an older version of guava (<16.01) is found (JAVA-961) |
| 10 | - | |
| 10 | +- [bug] TypeCodec.parse() implementations should be case insensitive when checking for keyword NULL (JAVA-972) | |
| 11 | 11 | |
| 12 | 12 | ### 3.0.0-alpha4 |
| 13 | 13 |
modified driver-core/src/main/java/com/datastax/driver/core/TypeCodec.java +21 −21
| @@ -763,7 +763,7 @@ | ||
| 763 | 763 | |
| 764 | 764 | @Override |
| 765 | 765 | public String parse(String value) { |
| 766 | - if (value == null || value.isEmpty() || value.equals("NULL")) | |
| 766 | + if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) | |
| 767 | 767 | return null; |
| 768 | 768 | if (value.charAt(0) != '\'' || value.charAt(value.length() - 1) != '\'') |
| 769 | 769 | throw new InvalidTypeException("text or varchar values must be enclosed by single quotes"); |
| @@ -889,7 +889,7 @@ | ||
| 889 | 889 | @Override |
| 890 | 890 | public Long parse(String value) { |
| 891 | 891 | try { |
| 892 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : Long.parseLong(value); | |
| 892 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : Long.parseLong(value); | |
| 893 | 893 | } catch (NumberFormatException e) { |
| 894 | 894 | throw new InvalidTypeException(String.format("Cannot parse 64-bits long value from \"%s\"", value)); |
| 895 | 895 | } |
| @@ -959,7 +959,7 @@ | ||
| 959 | 959 | |
| 960 | 960 | @Override |
| 961 | 961 | public ByteBuffer parse(String value) { |
| 962 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : Bytes.fromHexString(value); | |
| 962 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : Bytes.fromHexString(value); | |
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | @Override |
| @@ -994,7 +994,7 @@ | ||
| 994 | 994 | |
| 995 | 995 | @Override |
| 996 | 996 | public ByteBuffer parse(String value) { |
| 997 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : Bytes.fromHexString(value); | |
| 997 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : Bytes.fromHexString(value); | |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | @Override |
| @@ -1031,7 +1031,7 @@ | ||
| 1031 | 1031 | |
| 1032 | 1032 | @Override |
| 1033 | 1033 | public Boolean parse(String value) { |
| 1034 | - if (value == null || value.isEmpty() || value.equals("NULL")) | |
| 1034 | + if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) | |
| 1035 | 1035 | return null; |
| 1036 | 1036 | if (value.equalsIgnoreCase(Boolean.FALSE.toString())) |
| 1037 | 1037 | return false; |
| @@ -1078,7 +1078,7 @@ | ||
| 1078 | 1078 | @Override |
| 1079 | 1079 | public BigDecimal parse(String value) { |
| 1080 | 1080 | try { |
| 1081 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : new BigDecimal(value); | |
| 1081 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : new BigDecimal(value); | |
| 1082 | 1082 | } catch (NumberFormatException e) { |
| 1083 | 1083 | throw new InvalidTypeException(String.format("Cannot parse decimal value from \"%s\"", value)); |
| 1084 | 1084 | } |
| @@ -1137,7 +1137,7 @@ | ||
| 1137 | 1137 | @Override |
| 1138 | 1138 | public Double parse(String value) { |
| 1139 | 1139 | try { |
| 1140 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : Double.parseDouble(value); | |
| 1140 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : Double.parseDouble(value); | |
| 1141 | 1141 | } catch (NumberFormatException e) { |
| 1142 | 1142 | throw new InvalidTypeException(String.format("Cannot parse 64-bits double value from \"%s\"", value)); |
| 1143 | 1143 | } |
| @@ -1182,7 +1182,7 @@ | ||
| 1182 | 1182 | @Override |
| 1183 | 1183 | public Float parse(String value) { |
| 1184 | 1184 | try { |
| 1185 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : Float.parseFloat(value); | |
| 1185 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : Float.parseFloat(value); | |
| 1186 | 1186 | } catch (NumberFormatException e) { |
| 1187 | 1187 | throw new InvalidTypeException(String.format("Cannot parse 32-bits float value from \"%s\"", value)); |
| 1188 | 1188 | } |
| @@ -1226,7 +1226,7 @@ | ||
| 1226 | 1226 | |
| 1227 | 1227 | @Override |
| 1228 | 1228 | public InetAddress parse(String value) { |
| 1229 | - if (value == null || value.isEmpty() || value.equals("NULL")) | |
| 1229 | + if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) | |
| 1230 | 1230 | return null; |
| 1231 | 1231 | |
| 1232 | 1232 | value = value.trim(); |
| @@ -1277,7 +1277,7 @@ | ||
| 1277 | 1277 | @Override |
| 1278 | 1278 | public Byte parse(String value) { |
| 1279 | 1279 | try { |
| 1280 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : Byte.parseByte(value); | |
| 1280 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : Byte.parseByte(value); | |
| 1281 | 1281 | } catch (NumberFormatException e) { |
| 1282 | 1282 | throw new InvalidTypeException(String.format("Cannot parse 8-bits int value from \"%s\"", value)); |
| 1283 | 1283 | } |
| @@ -1322,7 +1322,7 @@ | ||
| 1322 | 1322 | @Override |
| 1323 | 1323 | public Short parse(String value) { |
| 1324 | 1324 | try { |
| 1325 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : Short.parseShort(value); | |
| 1325 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : Short.parseShort(value); | |
| 1326 | 1326 | } catch (NumberFormatException e) { |
| 1327 | 1327 | throw new InvalidTypeException(String.format("Cannot parse 16-bits int value from \"%s\"", value)); |
| 1328 | 1328 | } |
| @@ -1367,7 +1367,7 @@ | ||
| 1367 | 1367 | @Override |
| 1368 | 1368 | public Integer parse(String value) { |
| 1369 | 1369 | try { |
| 1370 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : Integer.parseInt(value); | |
| 1370 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : Integer.parseInt(value); | |
| 1371 | 1371 | } catch (NumberFormatException e) { |
| 1372 | 1372 | throw new InvalidTypeException(String.format("Cannot parse 32-bits int value from \"%s\"", value)); |
| 1373 | 1373 | } |
| @@ -1453,7 +1453,7 @@ | ||
| 1453 | 1453 | |
| 1454 | 1454 | @Override |
| 1455 | 1455 | public Date parse(String value) { |
| 1456 | - if (value == null || value.isEmpty() || value.equals("NULL")) | |
| 1456 | + if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) | |
| 1457 | 1457 | return null; |
| 1458 | 1458 | |
| 1459 | 1459 | // strip enclosing single quotes, if any |
| @@ -1511,7 +1511,7 @@ | ||
| 1511 | 1511 | |
| 1512 | 1512 | @Override |
| 1513 | 1513 | public LocalDate parse(String value) { |
| 1514 | - if (value == null || value.isEmpty() || value.equals("NULL")) | |
| 1514 | + if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) | |
| 1515 | 1515 | return null; |
| 1516 | 1516 | |
| 1517 | 1517 | // strip enclosing single quotes, if any |
| @@ -1655,7 +1655,7 @@ | ||
| 1655 | 1655 | |
| 1656 | 1656 | @Override |
| 1657 | 1657 | public Long parse(String value) { |
| 1658 | - if (value == null || value.isEmpty() || value.equals("NULL")) | |
| 1658 | + if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) | |
| 1659 | 1659 | return null; |
| 1660 | 1660 | |
| 1661 | 1661 | // enclosing single quotes required, even for long literals |
| @@ -1725,7 +1725,7 @@ | ||
| 1725 | 1725 | @Override |
| 1726 | 1726 | public UUID parse(String value) { |
| 1727 | 1727 | try { |
| 1728 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : UUID.fromString(value); | |
| 1728 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : UUID.fromString(value); | |
| 1729 | 1729 | } catch (IllegalArgumentException e) { |
| 1730 | 1730 | throw new InvalidTypeException(String.format("Cannot parse UUID value from \"%s\"", value)); |
| 1731 | 1731 | } |
| @@ -1811,7 +1811,7 @@ | ||
| 1811 | 1811 | @Override |
| 1812 | 1812 | public BigInteger parse(String value) { |
| 1813 | 1813 | try { |
| 1814 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : new BigInteger(value); | |
| 1814 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : new BigInteger(value); | |
| 1815 | 1815 | } catch (NumberFormatException e) { |
| 1816 | 1816 | throw new InvalidTypeException(String.format("Cannot parse varint value from \"%s\"", value)); |
| 1817 | 1817 | } |
| @@ -1907,7 +1907,7 @@ | ||
| 1907 | 1907 | |
| 1908 | 1908 | @Override |
| 1909 | 1909 | public C parse(String value) { |
| 1910 | - if (value == null || value.isEmpty() || value.equals("NULL")) | |
| 1910 | + if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) | |
| 1911 | 1911 | return null; |
| 1912 | 1912 | |
| 1913 | 1913 | int idx = ParseUtils.skipSpaces(value, 0); |
| @@ -2047,7 +2047,7 @@ | ||
| 2047 | 2047 | |
| 2048 | 2048 | @Override |
| 2049 | 2049 | public Map<K, V> parse(String value) { |
| 2050 | - if (value == null || value.isEmpty() || value.equals("NULL")) | |
| 2050 | + if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) | |
| 2051 | 2051 | return null; |
| 2052 | 2052 | |
| 2053 | 2053 | int idx = ParseUtils.skipSpaces(value, 0); |
| @@ -2188,7 +2188,7 @@ | ||
| 2188 | 2188 | |
| 2189 | 2189 | @Override |
| 2190 | 2190 | public UDTValue parse(String value) { |
| 2191 | - if (value == null || value.isEmpty() || value.equals("NULL")) | |
| 2191 | + if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) | |
| 2192 | 2192 | return null; |
| 2193 | 2193 | |
| 2194 | 2194 | UDTValue v = definition.newValue(); |
| @@ -2316,7 +2316,7 @@ | ||
| 2316 | 2316 | |
| 2317 | 2317 | @Override |
| 2318 | 2318 | public TupleValue parse(String value) { |
| 2319 | - if (value == null || value.isEmpty() || value.equals("NULL")) | |
| 2319 | + if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) | |
| 2320 | 2320 | return null; |
| 2321 | 2321 | |
| 2322 | 2322 | TupleValue v = definition.newValue(); |
modified driver-core/src/test/java/com/datastax/driver/core/DataTypeTest.java +31 −23
| @@ -21,7 +21,6 @@ | ||
| 21 | 21 | import java.nio.ByteBuffer; |
| 22 | 22 | import java.util.*; |
| 23 | 23 | |
| 24 | -import com.google.common.collect.Lists; | |
| 25 | 24 | import org.testng.annotations.Test; |
| 26 | 25 | |
| 27 | 26 | import static com.google.common.collect.Lists.newArrayList; |
| @@ -70,13 +69,13 @@ | ||
| 70 | 69 | return new TestValue[]{ |
| 71 | 70 | new TestValue("foo", "'foo'", "'foo'"), |
| 72 | 71 | new TestValue("fo'o", "'fo''o'", "'fo''o'"), |
| 73 | - new TestValue(null, null, "NULL") }; | |
| 72 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 74 | 73 | case BIGINT: |
| 75 | 74 | return new TestValue[]{ |
| 76 | 75 | new TestValue(42L, "42", "42"), |
| 77 | 76 | new TestValue(91294377723L, "91294377723", "91294377723"), |
| 78 | 77 | new TestValue(-133L, "-133", "-133"), |
| 79 | - new TestValue(null, null, "NULL") }; | |
| 78 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 80 | 79 | case TIMESTAMP: |
| 81 | 80 | // input: single quotes are optional for long literals, mandatory for date patterns |
| 82 | 81 | return new TestValue[]{ |
| @@ -84,7 +83,7 @@ | ||
| 84 | 83 | new TestValue(new Date(91294377723L), "91294377723", "91294377723"), |
| 85 | 84 | new TestValue(new Date(-133L), "-133", "-133"), |
| 86 | 85 | new TestValue(new Date(784041330999L), "'1994-11-05T14:15:30.999+0100'", "784041330999"), |
| 87 | - new TestValue(null, null, "NULL") }; | |
| 86 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 88 | 87 | case DATE: |
| 89 | 88 | // input: single quotes are optional for long literals, mandatory for date patterns |
| 90 | 89 | return new TestValue[]{ |
| @@ -92,43 +91,43 @@ | ||
| 92 | 91 | new TestValue(LocalDate.fromDaysSinceEpoch(0), "'1970-01-01'", "'1970-01-01'"), |
| 93 | 92 | new TestValue(LocalDate.fromDaysSinceEpoch((int)(2147483648L - (1L << 31))), "'2147483648'", "'1970-01-01'"), |
| 94 | 93 | new TestValue(LocalDate.fromDaysSinceEpoch((int)(0 - (1L << 31))), "0", "'-5877641-06-23'"), |
| 95 | - new TestValue(null, null, "NULL") }; | |
| 94 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 96 | 95 | case TIME: |
| 97 | 96 | // input: all literals must by enclosed in single quotes |
| 98 | 97 | return new TestValue[]{ |
| 99 | 98 | new TestValue(54012123450000L, "'54012123450000'", "'15:00:12.123450000'"), |
| 100 | 99 | new TestValue(0L, "'0'", "'00:00:00.000000000'"), |
| 101 | 100 | new TestValue(54012012345000L, "'15:00:12.012345000'", "'15:00:12.012345000'"), |
| 102 | - new TestValue(null, null, "NULL") }; | |
| 101 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 103 | 102 | case BLOB: |
| 104 | 103 | return new TestValue[]{ |
| 105 | 104 | new TestValue(Bytes.fromHexString("0x2450"), "0x2450", "0x2450"), |
| 106 | 105 | new TestValue(ByteBuffer.allocate(0), "0x", "0x"), |
| 107 | - new TestValue(null, null, "NULL") }; | |
| 106 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 108 | 107 | case BOOLEAN: |
| 109 | 108 | return new TestValue[]{ |
| 110 | 109 | new TestValue(true, "true", "true"), |
| 111 | 110 | new TestValue(false, "false", "false"), |
| 112 | - new TestValue(null, null, "NULL") }; | |
| 111 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 113 | 112 | case DECIMAL: |
| 114 | 113 | return new TestValue[]{ |
| 115 | 114 | new TestValue(new BigDecimal("1.23E+8"), "1.23E+8", "1.23E+8"), |
| 116 | - new TestValue(null, null, "NULL") }; | |
| 115 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 117 | 116 | case DOUBLE: |
| 118 | 117 | return new TestValue[]{ |
| 119 | 118 | new TestValue(2.39324324, "2.39324324", "2.39324324"), |
| 120 | 119 | new TestValue(-12., "-12.0", "-12.0"), |
| 121 | - new TestValue(null, null, "NULL") }; | |
| 120 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 122 | 121 | case FLOAT: |
| 123 | 122 | return new TestValue[]{ |
| 124 | 123 | new TestValue(2.39f, "2.39", "2.39"), |
| 125 | 124 | new TestValue(-12.f, "-12.0", "-12.0"), |
| 126 | - new TestValue(null, null, "NULL") }; | |
| 125 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 127 | 126 | case INET: |
| 128 | 127 | try { |
| 129 | 128 | return new TestValue[]{ |
| 130 | 129 | new TestValue(InetAddress.getByName("128.2.12.3"), "'128.2.12.3'", "'128.2.12.3'"), |
| 131 | - new TestValue(null, null, "NULL") }; | |
| 130 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 132 | 131 | } catch (java.net.UnknownHostException e) { |
| 133 | 132 | throw new RuntimeException(); |
| 134 | 133 | } |
| @@ -136,30 +135,30 @@ | ||
| 136 | 135 | return new TestValue[]{ |
| 137 | 136 | new TestValue((byte)-4, "-4", "-4"), |
| 138 | 137 | new TestValue((byte)44, "44", "44"), |
| 139 | - new TestValue(null, null, "NULL") }; | |
| 138 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 140 | 139 | case SMALLINT: |
| 141 | 140 | return new TestValue[]{ |
| 142 | 141 | new TestValue((short)-3, "-3", "-3"), |
| 143 | 142 | new TestValue((short)43, "43", "43"), |
| 144 | - new TestValue(null, null, "NULL") }; | |
| 143 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 145 | 144 | case INT: |
| 146 | 145 | return new TestValue[]{ |
| 147 | 146 | new TestValue(-2, "-2", "-2"), |
| 148 | 147 | new TestValue(42, "42", "42"), |
| 149 | - new TestValue(null, null, "NULL") }; | |
| 148 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 150 | 149 | case TIMEUUID: |
| 151 | 150 | return new TestValue[]{ |
| 152 | 151 | new TestValue(UUID.fromString("FE2B4360-28C6-11E2-81C1-0800200C9A66"), "fe2b4360-28c6-11e2-81c1-0800200c9a66", "fe2b4360-28c6-11e2-81c1-0800200c9a66"), |
| 153 | - new TestValue(null, null, "NULL") }; | |
| 152 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 154 | 153 | case UUID: |
| 155 | 154 | return new TestValue[]{ |
| 156 | 155 | new TestValue(UUID.fromString("FE2B4360-28C6-11E2-81C1-0800200C9A66"), "fe2b4360-28c6-11e2-81c1-0800200c9a66", "fe2b4360-28c6-11e2-81c1-0800200c9a66"), |
| 157 | 156 | new TestValue(UUID.fromString("067e6162-3b6f-4ae2-a171-2470b63dff00"), "067e6162-3b6f-4ae2-a171-2470b63dff00", "067e6162-3b6f-4ae2-a171-2470b63dff00"), |
| 158 | - new TestValue(null, null, "NULL") }; | |
| 157 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 159 | 158 | case VARINT: |
| 160 | 159 | return new TestValue[]{ |
| 161 | 160 | new TestValue(new BigInteger("12387290982347987032483422342432"), "12387290982347987032483422342432", "12387290982347987032483422342432"), |
| 162 | - new TestValue(null, null, "NULL") }; | |
| 161 | + new TestValue(null, null, "NULL"), new TestValue(null, "null", "NULL"), new TestValue(null, "NULL", "NULL") }; | |
| 163 | 162 | default: |
| 164 | 163 | throw new RuntimeException("Missing handling of " + dt); |
| 165 | 164 | } |
| @@ -204,8 +203,11 @@ | ||
| 204 | 203 | @Test(groups = "unit") |
| 205 | 204 | public void parseFormatSetTest() { |
| 206 | 205 | String toParse = "{'Foo','Bar','Foo''bar'}"; |
| 207 | - Set<String> toFormat = new LinkedHashSet<String>() {{ add("Foo"); | |
| 208 | - add("Bar"); add("Foo'bar"); }}; | |
| 206 | + Set<String> toFormat = new LinkedHashSet<String>() {{ | |
| 207 | + add("Foo"); | |
| 208 | + add("Bar"); | |
| 209 | + add("Foo'bar"); | |
| 210 | + }}; | |
| 209 | 211 | DataType dt = DataType.set(DataType.text()); |
| 210 | 212 | assertEquals(codecRegistry.codecFor(dt).parse(toParse), toFormat); |
| 211 | 213 | assertEquals(codecRegistry.codecFor(dt).format(toFormat), toParse); |
| @@ -215,7 +217,11 @@ | ||
| 215 | 217 | @Test(groups = "unit") |
| 216 | 218 | public void parseFormatMapTest() { |
| 217 | 219 | String toParse = "{'Foo':3,'Bar':42,'Foo''bar':-24}"; |
| 218 | - Map<String, Integer> toFormat = new LinkedHashMap<String, Integer>(){{ put("Foo", 3); put("Bar", 42); put("Foo'bar", -24); }}; | |
| 220 | + Map<String, Integer> toFormat = new LinkedHashMap<String, Integer>() {{ | |
| 221 | + put("Foo", 3); | |
| 222 | + put("Bar", 42); | |
| 223 | + put("Foo'bar", -24); | |
| 224 | + }}; | |
| 219 | 225 | DataType dt = DataType.map(DataType.text(), DataType.cint()); |
| 220 | 226 | assertEquals(codecRegistry.codecFor(dt).parse(toParse), toFormat); |
| 221 | 227 | assertEquals(codecRegistry.codecFor(dt).format(toFormat), toParse); |
| @@ -239,7 +245,9 @@ | ||
| 239 | 245 | toFormat.setString("t", "fo'o"); |
| 240 | 246 | toFormat.setInt("i", 3); |
| 241 | 247 | toFormat.setList("l", Arrays.<String>asList("a", "b")); |
| 242 | - toFormat.setMap("s", new HashMap<Integer, UDTValue>(){{ put(3, udt1.newValue().setBytes("a", ByteBuffer.wrap(new byte[]{1}))); }}); | |
| 248 | + toFormat.setMap("s", new HashMap<Integer, UDTValue>() {{ | |
| 249 | + put(3, udt1.newValue().setBytes("a", ByteBuffer.wrap(new byte[]{ 1 }))); | |
| 250 | + }}); | |
| 243 | 251 | |
| 244 | 252 | assertEquals(codecRegistry.codecFor(udt2).parse(toParse), toFormat); |
| 245 | 253 | assertEquals(codecRegistry.codecFor(udt2).format(toFormat), toParse); |
| @@ -313,7 +321,7 @@ | ||
| 313 | 321 | assertThat(dataTypes).doesNotContainAnyElementsOf(newArrayList(DataType.tinyint(), DataType.smallint())); |
| 314 | 322 | |
| 315 | 323 | // Ensure all values are <= V3. |
| 316 | - for(DataType dataType : dataTypes) { | |
| 324 | + for (DataType dataType : dataTypes) { | |
| 317 | 325 | assertThat(dataType.getName().minProtocolVersion).isLessThanOrEqualTo(ProtocolVersion.V3); |
| 318 | 326 | } |
| 319 | 327 | } |
modified driver-core/src/test/java/com/datastax/driver/core/JsonCodec.java +1 −1
| @@ -76,7 +76,7 @@ | ||
| 76 | 76 | @Override |
| 77 | 77 | @SuppressWarnings("unchecked") |
| 78 | 78 | public T parse(String value) throws InvalidTypeException { |
| 79 | - if (value == null || value.isEmpty() || value.equals("NULL")) | |
| 79 | + if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) | |
| 80 | 80 | return null; |
| 81 | 81 | if (value.charAt(0) != '\'' || value.charAt(value.length() - 1) != '\'') |
| 82 | 82 | throw new InvalidTypeException("JSON strings must be enclosed by single quotes"); |
modified driver-core/src/test/java/com/datastax/driver/core/MappingCodec.java +1 −1
| @@ -54,7 +54,7 @@ | ||
| 54 | 54 | |
| 55 | 55 | @Override |
| 56 | 56 | public T parse(String value) throws InvalidTypeException { |
| 57 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : deserialize(innerCodec.parse(value)); | |
| 57 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : deserialize(innerCodec.parse(value)); | |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | @Override |
modified driver-core/src/test/java/com/datastax/driver/core/StringParsingCodec.java +1 −1
| @@ -66,7 +66,7 @@ | ||
| 66 | 66 | |
| 67 | 67 | @Override |
| 68 | 68 | public T parse(String value) throws InvalidTypeException { |
| 69 | - return value == null || value.isEmpty() || value.equals("NULL") ? null : fromString(innerCodec.parse(value)); | |
| 69 | + return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : fromString(innerCodec.parse(value)); | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |