Skip to content

Commit

Permalink
Revert "simplify ds and jdbc driver setup"
Browse files Browse the repository at this point in the history
This reverts commit 65f4d8a.
  • Loading branch information
BalusC committed Sep 16, 2024
1 parent cb446c5 commit 52b7691
Show file tree
Hide file tree
Showing 18 changed files with 505 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/jakartified.maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
sudo -u postgres psql postgres -c "CREATE USER test WITH ENCRYPTED PASSWORD 'test';"
sudo -u postgres psql postgres -c "GRANT ALL PRIVILEGES ON DATABASE test TO test;"
- name: Test with Maven
run: mvn -B verify -Dmaven.javadoc.skip=true -P ${{matrix.server}}
run: mvn verify -Dmaven.javadoc.skip=true -P ${{matrix.server}}
247 changes: 241 additions & 6 deletions pom.xml

Large diffs are not rendered by default.

18 changes: 7 additions & 11 deletions src/test/java/org/omnifaces/optimusfaces/test/OptimusFacesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import static org.omnifaces.optimusfaces.model.PagedDataModel.QUERY_PARAMETER_SELECTION;
import static org.omnifaces.optimusfaces.test.service.StartupService.ROWS_PER_PAGE;
import static org.omnifaces.optimusfaces.test.service.StartupService.TOTAL_RECORDS;
import static org.omnifaces.persistence.Database.H2;
import static org.omnifaces.persistence.Database.MYSQL;
import static org.omnifaces.persistence.Database.POSTGRESQL;
import static org.openqa.selenium.Keys.BACK_SPACE;
import static org.openqa.selenium.Keys.SPACE;
Expand Down Expand Up @@ -123,21 +121,19 @@ protected static <T extends OptimusFacesIT> WebArchive createArchive(Class<T> te
.addAsLibraries(maven.loadPomFromFile("pom.xml").importCompileAndRuntimeDependencies().resolve().withTransitivity().asFile())
.addAsLibraries(maven.resolve("org.omnifaces:omnifaces:" + getProperty("test.omnifaces.version"), "org.primefaces:primefaces:jar:jakarta:" + getProperty("test.primefaces.version")).withTransitivity().asFile());

addDataSourceConfig(maven, archive, database);
addDataSourceConfig(database, archive);
addPersistenceConfig(maven, archive);
addResources(new File(testClass.getClassLoader().getResource(packageName).getFile()), "", archive::addAsWebResource);

return archive;
}

