Package org.milyn.cdr

Examples of org.milyn.cdr.SmooksResourceConfiguration


            return;
        }
        processed = true;

        // Add the create bean visitor...
        SmooksResourceConfiguration creatorConfig = visitorMap.addVisitor(beanInstanceCreator, createOnElement, targetNamespace, true);
        creatorConfig.setParameter("beanId", getBeanId());
        creatorConfig.setParameter("beanClass", beanClass.getName());

        // Recurse down the wired beans...
        for(Bean bean : wirings) {
            bean.addVisitors(visitorMap);
        }

        // Add the populate bean visitors...
        for(Binding binding : bindings) {
            SmooksResourceConfiguration populatorConfig = visitorMap.addVisitor(binding.beanInstancePopulator, binding.selector, targetNamespace, true);
            populatorConfig.setParameter("beanId", getBeanId());
            if(binding.assertTargetIsCollection) {
                assertBeanClassIsCollection();
            }
        }
    }
View Full Code Here


public class BaseTransUnitsTest extends TestCase {

  public void test_RenameAttributeTU() {
    Document doc = parseCPResource("testpage1.html");
    SmooksResourceConfiguration resourceConfiguration = new SmooksResourceConfiguration("body", "device", "xxx");
    Element body = (Element)XmlUtil.getNode(doc, "/html/body");
    RenameAttributeTU tu;

    resourceConfiguration.setParameter("attributeName", "attrib1");
    resourceConfiguration.setParameter("attributeNewName", "attrib2");
    tu = Configurator.configure(new RenameAttributeTU(), resourceConfiguration);
        tu.visitAfter(body, null);
    assertEquals("Default overwrite protection failed.", "value2", body.getAttribute("attrib2"));

    resourceConfiguration.setParameter("overwrite", "true");
        tu = Configurator.configure(new RenameAttributeTU(), resourceConfiguration);
    tu.visitAfter(body, null);
    assertFalse("Rename failed to remove target attribute.", body.hasAttribute("attrib1"));
    assertEquals("Overwrite failed.", "value1", body.getAttribute("attrib2"));
  }
View Full Code Here

