All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.axiom.ts.soap.SOAPTestSuiteBuilder Maven / Gradle / Ivy

Go to download

The Axiom implementation test suite. This test suite can be used to check conformance of a particular Axiom implementation.

There is a newer version: 2.0.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.axiom.ts.soap;

import static org.apache.axiom.testing.multiton.Multiton.getInstances;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.xml.namespace.QName;

import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMSourcedElement;
import org.apache.axiom.om.TestConstants;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPConstants;
import org.apache.axiom.testing.multiton.Multiton;
import org.apache.axiom.testutils.suite.MatrixTestSuiteBuilder;
import org.apache.axiom.ts.dimension.ExpansionStrategy;
import org.apache.axiom.ts.dimension.serialization.SerializationStrategy;

public class SOAPTestSuiteBuilder extends MatrixTestSuiteBuilder {
    private static final String[] badSOAPFiles = { "wrongSoapNs.xml", "notnamespaceQualified.xml", "soap11/twoheaders.xml", "soap11/twoBodymessage.xml",
            "soap11/envelopeMissing.xml", "soap11/haederBodyWrongOrder.xml", "soap11/invalid-faultcode.xml", "soap11/invalid-faultstring.xml",
            "soap11/invalid-faultactor.xml", "soap11/processing-instruction.xml", "soap11/entity-reference.xml",
            "soap12/header-bad-case.xml", "soap12/header-no-namespace.xml", "soap12/processing-instruction.xml", "soap12/entity-reference.xml",
            "soap12/additional-element-after-body.xml"};
    
    private static final List goodSOAPFiles;
    
    static {
        goodSOAPFiles = new ArrayList();
        goodSOAPFiles.addAll(Arrays.asList(
                new SimpleSOAPSample(SOAPSpec.SOAP11, TestConstants.WHITESPACE_MESSAGE),
                new SimpleSOAPSample(SOAPSpec.SOAP11, TestConstants.MINIMAL_MESSAGE),
                new SimpleSOAPSample(SOAPSpec.SOAP11, TestConstants.REALLY_BIG_MESSAGE),
                new SimpleSOAPSample(SOAPSpec.SOAP11, TestConstants.EMPTY_BODY_MESSAGE),
                new SimpleSOAPSample(SOAPSpec.SOAP11, "soap/soap11/soapfault.xml"),
                new SimpleSOAPSample(SOAPSpec.SOAP11, "soap/soap11/soapfault2.xml"),
                new SimpleSOAPSample(SOAPSpec.SOAP11, "soap/soap11/bodyNotQualified.xml"),
                new SimpleSOAPSample(SOAPSpec.SOAP11, "soap/soap11/message.xml"),
                new SimpleSOAPSample(SOAPSpec.SOAP12, "soap/soap12/message.xml"),
                new SimpleSOAPSample(SOAPSpec.SOAP11, "soap/soap11/faultelements-with-comment.xml"),
                new SimpleSOAPSample(SOAPSpec.SOAP11, "soap/soap11/additional-element-after-body.xml"),
                new SimpleSOAPSample(SOAPSpec.SOAP11, "soap/soap11/empty-header.xml"),
                new SimpleSOAPSample(SOAPSpec.SOAP12, "soap/soap12/empty-header.xml")));
        goodSOAPFiles.addAll(Multiton.getInstances(SOAPSample.class));
    }
    
    private static final QName[] generalQNames = {
        new QName("root"),
        new QName("urn:test", "root", "p"),
        new QName("urn:test", "root") };
    
    private static final QName[] noFaultQNames = {
        new QName("root"),
        new QName("urn:test", "root", "p"),
        new QName("urn:test", "root"),
        new QName("Fault"),
        new QName("urn:test", "Fault", "p"),
        new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI, "NoFault", SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX),
        new QName(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI, "NoFault", SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX) };
    
    private final OMMetaFactory metaFactory;
    private final boolean supportsOMSourcedElement;
    private final boolean supportsBodyElementNameOptimization;
    
    /**
     * Constructor.
     * 
     * @param metaFactory
     * @param supportsOMSourcedElement
     *            indicates whether the implementation supports {@link OMSourcedElement}
     * @param supportsBodyElementNameOptimization
     *            indicates whether the implementation supports the optimization described by AXIOM-282
     */
    public SOAPTestSuiteBuilder(OMMetaFactory metaFactory, boolean supportsOMSourcedElement, boolean supportsBodyElementNameOptimization) {
        this.metaFactory = metaFactory;
        this.supportsOMSourcedElement = supportsOMSourcedElement;
        this.supportsBodyElementNameOptimization = supportsBodyElementNameOptimization;
    }
    
    private void addTests(SOAPSpec spec) {
        BooleanLiteral[] booleanLiterals = spec.getBooleanLiterals();
        String[] invalidBooleanLiterals = spec.getInvalidBooleanLiterals();
        addTest(new org.apache.axiom.ts.soap.body.TestAddFault1(metaFactory, spec));
        addTest(new org.apache.axiom.ts.soap.body.TestAddFault2(metaFactory, spec));
        addTest(new org.apache.axiom.ts.soap.body.TestCloneOMElement(metaFactory, spec));
        addTest(new org.apache.axiom.ts.soap.body.TestGetFault(metaFactory, spec));
        addTest(new org.apache.axiom.ts.soap.body.TestGetFaultFakeFault(metaFactory, spec));
        addTest(new org.apache.axiom.ts.soap.body.TestGetFaultWithParser(metaFactory, spec));
        for (int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy