From 54f16e552a3d6c5579282de5c8d6a92395f6c049 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Sat, 13 May 2023 15:18:03 +0200 Subject: refact(core): remove double serialization in central error handling --- .../ProtocolFinalizationControllerTest.java | 29 +++++++++------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'eaaf_core/src/test/java/at/gv') diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java index 4341d141..e165f84b 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java @@ -19,7 +19,6 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.util.SerializationUtils; import at.gv.egiz.eaaf.core.api.data.EaafConfigConstants; import at.gv.egiz.eaaf.core.api.data.EaafConstants; @@ -107,8 +106,7 @@ public class ProtocolFinalizationControllerTest { protocolRequest.setSpConfig(new DummySpConfiguration(spConfig, config)); Throwable throwable = new EaafException("internal.00"); final ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable); - final byte[] serialized = SerializationUtils.serialize(exceptionContainer); - storage.put(token, serialized, -1); + storage.put(token, exceptionContainer, -1); // perform test controller.errorRedirect(httpReq, httpResp); @@ -174,8 +172,7 @@ public class ProtocolFinalizationControllerTest { protocolRequest.setSpConfig(new DummySpConfiguration(spConfig, config)); Throwable throwable = new EaafException("internal.00"); final ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable); - final byte[] serialized = SerializationUtils.serialize(exceptionContainer); - storage.put(token, serialized, -1); + storage.put(token, exceptionContainer, -1); // perform test controller.errorHandling(httpReq, httpResp); @@ -218,8 +215,7 @@ public class ProtocolFinalizationControllerTest { Throwable throwable = new EaafException("internal.00"); final ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable); - final byte[] serialized = SerializationUtils.serialize(exceptionContainer); - storage.put(token, serialized, -1); + storage.put(token, exceptionContainer, -1); String secondErrorTicket = requestIdValidationStragegy.generateExternalPendingRequestId(); errorService.setErrorIdTokenForRedirect(secondErrorTicket); @@ -241,10 +237,10 @@ public class ProtocolFinalizationControllerTest { assertEquals("wrong intErrorCode", "internal.00", params.get("errorCode")); assertTrue("wrong extErrorCode", ((String) params.get("extErrorCode")).contains("internal.00")); - byte[] secondErrorSerialized = storage.get( - requestIdValidationStragegy.getPendingRequestIdWithOutChecks(secondErrorTicket), byte[].class); - assertNotNull("Exception not removed from cache", secondErrorSerialized); - ExceptionContainer secondError = (ExceptionContainer) SerializationUtils.deserialize(secondErrorSerialized); + ExceptionContainer secondError = storage.get( + requestIdValidationStragegy.getPendingRequestIdWithOutChecks(secondErrorTicket), + ExceptionContainer.class); + assertNotNull("Exception not removed from cache", secondError); assertEquals("wrong pengingReq", protocolRequest.getUniqueTransactionIdentifier(), secondError.getPendingRequest().getUniqueTransactionIdentifier()); assertEquals("wrong exception", throwable.getMessage(), secondError.getExceptionThrown().getMessage()); @@ -274,8 +270,7 @@ public class ProtocolFinalizationControllerTest { Throwable throwable = new EaafException("internal.00"); final ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable); - final byte[] serialized = SerializationUtils.serialize(exceptionContainer); - storage.put(token, serialized, -1); + storage.put(token, exceptionContainer, -1); String secondErrorTicket = requestIdValidationStragegy.generateExternalPendingRequestId(); errorService.setErrorIdTokenForRedirect(secondErrorTicket); @@ -296,10 +291,10 @@ public class ProtocolFinalizationControllerTest { assertEquals("wrong intErrorCode", "internal.00", params.get("errorCode")); assertTrue("wrong extErrorCode", ((String) params.get("extErrorCode")).contains("internal.00")); - byte[] secondErrorSerialized = storage.get( - requestIdValidationStragegy.getPendingRequestIdWithOutChecks(secondErrorTicket), byte[].class); - assertNotNull("Exception not removed from cache", secondErrorSerialized); - ExceptionContainer secondError = (ExceptionContainer) SerializationUtils.deserialize(secondErrorSerialized); + ExceptionContainer secondError = storage.get( + requestIdValidationStragegy.getPendingRequestIdWithOutChecks(secondErrorTicket), + ExceptionContainer.class); + assertNotNull("Exception not removed from cache", secondError); assertEquals("wrong pengingReq", protocolRequest.getUniqueTransactionIdentifier(), secondError.getPendingRequest().getUniqueTransactionIdentifier()); assertEquals("wrong exception", throwable.getMessage(), secondError.getExceptionThrown().getMessage()); -- cgit v1.2.3