KeyStoreBuilderParametersTest.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:conscrypt 作者:
@Test
public void test_init_List() {
    TestKeyStore testKeyStore1 = TestKeyStore.getClient();
    TestKeyStore testKeyStore2 = TestKeyStore.getServer();
    Builder builder1 = Builder.newInstance(
            testKeyStore1.keyStore, new PasswordProtection(testKeyStore1.storePassword));
    Builder builder2 = Builder.newInstance(
            testKeyStore2.keyStore, new PasswordProtection(testKeyStore2.storePassword));

    List<Builder> list = Arrays.asList(builder1, builder2);
    KeyStoreBuilderParameters ksbp = new KeyStoreBuilderParameters(list);
    assertNotNull(ksbp);
    assertNotNull(ksbp.getParameters());
    assertNotSame(list, ksbp.getParameters());
    assertEquals(2, ksbp.getParameters().size());
    assertSame(builder1, ksbp.getParameters().get(0));
    assertSame(builder2, ksbp.getParameters().get(1));

    // confirm result is not modifiable
    try {
        ksbp.getParameters().set(0, builder2);
        fail();
    } catch (UnsupportedOperationException expected) {
        // Ignored.
    }

    // confirm result is a copy of original
    list.set(0, builder2);
    assertSame(builder1, ksbp.getParameters().get(0));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号