Log Output in DBUnit - dbunit

I feel that this is something I could easily figure out but I'm having a hard time finding information on how to change the log level of DBUnit. Can anyone solve this problem for me?

After avoiding the problem for a while, I came to a solution.
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.util.StatusPrinter;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
Logger logger = (Logger)LoggerFactory.getLogger("org.dbunit")
logger.setLevel(Level. ERROR);
Hopefully this lead someone to a solution to their own similar problem.

When using log4j add the following to your log4j.properties:
# DbUnit
log4j.logger.org.dbunit=ERROR

When using Spring Boot, you may simply add the following property to your application.properties:
logging.level.org.dbunit: ERROR

Related

Registering a resteasy service in a Quarkus extension

I am currently attempting to write my first Quarkus extension, which needs to deploy a rest service. For that purpose I have been looking at the Quarkus tutorial for creating extensions here, and it is pretty close to what I need to do. The problem is that it shows a Servlet, and I would very much like to deploy a RestEasy(Jackson) service instead.
I have created an extension project and added the following service in the runtime module
package my.test.quarkus.extension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
#Path("/mytest")
public class TestEndpoint {
private static Logger LOGGER = LoggerFactory.getLogger(TestEndpoint.class);
#POST
#Path("/service")
public void testService(){
LOGGER.info("Logit!");
}
}
But the service is not being picked up it seems, as my test returns 404.
package my.test.quarkus.extension.test;
import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
public class ExtensionTest {
#RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withEmptyApplication();
#Test
public void testGreeting() {
RestAssured.when().post("/mytest/service").then().statusCode(200);
}
}
I assume i need a BuildItem registering the service inside the deployment project of my extension, but my question is, which BuildItem do i use? Looking at the list of BuildItems there are loads of them, and even filtering those out that has nothing to do with RestEasy, still leaves over 50, most of them without JavaDoc.
If someone can help me with the problem at hand, simply registering a RestEasy service, as well as an interceptor, from an extension, that would be appreciated. And you will get bonus gratitude if you can explain exactly how to navigate through the Quarkus BuildItems when building extensions, because to me it just seems like a jungle of code, but I am guessing I am missing something.

Spring security test with user

At https://docs.spring.io/spring-security/site/docs/4.0.4.RELEASE/reference/html/test-mockmvc.html
I see test example
mvc.perform(get("/admin").with(user("admin").password("pass")...
What imports I have to perform for using
user("admin")
and
password("pass")
ok, don't bother it is
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*;

How can we access the java security package in Jmeter?

I need to access the security package in Java using Jmeter on Bean Shell. Is there anyway to do this ?
I have got error like this.
Sourced file: inline evaluation of: ``import android.util.Base64.*; import java.security.spec.X509EncodedKeySpec;
Help on this is useful!
I suspect the problem is with import android.util.Base64.* - android package is not part of Java. You probably meant to have
import java.util.Base64;
Note that you need to have Java 8

missing dependencies in latest spring security test

I need to resolve certain methods (status, jsonPath, content) mentioned in code shown below -
mockMvc.perform(MockMvcRequestBuilders.get("/api/token")
.with(getAuthentication(getOauthTestAuthentication()))
.sessionAttr("scopedTarget.oauth2ClientContext", getOauth2ClientContext()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.username").value("cominventor"))
.andExpect(jsonPath("$.token").value("my-fun-token"));
When I searched for related projects containing these methods, many of them are importing the following
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
The problem is that I am unable to find a counterpart in package spring-security-test with version 4.2.2.RELEASE
The closest options that could have worked but haven't are
import static org.springframework.test.web.servlet.ResultMatcher.*;
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.*;
The above don't contain the methods I am looking for. Any idea where should I look for these methods or their newer counterparts.
Everything worked out once I set the spring-security-test version to 4.0.2.RELEASE
I had the same problem, and I solved it importing the artifact
org.springframework.security:spring-security-test:4.2.3.RELEASE
I am using spring-boot-starter-test:1.5.3, and for some reason the folks at Spring decided not to include spring-security-test in its POM.

liferay event listener

i have some hard task, i need to change some part of my project using jboss portal 2.7.2 into liferay. Ofc less change better but all jboss portal must disappear. I need 2 replace classes below. So my question is how using liferay portal implements(or not(if already exist)) listener which will know when someone is trying 2 log in. Make login possible without reloading etc. Ofc it was nice if there was some pro eventlistener in liferay which can recognise other events not only logging but i will be glad for all help. 4 the rest of this class will be nice if someone know replacment 4 them in liferay.
import org.jboss.portal.api.event.PortalEvent;
import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.api.event.PortalEventListener;
import org.jboss.portal.api.session.PortalSession;
import org.jboss.portal.api.user.event.UserAuthenticationEvent;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
import org.jboss.portal.identity.UserProfileModule;
Liferay has similar approache. Create a Hook and add properties like http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/extending-and-overriding-%3Cem%3Eportal-properties%3C-e-1
With the properties you can specificy wich class schould be call by the portal events:
login.events.post=my.package.AfterLoginHandler
with the same approche you can listen to creating/changes/removes of entities:
value.object.listener.com.liferay.portal.model.User=my.package.UserListener
value.object.listener.com.liferay.portal.model.Layout=my.package.LayoutListener
...
Liferay does allow adding handlers to login events. More information can be found # http://www.learnercorner.in/topics?showTopic=16001

Resources