aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggrzy...@apache.org
Subject [aries-jpa] branch master updated: [tests] Fix Karaf integration tests
Date Thu, 10 Jun 2021 07:56:09 GMT
This is an automated email from the ASF dual-hosted git repository.

ggrzybek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jpa.git


The following commit(s) were added to refs/heads/master by this push:
     new c9056db  [tests] Fix Karaf integration tests
c9056db is described below

commit c9056db8d57c2165633d6ad3666df2c8947ed5a0
Author: Grzegorz Grzybek <gr.grzybek@gmail.com>
AuthorDate: Thu Jun 10 09:54:54 2021 +0200

    [tests] Fix Karaf integration tests
    
    * upgrade Karaf to 4.2.11
    * upgrade pax-url to 2.6.7 (https for Maven Central)
    * upgrade pax-jdbc to 1.5.1 (fixed H2 configuration)
---
 .gitignore                                         |  3 ++
 .../example/tasklist/ds/impl/TaskServiceImpl.java  |  2 +-
 itests/jpa-container-itest-karaf/pom.xml           |  2 +-
 .../aries/jpa/itest/karaf/AbstractJPAItest.java    | 13 ++++----
 .../org/apache/aries/jpa/itest/karaf/DSTest.java   | 24 +++++++-------
 .../src/test/resources/org.ops4j.pax.logging.cfg   | 37 ++++++++++++++++++----
 itests/pom.xml                                     |  2 +-
 jpa-features/pom.xml                               |  2 +-
 8 files changed, 57 insertions(+), 28 deletions(-)

diff --git a/.gitignore b/.gitignore
index 24e82e9..45659c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,6 @@ target/
 .settings
 .project
 .DS_Store
+*.iml
+.idea/
+*.swp
diff --git a/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java
b/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java
index 8bef894..2292c1b 100644
--- a/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java
+++ b/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java
@@ -62,7 +62,7 @@ public class TaskServiceImpl implements TaskService {
         return jpa.txExpr(new EmFunction<Collection<Task>>() {
             @Override
             public Collection<Task> apply(EntityManager em) {
-                return em.createQuery("select t from Task t", Task.class).getResultList();
+                return em.createQuery("select t from Task t order by t.id desc", Task.class).getResultList();
             }
         });
     }
diff --git a/itests/jpa-container-itest-karaf/pom.xml b/itests/jpa-container-itest-karaf/pom.xml
index af73c19..3168e8b 100644
--- a/itests/jpa-container-itest-karaf/pom.xml
+++ b/itests/jpa-container-itest-karaf/pom.xml
@@ -34,7 +34,7 @@
     
     <properties>
         <baseline.skip>true</baseline.skip>
-        <karaf.version>4.0.8</karaf.version>
+        <karaf.version>4.2.11</karaf.version>
     </properties>
 
     <dependencies>
