Search in sources :

Example 36 with Document

use of org.datanucleus.samples.annotations.one_many.bidir_3.Document in project JMRI by JMRI.

the class QualifierAdderTest method setUp.

// The minimal setup for log4J
@Override
protected void setUp() {
    apps.tests.Log4JFixture.setUp();
    p = new ProgDebugger();
    cvtable = new CvTableModel(new JLabel(""), p);
    model = new VariableTableModel(new JLabel(""), new String[] { "Name", "Value" }, cvtable, new IndexedCvTableModel(new JLabel(""), p));
    // create a JDOM tree with just some elements
    Element root = new Element("decoder-config");
    Document doc = new Document(root);
    doc.setDocType(new DocType("decoder-config", "decoder-config.dtd"));
    // add some elements
    Element el1, el2, el3;
    root.addContent(// the sites information here lists all relevant
    new Element("decoder").addContent(new Element("variables").addContent(el1 = new Element("variable").setAttribute("CV", "1").setAttribute("item", "one").addContent(new Element("decVal").setAttribute("max", "31").setAttribute("min", "1"))).addContent(el2 = new Element("variable").setAttribute("CV", "2").setAttribute("item", "two").addContent(new Element("decVal").setAttribute("max", "31").setAttribute("min", "1"))).addContent(el3 = new Element("variable").setAttribute("CV", "3").setAttribute("item", "three").addContent(new Element("decVal").setAttribute("max", "31").setAttribute("min", "1")))));
    // end of adding contents
    // and test reading this
    model.setRow(0, el1);
    model.setRow(1, el2);
    model.setRow(1, el3);
    v1 = model.findVar("one");
    v2 = model.findVar("two");
    v3 = model.findVar("three");
}
Also used : ProgDebugger(jmri.progdebugger.ProgDebugger) Element(org.jdom2.Element) JLabel(javax.swing.JLabel) Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Example 37 with Document

use of org.datanucleus.samples.annotations.one_many.bidir_3.Document in project JMRI by JMRI.

the class QualifierAdderTest method testExistsOk1.

