How i can add some jvm options to arquillian test - testing

Its possible to add some jvm options to embedded glassfish using arquillian ?
I need to add that jvm options:
-Djavax.net.ssl.keyStorePassword=changeit
-Djavax.net.ssl.trustStorePassword=changeit

Java properties on Glassfish are configured in domain.xml. Since you are running an embedded Glassfish, you don't really have a domain.xml file you could modify. You can try to do this in arquillian.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<arquillian xmlns="http://www.jboss.org/arquillian-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/arquillian-1.0 http://jboss.org/schema/arquillian/arquillian-1.0.xsd">
<engine>
<property name="deploymentExportPath">target/</property>
</engine>
<container qualifier="glassfish" default="true">
<configuration>
<property name="configurationXml">file:src/test/resources/domain.xml</property>
...
</configuration>
</container>
</arquillian>
The configurationXml property is used to pass the configuration file to use for the embedded insance. See also https://docs.jboss.org/author/display/ARQ/GlassFish+3.1+-+Embedded. domain.xml itself has a section for JVM arguments.

Related

How to fix NoClassDefFoundError error with Aquillian

Hi I set up Arquillian with Wildfly 10 embedded, which is loaded into the target folder.
I see two mistakes at the moment:
Cannot not load JBoss LogManager. The LogManager has likely been accessed prior to this initialization.
java.lang.NoClassDefFoundError: org/jboss/remoting3/spi/ConnectionProviderFactory
The first one I hope I can ignore. The second one I can't solve. Any idea why?
The ejb has dependency to four external ejbs over JNDI. In the arquillian.xml I mentioned nothing about this dependency.
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="wildfly10" default="true">
<configuration>
<property name="jbossHome">target/wildfly-10.0.0.Final/</property>
<property name="modulePath">target/wildfly-10.0.0.Final/modules</property>
</configuration>
</container>
</arquillian>
Where does the second error comes from? How can I solve it?
Thanks,
Markus
Ok, solved it was a Maven exclusion problem. :-(

Apply play framework evolution in test Environment

I am set up my play framework jpa as following:
in application.conf:
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
db.default.user=sa
db.default.password=""
applyEvolutions.default=true
db.default.jndiName=DefaultDS
jpa.default=defaultPersistenceUnit
persistence.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
I am start play in test as this:
start(fakeApplication(inMemoryDatabase(), globalSettings));
running this project working well but testing it fails because of lacking database evolution!
How can I enable Play Framework evolution in test environment?
I am using hibernate 3.6
Force down evolutions too in your application.conf :
applyDownEvolutions.default=true
Be careful, if you use the same conf file in production.
Try to set hibernate.hbm2ddl.auto to "none" and hence your evolutions should apply correctly.
I guess hibernate "assumes control" before the evolution plugin and that causes problem. You may try to modify plugin loading order (JPAPlugin vs EvolutionPlugin) to see if it makes any difference.

How to externalize properties of persistence.xml for JBOSS 7.1.1?

My persistence.xml is currently present in the application war(in META-INF folder.). However, for the application to be run across multiple DBs the persistence needs to be changed again and again. I want to avoid it. But, I am not able to understand how will i configure the properties(like dialect) in the persistence.xml from, say, a property file which i would change based on my DB, hence not compelling me to update and redeploy my war.
My problem can also be resolved if i can configure the dialect in the datasource in standalone.xml where i have mentioned other DB details. I am not being able to make out what the property would be.
Though i would prefer a solution for the first one.
PS: I am rookie in Web App development. Questions might annoy you. :D
I use a method that works well for hibernate.
1) put the hibernate configuration properties in a xml file (call it hibernate.cfg.xml but it's not mandatory)
this is an example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.search.default.directory_provider">ram</property>
</session-factory>
</hibernate-configuration>
you can put there only hibernate properties that do not start with hibernate.ejb
2) Create a jboss module. It's very simple. Suppose you want to call the module com.myorganization.config than create a directory structure in the modules folder of you server installation: /com/myorganization/config/main. In the main folder put the hibernate.cfg.xml file and the following module.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.myorganization.config">
<resources>
<resource-root path="."/>
</resources>
</module>
3) In your persistence.xml adding the following property:
<property name="hibernate.ejb.cfgfile" value="/hibernate.cfg.xml" />
4) Finally, in the META-INF/MANIFEST.MF file add the following line:
Dependencies: com.myorganization.config
If you like maven use the maven-war-plugin in order to change the MANIFEST.MF:
<configuration>
<archive>
<manifestEntries>
<Dependencies>com.myorganization.config</Dependencies>
</manifestEntries>
</archive>
</configuration>
That's all.

