Package com.j256.ormlite.db

Examples of com.j256.ormlite.db.DatabaseType


  @Test
  public void testAppendArgOrValueString() throws SQLException {
    String value = "23wbdqwbdq13";
    StringBuilder sb = new StringBuilder();
    DatabaseType databaseType = createMock(DatabaseType.class);
    databaseType.appendEscapedWord(sb, value);
    replay(databaseType);
    cmpString.appendArgOrValue(databaseType, stringFieldType, sb, new ArrayList<ArgumentHolder>(), value);
    verify(databaseType);
  }
View Full Code Here


    verify(databaseConnection);
  }

  @Test
  public void testGeneratedIdSequence() throws Exception {
    DatabaseType databaseType = new NeedsSequenceDatabaseType();
    connectionSource.setDatabaseType(databaseType);
    TableInfo<GeneratedId, Integer> tableInfo =
        new TableInfo<GeneratedId, Integer>(connectionSource, null, GeneratedId.class);
    StatementExecutor<GeneratedId, Integer> se =
        new StatementExecutor<GeneratedId, Integer>(databaseType, tableInfo, null);
View Full Code Here

    verify(databaseConnection);
  }

  @Test
  public void testGeneratedIdSequenceLong() throws Exception {
    DatabaseType databaseType = new NeedsSequenceDatabaseType();
    connectionSource.setDatabaseType(databaseType);
    StatementExecutor<GeneratedIdLong, Long> se =
        new StatementExecutor<GeneratedIdLong, Long>(databaseType, new TableInfo<GeneratedIdLong, Long>(
            connectionSource, null, GeneratedIdLong.class), null);
    DatabaseConnection databaseConnection = createMock(DatabaseConnection.class);
View Full Code Here

  }

  @Test
  public void testFromDbField() throws Exception {
    Field[] fields = Foo.class.getDeclaredFields();
    DatabaseType databaseType = new StubDatabaseType();
    assertTrue(fields.length >= 1);
    DatabaseFieldConfig config = DatabaseFieldConfig.fromField(databaseType, "foo", fields[0]);
    assertNotNull(config);
    assertTrue(config.isCanBeNull());
    assertEquals(fields[0].getName(), config.getFieldName());
View Full Code Here

  private final static String STUFF_FIELD_NAME = "notstuff";
  private final static int LENGTH_LENGTH = 100;

  @Test
  public void testJavaxAnnotations() throws Exception {
    DatabaseType databaseType = new StubDatabaseType();
    Field[] fields = JavaxAnno.class.getDeclaredFields();
    assertTrue(fields.length >= 8);

    // not a column
    assertNull(DatabaseFieldConfig.fromField(databaseType, "foo", fields[0]));
View Full Code Here

    assertEquals(fields[6].getName(), config.getFieldName());
  }

  @Test
  public void testJavaxJustId() throws Exception {
    DatabaseType databaseType = new StubDatabaseType();
    Field[] fields = JavaxAnnoJustId.class.getDeclaredFields();
    assertTrue(fields.length >= 1);

    DatabaseFieldConfig config = DatabaseFieldConfig.fromField(databaseType, "foo", fields[0]);
    assertNotNull(config);
View Full Code Here

    assertEquals(fields[0].getName(), config.getFieldName());
  }

  @Test
  public void testJavaxGetSet() throws Exception {
    DatabaseType databaseType = new StubDatabaseType();
    Field[] fields = JavaxGetSet.class.getDeclaredFields();
    assertTrue(fields.length >= 1);

    DatabaseFieldConfig config = DatabaseFieldConfig.fromField(databaseType, "foo", fields[0]);
    assertNotNull(config);
View Full Code Here

    assertEquals(fields[0].getName(), config.getFieldName());
  }

  @Test
  public void testJavaxUnique() throws Exception {
    DatabaseType databaseType = new StubDatabaseType();
    Field[] fields = JavaxUnique.class.getDeclaredFields();
    assertTrue(fields.length >= 1);

    DatabaseFieldConfig config = DatabaseFieldConfig.fromField(databaseType, "foo", fields[0]);
    assertNotNull(config);
View Full Code Here

    assertEquals(fields[0].getName(), config.getFieldName());
  }

  @Test(expected = IllegalArgumentException.class)
  public void testUnknownEnumVal() throws Exception {
    DatabaseType databaseType = new StubDatabaseType();
    Field[] fields = BadUnknownVal.class.getDeclaredFields();
    assertTrue(fields.length >= 1);
    DatabaseFieldConfig.fromField(databaseType, "foo", fields[0]);
  }
View Full Code Here

    DatabaseFieldConfig.fromField(databaseType, "foo", fields[0]);
  }

  @Test
  public void testIndex() throws Exception {
    DatabaseType databaseType = new StubDatabaseType();
    Field[] fields = Index.class.getDeclaredFields();
    assertTrue(fields.length >= 1);
    String tableName = "foo";
    DatabaseFieldConfig fieldConfig = DatabaseFieldConfig.fromField(databaseType, tableName, fields[0]);
    assertEquals(tableName + "_" + fields[0].getName() + "_idx", fieldConfig.getIndexName());
View Full Code Here

TOP

Related Classes of com.j256.ormlite.db.DatabaseType

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.