mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-23 04:36:50 +00:00
Replaced all IllegalStateException with DataException in arbitrary code
This was necessary to ensure that all exceptions are caught intentionally, as otherwise it creates endless amounts of edge cases.
This commit is contained in:
@@ -22,7 +22,7 @@ public class ArbitraryDataDigestTests extends Common {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDirectoryDigest() throws IOException {
|
||||
public void testDirectoryDigest() throws IOException, DataException {
|
||||
Path dataPath = Paths.get("src/test/resources/arbitrary/demo1");
|
||||
String expectedHash58 = "DKyMuonWKoneJqiVHgw26Vk1ytrZG9PGsE9xfBg3GKDp";
|
||||
|
||||
|
@@ -18,7 +18,7 @@ public class ArbitraryDataFileTests extends Common {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitAndJoin() {
|
||||
public void testSplitAndJoin() throws DataException {
|
||||
String dummyDataString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
ArbitraryDataFile arbitraryDataFile = new ArbitraryDataFile(dummyDataString.getBytes());
|
||||
assertTrue(arbitraryDataFile.exists());
|
||||
@@ -45,7 +45,7 @@ public class ArbitraryDataFileTests extends Common {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitAndJoinWithLargeFiles() {
|
||||
public void testSplitAndJoinWithLargeFiles() throws DataException {
|
||||
int fileSize = (int) (5.5f * 1024 * 1024); // 5.5MiB
|
||||
byte[] randomData = new byte[fileSize];
|
||||
new Random().nextBytes(randomData); // No need for SecureRandom here
|
||||
|
@@ -148,7 +148,7 @@ public class ArbitraryDataMergeTests extends Common {
|
||||
patch.create();
|
||||
fail("Creating patch should fail due to matching states");
|
||||
|
||||
} catch (IllegalStateException expectedException) {
|
||||
} catch (DataException expectedException) {
|
||||
assertEquals("Current state matches previous state. Nothing to do.", expectedException.getMessage());
|
||||
}
|
||||
|
||||
|
@@ -234,7 +234,7 @@ public class ArbitraryDataTests extends Common {
|
||||
arbitraryDataReader1a.loadSynchronously(true);
|
||||
fail("Loading data with null identifier should fail due to nonexistent PUT transaction");
|
||||
|
||||
} catch (IllegalStateException expectedException) {
|
||||
} catch (DataException expectedException) {
|
||||
assertEquals(String.format("Couldn't find PUT transaction for name %s, service %s "
|
||||
+ "and identifier ", name.toLowerCase(), service), expectedException.getMessage());
|
||||
}
|
||||
@@ -246,7 +246,7 @@ public class ArbitraryDataTests extends Common {
|
||||
arbitraryDataReader1b.loadSynchronously(true);
|
||||
fail("Loading data with incorrect identifier should fail due to nonexistent PUT transaction");
|
||||
|
||||
} catch (IllegalStateException expectedException) {
|
||||
} catch (DataException expectedException) {
|
||||
assertEquals(String.format("Couldn't find PUT transaction for name %s, service %s "
|
||||
+ "and identifier %s", name.toLowerCase(), service, differentIdentifier), expectedException.getMessage());
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public class ArbitraryDataTests extends Common {
|
||||
arbitraryDataReader1c.loadSynchronously(true);
|
||||
fail("Loading data with incorrect identifier should fail due to nonexistent PUT transaction");
|
||||
|
||||
} catch (IllegalStateException expectedException) {
|
||||
} catch (DataException expectedException) {
|
||||
assertEquals(String.format("Couldn't find PUT transaction for name %s, service %s "
|
||||
+ "and identifier %s", name.toLowerCase(), service, differentIdentifier), expectedException.getMessage());
|
||||
}
|
||||
|
Reference in New Issue
Block a user