Search in sources :

Example 1 with SamEnablingPolicy

use of org.talend.esb.policy.samenabling.SamEnablingPolicy in project tesb-rt-se by Talend.

the class SamEnablingAssertionTest method testEqual.

@Test
public void testEqual() {
    SamEnablingPolicy sep = new SamEnablingPolicy(generateStubElement());
    assertFalse(sep.equal(null));
    assertTrue(sep.equal(sep));
}
Also used : SamEnablingPolicy(org.talend.esb.policy.samenabling.SamEnablingPolicy) Test(org.junit.Test)

Example 2 with SamEnablingPolicy

use of org.talend.esb.policy.samenabling.SamEnablingPolicy in project tesb-rt-se by Talend.

the class SamEnablingInterceptorProviderTest method createSamlAssertion.

public List<Assertion> createSamlAssertion(String appliesTo) throws Exception {
    List<Assertion> assertions = new ArrayList<Assertion>();
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = dbf.newDocumentBuilder();
    Document doc = builder.newDocument();
    Element element = doc.createElement("root");
    doc.appendChild(element);
    element.setAttribute("appliesTo", appliesTo);
    assertions.add(new SamEnablingPolicy(element));
    return assertions;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) SamEnablingPolicy(org.talend.esb.policy.samenabling.SamEnablingPolicy) Element(org.w3c.dom.Element) Assertion(org.apache.neethi.Assertion) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document)

Example 3 with SamEnablingPolicy

use of org.talend.esb.policy.samenabling.SamEnablingPolicy in project tesb-rt-se by Talend.

the class SamEnablingAssertionTest method testIgnorable.

@Test
public void testIgnorable() {
    SamEnablingPolicy sep = new SamEnablingPolicy(generateStubElement());
    assertFalse(sep.isIgnorable());
}
Also used : SamEnablingPolicy(org.talend.esb.policy.samenabling.SamEnablingPolicy) Test(org.junit.Test)

Example 4 with SamEnablingPolicy

use of org.talend.esb.policy.samenabling.SamEnablingPolicy in project tesb-rt-se by Talend.

the class SamEnablingAssertionTest method testSerialization.

@Test
public void testSerialization() throws Exception {
    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
    // $NON-NLS-1$
    outputFactory.setProperty(// $NON-NLS-1$
    "javax.xml.stream.isRepairingNamespaces", Boolean.TRUE);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    XMLStreamWriter writer = outputFactory.createXMLStreamWriter(baos, "UTF-8");
    SamEnablingPolicy sep = new SamEnablingPolicy(generateStubElement());
    sep.serialize(writer);
    writer.flush();
    writer.close();
    assertTrue(baos.toString().equalsIgnoreCase("<tpa:ServiceActivityMonitoring xmlns:tpa=\"http://types.talend.com/policy/assertion/1.0\" appliesTo=\"none\"/>"));
}
Also used : XMLOutputFactory(javax.xml.stream.XMLOutputFactory) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) SamEnablingPolicy(org.talend.esb.policy.samenabling.SamEnablingPolicy) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Aggregations

SamEnablingPolicy (org.talend.esb.policy.samenabling.SamEnablingPolicy)4 Test (org.junit.Test)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ArrayList (java.util.ArrayList)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 XMLOutputFactory (javax.xml.stream.XMLOutputFactory)1 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)1 Assertion (org.apache.neethi.Assertion)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1