Search in sources :

Example 6 with ConfigClass

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

the class ConfigClassBuilderTest method testBuildConfigClass.

@Test
public void testBuildConfigClass() throws Exception {
    ConfigClass configClass = buildConfigClass("/testNamespace/config/testComponent.as", "expected");
    Assert.assertEquals("testNamespace.config", configClass.getPackageName());
    Assert.assertEquals("testComponent", configClass.getName());
    Assert.assertEquals("testPackage.TestComponent", configClass.getComponentClassName());
    Assert.assertEquals("This is a TestComponent with panel as baseclass. <p>This class serves as a typed config object for the constructor of the class <code>testPackage.TestComponent</code>. It defines the EXML element <code>&lt;tc:testComponent></code> with <code>xmlns:tc=\"exml:testNamespace.config\"</code>.</p> <p>Using this config class also takes care of registering the target class under the xtype <code>\"testNamespace.config.testComponent\"</code> with Ext JS.</p> @see testPackage.TestComponent @see ext.Panel", configClass.getDescription());
    Set<String> attributeNames = new HashSet<String>();
    for (ConfigAttribute configAttribute : configClass.getCfgs()) {
        attributeNames.add(configAttribute.getName());
        if ("propertyOne".equals(configAttribute.getName())) {
            Assert.assertEquals("Boolean", configAttribute.getType());
            Assert.assertEquals("Some Boolean property @see Boolean", configAttribute.getDescription());
        }
        if ("propertyTwo".equals(configAttribute.getName())) {
            Assert.assertEquals("Number", configAttribute.getType());
            Assert.assertEquals("Some Number property", configAttribute.getDescription());
        }
    }
    Assert.assertEquals(new HashSet<String>(Arrays.asList("propertyOne", "propertyTwo", "propertyThree", "propertyFour", "propertyFive", "propertySix", "propertySeven", "propertyEight", "propertyNine", "propertyTen", "propertyEleven", "propertyTwelve", "property13", "property14")), attributeNames);
}
Also used : ConfigClass(net.jangaroo.exml.model.ConfigClass) ConfigAttribute(net.jangaroo.exml.model.ConfigAttribute) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with ConfigClass

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

the class ConfigClassBuilderTest method testBuildNonConfigClass.

@Test
public void testBuildNonConfigClass() throws Exception {
    ConfigClass configClass = buildConfigClass("/testNamespace/config/NonConfig.as", "test-module");
    Assert.assertNull(configClass);
}
Also used : ConfigClass(net.jangaroo.exml.model.ConfigClass) Test(org.junit.Test)

Example 8 with ConfigClass

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

the class ConfigClassRegistryTest method testScanInitially.

@Test
public void testScanInitially() throws Exception {
    setUp("testNamespace.config");
    ConfigClass configClass = getConfigClassRegistry().getConfigClassByName("testNamespace.config.testLabel");
    Assert.assertNotNull(configClass);
    Assert.assertEquals("testNamespace.config", configClass.getPackageName());
    Assert.assertEquals("testPackage.TestLabel", configClass.getComponentClassName());
    ConfigClass labelConfigClass = getConfigClassRegistry().getConfigClassByName("ext.config.label");
    Assert.assertNotNull(labelConfigClass);
    Assert.assertEquals("ext.config.label", labelConfigClass.getFullName());
    Assert.assertEquals(labelConfigClass, configClass.getSuperClass());
    Assert.assertEquals(1, configClass.getCfgs().size());
}
Also used : ConfigClass(net.jangaroo.exml.model.ConfigClass) Test(org.junit.Test)

Example 9 with ConfigClass

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

the class ConfigClassRegistryTest method testGenerateFromExml.

@Test
public void testGenerateFromExml() throws Exception {
    setUp("testNamespace.config");
    ConfigClass configClass = getConfigClassRegistry().getConfigClassByName("testNamespace.config.testLabel");
    Assert.assertNotNull(configClass);
    Assert.assertEquals("testNamespace.config", configClass.getPackageName());
    Assert.assertEquals("testPackage.TestLabel", configClass.getComponentClassName());
    Assert.assertEquals(1, configClass.getCfgs().size());
    // 2nd try should return the same object
    Assert.assertEquals(configClass, getConfigClassRegistry().getConfigClassByName("testNamespace.config.testLabel"));
}
Also used : ConfigClass(net.jangaroo.exml.model.ConfigClass) Test(org.junit.Test)

Example 10 with ConfigClass

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

the class ConfigClassRegistryTest method testGenerateFromExmlWithPregeneratedActionScript.

@Test
public void testGenerateFromExmlWithPregeneratedActionScript() throws Exception {
    setUp("testNamespace.config", "/expected", "/ext-as");
    File destDir = new File(outputFolder.getRoot(), "testNamespace/config");
    destDir.mkdirs();
    FileUtils.copyFileToDirectory(new File(getConfigClassRegistry().getConfig().getSourcePath().get(0), "testNamespace/config/testComponent.as"), destDir);
    ConfigClass configClass = getConfigClassRegistry().getConfigClassByName("testNamespace.config.testComponent");
    Assert.assertNotNull(configClass);
    Assert.assertEquals("testNamespace.config", configClass.getPackageName());
    Assert.assertEquals("testPackage.TestComponent", configClass.getComponentClassName());
    Assert.assertEquals(14, configClass.getCfgs().size());
    // 2nd try should return the same object
    Assert.assertEquals(configClass, getConfigClassRegistry().getConfigClassByName("testNamespace.config.testComponent"));
}
Also used : ConfigClass(net.jangaroo.exml.model.ConfigClass) File(java.io.File) Test(org.junit.Test)

Aggregations

ConfigClass (net.jangaroo.exml.model.ConfigClass)16 Test (org.junit.Test)8 File (java.io.File)3 ConfigAttribute (net.jangaroo.exml.model.ConfigAttribute)3 Element (org.w3c.dom.Element)3 ArrayList (java.util.ArrayList)2 ExmlcException (net.jangaroo.exml.api.ExmlcException)2 JsonObject (net.jangaroo.exml.json.JsonObject)2 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 HashSet (java.util.HashSet)1 ExmlConfiguration (net.jangaroo.exml.config.ExmlConfiguration)1 Code (net.jangaroo.exml.json.Code)1 AnnotationAt (net.jangaroo.exml.model.AnnotationAt)1 ConfigClassRegistry (net.jangaroo.exml.model.ConfigClassRegistry)1 Declaration (net.jangaroo.exml.model.Declaration)1 ExmlModel (net.jangaroo.exml.model.ExmlModel)1 PublicApiMode (net.jangaroo.exml.model.PublicApiMode)1