当前位置: 首页>>代码示例>>Java>>正文


Java Database.createDynaBeanFor方法代码示例

本文整理汇总了Java中org.apache.ddlutils.model.Database.createDynaBeanFor方法的典型用法代码示例。如果您正苦于以下问题:Java Database.createDynaBeanFor方法的具体用法?Java Database.createDynaBeanFor怎么用?Java Database.createDynaBeanFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ddlutils.model.Database的用法示例。


在下文中一共展示了Database.createDynaBeanFor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSpecialCharacters

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests special characters in the data XML (for DDLUTILS-63).
 */
public void testSpecialCharacters() throws Exception
{
    Database model = readModel(
        "<?xml version='1.0' encoding='ISO-8859-1'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" +
        "  <table name='test'>\n"+
        "    <column name='id' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='value' type='VARCHAR' size='50' required='true'/>\n"+
        "  </table>\n"+
        "</database>");
    String testedValue = "Some Special Characters: \u0001\u0009\u0010";

    SqlDynaBean bean = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "ISO-8859-1",
                  "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <value " + DatabaseIO.BASE64_ATTR_NAME + "=\"true\">" + new String(Base64.encodeBase64(testedValue.getBytes("UTF-8")), "ISO-8859-1") + "</value>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:29,代码来源:TestDataReaderAndWriter.java

示例2: testSpecialCharactersUTF8

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests special characters in the data XML (for DDLUTILS-233).
 */
public void testSpecialCharactersUTF8() throws Exception
{
    Database model = readModel(
        "<?xml version='1.0' encoding='UTF-8'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" +
        "  <table name='test'>\n"+
        "    <column name='id' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='value' type='VARCHAR' size='50' required='true'/>\n"+
        "  </table>\n"+
        "</database>");
    String testedValue = "Some Special Characters: \u0001\u0009\u0010";

    SqlDynaBean bean = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "ISO-8859-1",
                  "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <value " + DatabaseIO.BASE64_ATTR_NAME + "=\"true\">" + new String(Base64.encodeBase64(testedValue.getBytes("UTF-8")), "UTF-8") + "</value>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:29,代码来源:TestDataReaderAndWriter.java

示例3: testColumnNameIsTableName

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when a column name is 'table-name'.
 */
public void testColumnNameIsTableName() throws Exception
{
    Database model = readModel(
        "<?xml version='1.0' encoding='UTF-8'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" +
        "  <table name='test'>\n"+
        "    <column name='id' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='table-name' type='VARCHAR' size='50' required='true'/>\n"+
        "  </table>\n"+
        "</database>");
    String testedValue = "Some Text";

    SqlDynaBean bean = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));

    bean.set("id", new Integer(1));
    bean.set("table-name", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column column-name=\"table-name\">" + testedValue + "</column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:29,代码来源:TestDataReaderAndWriter.java

示例4: testColumnNameIsColumnName

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when a column name is 'column-name'.
 */
public void testColumnNameIsColumnName() throws Exception
{
    Database model = readModel(
        "<?xml version='1.0' encoding='UTF-8'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" +
        "  <table name='test'>\n"+
        "    <column name='id' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='column-name' type='VARCHAR' size='50' required='true'/>\n"+
        "  </table>\n"+
        "</database>");
    String testedValue = "Some Text";

    SqlDynaBean bean = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));

    bean.set("id", new Integer(1));
    bean.set("column-name", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\" column-name=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:27,代码来源:TestDataReaderAndWriter.java

示例5: testTableNameNotAValidXmlIdentifier

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when the table name is not a valid XML identifier.
 */
public void testTableNameNotAValidXmlIdentifier() throws Exception
{
    Database model = readModel(
        "<?xml version='1.0' encoding='UTF-8'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" +
        "  <table name='test$'>\n"+
        "    <column name='id' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='value' type='VARCHAR' size='50' required='true'/>\n"+
        "  </table>\n"+
        "</database>");
    String testedValue = "Some Text";

    SqlDynaBean bean = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table table-name=\"test$\" id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:27,代码来源:TestDataReaderAndWriter.java

示例6: testColumnNameIsColumn

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when a column name is 'column'.
 */
public void testColumnNameIsColumn() throws Exception
{
    Database model = readModel(
        "<?xml version='1.0' encoding='UTF-8'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" +
        "  <table name='test'>\n"+
        "    <column name='id' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='column' type='VARCHAR' size='50' required='true'/>\n"+
        "  </table>\n"+
        "</database>");
    String testedValue = "Some Text";

    SqlDynaBean bean = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));

    bean.set("id", new Integer(1));
    bean.set("column", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\" column=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:27,代码来源:TestDataReaderAndWriter.java

示例7: testColumnNameAndValueShort

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when a column name is a normal valid tag,
 * and both column name and value are shorter than 255 characters.
 */
public void testColumnNameAndValueShort() throws Exception
{
    Database model = readModel(
        "<?xml version='1.0' encoding='UTF-8'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" +
        "  <table name='test'>\n"+
        "    <column name='id' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='value' type='VARCHAR' size='50' required='true'/>\n"+
        "  </table>\n"+
        "</database>");
    String testedValue = "Some Text";

    SqlDynaBean bean = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:28,代码来源:TestDataReaderAndWriter.java

示例8: testColumnNameShortAndValueLong

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when a column name is a normal valid tag,
 * and the column name is shorter than 255 characters but the value is longer.
 */
public void testColumnNameShortAndValueLong() throws Exception
{
    Database model = readModel(
        "<?xml version='1.0' encoding='UTF-8'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" +
        "  <table name='test'>\n"+
        "    <column name='id' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='value' type='VARCHAR' size='400' required='true'/>\n"+
        "  </table>\n"+
        "</database>");
    String testedValue = StringUtils.repeat("Some Text", 40);

    SqlDynaBean bean = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <value>" + testedValue + "</value>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:TestDataReaderAndWriter.java

示例9: testColumnNameShortAndInvalidAndValueLong

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when a column name is not a valid tag,
 * and the column name is shorter than 255 characters and the value is longer.
 */
public void testColumnNameShortAndInvalidAndValueLong() throws Exception
{
    Database model = readModel(
        "<?xml version='1.0' encoding='UTF-8'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" +
        "  <table name='test'>\n"+
        "    <column name='id' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='the value' type='VARCHAR' size='50' required='true'/>\n"+
        "  </table>\n"+
        "</database>");
    String testedValue = StringUtils.repeat("Some Text", 40);

    SqlDynaBean bean = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));

    bean.set("id", new Integer(1));
    bean.set("the value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column column-name=\"the value\">" + testedValue + "</column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:TestDataReaderAndWriter.java

示例10: testColumnNameAndValueShortAndInvalid

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when a column name is not a valid tag,
 * and the value is invalid, and both are short.
 */
public void testColumnNameAndValueShortAndInvalid() throws Exception
{
    Database model = readModel(
        "<?xml version='1.0' encoding='UTF-8'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" +
        "  <table name='test'>\n"+
        "    <column name='id' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='the value' type='VARCHAR' size='50' required='true'/>\n"+
        "  </table>\n"+
        "</database>");
    String testedValue = "the\u0000value";

    SqlDynaBean bean = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));

    bean.set("id", new Integer(1));
    bean.set("the value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column column-name=\"the value\" " + DatabaseIO.BASE64_ATTR_NAME + "=\"true\">" + new String(Base64.encodeBase64(testedValue.getBytes("UTF-8")), "UTF-8") + "</column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:TestDataReaderAndWriter.java

示例11: testTableNameContainsAmpersand

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when the table name contains a '&' character.
 */
public void testTableNameContainsAmpersand() throws Exception
{
    String   tableName   = "test&table";
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName("value");
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName(tableName);
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table table-name=\"test&amp;table\" id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:37,代码来源:TestDataReaderAndWriter.java

示例12: testTableNameContainsLessCharacter

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when the table name contains a '<' character.
 */
public void testTableNameContainsLessCharacter() throws Exception
{
    String   tableName   = "test<table";
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName("value");
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName(tableName);
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table table-name=\"test&lt;table\" id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:37,代码来源:TestDataReaderAndWriter.java

示例13: testTableNameContainsMoreCharacter

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when the table name contains a '>' character.
 */
public void testTableNameContainsMoreCharacter() throws Exception
{
    String   tableName   = "test>table";
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName("value");
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName(tableName);
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table table-name=\"test>table\" id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:37,代码来源:TestDataReaderAndWriter.java

示例14: testColumnValueContainsLessCharacter

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when a column value contains the '<' character.
 */
public void testColumnValueContainsLessCharacter() throws Exception
{
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();
    String   columnName  = "foo<bar";

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName(columnName);
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName("test");
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set(columnName, testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column column-name=\"foo&lt;bar\">" + testedValue + "</column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:39,代码来源:TestDataReaderAndWriter.java

示例15: testTableNameIsTable

import org.apache.ddlutils.model.Database; //导入方法依赖的package包/类
/**
 * Tests the reader & writer behavior when the table name is 'table'.
 */
public void testTableNameIsTable() throws Exception
{
    Database model = readModel(
        "<?xml version='1.0' encoding='UTF-8'?>\n"+
        "<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n" +
        "  <table name='table'>\n"+
        "    <column name='id' type='INTEGER' primaryKey='true' required='true'/>\n"+
        "    <column name='value' type='VARCHAR' size='50' required='true'/>\n"+
        "  </table>\n"+
        "</database>");
    String testedValue = "Some Text";

    DatabaseIO modelIO = new DatabaseIO();

    modelIO.setValidateXml(true);

    SqlDynaBean bean = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table table-name=\"table\" id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:31,代码来源:TestDataReaderAndWriter.java


注:本文中的org.apache.ddlutils.model.Database.createDynaBeanFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。