Sha256: 501e80529d40bd28ba8fe79c08e061303f10d0549b478392fda6f9b09a09ee14

Contents?: true

Size: 976 Bytes

Versions: 2

Compression:

Stored size: 976 Bytes

Contents

require 'test/unit'
require 'rubygems'
require 'rubeus'
require 'test/rubeus/extensions/java/sql/test_sql_helper'

# Test for statement.rb
class TestStatement < Test::Unit::TestCase
  include TestSqlHelper

  def setup
    setup_connection
  end

  def test_query
    # Drop test table
    begin
      @con.statement do |stmt|
        stmt.execute_update("DROP TABLE TEST")
      end
    rescue
      # table test is already exist
    end

    @con.statement do |stmt|
      stmt.execute_update("CREATE TABLE TEST (ID INT, NAME CHAR(10))")
      stmt.execute_update("INSERT INTO TEST VALUES(1, 'row1')")
      stmt.execute_update("INSERT INTO TEST VALUES(2, 'row2')")

      stmt.query("SELECT * FROM TEST ORDER BY ID") do |rs|
        i = 1
        rs.each_hash do |rsNext|
          assert_equal(i, rsNext["ID"])
          assert_equal("row#{i}      ", rsNext["NAME"])

          i += 1
        end
      end
    end
  end

  def teardown
    teardown_connection
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubeus-0.0.9-java test/rubeus/extensions/java/sql/test_statement.rb
rubeus-0.0.8-java test/rubeus/extensions/java/sql/test_statement.rb