summaryrefslogtreecommitdiff
path: root/eaaf_core_utils/src/test/java
diff options
context:
space:
mode:
authorThomas <>2023-06-06 08:21:12 +0200
committerThomas <>2023-06-06 08:21:12 +0200
commit0b9a16e74f1aef687dc1dd397b0b8495ef64a1af (patch)
treeca9411f6fe5130f7ba2ae8201115cb8133593f8e /eaaf_core_utils/src/test/java
parentd225d5ed5a77a2692ff98115309911ca273b2119 (diff)
downloadEAAF-Components-0b9a16e74f1aef687dc1dd397b0b8495ef64a1af.tar.gz
EAAF-Components-0b9a16e74f1aef687dc1dd397b0b8495ef64a1af.tar.bz2
EAAF-Components-0b9a16e74f1aef687dc1dd397b0b8495ef64a1af.zip
fix(core): add some more allowed classes to Exception deserialization.
Diffstat (limited to 'eaaf_core_utils/src/test/java')
-rw-r--r--eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/utils/EaafSerializationUtilsTest.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/utils/EaafSerializationUtilsTest.java b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/utils/EaafSerializationUtilsTest.java
index 3535b217..898b336a 100644
--- a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/utils/EaafSerializationUtilsTest.java
+++ b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/utils/EaafSerializationUtilsTest.java
@@ -158,6 +158,35 @@ public class EaafSerializationUtilsTest {
}
+ @Test
+ public void typeModeWithExceptionsAndParams() {
+ EaafException error1 = new EaafException(rand());
+ EaafAuthenticationException error2 = new EaafAuthenticationException(rand(),
+ new Object[] {
+ Integer.valueOf(17),
+ String.valueOf(17.1),
+ Float.valueOf("18.3")
+ },
+ error1);
+
+ byte[] object = EaafSerializationUtils.serialize(error2);
+
+ // check if less allowed classes throw a deserialization exception
+ assertThrows(IllegalArgumentException.class, () -> EaafSerializationUtils.typeSpecificDeserialize(
+ object, Sets.newHashSet(Throwable.class), Throwable.class));
+ assertThrows(IllegalArgumentException.class, () -> EaafSerializationUtils.typeSpecificDeserialize(
+ object, Sets.newHashSet(Throwable.class, StackTraceElement[].class, StackTraceElement.class),
+ Throwable.class));
+
+ // minimum allowed classes to de-serialize an Throwable
+ assertNotNull(EaafSerializationUtils.typeSpecificDeserialize(
+ object, Sets.newHashSet(Throwable.class, StackTraceElement[].class,
+ StackTraceElement.class, Collections.EMPTY_LIST.getClass(),
+ Integer.class, Long.class, Double.class, Float.class, String.class, Number.class),
+ Throwable.class));
+
+ }
+
private String rand() {
return RandomStringUtils.randomAlphanumeric(10);
}