Package google.registry.keyring.api
Class ComparatorKeyring
java.lang.Object
google.registry.util.ComparingInvocationHandler<Keyring>
google.registry.keyring.api.ComparatorKeyring
- All Implemented Interfaces:
InvocationHandler
Checks that a second keyring returns the same result as the current one.
Will behave exactly like the "actualKeyring" - as in will throw / return the exact same values - no matter what the "secondKeyring" does. But will log a warning if "secondKeyring" acts differently than "actualKeyring".
If both keyrings threw exceptions, there is no check whether the exeptions are the same. The assumption is that an error happened in both, but they might report that error differently.
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
compareResults
(Method method, Object a, Object b) Implements equals for the PGP classes.static Keyring
Returns an instance of Keyring that is an exact proxy of "original".protected void
Called when there was a difference between the implementations.protected String
stringifyResult
(Method method, Object a) Implements toString for the PGP classes.protected String
stringifyThrown
(Method method, Throwable throwable) Implements toString for thrown exceptions.Methods inherited from class google.registry.util.ComparingInvocationHandler
compareThrown, invoke, makeProxy
-
Method Details
-
create
Returns an instance of Keyring that is an exact proxy of "original".This proxy will log any differences in return value or thrown exceptions with "second".
-
log
Description copied from class:ComparingInvocationHandler
Called when there was a difference between the implementations.- Specified by:
log
in classComparingInvocationHandler<Keyring>
- Parameters:
method
- the method where the difference was foundmessage
- human readable description of the difference found
-
compareResults
Implements equals for the PGP classes.- Overrides:
compareResults
in classComparingInvocationHandler<Keyring>
- Parameters:
method
- the method whose return value is givena
- the object returned by a call to method for the "actual" implementationb
- the object returned by a call to method for the "second" implementation
-
stringifyResult
Implements toString for the PGP classes.- Overrides:
stringifyResult
in classComparingInvocationHandler<Keyring>
- Parameters:
method
- the method whose return value is givena
- the object returned by a call to method
-
stringifyThrown
Description copied from class:ComparingInvocationHandler
Implements toString for thrown exceptions.By default exceptions are logged using their .toString. If more data is needed (part of stack trace for example), override this method with the desired implementation.
- Overrides:
stringifyThrown
in classComparingInvocationHandler<Keyring>
- Parameters:
method
- the method whose return value is giventhrowable
- the exception thrown by a call to method
-