Setting Tracing On for apache camel - grails

I want to test my integration test cases, for that i want to set my camel tracing on to debug my test cases.
how to do this in grails any idea? I am using log4j for logging.

From Camel 2.12 onwards you must explicit enable tracing on the CamelContext. The class contains setTracing(Boolean enabled) method.
So if you are using XML DSL:
<camelContext trace="true" ...>
otherwise:
camelContext.setTracing(true)
To setup logging is quite trivial I supposed.

Related

Is it possible to use Micronaut Declarative HTTP client in grails 4 functional API tests?

I am trying to create a Declarative client to test the API I am writing in grails 4, like you can do it in micronaut.
As far as I have come, you can create a declarative client if you know the base URL at compile time. Because the grails functional (integration) tests create a server on a random port, you cannot know that port beforehand and use the #Client('http://localhost:8080') annotation.
Using something like #Client('http://localhost:${local.server.port}') fails with grails complaining that the configuration property cannot be looked up.
Is there something I am missing?
Is it possible to use Micronnaut Declarative HTTP client in grails 4
functional API tests?
It is.
A problem with doing that is that when using #Client('/') to connect to the local running server, an EmbeddedServer bean needs to be configured in the context to answer the question of what port the app is running on. Some of the relevant code is at https://github.com/micronaut-projects/micronaut-core/blob/458bbf07221407abe7e283815fb62b7b4d1fc224/http-client-core/src/main/java/io/micronaut/http/client/DefaultLoadBalancerResolver.java#L93.
We will add testing support to make this easier but you can make it work by registering the bean yourself. See the following:
src/integration-test/groovy/com/objectcomputing/example/TestEmbeddedServer.groovy
src/integration-test/groovy/com/objectcomputing/example/BookClient.groovy
src/integration-test/groovy/com/objectcomputing/example/EmbeddedServerTest.groovy
src/integration-test/groovy/com/objectcomputing/example/BookFunctionalSpec.groovy
That is a kludge for now, but I believe it will work until proper support is released in the testing framework.

Configure Flogger with log4j2 backend

I try to use flogger with the log4j2 backend. Seems to work fine.
My problem is, how to configure output pattern, output level or appenders in general using log4j files (xml or properties).
If using this constellation without any configuration, only level error is logged.
OK, I missed to add log4j-web package, so everything was fine in a standalone app, but this package is needed in a web application

Order of Grails Bootstrap classes

On one of our feature branches of our project we have a strange issue with running our grails integration tests. In our application we have the base project and one plugin, which relies on data from the base application. The default data is created in the "Bootstrap" Classes of the project and the plugin.
since yesterday the bootstrap of the plugin is called before the base bootstrap, and fails, because of the missing data from the application. This happens only if we run the integration tests, and only on our buildserver (Windows Server 2012 with Atlassian Bamboo).
test-app -integration --stacktrace -non-interactive
how can we fix this problem?
Grails makes no guarantees about ordering of BootStrap classes so it isn't something that should be relied about in your application.
If you need to control ordering of logic that is run at startup there are better solutions, for example you could use the platform-core plugin's event model to trigger an event in your application that your plugin listens to once the data it needs is in place. See http://grails-plugins.github.io/grails-platform-core/guide/events.html

Empty fields are validated on one environment but not on other environment

I have the same JSF war deployed in two environments, both environments are apparently identical (Weblogic 10.3.3). There is no entry in the web.xml for javax.faces.VALIDATE_EMPTY_FIELDS.
In one of the environments, the validators are getting invoked on empty fields and in the other they are not.
The JSF war and the application code is EXACTLY the same.
The JSF Specification version is 2.0 and Implementation Version is 1.0.0.0_2-0-2. I know I can add the parameter javax.faces.VALIDATE_EMPTY_FIELDS in web.xml to ensure identical behavior in all environments, but I want to know why they have a different default behavior? Is it possible that it could be something related to presence of JSR 303 validation in one environment and not in another? How do I check this?
JSR 303 validation is auto enabled if the implementation jar is on the classpath.

how can i use log4j in grails application?

how can i use log4j in grails application?
Look at the Logging section of the manual.
log4j is built in and has a basic configuration out of the box.
You could use log4j right from the box, for example:
log.debug "The value of foo is $foo"
Configuration of logging in last version
If you are into unit testing be sure to check mockLogging method in Testing section.

Resources