By the way, it would be nice to be able to check the generated test.war for if the resources are included correctly. But since it is undeployed after the test, it disappears immediately.
As long as the src/test/resources directory is in the classpath, you need the following VM argument:
1 of 1 people found this helpful
After you build the archive, send this to sysout:
Thank you for the answers.
Ok archive.toString lets you see the structure, although not check the real test.war.
Is there an option to tell Arquillian not to undeploy the test.war after the test? Or to drop the file in another location?
The VM argument didn't do any effect. The output folder of src/test/resources is target/test-classes.
I hope I understand correctly what you mean.
I run the test in Eclipse, Run Configurations, Maven Build with goal test.There, you cannot control the class path explicitly. I guess Maven takes care of it, right? In the JRE tab I add the argument.
Where is the log file supposed to appear if I use a simple appender file name without path? In the base directory of the run? Or in a JBoss folder?
Thanks in advance,
I would start by seeing where it is picking up the log4j.properties from.
Add this to your VM arguments:
Watch in the console of the JUnit/TestNG run and see if it is using your log4j.properties.
If not, I would get that right first.
I have found that the log messages are all written to the jboss server.log.
If I explicitly initialize log4j in the test:
Logger log = Logger.getLogger(EstabTypeTest.class);
I get in the jboss console:
19:21:07,480 ERROR [STDERR] log4j:ERROR Could not read configuration file [log4j.properties].
19:21:07,480 ERROR [STDERR] java.io.FileNotFoundException: log4j.properties (El sistema no puede encontrar el archivo especificado)
19:21:07,481 ERROR [STDERR] at java.io.FileInputStream.open(Native Method)
19:21:07,481 ERROR [STDERR] at java.io.FileInputStream.<init>(FileInputStream.java:106)
19:21:07,481 ERROR [STDERR] at java.io.FileInputStream.<init>(FileInputStream.java:66)
19:21:07,481 ERROR [STDERR] at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:306)
19:21:07,502 ERROR [STDERR] log4j:ERROR Ignoring configuration file [log4j.properties].
19:21:07,503 INFO [STDOUT] log: org.jboss.logmanager.log4j.BridgeLogger@5a90f357
Although log4j.properties is in target/test-classes and I can see in the Maven debug output that the folder is added to the class-path.
[DEBUG] Test Classpath :
The path is also in the manifest of the surefire jar file in target/surefire.
On other hand, if I put the absolute path in PropertyConfigurator.configure(), then the file is created. But all messages are nevertheless written to the jboss.log.
1 of 1 people found this helpful
There is JUnit/TestNG logging (where you can see output from arquillian bundling, deploying, method invocation, undeploying...).
There is JBoss logging (where you can see output from within the @test methods).
I don't bundle anything in the test.jar for logging.
Edit server\default\deploy\jboss-logging.xml and change the console level to whatever you want (requires JBoss restart).
Then in your class, do this:
private static Logger logger = Logger.getLogger(YourTestClass.class);
logger.info("this will go to the Jboss console if the level is set correctly");
Let me know if that helps...
Ok that works, but what I really want is writing the log to my own log file. I found how to do it, but hit this known bug:
So let's wait until this is fixed.