コード例 #1
0
  /** {@inheritDoc} */
  @Test
  public void testSingleElementOptionalAttributesUnmarshall() {
    AuthnRequest req = (AuthnRequest) unmarshallElement(singleElementOptionalAttributesFile);

    Assert.assertEquals(
        req.isForceAuthnXSBoolean(),
        expectedForceAuthn,
        "Unmarshalled ForceAuthn was not the expected value");
    Assert.assertEquals(
        req.isPassiveXSBoolean(),
        expectedIsPassive,
        "Unmarshalled IsPassive was not the expected value");
    Assert.assertEquals(
        req.getProtocolBinding(),
        expectedProtocolBinding,
        "Unmarshalled ProtocolBinding was not the expected value");
    Assert.assertEquals(
        req.getAssertionConsumerServiceIndex(),
        expectedAssertionConsumerServiceIndex,
        "Unmarshalled AssertionConsumerServiceIndex was not the expected value");
    Assert.assertEquals(
        req.getAssertionConsumerServiceURL(),
        expectedAssertionConsumerServiceURL,
        "Unmarshalled AssertionConsumerServiceURL was not the expected value");
    Assert.assertEquals(
        req.getAttributeConsumingServiceIndex(),
        expectedAttributeConsumingServiceIndex,
        "Unmarshalled AttributeConsumingServiceIndex was not the expected value");
    Assert.assertEquals(
        req.getProviderName(),
        expectedProviderName,
        "Unmarshalled ProviderName was not the expected value");

    super.helperTestSingleElementOptionalAttributesUnmarshall(req);
  }
コード例 #2
0
  /** Test the proper behavior of the XSBooleanValue attributes. */
  @Test
  public void testXSBooleanAttributes() {
    AuthnRequest req = (AuthnRequest) buildXMLObject(AuthnRequest.DEFAULT_ELEMENT_NAME);

    // ForceAuthn attribute
    req.setForceAuthn(Boolean.TRUE);
    Assert.assertEquals(
        req.isForceAuthn(), Boolean.TRUE, "Unexpected value for boolean attribute found");
    Assert.assertNotNull(req.isForceAuthnXSBoolean(), "XSBooleanValue was null");
    Assert.assertEquals(
        req.isForceAuthnXSBoolean(),
        new XSBooleanValue(Boolean.TRUE, false),
        "XSBooleanValue was unexpected value");
    Assert.assertEquals(
        req.isForceAuthnXSBoolean().toString(),
        "true",
        "XSBooleanValue string was unexpected value");

    req.setForceAuthn(Boolean.FALSE);
    Assert.assertEquals(
        req.isForceAuthn(), Boolean.FALSE, "Unexpected value for boolean attribute found");
    Assert.assertNotNull(req.isForceAuthnXSBoolean(), "XSBooleanValue was null");
    Assert.assertEquals(
        req.isForceAuthnXSBoolean(),
        new XSBooleanValue(Boolean.FALSE, false),
        "XSBooleanValue was unexpected value");
    Assert.assertEquals(
        req.isForceAuthnXSBoolean().toString(),
        "false",
        "XSBooleanValue string was unexpected value");

    req.setForceAuthn((Boolean) null);
    Assert.assertEquals(
        req.isForceAuthn(), Boolean.FALSE, "Unexpected default value for boolean attribute found");
    Assert.assertNull(req.isForceAuthnXSBoolean(), "XSBooleanValue was not null");

    // IsPassive attribute
    req.setIsPassive(Boolean.TRUE);
    Assert.assertEquals(
        req.isPassive(), Boolean.TRUE, "Unexpected value for boolean attribute found");
    Assert.assertNotNull(req.isPassiveXSBoolean(), "XSBooleanValue was null");
    Assert.assertEquals(
        req.isPassiveXSBoolean(),
        new XSBooleanValue(Boolean.TRUE, false),
        "XSBooleanValue was unexpected value");
    Assert.assertEquals(
        req.isPassiveXSBoolean().toString(), "true", "XSBooleanValue string was unexpected value");

    req.setIsPassive(Boolean.FALSE);
    Assert.assertEquals(
        req.isPassive(), Boolean.FALSE, "Unexpected value for boolean attribute found");
    Assert.assertNotNull(req.isPassiveXSBoolean(), "XSBooleanValue was null");
    Assert.assertEquals(
        req.isPassiveXSBoolean(),
        new XSBooleanValue(Boolean.FALSE, false),
        "XSBooleanValue was unexpected value");
    Assert.assertEquals(
        req.isPassiveXSBoolean().toString(), "false", "XSBooleanValue string was unexpected value");

    req.setIsPassive((Boolean) null);
    Assert.assertEquals(
        req.isPassive(), Boolean.FALSE, "Unexpected default value for boolean attribute found");
    Assert.assertNull(req.isPassiveXSBoolean(), "XSBooleanValue was not null");
  }