@Test
public void testValidPModeWithSecurity() {

    PMode validPMode = new PMode();
    validPMode.setMep(EbMSConstants.TWO_WAY_MEP);
    validPMode.setMepBinding(EbMSConstants.TWO_WAY_PUSH_PULL);
    PartnerConfig initiator = new PartnerConfig();
    SecurityConfig secConfig = new SecurityConfig();
    SigningConfig sigConfig = new SigningConfig();
    sigConfig.setKeystoreAlias("exampleca");
    secConfig.setSignatureConfiguration(sigConfig);
    EncryptionConfig encConfig = new EncryptionConfig();
    encConfig.setKeystoreAlias("partya");
    secConfig.setEncryptionConfiguration(encConfig);
    initiator.setSecurityConfiguration(secConfig);
    validPMode.setInitiator(initiator);
    UsernameTokenConfig tokenConfig = new UsernameTokenConfig();
    tokenConfig.setUsername("username");
    tokenConfig.setPassword("secret");
    PartnerConfig responder = new PartnerConfig();
    secConfig = new SecurityConfig();
    sigConfig = new SigningConfig();
    sigConfig.setKeystoreAlias("partyb");
    sigConfig.setCertificatePassword("ExampleB");
    secConfig.setSignatureConfiguration(sigConfig);
    encConfig = new EncryptionConfig();
    encConfig.setKeystoreAlias("partyb");
    encConfig.setCertificatePassword("ExampleB");
    secConfig.setEncryptionConfiguration(encConfig);
    responder.setSecurityConfiguration(secConfig);
    validPMode.setResponder(responder);
    validPMode.addLeg(new Leg());
    Leg leg = new Leg();
    PullRequestFlow prFlow = new PullRequestFlow();
    prFlow.setMPC("sub-MPC");
    secConfig = new SecurityConfig();
    sigConfig = new SigningConfig();
    sigConfig.setKeystoreAlias("partyc");
    secConfig.setSignatureConfiguration(sigConfig);
    prFlow.setSecurityConfiguration(secConfig);
    leg.addPullRequestFlow(prFlow);
    validPMode.addLeg(leg);
    assertTrue(Utils.isNullOrEmpty(validator.validatePMode(validPMode)));
}