    assertEquals("Overwrite failed.", "value1", body.getAttribute("attrib2"));
  }

  public void test_RemoveAttributeTU() {
    Document doc = parseCPResource("testpage1.html");
    SmooksResourceConfiguration resourceConfiguration = new SmooksResourceConfiguration("body", "device", "xxx");
    Element body = (Element)XmlUtil.getNode(doc, "/html/body");
    RemoveAttributeTU tu;

    resourceConfiguration.setParameter("attributeName", "attrib1");
        tu = Configurator.configure(new RemoveAttributeTU(), resourceConfiguration);

    assertTrue("XPath failed - test corrupted.", body.hasAttribute("attrib1"));
    tu.visitAfter(body, null);
    assertFalse("Failed to remove target attribute.", body.hasAttribute("attrib1"));
View Full Code Here

    assertFalse("Failed to remove target attribute.", body.hasAttribute("attrib1"));
  }

  public void test_RenameElementTU() {
    Document doc = parseCPResource("testpage1.html");
    SmooksResourceConfiguration resourceConfiguration = new SmooksResourceConfiguration("body", "device", "xxx");
    Element body = (Element)XmlUtil.getNode(doc, "/html/body");
    RenameElementTU tu;

    resourceConfiguration.setParameter("replacementElement", "head");
        tu = Configurator.configure(new RenameElementTU(), resourceConfiguration);

    tu.visitAfter(body, null);
    assertNull("Failed to rename target element.", XmlUtil.getNode(doc, "/html/body"));
    assertNotNull("Failed to rename target element.", XmlUtil.getNode(doc, "/html/head"));
View Full Code Here

    assertNotNull("Failed to rename target element.", XmlUtil.getNode(doc, "/html/head"));
  }

  public void test_RenameElementTU_root_element() {
    Document doc = parseCPResource("testpage1.html");
    SmooksResourceConfiguration resourceConfiguration = new SmooksResourceConfiguration("body", "device", "xxx");
    Element body = (Element)XmlUtil.getNode(doc, "/html/body");
    RenameElementTU tu;

    resourceConfiguration.setParameter("replacementElement", "head");
        tu = Configurator.configure(new RenameElementTU(), resourceConfiguration);

    tu.visitAfter(body, null);
    assertNull("Failed to rename target element.", XmlUtil.getNode(doc, "/html/body"));
    assertNotNull("Failed to rename target element.", XmlUtil.getNode(doc, "/html/head"));
View Full Code Here

    assertNotNull("Failed to rename target element.", XmlUtil.getNode(doc, "/html/head"));
  }

  public void test_RemoveElementTU() {
    Document doc = parseCPResource("testpage1.html");
    SmooksResourceConfiguration resourceConfiguration = new SmooksResourceConfiguration("body", "device", "xxx");
    Element body = (Element)XmlUtil.getNode(doc, "/html/body");
    RemoveElementTU tu;

        tu = Configurator.configure(new RemoveElementTU(), resourceConfiguration);
View Full Code Here

                    SmooksResourceConfigurationList configList;

                    try {
                        configList = XMLConfigDigester.digestConfig(bindingSource.getByteStream(), "./", extendedConfigDigesters, classloader);
                        for(int i = 0; i < configList.size(); i++) {
                            SmooksResourceConfiguration config = configList.get(i);
                           
                            if(config.getSelectorNamespaceURI() == null) {
                                SelectorStep selectorStep = config.getSelectorStep();

                                // And if there isn't a namespace prefix specified on the element (unresolved at this point),
                                // then assign the binding config namespace...
                                if(selectorStep.getTargetElement().getPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) {
                                    config.setSelectorNamespaceURI(namespace.uri);
                                }
                            }
                        }
                    } catch (URISyntaxException e) {
                        throw new SmooksConfigurationException("Unexpected configuration digest exception.", e);
View Full Code Here

    assertNull("Failed to remove target element.", XmlUtil.getNode(doc, "/html/body"));
  }

  public void test_RemoveElementTU_root_element() {
    Document doc = parseCPResource("testpage1.html");
    SmooksResourceConfiguration resourceConfiguration = new SmooksResourceConfiguration("html", "xxx");
    Element body = (Element)XmlUtil.getNode(doc, "/html/body");
    RemoveElementTU tu;

        tu = Configurator.configure(new RemoveElementTU(), resourceConfiguration);
View Full Code Here

    assertEquals("Remove root element but shouldn't have.", body, doc.getDocumentElement());
  }
 
  public void test_SetAttributeTU() {
    Document doc = parseCPResource("testpage1.html");
    SmooksResourceConfiguration resourceConfiguration = new SmooksResourceConfiguration("body", "device", "xxx");
    Element body = (Element)XmlUtil.getNode(doc, "/html/body");
    SetAttributeTU tu;

    resourceConfiguration.setParameter("attributeName", "attrib1");
    resourceConfiguration.setParameter("attributeValue", "value3");
        tu = Configurator.configure(new SetAttributeTU(), resourceConfiguration);
    tu.visitAfter(body, null);
    assertEquals("Default overwrite protection failed.", "value1", body.getAttribute("attrib1"));

    resourceConfiguration.setParameter("overwrite", "true");
        tu = Configurator.configure(new SetAttributeTU(), resourceConfiguration);
    tu.visitAfter(body, null);
    assertEquals("Overwrite failed.", "value3", body.getAttribute("attrib1"));
  }
View Full Code Here

            configurator.getParameters().setProperty("illegalElementNameCharReplacement", illegalElementNameCharReplacement);
        }
        configurator.setTargetProfile(targetProfile);

        List<SmooksResourceConfiguration> configList = configurator.toConfig();
        SmooksResourceConfiguration config = configList.get(0);

        if(keyMap != null) {
            Parameter keyMapParam = new Parameter(YamlReader.CONFIG_PARAM_KEY_MAP, keyMap);
            config.setParameter(keyMapParam);
        }

        return configList;
    }
View Full Code Here

TOP

Related Classes of org.milyn.cdr.SmooksResourceConfiguration

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.