@RepeatedTest(2)
    void verifyGetExistingTicketWithImproperClass() throws Throwable {
        val ticketGrantingTicketId = TestTicketIdentifiers.generate().ticketGrantingTicketId();
        FunctionUtils.doAndRetry(callback -> {
            val added = ticketRegistry.addTicket(new TicketGrantingTicketImpl(ticketGrantingTicketId,
                CoreAuthenticationTestUtils.getAuthentication(),
                NeverExpiresExpirationPolicy.INSTANCE));

            assertThrows(ClassCastException.class,
                () -> ticketRegistry.getTicket(added.getId(), ServiceTicket.class),
                () -> "Should throw ClassCastException. useEncryption[" + useEncryption + ']');
            return null;
        });
    }
This is {@link BaseTicketRegistryTests}.

@author Misagh Moayyed
@since 5.3.0
core/cas-server-core-tickets/src/test/java/org/apereo/cas/ticket/registry/BaseTicketRegistryTests.java