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

    Assert.assertNotNull(req, "AuthnRequest was null");
    Assert.assertEquals(
        req.isForceAuthn(), Boolean.FALSE, "ForceAuthn (empty) was not default value");
    Assert.assertEquals(req.isPassive(), Boolean.FALSE, "IsPassive (empty) was not default value");
    Assert.assertNull(req.getProtocolBinding(), "ProtocolBinding was not null");
    Assert.assertNull(
        req.getAssertionConsumerServiceIndex(), "AssertionConsumerServiceIndex was not null");
    Assert.assertNull(
        req.getAssertionConsumerServiceURL(), "AssertionConsumerServiceURL was not null");
    Assert.assertNull(
        req.getAttributeConsumingServiceIndex(), "AttributeConsumingServiceIndex was not null");
    Assert.assertNull(req.getProviderName(), "ProviderName was not null");

    super.helperTestSingleElementUnmarshall(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");
  }