@Test
        void verifyExchangeTokensWithActor() throws Throwable {
            val registeredService = getRegisteredService(UUID.randomUUID().toString(), "secret",
                Set.of(OAuth20GrantTypes.TOKEN_EXCHANGE));
            val key = EncodingUtils.generateJsonWebKey(512);
            registeredService.getProperties().put(
                RegisteredServiceProperty.RegisteredServiceProperties.ACCESS_TOKEN_AS_JWT_SIGNING_KEY.getPropertyName(),
                new DefaultRegisteredServiceProperty(key));
            servicesManager.save(registeredService);

            val subjectToken = getAccessToken(registeredService.getServiceId(), registeredService.getClientId());
            ticketRegistry.addTicket(subjectToken);

            val actorToken = getAccessToken(RegisteredServiceTestUtils.getAuthentication("adminuser"),
                registeredService.getServiceId(), registeredService.getClientId());
            ticketRegistry.addTicket(actorToken);

            val mockRequest = new MockHttpServletRequest(HttpMethod.GET.name(), CONTEXT + OAuth20Constants.ACCESS_TOKEN_URL);
            mockRequest.setParameter(OAuth20Constants.REQUESTED_TOKEN_TYPE, OAuth20TokenExchangeTypes.JWT.getType());
            mockRequest.setParameter(OAuth20Constants.SUBJECT_TOKEN, subjectToken.getId());
            mockRequest.setParameter(OAuth20Constants.ACTOR_TOKEN_TYPE, OAuth20TokenExchangeTypes.ACCESS_TOKEN.getType());
            mockRequest.setParameter(OAuth20Constants.ACTOR_TOKEN, actorToken.getId());

            val service = RegisteredServiceTestUtils.getService(SERVICE_URL);
            val mockResponse = new MockHttpServletResponse();
            val webContext = new JEEContext(mockRequest, mockResponse);
            val authentication = RegisteredServiceTestUtils.getAuthentication("casuser");
            val tokenRequestContext = buildAccessTokenRequestContext(registeredService, authentication,
                OAuth20GrantTypes.TOKEN_EXCHANGE, service, webContext).withActorToken(actorToken.getAuthentication());
            val result = oauthTokenGenerator.generate(tokenRequestContext);
            assertNotNull(result);
            val mv = generateAccessTokenResponse(registeredService, service, result, tokenRequestContext);
            val id = mv.getModel().get(OAuth20Constants.ACCESS_TOKEN).toString();
            val claims = accessTokenJwtBuilder.unpack(Optional.of(registeredService), id);
            assertNotNull(claims);
            val actor = claims.getJSONObjectClaim(OAuth20Constants.CLAIM_ACT).get(OAuth20Constants.CLAIM_SUB);
            assertEquals("adminuser", actor);
        }
This is {@link OAuth20DefaultTokenGeneratorTests}.

@author Misagh Moayyed
@since 6.1.0
support/cas-server-support-oauth/src/test/java/org/apereo/cas/support/oauth/web/response/accesstoken/OAuth20DefaultTokenGeneratorTests.java