Package com.eviware.soapui.support.xml

Examples of com.eviware.soapui.support.xml.XmlObjectTreeModel$AbstractXmlTreeNode


                    // get value of that property
                    String value = context.expand(property.getValue());

                    // we have something that looks like xpath, or hope so.

                    XmlObjectTreeModel model = null;

                    // model = new XmlObjectTreeModel(
                    // property.getSchemaType().getTypeSystem(),
                    // XmlObject.Factory.parse( value ) );
                    model = new XmlObjectTreeModel(property.getSchemaType().getTypeSystem(),
                            XmlUtils.createXmlObject(value));

                    XmlTreeNode[] nodes = model.selectTreeNodes(context.expand(parameter.getXpath()));

                    // for each invalid type set all nodes

                    for (String xpathInjectionString : xpathList.getXpathListList()) {
View Full Code Here


                                continue;
                            }
                            // XmlObjectTreeModel model = new XmlObjectTreeModel(
                            // property.getSchemaType().getTypeSystem(),
                            // XmlObject.Factory.parse( value ) );
                            XmlObjectTreeModel model = new XmlObjectTreeModel(property.getSchemaType().getTypeSystem(),
                                    XmlUtils.createXmlObject(value));
                            XmlTreeNode[] nodes = model.selectTreeNodes(context.expand(param.getXpath()));
                            StringBuffer buffer = new StringBuffer(value);
                            for (int cnt = 0; cnt < nodes.length; cnt++) {
                                // find right node
                                // this finds where node that needs updateing begins
                                int start = value.indexOf("<" + nodes[cnt].getNodeName()); // keeps
                                // node
                                // start
                                int cnt2 = 0;
                                // if have more than one node that matches xpath, find
                                // next one.
                                while (cnt2 < cnt) {
                                    start = value.indexOf("<" + nodes[cnt].getNodeName(), start + 1);
                                    cnt2++;
                                }
                                // get node xml
                                String nodeXml = getXmlForNode(nodes[cnt]);
                                // find end of target xml node
                                int end = value.indexOf("<" + nodes[cnt].getNodeName(), start + 1);
                                if (end <= 0) {
                                    if (nodeXml.endsWith("</" + nodes[cnt].getDomNode().getNodeName() + ">")) {
                                        end = value.indexOf("</" + nodes[cnt].getDomNode().getNodeName() + ">")
                                                + ("</" + nodes[cnt].getDomNode().getNodeName() + ">").length();
                                    } else {
                                        end = value.indexOf(">", value.indexOf("/", start));
                                    }
                                }
                                if (end <= 0 || end <= start) {
                                    break;
                                }
                                // replace node with right value
                                buffer.replace(start, end + 1, parameterMutations.get(param).get(0));
                            }
                            params.put(param.getLabel(), parameterMutations.get(param).get(0));
                            parameterMutations.get(param).remove(0);

                            testStep.getProperties().get(param.getName()).setValue(buffer.toString());
                        }

                        break;
                    }
                }
            }
        } else {
            for (TestProperty property : testStep.getPropertyList()) {

                String value = context.expand(property.getValue());
                if (XmlUtils.seemsToBeXml(value)) {
                    StringBuffer buffer = new StringBuffer(value);
                    XmlObjectTreeModel model = null;
                    // model = new XmlObjectTreeModel(
                    // property.getSchemaType().getTypeSystem(),
                    // XmlObject.Factory.parse( value ) );
                    model = new XmlObjectTreeModel(property.getSchemaType().getTypeSystem(),
                            XmlUtils.createXmlObject(value));
                    for (SecurityCheckedParameter param : getParameterHolder().getParameterList()) {
                        if (param.getXpath() == null || param.getXpath().trim().length() == 0) {
                            if (parameterMutations.containsKey(param)) {
                                testStep.getProperties().get(param.getName())
                                        .setValue(parameterMutations.get(param).get(0));
                                params.put(param.getLabel(), parameterMutations.get(param).get(0));
                                parameterMutations.get(param).remove(0);
                            }
                        } else {
                            // no value, do nothing.
                            if (value == null || value.trim().equals("")) {
                                continue;
                            }
                            if (param.getName().equals(property.getName())) {
                                XmlTreeNode[] nodes = model.selectTreeNodes(context.expand(param.getXpath()));
                                if (parameterMutations.containsKey(param)) {
                                    if (parameterMutations.get(param).size() > 0) {
                                        for (int cnt = 0; cnt < nodes.length; cnt++) {
                                            // find right node
                                            // keeps node start
View Full Code Here

                        // we have something that looks like xpath, or hope so.

                        // XmlObjectTreeModel model = new XmlObjectTreeModel(
                        // property.getSchemaType().getTypeSystem(),
                        // XmlObject.Factory.parse( value ) );
                        XmlObjectTreeModel model = new XmlObjectTreeModel(property.getSchemaType().getTypeSystem(),
                                XmlUtils.createXmlObject(value));
                        XmlTreeNode[] nodes = model.selectTreeNodes(context.expand(parameter.getXpath()));

                        if (nodes.length > 0 && !(nodes[0] instanceof AttributeXmlTreeNode)) {
                            if (!parameterMutations.containsKey(parameter)) {
                                parameterMutations.put(parameter, new ArrayList<String>());
                            }
View Full Code Here

    }

    private void extractMutations(TestStep testStep, SecurityTestRunContext context) throws XmlException, Exception {
        strategy = getExecutionStrategy().getStrategy();

        XmlObjectTreeModel model = null;// getXmlObjectTreeModel( testStep );
        List<SecurityCheckedParameter> scpList = getParameterHolder().getParameterList();
        StringToStringMap stsmap = new StringToStringMap();
        for (SecurityCheckedParameter scp : scpList) {
            if (scp.isChecked() && scp.getXpath().trim().length() > 0) {
                XmlTreeNode[] treeNodes = null;

                if (strategy.equals(StrategyTypeConfig.ONE_BY_ONE)) {
                    stsmap = new StringToStringMap();
                    model = SecurityScanUtil.getXmlObjectTreeModel(testStep, scp);
                } else {
                    if (model == null) {
                        model = SecurityScanUtil.getXmlObjectTreeModel(testStep, scp);
                    }

                }
                treeNodes = model.selectTreeNodes(context.expand(scp.getXpath()));

                if (treeNodes.length > 0) {
                    XmlTreeNode mynode = treeNodes[0];

                    if (mynode.isLeaf()) {
                        if (mynode.getSchemaType() != null && mynode.getSchemaType().getEnumerationValues() != null
                                && mynode.getSchemaType().getEnumerationValues().length > 0) {
                            EnumerationValues nodeInfo = new EnumerationValues(mynode.getSchemaType().getBaseType()
                                    .getShortJavaName());
                            for (XmlAnySimpleType s : mynode.getSchemaType().getEnumerationValues()) {
                                nodeInfo.addValue(s.getStringValue());
                            }
                            updateEnumNodeValue(mynode, nodeInfo);
                            stsmap.put(scp.getLabel(), mynode.getNodeText());
                            // addToUpdated( context, scp.getLabel(),
                            // mynode.getNodeText() );
                            if (strategy.equals(StrategyTypeConfig.ONE_BY_ONE)) {
                                PropertyMutation pm = new PropertyMutation();
                                pm.setPropertyName(scp.getName());
                                pm.setPropertyValue(model.getXmlObject().toString());
                                stsmap = new StringToStringMap();
                                stsmap.put(scp.getLabel(), mynode.getNodeText());
                                pm.setMutatedParameters(stsmap);
                                addMutation(context, pm);
                            }
                        } else {
                            SchemaTypeImpl simpleType = (SchemaTypeImpl) mynode.getSchemaType();
                            XmlObjectTreeModel model2 = new XmlObjectTreeModel(simpleType.getTypeSystem(),
                                    simpleType.getParseObject());
                            extractRestrictions(model2, context, mynode, model, scp, stsmap);
                        }
                    }
                }
View Full Code Here

        }

        String name = parameter.getName();
        String xpath = parameter.getXpath();
        TestProperty tp = getTestStep().getProperty(name);
        XmlObjectTreeModel xmlObjectTreeModel = null;
        if (tp.getSchemaType() != null && XmlUtils.seemsToBeXml(tp.getValue())) {
            try {
                // xmlObjectTreeModel = new XmlObjectTreeModel(
                // tp.getSchemaType().getTypeSystem(),
                // XmlObject.Factory.parse( tp.getValue() ) );
                xmlObjectTreeModel = new XmlObjectTreeModel(tp.getSchemaType().getTypeSystem(),
                        XmlUtils.createXmlObject(tp.getValue()));
            } catch (XmlException e) {
                SoapUI.logError(e);
            }

            XmlTreeNode[] treeNodes = xmlObjectTreeModel.selectTreeNodes(xpath);

            if (treeNodes.length == 0) {
                restrictionLabel.setJlabel("<html><pre>    </pre></html>");
                return;
            }
            List<String> list = null;
            if (treeNodes[0].getSchemaType() != null && treeNodes[0].getSchemaType().getEnumerationValues() != null) {
                list = BoundaryRestrictionUtill.extractEnums(treeNodes[0]);
                restrictionLabel.setJlabel(list.toString().replaceFirst(",", ""));
            } else {
                SchemaTypeImpl simpleType = (SchemaTypeImpl) treeNodes[0].getSchemaType();
                if (simpleType != null && !simpleType.isNoType()) {
                    XmlObjectTreeModel model2 = new XmlObjectTreeModel(simpleType.getTypeSystem(),
                            simpleType.getParseObject());
                    list = BoundaryRestrictionUtill.getRestrictions(model2.getRootNode(), new ArrayList<String>());
                    if (list.isEmpty()) {
                        list.add("No restrictions in schema are specified for this parameter!");
                    }
                    restrictionLabel.setJlabel(list.toString());
                } else {
View Full Code Here

            TestProperty tp = testStep.getProperty(scp.getName());
            if (tp.getSchemaType() != null && XmlUtils.seemsToBeXml(tp.getValue())) {
                // return new XmlObjectTreeModel(
                // tp.getSchemaType().getTypeSystem(), XmlObject.Factory.parse(
                // tp.getValue() ) );
                return new XmlObjectTreeModel(tp.getSchemaType().getTypeSystem(), XmlUtils.createXmlObject(tp.getValue()));
            }
        } catch (Exception e) {
            SoapUI.logError(e);
        }
        return null;
View Full Code Here

TOP

Related Classes of com.eviware.soapui.support.xml.XmlObjectTreeModel$AbstractXmlTreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.