Configure Logging for Deltaspike Test-Control - junit

I've CDI based test using following dependencies:
<dependency>
<groupId>org.apache.deltaspike.modules</groupId>
<artifactId>deltaspike-test-control-module-api</artifactId>
<version>1.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.deltaspike.modules</groupId>
<artifactId>deltaspike-test-control-module-impl</artifactId>
<version>1.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.deltaspike.cdictrl</groupId>
<artifactId>deltaspike-cdictrl-weld</artifactId>
<version>1.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>2.2.13.Final</version>
<scope>test</scope>
</dependency>
These are my logging.properties:
.handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$-6s %2$s %5$s%6$s%n
.level=INFO
java.util.logging.ConsoleHandler.level=INFO
When running a test I have these log messages:
2016-04-24 11:10:32 INFORMATION org.apache.deltaspike.core.util.ProjectStageProducer initProjectStage Computed the following DeltaSpike ProjectStage: Production
2016-04-24 11:10:33 INFORMATION org.apache.deltaspike.core.api.config.PropertyLoader loadAllProperties could not find any property files with name META-INF/apache-deltaspike_test-container
2016-04-24 11:10:34 INFORMATION org.apache.deltaspike.testcontrol.api.junit.CdiTestSuiteRunner$LogRunListener testStarted [run] com.foo.Bar#someMethod
2016-04-24 11:10:34 INFORMATION org.apache.deltaspike.testcontrol.api.junit.CdiTestSuiteRunner$LogRunListener testFinished [finished] com.foo.Bar#someMethod
I don't need these messages so I added following configuration to my logging.properties:
org.apache.deltaspike.level=WARNING
Now the first two lines are gone. How can I get rid of the CdiTestSuiteRunner$LogRunListener messages?
Note: I can get rid of these messages with following configuration:
java.util.logging.ConsoleHandler.level=WARNING
But that's oviously not what I want.

I'd consider it a bug in deltaspike. According to https://github.com/apache/deltaspike/blob/master/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestSuiteRunner.java#L155 we're overriding the log level.
I created https://issues.apache.org/jira/browse/DELTASPIKE-1133 to fix.

Related

Reverse engineering with hibernate on a maven project using MySQL

I am trying to apply reverse engineering with hibernate on a maven project using MySQL as a data base, I allredy installed the jBOSS from the market place and configuration properties are successfully created by I have problem with the java.lang.runtimeexception java.lang.reflect.invocationtargetexc
this problem is due with the missing of dependencies of your maven project to resorve that try to add those dependencies in your project
<dependency>
<groupId>hibernate</groupId>
<artifactId>hibernate3</artifactId>
<version>3.2.3.GA</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>

Error:org.apache.commons.logging.LogFactoryjava.lang.NoClassDefFoundError for application build with micronaut-bom1.2.10, graal19.2.1 & aws-sdk2.10.56

Created an application using micronaut bom 1.2.10 version, along with software.amazon.awssdk:lambda:2.10.56 & software.amazon.awssdk:s3:2.10.56 dependencies which had functionality to retrieve data from s3 storage and used graal 19.2.1 to create a native image.
The native image is successfully created but when i try to access the endpoint it fails for below exception:
failed: org.apache.commons.logging.LogFactoryjava.lang.NoClassDefFoundError: org.apache.commons.logging.LogFactory
and series of exceptions with specifically while creating S3 client.
The exception also had failure at below point:
failed: Could not initialize class software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactoryjava.lang.NoClassDefFoundError: Could not initialize class software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory
Code for S3Client :
S3Client s3Client = S3Client.builder().region(getRegion()).build();
build-native-image.sh
${GRAALVM_HOME}/bin/native-image --no-server -cp example-function-*-all.jar
-H:IncludeResources="git.properties"
-H:IncludeResources="logback.xml"
-H:IncludeResources="application.properties" \
So this issue was resolved by adding below configuration in build.gradle:
allprojects {
configurations {
all {
exclude(group = "commons-logging")
}
}
}
and in the dependencies added:
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.30'
I hope this helps.
I faced the same issue, when running tests, with the exact same NoClassDefFoundError but when using AWS sts and secretsmanager libraries. I could actually get it to work by just including the jcl-over-slf4j dependency, while the error happened when using the slf4j-api dependency. I did not need to exclude commons-logging. Snippet of dependency in maven pom.xml that worked:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.17.89</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>secretsmanager</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sts</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
</dependencies>

