protected Subject subject(String saslMechanism) {
        return subjects.get(saslMechanism);
    }
@Test
    public void testNativeGssapiCredentials() throws Exception {
        System.setProperty(SaslChannelBuilder.GSS_NATIVE_PROP, "true");

        TestJaasConfig jaasConfig = new TestJaasConfig();
        jaasConfig.addEntry("jaasContext", TestGssapiLoginModule.class.getName(), new HashMap<>());
        JaasContext jaasContext = new JaasContext("jaasContext", JaasContext.Type.SERVER, jaasConfig, null);
        Map<String, JaasContext> jaasContexts = Collections.singletonMap("GSSAPI", jaasContext);
        GSSManager gssManager = Mockito.mock(GSSManager.class);
        GSSName gssName = Mockito.mock(GSSName.class);
        Mockito.when(gssManager.createName(Mockito.anyString(), Mockito.any()))
                .thenAnswer(unused -> gssName);
        Oid oid = new Oid("1.2.840.113554.1.2.2");
        Mockito.when(gssManager.createCredential(gssName, GSSContext.INDEFINITE_LIFETIME, oid, GSSCredential.ACCEPT_ONLY))
                .thenAnswer(unused -> Mockito.mock(GSSCredential.class));

        SaslChannelBuilder channelBuilder1 = createGssapiChannelBuilder(jaasContexts, gssManager);
        assertEquals(1, channelBuilder1.subject("GSSAPI").getPrincipals().size());
        assertEquals(1, channelBuilder1.subject("GSSAPI").getPrivateCredentials().size());

        SaslChannelBuilder channelBuilder2 = createGssapiChannelBuilder(jaasContexts, gssManager);
        assertEquals(1, channelBuilder2.subject("GSSAPI").getPrincipals().size());
        assertEquals(1, channelBuilder2.subject("GSSAPI").getPrivateCredentials().size());
        assertSame(channelBuilder1.subject("GSSAPI"), channelBuilder2.subject("GSSAPI"));

        Mockito.verify(gssManager, Mockito.times(1))
                .createCredential(gssName, GSSContext.INDEFINITE_LIFETIME, oid, GSSCredential.ACCEPT_ONLY);
    }