Package org.exolab.castor.builder.info

Examples of org.exolab.castor.builder.info.ClassInfo


    /**
     * SetUp sets the PropertyHolder to test.
     */
    protected void setUp() throws Exception {
        _holder = new ClassInfo(new JClass("test"));
    }
View Full Code Here


    /**
     * Shows the usage of JDOClassNature.
     */
    public void testUsage() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        if (!classInfo.hasNature(JDOClassInfoNature.class.getName())) {
            classInfo.addNature(JDOClassInfoNature.class.getName());
            JDOClassInfoNature jdo = new JDOClassInfoNature(classInfo);
            jdo.setTableName("BOOK");
            jdo.addPrimaryKey("ISBN");
            // TODO Tobias jdo.addPrimaryKey("ISBN","Generator");
            assertEquals("BOOK", jdo.getTableName());
View Full Code Here

    /**
     * Tests set and get JDO table name.
     */
    public void testTableName() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        classInfo.addNature(JDOClassInfoNature.class.getName());
        JDOClassInfoNature jdo = new JDOClassInfoNature(classInfo);
        jdo.setTableName("BOOK");
        assertEquals("BOOK", jdo.getTableName());
    }
View Full Code Here

    /**
     * Tests set and get primary keys. Adding the author column to the primary
     * key in reality would net really make sense.
     */
    public void testPrimaryKeys() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        classInfo.addNature(JDOClassInfoNature.class.getName());
        JDOClassInfoNature jdo = new JDOClassInfoNature(classInfo);

        List columns = new LinkedList();
        columns.add("ISBN");
        columns.add("AUTHOR");
View Full Code Here

    /**
     * Tests set and get {@link AccessMode} of the JDO entity.
     */
    public void testAccessMode() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        classInfo.addNature(JDOClassInfoNature.class.getName());
        JDOClassInfoNature jdo = new JDOClassInfoNature(classInfo);
        jdo.setAccessMode(AccessMode.Shared);
        assertNotNull(jdo.getAccessMode());
        assertEquals(AccessMode.Shared, jdo.getAccessMode());
    }
View Full Code Here

    /**
     * Tests if getFields returns a list of {@link JDOFieldInfoNature}s.
     */
    public void testGetElementFields() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        FieldInfoFactory factory = new FieldInfoFactory();
        FieldInfo field = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "isbn");
        field.addNature(JDOFieldInfoNature.class.getName());
        JDOFieldInfoNature jdoField = new JDOFieldInfoNature(field);
        jdoField.setColumnName("isbn");
        jdoField.setColumnType("integer");
        classInfo.addFieldInfo(field);
        classInfo.addNature(JDOClassInfoNature.class.getName());
        JDOClassInfoNature jdo = new JDOClassInfoNature(classInfo);

        List jdoFields = jdo.getFields();
        assertEquals(1, jdoFields.size());
        JDOFieldInfoNature jdoFieldReceived = (JDOFieldInfoNature) jdoFields
View Full Code Here

   
    /**
     * Tests if getFields returns a list of {@link JDOFieldInfoNature}s.
     */
    public void testGetElementFieldsWithMoreThanOneField() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        FieldInfoFactory factory = new FieldInfoFactory();
        FieldInfo isbn = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "isbn");
        FieldInfo title = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "title");
        isbn.addNature(JDOFieldInfoNature.class.getName());
        title.addNature(JDOFieldInfoNature.class.getName());
        JDOFieldInfoNature jdoIsbn = new JDOFieldInfoNature(isbn);
        JDOFieldInfoNature jdoTitle = new JDOFieldInfoNature(title);
        jdoIsbn.setColumnName("isbn");
        jdoIsbn.setColumnType("integer");
        jdoTitle.setColumnName("title");
        jdoTitle.setColumnType("varchar");
       
        classInfo.addFieldInfo(isbn);
        classInfo.addFieldInfo(title);
        classInfo.addNature(JDOClassInfoNature.class.getName());
        JDOClassInfoNature jdo = new JDOClassInfoNature(classInfo);

        List jdoFields = jdo.getFields();
        assertEquals(2, jdoFields.size());
       
View Full Code Here

    /**
     * Test getFields with a ClassInfo having a FieldInfo but without
     * JDOFieldInfoNature.
     */
    public void testGetElementFieldsWithoutNatures() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        FieldInfoFactory factory = new FieldInfoFactory();
        FieldInfo field = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "isbn");
        classInfo.addFieldInfo(field);
        classInfo.addNature(JDOClassInfoNature.class.getName());
        JDOClassInfoNature jdo = new JDOClassInfoNature(classInfo);

        List jdoFields = jdo.getFields();
        assertEquals(0, jdoFields.size());
    }
View Full Code Here

    /**
     * Test getFields with a ClassInfo no fields added before.
     */
    public void testGetElementFieldsNoFieldsAdded() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        classInfo.addNature(JDOClassInfoNature.class.getName());
        JDOClassInfoNature jdo = new JDOClassInfoNature(classInfo);

        List jdoFields = jdo.getFields();
        assertEquals(0, jdoFields.size());
    }
View Full Code Here

   
    /**
     * Tests if getFields returns a list of {@link JDOFieldInfoNature}s.
     */
    public void testGetElementFieldsOnlyOneHasNature() {
        ClassInfo classInfo = new ClassInfo(new JClass("test"));
        FieldInfoFactory factory = new FieldInfoFactory();
        FieldInfo field = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "isbn");
        FieldInfo field2 = factory.createFieldInfo(new XSClass(
                new JClass("Book")), "abc");
        field.addNature(JDOFieldInfoNature.class.getName());
        JDOFieldInfoNature jdoField = new JDOFieldInfoNature(field);
        jdoField.setColumnName("isbn");
        jdoField.setColumnType("integer");
        classInfo.addFieldInfo(field);
        classInfo.addFieldInfo(field2);
        classInfo.addNature(JDOClassInfoNature.class.getName());
        JDOClassInfoNature jdo = new JDOClassInfoNature(classInfo);

        List jdoFields = jdo.getFields();
        assertEquals(1, jdoFields.size());
        JDOFieldInfoNature jdoFieldReceived = (JDOFieldInfoNature) jdoFields
View Full Code Here

TOP

Related Classes of org.exolab.castor.builder.info.ClassInfo

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.