Minor refactoring (for code consistency).
No functional changes.
Showing
3 changed files
with
32 additions
and
23 deletions
| ... | @@ -136,18 +136,19 @@ public class Ip4AddressTest { | ... | @@ -136,18 +136,19 @@ public class Ip4AddressTest { |
| 136 | @Test | 136 | @Test |
| 137 | public void testValueOfByteArrayIPv4() { | 137 | public void testValueOfByteArrayIPv4() { |
| 138 | Ip4Address ipAddress; | 138 | Ip4Address ipAddress; |
| 139 | + byte[] value; | ||
| 139 | 140 | ||
| 140 | - final byte[] value1 = new byte[] {1, 2, 3, 4}; | 141 | + value = new byte[] {1, 2, 3, 4}; |
| 141 | - ipAddress = Ip4Address.valueOf(value1); | 142 | + ipAddress = Ip4Address.valueOf(value); |
| 142 | assertThat(ipAddress.toString(), is("1.2.3.4")); | 143 | assertThat(ipAddress.toString(), is("1.2.3.4")); |
| 143 | 144 | ||
| 144 | - final byte[] value2 = new byte[] {0, 0, 0, 0}; | 145 | + value = new byte[] {0, 0, 0, 0}; |
| 145 | - ipAddress = Ip4Address.valueOf(value2); | 146 | + ipAddress = Ip4Address.valueOf(value); |
| 146 | assertThat(ipAddress.toString(), is("0.0.0.0")); | 147 | assertThat(ipAddress.toString(), is("0.0.0.0")); |
| 147 | 148 | ||
| 148 | - final byte[] value3 = new byte[] {(byte) 0xff, (byte) 0xff, | 149 | + value = new byte[] {(byte) 0xff, (byte) 0xff, |
| 149 | - (byte) 0xff, (byte) 0xff}; | 150 | + (byte) 0xff, (byte) 0xff}; |
| 150 | - ipAddress = Ip4Address.valueOf(value3); | 151 | + ipAddress = Ip4Address.valueOf(value); |
| 151 | assertThat(ipAddress.toString(), is("255.255.255.255")); | 152 | assertThat(ipAddress.toString(), is("255.255.255.255")); |
| 152 | } | 153 | } |
| 153 | 154 | ||
| ... | @@ -157,9 +158,10 @@ public class Ip4AddressTest { | ... | @@ -157,9 +158,10 @@ public class Ip4AddressTest { |
| 157 | @Test(expected = NullPointerException.class) | 158 | @Test(expected = NullPointerException.class) |
| 158 | public void testInvalidValueOfNullArrayIPv4() { | 159 | public void testInvalidValueOfNullArrayIPv4() { |
| 159 | Ip4Address ipAddress; | 160 | Ip4Address ipAddress; |
| 161 | + byte[] value; | ||
| 160 | 162 | ||
| 161 | - final byte[] fromArray = null; | 163 | + value = null; |
| 162 | - ipAddress = Ip4Address.valueOf(fromArray); | 164 | + ipAddress = Ip4Address.valueOf(value); |
| 163 | } | 165 | } |
| 164 | 166 | ||
| 165 | /** | 167 | /** |
| ... | @@ -169,9 +171,10 @@ public class Ip4AddressTest { | ... | @@ -169,9 +171,10 @@ public class Ip4AddressTest { |
| 169 | @Test(expected = IllegalArgumentException.class) | 171 | @Test(expected = IllegalArgumentException.class) |
| 170 | public void testInvalidValueOfShortArrayIPv4() { | 172 | public void testInvalidValueOfShortArrayIPv4() { |
| 171 | Ip4Address ipAddress; | 173 | Ip4Address ipAddress; |
| 174 | + byte[] value; | ||
| 172 | 175 | ||
| 173 | - final byte[] fromArray = new byte[] {1, 2, 3}; | 176 | + value = new byte[] {1, 2, 3}; |
| 174 | - ipAddress = Ip4Address.valueOf(fromArray); | 177 | + ipAddress = Ip4Address.valueOf(value); |
| 175 | } | 178 | } |
| 176 | 179 | ||
| 177 | /** | 180 | /** | ... | ... |
| ... | @@ -154,9 +154,10 @@ public class Ip6AddressTest { | ... | @@ -154,9 +154,10 @@ public class Ip6AddressTest { |
| 154 | @Test(expected = NullPointerException.class) | 154 | @Test(expected = NullPointerException.class) |
| 155 | public void testInvalidValueOfNullArrayIPv6() { | 155 | public void testInvalidValueOfNullArrayIPv6() { |
| 156 | Ip6Address ipAddress; | 156 | Ip6Address ipAddress; |
| 157 | + byte[] value; | ||
| 157 | 158 | ||
| 158 | - final byte[] fromArray = null; | 159 | + value = null; |
| 159 | - ipAddress = Ip6Address.valueOf(fromArray); | 160 | + ipAddress = Ip6Address.valueOf(value); |
| 160 | } | 161 | } |
| 161 | 162 | ||
| 162 | /** | 163 | /** |
| ... | @@ -166,9 +167,10 @@ public class Ip6AddressTest { | ... | @@ -166,9 +167,10 @@ public class Ip6AddressTest { |
| 166 | @Test(expected = IllegalArgumentException.class) | 167 | @Test(expected = IllegalArgumentException.class) |
| 167 | public void testInvalidValueOfShortArrayIPv6() { | 168 | public void testInvalidValueOfShortArrayIPv6() { |
| 168 | Ip6Address ipAddress; | 169 | Ip6Address ipAddress; |
| 170 | + byte[] value; | ||
| 169 | 171 | ||
| 170 | - final byte[] fromArray = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; | 172 | + value = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; |
| 171 | - ipAddress = Ip6Address.valueOf(fromArray); | 173 | + ipAddress = Ip6Address.valueOf(value); |
| 172 | } | 174 | } |
| 173 | 175 | ||
| 174 | /** | 176 | /** | ... | ... |
| ... | @@ -234,9 +234,10 @@ public class IpAddressTest { | ... | @@ -234,9 +234,10 @@ public class IpAddressTest { |
| 234 | @Test(expected = NullPointerException.class) | 234 | @Test(expected = NullPointerException.class) |
| 235 | public void testInvalidValueOfNullArrayIPv4() { | 235 | public void testInvalidValueOfNullArrayIPv4() { |
| 236 | IpAddress ipAddress; | 236 | IpAddress ipAddress; |
| 237 | + byte[] value; | ||
| 237 | 238 | ||
| 238 | - final byte[] fromArray = null; | 239 | + value = null; |
| 239 | - ipAddress = IpAddress.valueOf(IpAddress.Version.INET, fromArray); | 240 | + ipAddress = IpAddress.valueOf(IpAddress.Version.INET, value); |
| 240 | } | 241 | } |
| 241 | 242 | ||
| 242 | /** | 243 | /** |
| ... | @@ -245,9 +246,10 @@ public class IpAddressTest { | ... | @@ -245,9 +246,10 @@ public class IpAddressTest { |
| 245 | @Test(expected = NullPointerException.class) | 246 | @Test(expected = NullPointerException.class) |
| 246 | public void testInvalidValueOfNullArrayIPv6() { | 247 | public void testInvalidValueOfNullArrayIPv6() { |
| 247 | IpAddress ipAddress; | 248 | IpAddress ipAddress; |
| 249 | + byte[] value; | ||
| 248 | 250 | ||
| 249 | - final byte[] fromArray = null; | 251 | + value = null; |
| 250 | - ipAddress = IpAddress.valueOf(IpAddress.Version.INET6, fromArray); | 252 | + ipAddress = IpAddress.valueOf(IpAddress.Version.INET6, value); |
| 251 | } | 253 | } |
| 252 | 254 | ||
| 253 | /** | 255 | /** |
| ... | @@ -257,9 +259,10 @@ public class IpAddressTest { | ... | @@ -257,9 +259,10 @@ public class IpAddressTest { |
| 257 | @Test(expected = IllegalArgumentException.class) | 259 | @Test(expected = IllegalArgumentException.class) |
| 258 | public void testInvalidValueOfShortArrayIPv4() { | 260 | public void testInvalidValueOfShortArrayIPv4() { |
| 259 | IpAddress ipAddress; | 261 | IpAddress ipAddress; |
| 262 | + byte[] value; | ||
| 260 | 263 | ||
| 261 | - final byte[] fromArray = new byte[] {1, 2, 3}; | 264 | + value = new byte[] {1, 2, 3}; |
| 262 | - ipAddress = IpAddress.valueOf(IpAddress.Version.INET, fromArray); | 265 | + ipAddress = IpAddress.valueOf(IpAddress.Version.INET, value); |
| 263 | } | 266 | } |
| 264 | 267 | ||
| 265 | /** | 268 | /** |
| ... | @@ -269,9 +272,10 @@ public class IpAddressTest { | ... | @@ -269,9 +272,10 @@ public class IpAddressTest { |
| 269 | @Test(expected = IllegalArgumentException.class) | 272 | @Test(expected = IllegalArgumentException.class) |
| 270 | public void testInvalidValueOfShortArrayIPv6() { | 273 | public void testInvalidValueOfShortArrayIPv6() { |
| 271 | IpAddress ipAddress; | 274 | IpAddress ipAddress; |
| 275 | + byte[] value; | ||
| 272 | 276 | ||
| 273 | - final byte[] fromArray = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; | 277 | + value = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; |
| 274 | - ipAddress = IpAddress.valueOf(IpAddress.Version.INET6, fromArray); | 278 | + ipAddress = IpAddress.valueOf(IpAddress.Version.INET6, value); |
| 275 | } | 279 | } |
| 276 | 280 | ||
| 277 | /** | 281 | /** | ... | ... |
-
Please register or login to post a comment