Search in sources :

Example 11 with ExmlModel

use of net.jangaroo.exml.model.ExmlModel in project jangaroo-tools by CoreMedia.

the class ExmlComponentClassGeneratorTest method testGenerateClassWithUpperCaseFileName.

@Test
public void testGenerateClassWithUpperCaseFileName() throws Exception {
    setUp("exmlparser.config");
    File sourceFile = getFile("/exmlparser/AllElements.exml");
    ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
    ExmlModel model = exmlToModelParser.parse(sourceFile);
    Assert.assertEquals("AllElements", model.getClassName());
    Assert.assertEquals("allElements", model.getConfigClass().getName());
    Assert.assertEquals("exmlparser", model.getPackageName());
}
Also used : ExmlModel(net.jangaroo.exml.model.ExmlModel) ExmlToModelParser(net.jangaroo.exml.parser.ExmlToModelParser) ExmlSourceFile(net.jangaroo.exml.model.ExmlSourceFile) File(java.io.File) Test(org.junit.Test)

Example 12 with ExmlModel

use of net.jangaroo.exml.model.ExmlModel in project jangaroo-tools by CoreMedia.

the class ExmlToModelParserTest method testInheritProperties.

@Test
public void testInheritProperties() throws Exception {
    setUp("testNamespace.config");
    ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
    ExmlModel model = exmlToModelParser.parse(getFile("/testPackage/TestComponent2.exml"));
    Assert.assertEquals("testPackage.TestComponent", model.getSuperClassName());
    JsonObject expectedJsonObject = new JsonObject("items", new JsonArray(new JsonObject("propertyThree", "3").settingWrapperClass("testNamespace.config.testComponent2")), "columns", new JsonObject("xtype", "agridcolumn"));
    System.out.println(model.getJsonObject().toString(2));
    Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
}
Also used : JsonArray(net.jangaroo.exml.json.JsonArray) ExmlModel(net.jangaroo.exml.model.ExmlModel) JsonObject(net.jangaroo.exml.json.JsonObject) ExmlToModelParser(net.jangaroo.exml.parser.ExmlToModelParser) Test(org.junit.Test)

Example 13 with ExmlModel

use of net.jangaroo.exml.model.ExmlModel in project jangaroo-tools by CoreMedia.

the class ExmlToModelParserTest method testContainerDefaults.

@Test
public void testContainerDefaults() throws Exception {
    setUp("testNamespace.config");
    ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
    ExmlModel model = exmlToModelParser.parse(getFile("/testPackage/TestContainerDefaults.exml"));
    JsonObject expectedJsonObject = new JsonObject("defaults", new JsonObject("text", "it works!"), "defaultType", "button", "items", new JsonArray(new JsonObject("xtype", "container", "defaults", new JsonObject("propertyOne", true), "defaultType", "testNamespace.config.testComponent")));
    System.out.println(model.getJsonObject().toString(2));
    Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
}
Also used : JsonArray(net.jangaroo.exml.json.JsonArray) ExmlModel(net.jangaroo.exml.model.ExmlModel) JsonObject(net.jangaroo.exml.json.JsonObject) ExmlToModelParser(net.jangaroo.exml.parser.ExmlToModelParser) Test(org.junit.Test)

Example 14 with ExmlModel

use of net.jangaroo.exml.model.ExmlModel in project jangaroo-tools by CoreMedia.

the class ExmlToModelParserTest method testParseActions.

@Test
public void testParseActions() throws Exception {
    setUp("exmlparser.config");
    ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
    ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/TestActions.exml"));
    Assert.assertEquals("ext.Panel", model.getSuperClassName());
    JsonObject expectedJsonObject = new JsonObject("baseAction", JsonObject.code("net.jangaroo.ext.create(ext.config.action,{disabled: false})"));
    System.out.println(model.getJsonObject().toString(2));
    Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
}
Also used : ExmlModel(net.jangaroo.exml.model.ExmlModel) JsonObject(net.jangaroo.exml.json.JsonObject) ExmlToModelParser(net.jangaroo.exml.parser.ExmlToModelParser) Test(org.junit.Test)

Example 15 with ExmlModel

use of net.jangaroo.exml.model.ExmlModel in project jangaroo-tools by CoreMedia.

the class ExmlToModelParserTest method testParseTyped.

@Test
public void testParseTyped() throws Exception {
    setUp("exmlparser.config");
    ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
    ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/TestTyped.exml"));
    Assert.assertEquals("ext.Panel", model.getSuperClassName());
    JsonObject expectedJsonObject = new JsonObject("items", new JsonArray(new JsonObject("xtype", "component", // not the number 5!
    "margins", // not the number 5!
    "5"), new JsonObject("xtype", "component", // not the boolean false!
    "id", // not the boolean false!
    "false")));
    System.out.println(model.getJsonObject().toString(2));
    Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
}
Also used : JsonArray(net.jangaroo.exml.json.JsonArray) ExmlModel(net.jangaroo.exml.model.ExmlModel) JsonObject(net.jangaroo.exml.json.JsonObject) ExmlToModelParser(net.jangaroo.exml.parser.ExmlToModelParser) Test(org.junit.Test)

Aggregations

ExmlModel (net.jangaroo.exml.model.ExmlModel)18 ExmlToModelParser (net.jangaroo.exml.parser.ExmlToModelParser)17 Test (org.junit.Test)16 JsonObject (net.jangaroo.exml.json.JsonObject)11 JsonArray (net.jangaroo.exml.json.JsonArray)10 File (java.io.File)4 ExmlSourceFile (net.jangaroo.exml.model.ExmlSourceFile)4 Declaration (net.jangaroo.exml.model.Declaration)2 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 StringWriter (java.io.StringWriter)1 ExmlComponentClassGenerator (net.jangaroo.exml.generator.ExmlComponentClassGenerator)1 ConfigAttribute (net.jangaroo.exml.model.ConfigAttribute)1 ConfigClass (net.jangaroo.exml.model.ConfigClass)1