-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added metadata resouce-config.json for org.apache.commons:commons-dbc…
…p2:2.12.0 (#520)
- Loading branch information
1 parent
ea95723
commit a64c861
Showing
10 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
"resource-config.json" | ||
] |
5 changes: 5 additions & 0 deletions
5
metadata/org.apache.commons/commons-dbcp2/2.12.0/resource-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"bundles": [ | ||
{"name": "org.apache.commons.dbcp2.LocalStrings"} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"latest": true, | ||
"metadata-version": "2.12.0", | ||
"module": "org.apache.commons:commons-dbcp2", | ||
"tested-versions": [ | ||
"2.12.0" | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
gradlew.bat | ||
gradlew | ||
gradle/ | ||
build/ |
18 changes: 18 additions & 0 deletions
18
tests/src/org.apache.commons/commons-dbcp2/2.12.0/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck" | ||
} | ||
|
||
String libraryVersion = tck.testedLibraryVersion.get() | ||
|
||
dependencies { | ||
testImplementation "org.apache.commons:commons-dbcp2:$libraryVersion" | ||
testImplementation 'org.assertj:assertj-core:3.22.0' | ||
testImplementation 'com.h2database:h2:2.3.230' | ||
} |
2 changes: 2 additions & 0 deletions
2
tests/src/org.apache.commons/commons-dbcp2/2.12.0/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
library.version = 2.12.0 | ||
metadata.dir = org.apache.commons/commons-dbcp2/2.12.0/ |
13 changes: 13 additions & 0 deletions
13
tests/src/org.apache.commons/commons-dbcp2/2.12.0/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pluginManagement { | ||
def tckPath = Objects.requireNonNullElse( | ||
System.getenv("GVM_TCK_TCKDIR"), | ||
"../../../../tck-build-logic" | ||
) | ||
includeBuild(tckPath) | ||
} | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT" | ||
} | ||
|
||
rootProject.name = 'org.apache.commons.commons-dbcp2_tests' |
78 changes: 78 additions & 0 deletions
78
...commons-dbcp2/2.12.0/src/test/java/org_apache_commons/commons_dbcp2/CommonsDbcp2Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package org_apache_commons.commons_dbcp2; | ||
|
||
import org.apache.commons.dbcp2.BasicDataSource; | ||
import org.apache.commons.dbcp2.BasicDataSourceFactory; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.sql.Connection; | ||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
import java.util.Properties; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class CommonsDbcp2Test { | ||
private BasicDataSource dataSource; | ||
private Connection connection; | ||
|
||
@BeforeEach | ||
public void setUp() throws SQLException { | ||
Properties properties = new Properties(); | ||
properties.setProperty("driverClassName", "org.h2.Driver"); | ||
properties.setProperty("url", "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"); | ||
properties.setProperty("username", "fred"); | ||
properties.setProperty("password", "secret"); | ||
properties.setProperty("initialSize", "2"); | ||
properties.setProperty("minIdle", "1"); | ||
properties.setProperty("testOnBorrow", "true"); | ||
properties.setProperty("testOnConnect", "true"); | ||
properties.setProperty("validationQuery", "select 1"); | ||
BasicDataSourceFactory dataSourceFactory = new BasicDataSourceFactory(); | ||
dataSource = dataSourceFactory.createDataSource(properties); | ||
connection = dataSource.getConnection(); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() throws Exception { | ||
dataSource.close(); | ||
if (connection != null) { | ||
connection.close(); | ||
connection = null; | ||
} | ||
} | ||
|
||
@Test | ||
void testPreparedStatement() throws SQLException { | ||
try (Statement statement = connection.createStatement()) { | ||
statement.executeUpdate("CREATE TABLE person (id INT NOT NULL, name VARCHAR(255), PRIMARY KEY (id))"); | ||
} | ||
|
||
try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO person(id, name) VALUES( ?, ?)")) { | ||
preparedStatement.setInt(1, 1); | ||
preparedStatement.setString(2, "Elly"); | ||
int count = preparedStatement.executeUpdate(); | ||
assertThat(count).isEqualTo(1); | ||
} | ||
|
||
try (PreparedStatement preparedStatement = connection.prepareStatement("SELECT id, name FROM person WHERE name = ?")) { | ||
preparedStatement.setString(1, "Elly"); | ||
try (ResultSet rs = preparedStatement.executeQuery()) { | ||
assertThat(rs.next()).isEqualTo(true); | ||
assertThat(rs.getInt(1)).isEqualTo(1); | ||
assertThat(rs.getString(2)).isEqualTo("Elly"); | ||
// No more records | ||
assertThat(rs.next()).isEqualTo(false); | ||
} | ||
} | ||
} | ||
} |