Pax Exam synchronisation issues

Course Queries Competitions/Entrance Exams 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Competitions/Entrance Exams related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I am using Pax Exam to perform integration tests to my OSGi application. The application is comprised of a number of different bundles which I deploy to the test container using a ConfigurationFactory as follows:

public class TestConfigurationFactory implements ConfigurationFactory {

@Override
public Option[] createConfiguration() {
    return options(
            karafDistributionConfiguration()
                    .frameworkUrl(
                            maven().groupId("org.apache.karaf")
                                    .artifactId("apache-karaf")
                                    .version("3.0.1").type("tar.gz"))
                    .unpackDirectory(new File("target/exam"))
                    .useDeployFolder(false),
            keepRuntimeFolder(),
            // Karaf (own) features.
            KarafDistributionOption.features(
                    maven().groupId("org.apache.karaf.features")
                            .artifactId("standard").classifier("features")
                            .version("3.0.1").type("xml"), "scr"),
            // CXF features.
            KarafDistributionOption.features(maven()
                    .groupId("org.apache.cxf.karaf")
                    .artifactId("apache-cxf").version("2.7.9")
                    .classifier("features").type("xml")),
            // Application features.
            KarafDistributionOption.features(
                    maven().groupId("com.me.project")
                            .artifactId("my-karaf-features")
                            .version("1.0.0-SNAPSHOT")
                            .classifier("features").type("xml"), "my-feature"));
}
}

This works great and I can then write test methods to test my application, I have however the following problem which I understand is in essence a synchronisation issue. One of the bundles I deploy as part of my-feature has an EventHandler which listens for bundles being started and writes some information about each started bundle to the DB. This I assume is something that takes place asynchronously to the execution of my test method. After my test method is executed I can therefore see the following exception in my test output for a query that takes place in my EventHandler:

<openjpa-2.3.0-r422266:1540826 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Failed to execute query "XXX". Check the query syntax for correctness. See nested exception for details.
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:872)[90:org.apache.openjpa:2.3.0]
        at org.apache.openjpa.

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.