Skip to content

Commit

Permalink
fix windows bug (#1201)
Browse files Browse the repository at this point in the history
* fix windows bug

* update

* update
  • Loading branch information
EvenSol authored Dec 7, 2024
1 parent a485bd8 commit bc77211
Show file tree
Hide file tree
Showing 67 changed files with 133 additions and 121 deletions.
58 changes: 51 additions & 7 deletions .github/workflows/verify_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
test_java_11:
name: Assert tests and javadoc with java 11
name: Assert tests and javadoc with Java 11 on Ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -34,13 +34,11 @@ jobs:
file: jacoco.xml
name: codecov
token: ${{ secrets.CODECOV_TOKEN }}
# tags: coverage


test_java_8:
name: Assert tests with java 8
name: Assert tests with Java 8 on Ubuntu
runs-on: ubuntu-latest
needs: test_java_11

steps:
- uses: actions/checkout@v4
- name: Set up JDK 8
Expand All @@ -52,9 +50,8 @@ jobs:
- name: Run tests
run: mvn -B test --file pomJava8.xml -ntp


test_java_21:
name: Assert tests with java 21
name: Assert tests with Java 21 on Ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -68,3 +65,50 @@ jobs:
run: mvn javadoc:javadoc
- name: Run tests
run: mvn -B test --file pomJava21.xml -ntp

test_java_11_windows:
name: Assert tests with Java 11 on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: Generate javadoc
run: mvn javadoc:javadoc
- name: Run tests
run: mvn -B test --file pom.xml -ntp

test_java_8_windows:
name: Assert tests with Java 8 on Windows
runs-on: windows-latest
needs: test_java_11_windows
steps:
- uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
- name: Run tests
run: mvn -B test --file pomJava8.xml -ntp

test_java_21_windows:
name: Assert tests with Java 21 on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'maven'
- name: Generate javadoc
run: mvn javadoc:javadoc
- name: Run tests
run: mvn -B test --file pomJava21.xml -ntp
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
<configuration>
<rules>
<requireMavenVersion>
<version>3.8.8</version>
<version>3.8.7</version>
</requireMavenVersion>
</rules>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion pomJava21.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<configuration>
<rules>
<requireMavenVersion>
<version>3.8.8</version>
<version>3.8.7</version>
</requireMavenVersion>
</rules>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion pomJava8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<configuration>
<rules>
<requireMavenVersion>
<version>3.8.8</version>
<version>3.8.7</version>
</requireMavenVersion>
</rules>
</configuration>
Expand Down
25 changes: 11 additions & 14 deletions src/main/java/neqsim/util/database/NeqSimDataBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public NeqSimDataBase() {
* </p>
*
* @return a Connection object
* @throws java.sql.SQLException if any.
* @throws java.sql.SQLException if any.
* @throws java.lang.ClassNotFoundException if any.
*/
public Connection openConnection() throws SQLException, ClassNotFoundException {
Expand Down Expand Up @@ -163,7 +163,8 @@ public void setStatement(Statement statement) {
* </p>
*
* @param sqlString Query to execute.
* @return True if the first result is a ResultSet object; false if it is an update count or there
* @return True if the first result is a ResultSet object; false if it is an
* update count or there
* are no results
*/
public boolean execute(String sqlString) {
Expand Down Expand Up @@ -286,7 +287,7 @@ public static void setDataBaseType(String aDataBaseType) {
* Setter for the field <code>dataBaseType</code>.
* </p>
*
* @param aDataBaseType a {@link java.lang.String} object
* @param aDataBaseType a {@link java.lang.String} object
* @param connectionString a {@link java.lang.String} object
*/
public static void setDataBaseType(String aDataBaseType, String connectionString) {
Expand Down Expand Up @@ -402,8 +403,7 @@ public static String[] getComponentNames() {
*/
public static boolean hasComponent(String name) {
try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase();
java.sql.ResultSet dataSet =
database.getResultSet("select count(*) from comp WHERE NAME='" + name + "'")) {
java.sql.ResultSet dataSet = database.getResultSet("select count(*) from comp WHERE NAME='" + name + "'")) {
dataSet.next();
int size = dataSet.getInt(1);
if (size == 0) {
Expand All @@ -424,8 +424,7 @@ public static boolean hasComponent(String name) {
*/
public static boolean hasTempComponent(String name) {
try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase();
java.sql.ResultSet dataSet =
database.getResultSet("select count(*) from comptemp WHERE NAME='" + name + "'")) {
java.sql.ResultSet dataSet = database.getResultSet("select count(*) from comptemp WHERE NAME='" + name + "'")) {
dataSet.next();
int size = dataSet.getInt(1);
if (size == 0) {
Expand All @@ -451,7 +450,7 @@ public static void updateTable(String tableName) {
* Drops and re-creates table from contents in csv file.
*
* @param tableName Name of table to replace
* @param path Path to csv file to get table data from
* @param path Path to csv file to get table data from
*/
public static void updateTable(String tableName, String path) {
URL url = NeqSimDataBase.class.getClassLoader().getResource(path);
Expand All @@ -461,7 +460,7 @@ public static void updateTable(String tableName, String path) {
}
try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) {
database.execute("DROP TABLE IF EXISTS " + tableName);
String sqlString = "CREATE TABLE " + tableName + " AS SELECT * FROM CSVREAD('" + url + "')";
String sqlString = "CREATE TABLE " + tableName + " AS SELECT * FROM CSVREAD('file:" + url + "')";
database.execute(sqlString);
} catch (Exception ex) {
logger.error("Failed updating table " + tableName, ex);
Expand All @@ -472,7 +471,7 @@ public static void updateTable(String tableName, String path) {
* Drops and re-creates table from contents in csv file.
*
* @param tableName Name of table to replace
* @param path Path to csv file to
* @param path Path to csv file to
*/
public static void replaceTable(String tableName, String path) {
try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) {
Expand All @@ -494,8 +493,7 @@ public static void replaceTable(String tableName, String path) {
*/
public static void initH2DatabaseFromCSVfiles() {
h2IsInitalizing = true;
neqsim.util.database.NeqSimDataBase.connectionString =
"jdbc:h2:mem:neqsimthermodatabase;DB_CLOSE_DELAY=-1";
neqsim.util.database.NeqSimDataBase.connectionString = "jdbc:h2:mem:neqsimthermodatabase;DB_CLOSE_DELAY=-1";
neqsim.util.database.NeqSimDataBase.dataBaseType = "H2";

try {
Expand Down Expand Up @@ -539,8 +537,7 @@ public static void initH2DatabaseFromCSVfiles() {
// technicalrequirements, technicalrequirements_process, materialpipeproperties,
// materialplateproperties, fittings, LuciaData, Luciadata8

try (neqsim.util.database.NeqSimDataBase database =
new neqsim.util.database.NeqSimDataBase()) {
try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) {
database.execute("CREATE TABLE comptemp AS SELECT * FROM comp");
database.execute("CREATE TABLE intertemp AS SELECT * FROM inter");
}
Expand Down
Loading

0 comments on commit bc77211

Please sign in to comment.