Search in sources :

Example 1 with XmlMergerDelegate

use of com.devonfw.cobigen.xmlplugin.merger.delegates.XmlMergerDelegate in project cobigen by devonfw.

the class XmlPluginMergerIntegrationTest method setUp.

/**
 * Sets up a patchPreferingMerger and a basePreferingMerger without validation
 */
@Before
public void setUp() {
    final String mergeSchemaLocation = "src/main/resources/mergeSchemas/";
    this.patchPreferingMerger = new XmlMergerDelegate(mergeSchemaLocation, MergeType.PATCHATTACHOROVERWRITE, false);
    // ((XmlLawMergerDelegate) patchPreferingMerger).setValidation(false);
    this.basePreferingMerger = new XmlMergerDelegate(mergeSchemaLocation, MergeType.BASEATTACHOROVERWRITE, false);
    ((XmlMergerDelegate) this.basePreferingMerger).setValidation(false);
}
Also used : XmlMergerDelegate(com.devonfw.cobigen.xmlplugin.merger.delegates.XmlMergerDelegate) Before(org.junit.Before)

Example 2 with XmlMergerDelegate

use of com.devonfw.cobigen.xmlplugin.merger.delegates.XmlMergerDelegate in project cobigen by devonfw.

the class XmlPluginActivator method bindMerger.

@Override
public List<Merger> bindMerger() {
    List<Merger> merger = Lists.newLinkedList();
    merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.BASEOVERWRITE, false));
    merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.BASEATTACHOROVERWRITE, false));
    merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.PATCHOVERWRITE, false));
    merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.PATCHATTACHOROVERWRITE, false));
    // mergers with validation enabled
    merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.BASEOVERWRITEVALIDATE, true));
    merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.BASEATTACHOROVERWRITEVALIDATE, true));
    merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.PATCHOVERWRITEVALIDATE, true));
    merger.add(new XmlMergerDelegate(defaultMergeSchemaLocation, MergeType.PATCHATTACHOROVERWRITEVALIDATE, true));
    mergerList = merger;
    return merger;
}
Also used : Merger(com.devonfw.cobigen.api.extension.Merger) XmlMergerDelegate(com.devonfw.cobigen.xmlplugin.merger.delegates.XmlMergerDelegate)

Example 3 with XmlMergerDelegate

use of com.devonfw.cobigen.xmlplugin.merger.delegates.XmlMergerDelegate in project cobigen by devonfw.

the class XmlPluginMergerIntegrationTest method testValidationEnabledThrowsMergeException.

/**
 * Tests that a MergeException is thrown if the validation is enabled and the validation by LeXeMe failed and canceled
 * the merge
 *
 * @throws Exception should not happen
 */
@Test(expected = MergeException.class)
public void testValidationEnabledThrowsMergeException() throws Exception {
    String mergeSchemaLocation = "src/main/resources/mergeSchemas/";
    this.patchPreferingMerger = new XmlMergerDelegate(mergeSchemaLocation, MergeType.PATCHATTACHOROVERWRITEVALIDATE, true);
    this.basePreferingMerger = new XmlMergerDelegate(mergeSchemaLocation, MergeType.BASEATTACHOROVERWRITEVALIDATE, true);
    String basePath = this.resourcesRoot + "BaseFile_validation.xml";
    String patchPath = this.resourcesRoot + "PatchFile_validation.xml";
    File baseFile = new File(basePath);
    String patchString = readFile(patchPath, this.charset);
    this.basePreferingMerger.merge(baseFile, patchString, this.charset);
}
Also used : XmlMergerDelegate(com.devonfw.cobigen.xmlplugin.merger.delegates.XmlMergerDelegate) File(java.io.File) Test(org.junit.Test)

Aggregations

XmlMergerDelegate (com.devonfw.cobigen.xmlplugin.merger.delegates.XmlMergerDelegate)3 Merger (com.devonfw.cobigen.api.extension.Merger)1 File (java.io.File)1 Before (org.junit.Before)1 Test (org.junit.Test)1