private static void addDataSourceConfig(MavenResolverSystem maven, WebArchive archive, Database database) {
var jdbcDriverDependency = database == H2 ? "com.h2database:h2:" + getProperty("test.h2-driver.version")
: database == MYSQL ? "mysql:mysql-connector-java:" + getProperty("test.mysql-driver.version")
: database == POSTGRESQL ? "org.postgresql:postgresql:" + getProperty("test.postgresql-driver.version")
: null;
archive
.addAsWebInfResource("WEB-INF/web.xml/" + database.name().toLowerCase() + ".xml", "web.xml")
.addAsLibraries(maven.resolve(jdbcDriverDependency).withTransitivity().asFile());
private static void addDataSourceConfig(Database database, WebArchive archive) {
var dataSourceConfigXml = isWildFly() ? "wildfly-ds.xml" : isGlassFish() ? "glassfish-resources.xml" : isTomEE() ? "resources.xml" : null;

if (dataSourceConfigXml != null) {
archive.addAsWebInfResource("WEB-INF/" + dataSourceConfigXml + "/" + database.name().toLowerCase() + ".xml", dataSourceConfigXml);
}
}

private static void addPersistenceConfig(MavenResolverSystem maven, WebArchive archive) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
version="3.0"
>
<persistence-unit name="OptimusFacesIT">
<jta-data-source>java:app/OptimusFacesIT</jta-data-source>
<jta-data-source>java:openejb/Resource/OptimusFacesIT</jta-data-source>

<class>org.omnifaces.persistence.model.BaseEntity</class>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
>
<persistence-unit name="OptimusFacesIT">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:app/OptimusFacesIT</jta-data-source>
<jta-data-source>OptimusFacesIT</jta-data-source>

<properties>
<property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
version="3.0"
>
<persistence-unit name="OptimusFacesIT">
<jta-data-source>java:app/OptimusFacesIT</jta-data-source>
<jta-data-source>OptimusFacesIT</jta-data-source>

<properties>
<property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create" />
Expand Down
29 changes: 29 additions & 0 deletions src/test/resources/WEB-INF/glassfish-resources.xml/h2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright OmniFaces
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
<!--
H2 data source configuration for GlassFish/Payara.
-->
<!DOCTYPE resources PUBLIC
"-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN"
"http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-resource jndi-name="java:app/OptimusFacesIT" pool-name="OptimusFacesIT" />
<jdbc-connection-pool name="OptimusFacesIT" res-type="javax.sql.DataSource" datasource-classname="org.h2.jdbcx.JdbcDataSource">
<property name="url" value="jdbc:h2:mem:test;MODE=LEGACY" />
<property name="user" value="sa" />
<property name="password" value="sa" />
</jdbc-connection-pool>
</resources>
30 changes: 30 additions & 0 deletions src/test/resources/WEB-INF/glassfish-resources.xml/mysql.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright OmniFaces
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
<!--
MySQL data source configuration for GlassFish/Payara.
-->
<!DOCTYPE resources PUBLIC
"-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN"
"http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-resource jndi-name="java:app/OptimusFacesIT" pool-name="OptimusFacesIT" />
<jdbc-connection-pool name="OptimusFacesIT" res-type="javax.sql.DataSource" datasource-classname="com.mysql.cj.jdbc.MysqlConnectionPoolDataSource">
<property name="url" value="jdbc:mysql://localhost:3306/test" />
<property name="user" value="root" />
<property name="password" value="root" />
<property name="useSSL" value="false" />
</jdbc-connection-pool>
</resources>
29 changes: 29 additions & 0 deletions src/test/resources/WEB-INF/glassfish-resources.xml/postgresql.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright OmniFaces
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
<!--
PostgreSQL data source configuration for GlassFish/Payara.
-->
<!DOCTYPE resources PUBLIC
"-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN"
"http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-resource jndi-name="java:app/OptimusFacesIT" pool-name="OptimusFacesIT" />
<jdbc-connection-pool name="OptimusFacesIT" res-type="javax.sql.DataSource" datasource-classname="org.postgresql.ds.PGPoolingDataSource">
<property name="url" value="jdbc:postgresql:test" />
<property name="user" value="test" />
<property name="password" value="test" />
</jdbc-connection-pool>
</resources>
27 changes: 27 additions & 0 deletions src/test/resources/WEB-INF/resources.xml/h2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright OmniFaces
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
<!--
H2 data source configuration for TomEE.
-->
<resources>
<Resource id="OptimusFacesIT" type="javax.sql.DataSource">
JdbcDriver org.h2.Driver
JdbcUrl jdbc:h2:mem:test;MODE=LEGACY
UserName sa
Password sa
jtaManaged = true
</Resource>
</resources>
27 changes: 27 additions & 0 deletions src/test/resources/WEB-INF/resources.xml/mysql.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright OmniFaces
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
<!--
MySQL data source configuration for TomEE.
-->
<resources>
<Resource id="OptimusFacesIT" type="javax.sql.DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost:3306/test
UserName root
Password root
jtaManaged = true
</Resource>
</resources>
27 changes: 27 additions & 0 deletions src/test/resources/WEB-INF/resources.xml/postgresql.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright OmniFaces
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
<!--
PostgreSQL data source configurations for TomEE.
-->
<resources>
<Resource id="OptimusFacesIT" type="javax.sql.DataSource">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql:test
UserName test
Password test
jtaManaged = true
</Resource>
</resources>
34 changes: 0 additions & 34 deletions src/test/resources/WEB-INF/web.xml/h2.xml

This file was deleted.

34 changes: 0 additions & 34 deletions src/test/resources/WEB-INF/web.xml/mysql.xml

This file was deleted.

34 changes: 0 additions & 34 deletions src/test/resources/WEB-INF/web.xml/postgresql.xml

This file was deleted.

28 changes: 28 additions & 0 deletions src/test/resources/WEB-INF/wildfly-ds.xml/h2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright OmniFaces
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->
<!--
H2 data source configuration for WildFly.
-->
<datasources>
<datasource jta="true" jndi-name="java:/OptimusFacesIT" pool-name="OptimusFacesIT" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;MODE=LEGACY</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
</datasources>
Loading

0 comments on commit 52b7691

Please sign in to comment.