|
467 | 467 |
|
468 | 468 | end |
469 | 469 |
|
| 470 | + describe "JDBC connection URL" do |
| 471 | + it "should use service name syntax by default" do |
| 472 | + url = PLSQL::JDBCConnection.jdbc_connection_url(host: "myhost", port: 1521, database: "MYSERVICENAME") |
| 473 | + expect(url).to eq "jdbc:oracle:thin:@//myhost:1521/MYSERVICENAME" |
| 474 | + end |
| 475 | + |
| 476 | + it "should use default host and port when not specified" do |
| 477 | + url = PLSQL::JDBCConnection.jdbc_connection_url(database: "/MYSERVICENAME") |
| 478 | + expect(url).to eq "jdbc:oracle:thin:@//localhost:1521/MYSERVICENAME" |
| 479 | + end |
| 480 | + |
| 481 | + it "should use SID syntax when database starts with colon" do |
| 482 | + url = PLSQL::JDBCConnection.jdbc_connection_url(host: "myhost", port: 1521, database: ":MYSID") |
| 483 | + expect(url).to eq "jdbc:oracle:thin:@//myhost:1521:MYSID" |
| 484 | + end |
| 485 | + |
| 486 | + it "should use service name syntax when database starts with slash" do |
| 487 | + url = PLSQL::JDBCConnection.jdbc_connection_url(host: "myhost", port: 1521, database: "/MYSERVICENAME") |
| 488 | + expect(url).to eq "jdbc:oracle:thin:@//myhost:1521/MYSERVICENAME" |
| 489 | + end |
| 490 | + |
| 491 | + it "should use TNS alias when TNS_ADMIN is set and no host specified" do |
| 492 | + allow(ENV).to receive(:[]).and_call_original |
| 493 | + allow(ENV).to receive(:[]).with("TNS_ADMIN").and_return("/path/to/tns") |
| 494 | + url = PLSQL::JDBCConnection.jdbc_connection_url(database: "MYALIAS") |
| 495 | + expect(url).to eq "jdbc:oracle:thin:@MYALIAS" |
| 496 | + end |
| 497 | + |
| 498 | + it "should use custom URL when provided" do |
| 499 | + custom_url = "jdbc:oracle:thin:@//custom:1522/MYSERVICENAME" |
| 500 | + url = PLSQL::JDBCConnection.jdbc_connection_url(host: "myhost", database: "MYSERVICENAME", url: custom_url) |
| 501 | + expect(url).to eq custom_url |
| 502 | + end |
| 503 | + end if defined?(JRuby) |
| 504 | + |
470 | 505 | describe "logoff" do |
471 | 506 | before(:each) do |
472 | 507 | # restore connection before each test |
|
0 commit comments