Get java.util.logging working on UnitTesting

If you need to active the java.util.logging on your test, you can achieve it just adding the vm option
-Djava.util.logging.config.file=/path/to/logging.properties

where logging.properties can be something like

handlers = java.util.logging.ConsoleHandler
.level=INFO
your.package.level = FINE
java.util.logging.ConsoleHandler.level = FINE

You can find a more complete example on https://svn.apache.org/repos/asf/river/jtsk/skunk/surrogate/testfiles/logging.properties

,

Run nano on docker ubuntu image

I have tried to run nano on an ubuntu docker image and after installing it I always have this error:
Error opening terminal: unknown.

The solution is so easy as to run into the docker image export TERM=xterm

Problem is that it does not survive the restart, as in any bash session actually. I will try to add it on the Dockerfile but why that the term is set on the run command I am not very optimistic with it.

I have tried to run nano on an ubuntu docker image and after installing it I always have this error:
Error opening terminal: unknown.

The solution is so easy as to run into the docker image export TERM=xterm

Use multiple parameters with jjs in linux shebang script

If you try to use multiple parameters in the script on a linux OS like this,
#!/usr/bin/jjs -strict -scripting -fv

you will see something like this:
"-strict -scripting -fv" is not a recognized option. Use “-h” or “-help” to see a list of all supported options.

That happens because the linux interpreter is using all the parameters as a unique parameter.
The workaround is to use the *-J-Dnashorn.args* like

#!/usr/bin/jjs -J-Dnashorn.args= -strict -scripting -fv

If you try to use multiple parameters in the script on a linux OS like this,

#!/usr/bin/jjs -strict -scripting -fv

you will see something like this:

"-strict -scripting -fv" is not a recognized option. Use "-h" or "-help" to see a list of all supported options.

That happens because the linux interpreter is using all the parameters as a unique parameter.
The work around is to use the -J-Dnashorn.args like
#!/usr/bin/jjs -J-Dnashorn.args= -strict -scripting -fv
and it will work like a breeze.

Load test data to DB with javaEE

In the persistence.xml file, it is possible to use the property javax.persistence.sql-load-script-source
This property allows you to populate your datasource with given data.
The value is just a sql script file containing the insert statements to be used.
Analogous, you can also use properties to drop data. Many other options are available. If you are interested, just take a look at the section *9.4 Schema Generation* from [*JSR-000338 JavaTM Persistence 2.1*](http://download.oracle.com/otndocs/jcp/persistence-2_1-fr-eval-spec/index.html)

My persistence.xml file is like follows:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="Cookinghelper" transaction-type="JTA">
    <jta-data-source>java:jboss/datasources/cookinghelper</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
        <property name="hibernate.show_sql" value = "false" />
        <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
        <property name="javax.persistence.sql-load-script-source" value="META-INF/test-data.sql"/>
    </properties>
</persistence-unit>
</persistence>

Run Vert.x app from intellij

To run Vert.x on intelliJ, it is only required to create a standard application Launcher with the following parameters:

  • Main class: the vert.x main class, i.e. io.vertx.core.Starter or whatever it is for your version.
  • VM options: whatever you need or empty
  • Program arguments: run de.lacambra.vertx.MyFirstVerticle
  • Working directory: normally your project directory