Debugging remote container with arquillian fails

Debugging remote container jboss7.1.1 fails with arquillian. I set the debugging conf in the standalone.conf.bat as described here https://community.jboss.org/wiki/WhyDontBreakPointsWorkWhenDebugging. But that doesn't starts the jboss in debugging mode.
Consoleoutput:
INFO: Starting container with: [D:\java\jdk1.6.0_22\bin\java, -Xmx512m,
-XX:MaxPermSize=128m, -ea, -Djboss.home.dir=target/jboss-as-7.1.1.Final,
...
Using arquillian 1.0.3.Final.
If you use a managed container and arquillian is starting JBoss AS for you, you need to add the option to arquillian.xml. Something like:
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<engine>
<property name="deploymentExportPath">target/</property>
</engine>
<container qualifier="jboss" default="true">
<protocol type="jmx-as7">
<property name="executionType">REMOTE</property>
</protocol>
<configuration>
<property name="jbossHome">${basedir}/target/jboss-as-${jbossas.version}</property>
<property name="javaVmArguments">-Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y -Xmx512m -XX:MaxPermSize=128m</property>
</configuration>
</container>
</arquillian>

Maven - POM: How to make the jetty port changeable so that it can be retrieved later?

I'm working on an integration test suite and I've got a question for you.
My parent pom defines the use of the jetty plugin with the goal: run-war. I need to make the port that jetty listens on changeable via the command-line. This can be achieved by passing -Djetty.port=8099 for example.
In the child project, I need to use this port number to configure the endpoint for some SOAP tests that I'll need to run on the service hosted by jetty.
If I use ${jetty.port} in my child pom in the end-point configuration this works fine IF and only IF I explicitly pass -Djetty.port when invoking maven.
In my child pom:
<endpoint>http://127.0.0.1:${jetty.port}/{artifactId}<endpoint>
I need jetty.port to be filled in with 8080 which is what jetty defaults to if -Djetty.port is not explicitly passed, and still catch any other port values if the command line argument is specified.
Use the properties section, and add a jetty.port property with a default value:
<properties>
<jetty.port>8080</jetty.port>
</properties>
config maven jetty plugin:
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1H.14.1</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8085</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
</plugins>
If you want to use a newer version of jetty plugin, use the following configuration:
From http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html:
You could instead configure the connectors in a standard jetty xml config file and put its location into the jettyXml parameter. Note that since jetty-9.0 it is no longer possible to configure a https connector directly in the pom.xml: you need to use jetty xml config files to do it.
Something like:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.0.5.v20130815</version>
<configuration>
<jettyXml>src/main/resources/jetty.xml</jettyXml>
<webApp>
<contextPath>/yourCtxPath</contextPath>
</webApp>
</configuration>
</plugin>
would do the trick, with
jetty.xml file content:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call id="httpsConnector" name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg>
<Set name="host"><Property name="jetty.host" /></Set>
<Set name="port"><Property name="jetty.port" default="8085" /></Set>
<Set name="idleTimeout">30000</Set>
</New>
</Arg>
</Call>
</Configure>
See the log after 'mvn jetty:run', at the end should show something like:
2013-09-05 09:49:05.047:INFO:oejs.ServerConnector:main: Started ServerConnector#a6e9cb4{HTTP/1.1}{0.0.0.0:8085}
You will need to use maven 3 and java 7 for this version of plugin.