public void testExistsOk1() {
    Element e = new Element("variable").addContent(new Element("qualifier").addContent(new Element("variableref").addContent("one")).addContent(new Element("relation").addContent("exists")).addContent(new Element("value").addContent("1")));
    // create a JDOM tree with just some elements
    Element root = new Element("decoder-config");
    Document doc = new Document(root);
    doc.setDocType(new DocType("decoder-config", "decoder-config.dtd"));
    root.addContent(// the sites information here lists all relevant
    new Element("decoder").addContent(new Element("variables").addContent(e)));
    // print JDOM tree, to check
    //org.jdom2.output.XMLOutputter fmt 
    //    = new org.jdom2.output.XMLOutputter(org.jdom2.output.Format.getPrettyFormat());
    //try {
    //	 fmt.output(doc, System.out);
    //} catch (Exception ex) { log.error("error writing XML", ex);}
    // test Exists
    processModifierElements(e, v2);
    Assert.assertTrue(v2.getAvailable());
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Example 38 with Document

use of org.datanucleus.samples.annotations.one_many.bidir_3.Document in project JMRI by JMRI.

the class VariableTableModelTest method testVarEnumVar.

// Check creating an enumvar with various groupings
public void testVarEnumVar() {
    String[] args = { "CV", "Name" };
    VariableTableModel t = new VariableTableModel(null, args, new CvTableModel(null, p), null);
    // create a JDOM tree with just some elements
    Element root = new Element("decoder-config");
    Document doc = new Document(root);
    doc.setDocType(new DocType("decoder-config", "decoder-config.dtd"));
    // add some elements
    Element el0;
    root.addContent(// the sites information here lists all relevant
    new Element("decoder").addContent(new Element("variables").addContent(el0 = new Element("variable").setAttribute("CV", "99").setAttribute("label", "Enum Sample").setAttribute("mask", "VVVVVVVV").setAttribute("readOnly", "").addContent(new Element("enumVal").addContent(new Element("enumChoice").setAttribute("choice", "V0")).addContent(new Element("enumChoice").setAttribute("choice", "V1")).addContent(new Element("enumChoiceGroup").addContent(new Element("enumChoice").setAttribute("choice", "V2")).addContent(new Element("enumChoice").setAttribute("choice", "V3"))).addContent(new Element("enumChoice").setAttribute("choice", "V4"))))));
    // end of adding contents
    // and test reading this
    t.setRow(0, el0);
    // check
    Assert.assertEquals("name of variable 1", "Enum Sample", t.getLabel(0));
    EnumVariableValue ev = (EnumVariableValue) t.getVariable(t.findVarIndex("Enum Sample"));
    ev.setValue(1);
    Assert.assertEquals("value 1", "V1", ev.getTextValue());
    ev.setValue(2);
    Assert.assertEquals("value 2", "V2", ev.getTextValue());
    ev.setValue(3);
    Assert.assertEquals("value 3", "V3", ev.getTextValue());
    ev.setValue(4);
    Assert.assertEquals("value 4", "V4", ev.getTextValue());
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Example 39 with Document

use of org.datanucleus.samples.annotations.one_many.bidir_3.Document in project JMRI by JMRI.

the class VariableTableModelTest method testVarTableLoadBogus.

// Check creating bogus XML (unknown variable type)
public void testVarTableLoadBogus() {
    String[] args = { "CV", "Name" };
    VariableTableModel t = new VariableTableModel(null, args, new CvTableModel(null, p), null) {

        @Override
        void reportBogus() {
        }
    };
    // create a JDOM tree with just some elements
    Element root = new Element("decoder-config");
    Document doc = new Document(root);
    doc.setDocType(new DocType("decoder-config", "decoder-config.dtd"));
    // add some elements
    Element el0;
    root.addContent(// the sites information here lists all relevant
    new Element("decoder").addContent(new Element("variables").addContent(el0 = new Element("variable").setAttribute("CV", "17").setAttribute("mask", "VVVVVVVV").setAttribute("readOnly", "no").setAttribute("label", "long").addContent(new Element("bogusVal")))));
    // end of adding contents
    // print JDOM tree, to check
    //OutputStream o = System.out;
    //XMLOutputter fmt = new XMLOutputter();
    //fmt.setNewlines(true);   // pretty printing
    //fmt.setIndent(true);
    //try {
    //	 fmt.output(doc, o);
    //} catch (Exception e) { System.out.println("error writing XML: "+e);}
    // and test reading this
    t.setRow(0, el0);
    Assert.assertTrue(t.getRowCount() == 0);
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Example 40 with Document

use of org.datanucleus.samples.annotations.one_many.bidir_3.Document in project JMRI by JMRI.

the class PaneProgFrameTest method setupDoc.

// provide a test document in the above static variables
void setupDoc() {
    // create a JDOM tree with just some elements
    root = new Element("programmer-config");
    doc = new Document(root);
    doc.setDocType(new DocType("programmer-config", "programmer-config.dtd"));
    // add some elements
    root.addContent(new Element("programmer").setAttribute("showFnLanelPane", "yes").setAttribute("showRosterMediaPane", "yes").addContent(new Element("pane").setAttribute("name", "Basic").addContent(new Element("column").addContent(new Element("display").setAttribute("item", "Address")).addContent(new Element("display").setAttribute("item", "Start voltage")).addContent(new Element("display").setAttribute("item", "Normal direction of motion"))).addContent(new Element("column").addContent(new Element("display").setAttribute("item", "Address")).addContent(new Element("display").setAttribute("item", "Normal direction of motion")).addContent(new Element("display").setAttribute("item", "Normal direction of motion").setAttribute("format", "checkbox")).addContent(new Element("display").setAttribute("item", "Normal direction of motion").setAttribute("format", "radiobuttons")))).addContent(new Element("pane").setAttribute("name", "CV").addContent(new Element("column").addContent(new Element("cvtable")))).addContent(new Element("pane").setAttribute("name", "Other").addContent(new Element("column").addContent(new Element("display").setAttribute("item", "Address")).addContent(new Element("display").setAttribute("item", "Normal direction of motion")))));
    return;
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Aggregations

Document (org.jdom2.Document)391 Element (org.jdom2.Element)243 Test (org.junit.Test)104 SAXBuilder (org.jdom2.input.SAXBuilder)84 IOException (java.io.IOException)72 File (java.io.File)56 XMLOutputter (org.jdom2.output.XMLOutputter)56 JDOMException (org.jdom2.JDOMException)44 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)34 MCRNodeBuilder (org.mycore.common.xml.MCRNodeBuilder)25 DocType (org.jdom2.DocType)24 ArrayList (java.util.ArrayList)22 MCRContent (org.mycore.common.content.MCRContent)22 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)22 MCRException (org.mycore.common.MCRException)21 Document (com.google.cloud.language.v1.Document)20 HashMap (java.util.HashMap)19 Attribute (org.jdom2.Attribute)19 MCRObject (org.mycore.datamodel.metadata.MCRObject)19 URL (java.net.URL)18