Integration Test with Couchbase container

I am writing an integration test, which should use a couchbase container.
Using org.testcontainers.couchbase.CouchbaseContainer with
#Rule
public CouchbaseContainer couchbaseContainer = new CouchbaseContainer()
.withNewBucket(DefaultBucketSettings.builder()
.enableFlush(true)
.name("xxx").password("123456")
.quota(100)
.type(BucketType.COUCHBASE)
.build());
I get an error:
Caused by: com.couchbase.client.java.error.InvalidPasswordException: Passwords for bucket "xxx" do not match.
at com.couchbase.client.java.CouchbaseAsyncCluster$OpenBucketErrorHandler.call(CouchbaseAsyncCluster.java:651)
When I looked inside the container, I could see that bucket whose created without the user. (In order to be able to use that bucket, a user, with the same name must be created, and user's password is actually password to enter the bucket).
While not providing UserSettings, withNewBucket method generates user with all roles. I tried to add custome UserSettings, but the result was the same - user wasn't created.
Using
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>couchbase-client</artifactId>
<version>1.4.13</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>couchbase</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>jdbc</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>java-client</artifactId>
<version>2.5.9</version>
</dependency>
Any help is appreciated.

cannot resolve symbol "cucumber" in IntelliJ

I am seeing "cannot resolve cucumber" error even after adding "cucumber-java" in my POM
I also have tried adding "junt" to POM, but the issue is not resolved
After spending lot of time, I found the issue with the dependencies in POM. We have to add both "cucumber-java" and "cucumber-junit" to POM.xml in your maven project
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>

jodd exmple error: Please provide ConnectionProvider implementation

i see the Jodd in 30 minutes and download the example.
but when i run the project, tomcat console
806 [ERROR] j.j.c.DefaultAppCore.start:278 - java.lang.UnsupportedOperationException: Please provide ConnectionProvider implementation.
java.lang.UnsupportedOperationException: Please provide ConnectionProvider implementation.
at jodd.joy.core.DefaultAppCore.createConnectionProvider(DefaultAppCore.java:612)
at jodd.joy.core.DefaultAppCore.startDb(DefaultAppCore.java:562)
at jodd.joy.core.DefaultAppCore.start(DefaultAppCore.java:272)
at jodd.joy.core.DefaultWebApplication.initWebApplication(DefaultWebApplication.java:57)
at jodd.madvoc.Madvoc.start(Madvoc.java:205)
at jodd.madvoc.Madvoc.startNewWebApplication(Madvoc.java:180)
at jodd.madvoc.MadvocContextListener.contextInitialized(MadvocContextListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4738)
i use eclipse maven mysql
i import mysql jdbc and jodd db.
i dont know what is missing or where my mistake?
my pom.xml :
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jodd/jodd-joy -->
<dependency>
<groupId>org.jodd</groupId>
<artifactId>jodd-joy</artifactId>
<version>3.7.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jodd/jodd-bean -->
<dependency>
<groupId>org.jodd</groupId>
<artifactId>jodd-bean</artifactId>
<version>3.7.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jodd/jodd-http -->
<dependency>
<groupId>org.jodd</groupId>
<artifactId>jodd-http</artifactId>
<version>3.7.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
</dependencies>
Please try to use Jodd 3.7.0.
For some reason, our implementation was of provider was not bundled with 3.7.1. It will be returned in next version.
Or just take the code from here