Example usage for org.springframework.security.config.doc XmlNode child

List of usage examples for org.springframework.security.config.doc XmlNode child

Introduction

In this page you can find the example usage for org.springframework.security.config.doc XmlNode child.

Prototype

public Optional<XmlNode> child(String name) 

Source Link

Usage

From source file:org.springframework.security.config.doc.XsdDocumentedTests.java

@Test
public void parseWhenLatestXsdThenAllNamedSecurityFiltersAreDefinedAndOrderedProperly() throws IOException {
    XmlNode root = this.xml.parse(this.schemaDocumentLocation);

    List<String> nodes = root.child("schema").map(XmlNode::children).orElse(Stream.empty())
            .filter(node -> "simpleType".equals(node.simpleName())
                    && "named-security-filter".equals(node.attribute("name")))
            .flatMap(XmlNode::children).flatMap(XmlNode::children).map(node -> node.attribute("value"))
            .filter(StringUtils::isNotEmpty).collect(Collectors.toList());

    SecurityFiltersAssertions.assertEquals(nodes);
}

From source file:org.springframework.security.config.doc.XsdDocumentedTests.java

@Test
public void parseWhen31XsdThenAllNamedSecurityFiltersAreDefinedAndOrderedProperly() throws IOException {

    List<String> expected = Arrays.asList("FIRST", "CHANNEL_FILTER", "SECURITY_CONTEXT_FILTER",
            "CONCURRENT_SESSION_FILTER", "LOGOUT_FILTER", "X509_FILTER", "PRE_AUTH_FILTER", "CAS_FILTER",
            "FORM_LOGIN_FILTER", "OPENID_FILTER", "LOGIN_PAGE_FILTER", "DIGEST_AUTH_FILTER",
            "BASIC_AUTH_FILTER", "REQUEST_CACHE_FILTER", "SERVLET_API_SUPPORT_FILTER",
            "JAAS_API_SUPPORT_FILTER", "REMEMBER_ME_FILTER", "ANONYMOUS_FILTER", "SESSION_MANAGEMENT_FILTER",
            "EXCEPTION_TRANSLATION_FILTER", "FILTER_SECURITY_INTERCEPTOR", "SWITCH_USER_FILTER", "LAST");

    XmlNode root = this.xml.parse(this.schema31xDocumentLocation);

    List<String> nodes = root.child("schema").map(XmlNode::children).orElse(Stream.empty())
            .filter(node -> "simpleType".equals(node.simpleName())
                    && "named-security-filter".equals(node.attribute("name")))
            .flatMap(XmlNode::children).flatMap(XmlNode::children).map(node -> node.attribute("value"))
            .filter(StringUtils::isNotEmpty).collect(Collectors.toList());

    assertThat(nodes).isEqualTo(expected);
}