diff --git a/itests/jpa-container-itest-karaf/src/test/java/org/apache/aries/jpa/itest/karaf/AbstractJPAItest.java
b/itests/jpa-container-itest-karaf/src/test/java/org/apache/aries/jpa/itest/karaf/AbstractJPAItest.java
index c188e80..cc250f1 100644
--- a/itests/jpa-container-itest-karaf/src/test/java/org/apache/aries/jpa/itest/karaf/AbstractJPAItest.java
+++ b/itests/jpa-container-itest-karaf/src/test/java/org/apache/aries/jpa/itest/karaf/AbstractJPAItest.java
@@ -122,24 +122,25 @@ public abstract class AbstractJPAItest {
         if (localRepo == null) {
             localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
         }
-        MavenArtifactUrlReference karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").version("4.0.8").type("tar.gz");
+        MavenArtifactUrlReference karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").version("4.2.11").type("tar.gz");
         UrlReference enterpriseFeatureUrl = maven().groupId("org.apache.karaf.features").artifactId("enterprise").versionAsInProject().type("xml").classifier("features");
         UrlReference jpaFeatureUrl = maven().groupId("org.apache.aries.jpa").artifactId("jpa-features").versionAsInProject().type("xml").classifier("features");
-        UrlReference paxJdbcFeatureUrl = maven().groupId("org.ops4j.pax.jdbc").artifactId("pax-jdbc-features").version("0.7.0").type("xml").classifier("features");
+        UrlReference paxJdbcFeatureUrl = maven().groupId("org.ops4j.pax.jdbc").artifactId("pax-jdbc-features").version("1.5.1").type("xml").classifier("features");
         return CoreOptions.composite(
             //KarafDistributionOption.debugConfiguration("8000", true),
             karafDistributionConfiguration().frameworkUrl(karafUrl).name("Apache Karaf").unpackDirectory(new
File("target/exam")).useDeployFolder(false),
             configureSecurity().disableKarafMBeanServerBuilder(),
             systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
+            systemProperty("karaf.log").value(new File("target").getAbsolutePath()),
             keepRuntimeFolder(),
-            logLevel(LogLevel.INFO),
+            logLevel(LogLevel.DEBUG),
             when(localRepo != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository="
+ localRepo)),
             features(paxJdbcFeatureUrl, "pax-jdbc-config", "pax-jdbc-h2", "pax-jdbc-pool-dbcp2"),
-            features(enterpriseFeatureUrl, "transaction", "http-whiteboard", "hibernate/4.3.6.Final",
"scr"),
+            features(enterpriseFeatureUrl, "transaction", "http-whiteboard", "hibernate/5.4.29.Final",
"scr"),
             features(jpaFeatureUrl, "jpa"),
             mavenBundle("org.apache.aries.jpa.example", "org.apache.aries.jpa.example.tasklist.model").versionAsInProject(),
-            editConfigurationFilePut(DS_CONFIG, DataSourceFactory.OSGI_JDBC_DRIVER_NAME,
"H2-pool-xa"),
-            editConfigurationFilePut(DS_CONFIG, DataSourceFactory.JDBC_DATABASE_NAME, "tasklist;create=true"),
+            editConfigurationFilePut(DS_CONFIG, DataSourceFactory.OSGI_JDBC_DRIVER_NAME,
"H2 JDBC Driver"),
+            editConfigurationFilePut(DS_CONFIG, DataSourceFactory.JDBC_URL, "jdbc:h2:mem:tasklist;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE;TRACE_LEVEL_FILE=4"),
             editConfigurationFilePut(DS_CONFIG, DataSourceFactory.JDBC_DATASOURCE_NAME, "tasklist"),
             replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg", new File("src/test/resources/org.ops4j.pax.logging.cfg"))
 //            replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg", getConfigFile("/etc/org.ops4j.pax.logging.cfg")),
diff --git a/itests/jpa-container-itest-karaf/src/test/java/org/apache/aries/jpa/itest/karaf/DSTest.java
b/itests/jpa-container-itest-karaf/src/test/java/org/apache/aries/jpa/itest/karaf/DSTest.java
index bbd3a81..9e47b71 100644
--- a/itests/jpa-container-itest-karaf/src/test/java/org/apache/aries/jpa/itest/karaf/DSTest.java
+++ b/itests/jpa-container-itest-karaf/src/test/java/org/apache/aries/jpa/itest/karaf/DSTest.java
@@ -16,8 +16,10 @@
 package org.apache.aries.jpa.itest.karaf;
 
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.debugConfiguration;
 
 import java.util.Collection;
+import java.util.Iterator;
 
 import javax.inject.Inject;
 
@@ -25,7 +27,6 @@ import org.apache.aries.jpa.example.tasklist.model.Task;
 import org.apache.aries.jpa.example.tasklist.model.TaskService;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Configuration;
@@ -47,23 +48,24 @@ public class DSTest extends AbstractJPAItest {
         taskService = getService(TaskService.class, null);
     }
     
-    /**
-     * Test currently does not work as data source config is not deployed for unknown reason
-     */
-    @Ignore
     @Test
     public void test() throws BundleException {
         resolveBundles();
-        Assert.assertEquals(0, taskService.getTasks().size());
+        Collection<Task> tasks1 = taskService.getTasks();
+        Assert.assertEquals(1, tasks1.size());
         Task task = new Task();
-        task.setId(1);
-        task.setDescription("My task");
+        task.setId(2);
+        task.setDescription("My task 2");
         taskService.addTask(task);
         Collection<Task> tasks = taskService.getTasks();
-        Assert.assertEquals(1, tasks.size());
-        Task task1  = tasks.iterator().next();
+        Assert.assertEquals(2, tasks.size());
+        Iterator<Task> iterator = tasks.iterator();
+        Task task2  = iterator.next();
+        Assert.assertEquals(2, task2.getId().intValue());
+        Assert.assertEquals("My task 2", task2.getDescription());
+        Task task1  = iterator.next();
         Assert.assertEquals(1, task1.getId().intValue());
-        Assert.assertEquals("My task", task1.getDescription());
+        Assert.assertEquals("Task1", task1.getTitle());
     }
 
     @Configuration
diff --git a/itests/jpa-container-itest-karaf/src/test/resources/org.ops4j.pax.logging.cfg
b/itests/jpa-container-itest-karaf/src/test/resources/org.ops4j.pax.logging.cfg
index edb0278..421488c 100644
--- a/itests/jpa-container-itest-karaf/src/test/resources/org.ops4j.pax.logging.cfg
+++ b/itests/jpa-container-itest-karaf/src/test/resources/org.ops4j.pax.logging.cfg
@@ -15,10 +15,33 @@
 #    specific language governing permissions and limitations
 #    under the License.
 
-log4j.rootLogger=INFO, stdout
-log4j.logger.org.apache.aries.transaction=DEBUG
-log4j.logger.org.apache.aries.transaction.parsing=DEBUG
-log4j.logger.org.apache.aries.jpa.blueprint.impl=DEBUG
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %c | %m%n
+log4j2.appender.console.type = Console
+log4j2.appender.console.name = Console
+log4j2.appender.console.layout.type = PatternLayout
+log4j2.appender.console.layout.pattern = %d{DEFAULT} %-5.5p {%t} [%C.%M()] (%F:%L) : %m%n
+
+log4j2.appender.rolling.type = RollingRandomAccessFile
+log4j2.appender.rolling.name = RollingFile
+log4j2.appender.rolling.fileName = ${karaf.data}/log/karaf.log
+log4j2.appender.rolling.filePattern = ${karaf.data}/log/karaf-%i.log.gz
+log4j2.appender.rolling.append = true
+log4j2.appender.rolling.layout.type = PatternLayout
+log4j2.appender.rolling.layout.pattern = %d{DEFAULT} %-5.5p {%t} [%C.%M()] (%F:%L) : %m%n
+log4j2.appender.rolling.policies.type = Policies
+log4j2.appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
+log4j2.appender.rolling.policies.size.size = 16MB
+log4j2.appender.rolling.strategy.type = DefaultRolloverStrategy
+log4j2.appender.rolling.strategy.max = 20
+
+log4j2.rootLogger.level = INFO
+log4j2.rootLogger.appenderRef.RollingFile.ref = RollingFile
+log4j2.rootLogger.appenderRef.Console.ref = Console
+log4j2.rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter
+log4j2.rootLogger.appenderRef.Console.filter.threshold.level = ${karaf.log.console:-OFF}
+
+log4j2.logger.aries-tx.name = org.apache.aries.transaction
+log4j2.logger.aries-tx.level = DEBUG
+log4j2.logger.aries-jpa.name = org.apache.aries.jpa
+log4j2.logger.aries-jpa.level = DEBUG
+log4j2.logger.h2.name = h2database
+log4j2.logger.h2.level = DEBUG
diff --git a/itests/pom.xml b/itests/pom.xml
index 6a5ded2..b1ea0f7 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -37,7 +37,7 @@
         <paxlogging.version>1.7.3</paxlogging.version>
         <exam.version>4.10.0</exam.version>
         <equinox.version>3.11.3</equinox.version>
-        <url.version>2.5.2</url.version>
+        <url.version>2.6.7</url.version>
         <hibernate42.version>4.2.15.Final</hibernate42.version>
         <ant.bundle.version>1.8.2_2</ant.bundle.version>
         <antlr.bundle.version>2.7.7_5</antlr.bundle.version>
diff --git a/jpa-features/pom.xml b/jpa-features/pom.xml
index 84fdeb7..446a75b 100644
--- a/jpa-features/pom.xml
+++ b/jpa-features/pom.xml
@@ -26,7 +26,7 @@
         <relativePath>../jpa-parent</relativePath>
     </parent>
     <properties>
-        <karaf.version>4.0.3</karaf.version>
+        <karaf.version>4.2.11</karaf.version>
     </properties>
     <artifactId>jpa-features</artifactId>
     <name>Apache Aries JPA features</name>

Mime
View raw message