Package com.j256.ormlite.support

Examples of com.j256.ormlite.support.ConnectionSource


    });
  }

  @Test(expected = SQLException.class)
  public void testCreateTableThrow() throws Exception {
    final ConnectionSource connectionSource = createMock(ConnectionSource.class);
    testCreate(connectionSource, databaseType, 1, true, null, new Callable<Integer>() {
      public Integer call() throws Exception {
        return TableUtils.createTable(connectionSource, LocalFoo.class);
      }
    });
View Full Code Here


    });
  }

  @Test(expected = SQLException.class)
  public void testCreateTableAboveZero() throws Exception {
    final ConnectionSource connectionSource = createMock(ConnectionSource.class);
    testCreate(connectionSource, databaseType, 1, false, null, new Callable<Integer>() {
      public Integer call() throws Exception {
        return TableUtils.createTable(connectionSource, LocalFoo.class);
      }
    });
View Full Code Here

    });
  }

  @Test(expected = SQLException.class)
  public void testCreateTableBelowZero() throws Exception {
    final ConnectionSource connectionSource = createMock(ConnectionSource.class);
    testCreate(connectionSource, databaseType, -1, false, null, new Callable<Integer>() {
      public Integer call() throws Exception {
        return TableUtils.createTable(connectionSource, LocalFoo.class);
      }
    });
View Full Code Here

    });
  }

  @Test
  public void testCreateTableTableConfig() throws Exception {
    final ConnectionSource connectionSource = createMock(ConnectionSource.class);
    testCreate(connectionSource, databaseType, 0, false, null, new Callable<Integer>() {
      public Integer call() throws Exception {
        return (int) TableUtils.createTable(connectionSource,
            DatabaseTableConfig.fromClass(connectionSource, LocalFoo.class));
      }
View Full Code Here

    });
  }

  @Test
  public void testDropTable() throws Exception {
    final ConnectionSource connectionSource = createMock(ConnectionSource.class);
    testDrop(connectionSource, 0, false, new Callable<Integer>() {
      public Integer call() throws Exception {
        return (int) TableUtils.dropTable(connectionSource, LocalFoo.class, false);
      }
    });
View Full Code Here

    });
  }

  @Test(expected = SQLException.class)
  public void testDropTableThrow() throws Exception {
    final ConnectionSource connectionSource = createMock(ConnectionSource.class);
    testDrop(connectionSource, 0, true, new Callable<Integer>() {
      public Integer call() throws Exception {
        return (int) TableUtils.dropTable(connectionSource, LocalFoo.class, false);
      }
    });
View Full Code Here

    });
  }

  @Test
  public void testDropTableThrowIgnore() throws Exception {
    final ConnectionSource connectionSource = createMock(ConnectionSource.class);
    testDrop(connectionSource, 0, true, new Callable<Integer>() {
      public Integer call() throws Exception {
        return (int) TableUtils.dropTable(connectionSource, LocalFoo.class, true);
      }
    });
View Full Code Here

    });
  }

  @Test(expected = SQLException.class)
  public void testDropTableNegRows() throws Exception {
    final ConnectionSource connectionSource = createMock(ConnectionSource.class);
    testDrop(connectionSource, -1, false, new Callable<Integer>() {
      public Integer call() throws Exception {
        return (int) TableUtils.dropTable(connectionSource, LocalFoo.class, false);
      }
    });
View Full Code Here

    });
  }

  @Test
  public void testDropTableTableConfig() throws Exception {
    final ConnectionSource connectionSource = createMock(ConnectionSource.class);
    testDrop(connectionSource, 0, false, new Callable<Integer>() {
      public Integer call() throws Exception {
        return (int) TableUtils.dropTable(connectionSource,
            DatabaseTableConfig.fromClass(connectionSource, LocalFoo.class), false);
      }
View Full Code Here

    });
  }

  @Test
  public void testIndex() throws Exception {
    final ConnectionSource connectionSource = createMock(ConnectionSource.class);
    expect(connectionSource.getDatabaseType()).andReturn(databaseType).anyTimes();
    DatabaseConnection conn = createMock(DatabaseConnection.class);
    expect(connectionSource.getReadWriteConnection()).andReturn(conn);
    final CompiledStatement stmt = createMock(CompiledStatement.class);
    expect(conn.compileStatement(isA(String.class), isA(StatementType.class), isA(FieldType[].class))).andAnswer(
        new IAnswer<CompiledStatement>() {
          private int stmtC = 0;
          public CompiledStatement answer() throws Throwable {
            Object[] args = EasyMock.getCurrentArguments();
            assertNotNull(args);
            assertEquals(3, args.length);
            if (stmtC == 0) {
              assertEquals("CREATE TABLE `index` (`stuff` VARCHAR(255) ) ", args[0]);
            } else if (stmtC == 1) {
              assertEquals("CREATE INDEX `index_stuff_idx` ON `index` ( `stuff` )", args[0]);
            } else {
              fail("Should only be called twice");
            }
            stmtC++;
            assertEquals(StatementType.EXECUTE, args[1]);
            assertEquals(0, ((FieldType[]) args[2]).length);
            return stmt;
          }
        }).anyTimes();
    expect(stmt.runUpdate()).andReturn(0).anyTimes();
    connectionSource.releaseConnection(conn);
    expectLastCall().anyTimes();
    stmt.close();
    expectLastCall().anyTimes();
    replay(connectionSource, conn, stmt);
    TableUtils.createTable(connectionSource, Index.class);
View Full Code Here

TOP

Related Classes of com.j256.ormlite.support.ConnectionSource

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.