Polish AssertJ assertions
Fixes gh-4770
This commit is contained in:
@@ -218,21 +218,21 @@ public class BCryptTests {
|
||||
@Test
|
||||
public void decodingCharsOutsideAsciiGivesNoResults() {
|
||||
byte[] ba = BCrypt.decode_base64("ππππππππ", 1);
|
||||
assertThat(ba.length).isEqualTo(0);
|
||||
assertThat(ba).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodingStopsWithFirstInvalidCharacter() {
|
||||
assertThat(BCrypt.decode_base64("....", 1).length).isEqualTo(1);
|
||||
assertThat(BCrypt.decode_base64(" ....", 1).length).isEqualTo(0);
|
||||
assertThat(BCrypt.decode_base64("....", 1)).hasSize(1);
|
||||
assertThat(BCrypt.decode_base64(" ....", 1)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodingOnlyProvidesAvailableBytes() {
|
||||
assertThat(BCrypt.decode_base64("", 1).length).isEqualTo(0);
|
||||
assertThat(BCrypt.decode_base64("......", 3).length).isEqualTo(3);
|
||||
assertThat(BCrypt.decode_base64("......", 4).length).isEqualTo(4);
|
||||
assertThat(BCrypt.decode_base64("......", 5).length).isEqualTo(4);
|
||||
assertThat(BCrypt.decode_base64("", 1)).isEmpty();
|
||||
assertThat(BCrypt.decode_base64("......", 3)).hasSize(3);
|
||||
assertThat(BCrypt.decode_base64("......", 4)).hasSize(4);
|
||||
assertThat(BCrypt.decode_base64("......", 5)).hasSize(4);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,8 +268,8 @@ public class BCryptTests {
|
||||
|
||||
@Test
|
||||
public void genSaltGeneratesCorrectSaltPrefix() {
|
||||
assertThat(BCrypt.gensalt(4).startsWith("$2a$04$")).isTrue();
|
||||
assertThat(BCrypt.gensalt(31).startsWith("$2a$31$")).isTrue();
|
||||
assertThat(BCrypt.gensalt(4)).startsWith("$2a$04$");
|
||||
assertThat(BCrypt.gensalt(31)).startsWith("$2a$31$");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,7 @@ public class Utf8Tests {
|
||||
@Test
|
||||
public void utf8EncodesAndDecodesCorrectly() throws Exception {
|
||||
byte[] bytes = Utf8.encode("6048b75ed560785c");
|
||||
assertThat(bytes.length).isEqualTo(16);
|
||||
assertThat(bytes).hasSize(16);
|
||||
assertThat(Arrays.equals("6048b75ed560785c".getBytes("UTF-8"), bytes)).isTrue();
|
||||
|
||||
String decoded = Utf8.decode(bytes);
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ public class KeyGeneratorsTests {
|
||||
BytesKeyGenerator keyGenerator = KeyGenerators.secureRandom();
|
||||
assertThat(keyGenerator.getKeyLength()).isEqualTo(8);
|
||||
byte[] key = keyGenerator.generateKey();
|
||||
assertThat(key.length).isEqualTo(8);
|
||||
assertThat(key).hasSize(8);
|
||||
byte[] key2 = keyGenerator.generateKey();
|
||||
assertThat(Arrays.equals(key, key2)).isFalse();
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class KeyGeneratorsTests {
|
||||
BytesKeyGenerator keyGenerator = KeyGenerators.secureRandom(21);
|
||||
assertThat(keyGenerator.getKeyLength()).isEqualTo(21);
|
||||
byte[] key = keyGenerator.generateKey();
|
||||
assertThat(key.length).isEqualTo(21);
|
||||
assertThat(key).hasSize(21);
|
||||
byte[] key2 = keyGenerator.generateKey();
|
||||
assertThat(Arrays.equals(key, key2)).isFalse();
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class KeyGeneratorsTests {
|
||||
BytesKeyGenerator keyGenerator = KeyGenerators.shared(21);
|
||||
assertThat(keyGenerator.getKeyLength()).isEqualTo(21);
|
||||
byte[] key = keyGenerator.generateKey();
|
||||
assertThat(key.length).isEqualTo(21);
|
||||
assertThat(key).hasSize(21);
|
||||
byte[] key2 = keyGenerator.generateKey();
|
||||
assertThat(Arrays.equals(key, key2)).isTrue();
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class KeyGeneratorsTests {
|
||||
StringKeyGenerator keyGenerator = KeyGenerators.string();
|
||||
String hexStringKey = keyGenerator.generateKey();
|
||||
assertThat(hexStringKey.length()).isEqualTo(16);
|
||||
assertThat(Hex.decode(hexStringKey).length).isEqualTo(8);
|
||||
assertThat(Hex.decode(hexStringKey)).hasSize(8);
|
||||
String hexStringKey2 = keyGenerator.generateKey();
|
||||
assertThat(hexStringKey.equals(hexStringKey2)).isFalse();
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class EncodingUtilsTests {
|
||||
(byte) 67, (byte) 0xC0, (byte) 0xC1, (byte) 0xC2 };
|
||||
byte[] two = new byte[] { (byte) 0xFF, (byte) 65, (byte) 66 };
|
||||
byte[] subArray = EncodingUtils.subArray(bytes, 1, 4);
|
||||
assertThat(subArray.length).isEqualTo(3);
|
||||
assertThat(subArray).hasSize(3);
|
||||
assertThat(Arrays.equals(two, subArray)).isTrue();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user