问:
Adding Plugin to Kibana Image in docker-compose.yml
I am new to using docker and trying to add the elastalert plugin to my kibana image. I am using Kibana 7.0.1 and Elasticsearch 7.0.1 and trying to use the elastalert 7.0.1 kibana plugin from github. When I run docker-compose up using the below docker-compose.yml file it does seem to install the plugin, but it doesn't actually start up kibana. Am I missing another command? Thanks

```<code>services:
    ...
    kibana:
        image: docker.elastic.co/kibana/kibana:7.0.1
        ...
        command: ./bin/kibana-plugin install https://github.com/bitsensor/elastalert-kibana-plugin/releases/download/1.0.4/elastalert-kibana-plugin-1.0.4-7.0.1.zip
</code>```

答:
So when you override command section you must remember to keep existing behavior which is set by image author.

So in you case you can actually install kibana plugin this way but you must also add Kibana start at the end of the command by using e.g. && to run process after plugin installation. So in your case it should be:

```<code>     command: sh -c './bin/kibana-plugin install https://github.com/bitsensor/elastalert-kibana-plugin/releases/download/1.0.4/elastalert-kibana-plugin-1.0.4-7.0.1.zip && exec /usr/local/bin/kibana-docker'
</code>```

Body:
I am new to using docker and trying to add the elastalert plugin to my kibana image. I am using Kibana 7.0.1 and Elasticsearch 7.0.1 and trying to use the elastalert 7.0.1 kibana plugin from github. When I run docker-compose up using the below docker-compose.yml file it does seem to install the plugin, but it doesn't actually start up kibana. Am I missing another command? Thanks

services:
    ...
    kibana:
        image: docker.elastic.co/kibana/kibana:7.0.1
        ...
        command: ./bin/kibana-plugin install https://github.com/bitsensor/elastalert-kibana-plugin/releases/download/1.0.4/elastalert-kibana-plugin-1.0.4-7.0.1.zip

Body:
So when you override command section you must remember to keep existing behavior which is set by image author.

So in you case you can actually install kibana plugin this way but you must also add Kibana start at the end of the command by using e.g. && to run process after plugin installation. So in your case it should be:

     command: sh -c './bin/kibana-plugin install https://github.com/bitsensor/elastalert-kibana-plugin/releases/download/1.0.4/elastalert-kibana-plugin-1.0.4-7.0.1.zip && exec /usr/local/bin/kibana-docker'


来源: stackexchange

问:
Why doesn't my use of "protected" work?
I have read that a protected member can be accessed from derived classes, but the following does not work.</p>

```<code>class A
{
    protected int Test;
}
class B:A
{
    A instanceOfA= new A()

    public B()
    {
        instanceOfA.Test //Not possible
    }
}
</code>```

答:
You haven't set up your code correctly. Class B shouldn't have an instance of class A. Instead class B itself inherits the protected variables from class A.

Your code should look more like:

```<code>class A
{
   protected int Test;
}
class B:A
{
   public B()
   {
       int someInt = this.Test;
   }
}
</code>```

ContentLicense: CC BY-SA 3.0

Title: Why doesn't my use of "protected" work?

Body:
I have read that a protected member can be accessed from derived classes, but the following does not work.

class A
{
    protected int Test;
}
class B:A
{
    A instanceOfA= new A()

    public B()
    {
        instanceOfA.Test //Not possible
    }
}

Body:
You haven't set up your code correctly. Class B shouldn't have an instance of class A. Instead class B itself inherits the protected variables from class A.

Your code should look more like:

class A
{
   protected int Test;
}
class B:A
{
   public B()
   {
       int someInt = this.Test;
   }
}


问:
Restart the codeblock with a while-loop
Problem: I would like to restart my codeblock after the error message.

Console.Write("\tBitte geben Sie ihre erste Zahl ein: ");

if (!double.TryParse(Console.ReadLine(), out zahl1))
    Console.WriteLine("\tUngültige Eingabe. Bitte geben Sie nur Zahlen an!");
```

答:
Use a do ... while loop:

```<code>bool error;
do
{
    Console.Write("\tBitte geben Sie ihre erste Zahl ein: ");
    error = !double.TryParse(Console.ReadLine(), out zahl1);
    if (error)
        Console.WriteLine("\tUngültige Eingabe. Bitte geben Sie nur Zahlen an!");
} while(error);
</code>```

ContentLicense: CC BY-SA 4.0

Title: Restart the codeblock with a while-loop

Body:
Use a do ... while loop:

bool error;
do
{
    Console.Write("\tBitte geben Sie ihre erste Zahl ein: ");
    error = !double.TryParse(Console.ReadLine(), out zahl1);
    if (error)
        Console.WriteLine("\tUngültige Eingabe. Bitte geben Sie nur Zahlen an!");
} while(error);


问:
Show text vertically and counter-clockwise in any table cells
I have the following CSS and table with choice 3 and choice 4 vertically displayed but clockwise. I would like to show choice 3 and choice 4 vertically and counter-clockwise. I am not able to find style values for text-orientation for my need.

Note that text choice 3 and choice 4 are just examples, and the real texts could be quite long. I am looking for a solution that can apply to any cells in a table (and preferably center the text horizontally if a cell's space is quite wide).

.rotate {
  writing-mode: vertical-rl;
  text-orientation: mixed;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table>
  <tr>
    <td></td>
    <td>choice 1</td>
    <td>choice 2</td>
    <td>total</td>
  </tr>
  <tr>
    <td>
      <div class="rotate">choice 3</div>
    </td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td>
      <div class="rotate">choice 4</div>
    </td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td>total</td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table></code>```

Update
Here is my real table.

Here is a pic of testing display: flex

答:
You can add transform: rotate(180deg);

A quick note

Internet Explorer supports different values from an earlier version of
  the spec, which originated from SVG.

Source

Which vertical-rl is not included, therefore this  isn't going to work as expected in Internet Explorer

.rotate {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table>
  <tr>
    <td></td>
    <td>choice 1</td>
    <td>choice 2</td>
    <td>total</td>
  </tr>
  <tr>
    <td>
      <div class="rotate">choice 3</div>
    </td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td>
      <div class="rotate">choice 4</div>
    </td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td>total</td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table></code>```

Body:
I have the following CSS and table with choice 3 and choice 4 vertically displayed but clockwise. I would like to show choice 3 and choice 4 vertically and counter-clockwise. I am not able to find style values for text-orientation for my need.

Note that text choice 3 and choice 4 are just examples, and the real texts could be quite long. I am looking for a solution that can apply to any cells in a table (and preferably center the text horizontally if a cell's space is quite wide).

.rotate {
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

    choice 1
    choice 2
    total

choice 3

choice 4

    total

Update
Here is my real table.

Here is a pic of testing display: flex

Body:
You can add transform: rotate(180deg);

A quick note

Internet Explorer supports different values from an earlier version of
  the spec, which originated from SVG.

Source

Which vertical-rl is not included, therefore this  isn't going to work as expected in Internet Explorer

.rotate {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

<table>
  <tr>
    <td></td>
    <td>choice 1</td>
    <td>choice 2</td>
    <td>total</td>
  </tr>
  <tr>
    <td>
      <div class="rotate">choice 3</div>
    </td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td>
      <div class="rotate">choice 4</div>
    </td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td>total</td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table>


问:
How to fix jQuery media query that works with console.log() but not proper code
I am trying to change the background image of an element based on screen width and the reason I can't use CSS is because the image path is pulled in to the template using PHP.

I have tried several different methods of jQuery media query and the method I am using now does work because I added different messages inside console.log() and these displayed correctly.

When I replace the console.log() with the code for changing the image, it doesn't work.

var image;
jQuery(window).resize(function() {
  if (jQuery(window).width() <= 800) {
    var image = '<?php the_field("mobile_header_background"); ?>';
    var css = 'url(' + image + ') no-repeat center;';
    jQuery('.homehead').css("background", css);
  } else {
    var image = '<?php the_field("header_background"); ?>';
    var css = 'url(' + image + ') no-repeat center;';
    jQuery('.homehead').css("background", css);
  }
});
```

<pre class="lang-html prettyprint-override"><code><div class="homehead" style="background: url() no-repeat center; background-size: cover;">
</code>```

I expect the background value of the homehead div to update accordingly but it's just not working.

Edit:

I have just tried simplifying the code a bit removing the need for variables and outputting the image path straight in to the .css function but this also didn't work despite outputting the image path correctly.

jQuery(window).resize(function() {
  if (jQuery(window).width() <= 800) {
    jQuery(".homehead").css("background-image","url(<?php the_field('mobile_header_background'); ?>)");
  } else {
    jQuery(".homehead").css("background-image","url(<?php the_field('header_background'); ?>)");
  }
});
```

<pre class="lang-html prettyprint-override"><code><div class="homehead" style="background-image: url(); background-repeat: no-repeat; background-position: center; background-size: cover;">
</code>```

答:
The problem is that jQuery is ignoring the css setting because they don't like the syntax. If you remove the semicolon from the end of the css string, like

```<code>var css = 'url(' + image + ') no-repeat center';
</code>```

instead of

```<code>var css = 'url(' + image + ') no-repeat center;';
</code>```

it should work.

Just keep in mind that this code will only run on resize. You may want to run it on page load as well. I'd suggest moving the code into a named function and calling that on load, as well as passing it into the resize handler.

Body:
I am trying to change the background image of an element based on screen width and the reason I can't use CSS is because the image path is pulled in to the template using PHP.

I have tried several different methods of jQuery media query and the method I am using now does work because I added different messages inside console.log() and these displayed correctly.

When I replace the console.log() with the code for changing the image, it doesn't work.

var image;
jQuery(window).resize(function() {
  if (jQuery(window).width() <= 800) {
    var image = '<?php the_field("mobile_header_background"); ?>';
    var css = 'url(' + image + ') no-repeat center;';
    jQuery('.homehead').css("background", css);
  } else {
    var image = '<?php the_field("header_background"); ?>';
    var css = 'url(' + image + ') no-repeat center;';
    jQuery('.homehead').css("background", css);
  }
});

I expect the background value of the homehead div to update accordingly but it's just not working.

Edit:

I have just tried simplifying the code a bit removing the need for variables and outputting the image path straight in to the .css function but this also didn't work despite outputting the image path correctly.

jQuery(window).resize(function() {
  if (jQuery(window).width() <= 800) {
    jQuery(".homehead").css("background-image","url(<?php the_field('mobile_header_background'); ?>)");
  } else {
    jQuery(".homehead").css("background-image","url(<?php the_field('header_background'); ?>)");
  }
});

Body:
The problem is that jQuery is ignoring the css setting because they don't like the syntax. If you remove the semicolon from the end of the css string, like

var css = 'url(' + image + ') no-repeat center';

instead of

var css = 'url(' + image + ') no-repeat center;';

it should work.

Just keep in mind that this code will only run on resize. You may want to run it on page load as well. I'd suggest moving the code into a named function and calling that on load, as well as passing it into the resize handler.


问:
Insert Data With Carriage Returns
I have a command button that inserts data in to a worksheet from a userform, it then saves it as a .csv.

We then load the csv data using another userform - However, the problem arises when a Carriage Returns is inserted into a text box and inserted. Obviously the first solution I can think of is to stop commas being entered - however, is there a better solution?

答:
@Miguel has the right idea (his comment is on the main question thread).

This approach involves defining a list of integers relating to the ASCII codes for the characters you're having trouble with.  Line feed (10) will definitely be in there and you can decide on carriage return (13) commas (44) or speech marks (34).

const ListOfSpecialChars = "10,13,34,44"

You'll need an 'encoding' proc that accepts a string and outputs a string.
It would transform text in this kind of fashion:
ab,cd"ef  -> ab<<44>>cd<<34>>ef

This would be achieved by splitting the const and looping through each of the constituents, executing a replace:

```<code>For Each splitCharVal In Split(ListOfSpecialChars, ",")
    stringToEncode = Replace(stringToEncode, Chr(splitCharVal), "<<" & splitCharVal & ">>"
Next
</code>```

You'll also need a 'decoding' proc that does the opposite, which I'll let you work out.

So, when saving a file to CSV, you'll need to loop through the cells of each row in turn, encoding the text found within, then writing out a row to the file.

When reading in a row from the encoded CSV, you'll need to run the decode operation prior to writing out the text to the worksheet.

Title: Insert Data With Carriage Returns

Body:
@Miguel has the right idea (his comment is on the main question thread).

This approach involves defining a list of integers relating to the ASCII codes for the characters you're having trouble with.  Line feed (10) will definitely be in there and you can decide on carriage return (13) commas (44) or speech marks (34).

const ListOfSpecialChars = "10,13,34,44"

You'll need an 'encoding' proc that accepts a string and outputs a string.
It would transform text in this kind of fashion:
ab,cd"ef  -> ab<<44>>cd<<34>>ef

This would be achieved by splitting the const and looping through each of the constituents, executing a replace:

For Each splitCharVal In Split(ListOfSpecialChars, ",")
    stringToEncode = Replace(stringToEncode, Chr(splitCharVal), "<<" & splitCharVal & ">>"
Next

You'll also need a 'decoding' proc that does the opposite, which I'll let you work out.

So, when saving a file to CSV, you'll need to loop through the cells of each row in turn, encoding the text found within, then writing out a row to the file.

When reading in a row from the encoded CSV, you'll need to run the decode operation prior to writing out the text to the worksheet.


问:
Logs getting flooded with AWS Http calls
Issue we are facing is that our log files are getting flooded, when we turn on http logging in log4j.

What we turn on in log4j

```<code><AsyncLogger name="org.mule.module.http.internal.HttpMessageLogger" level="DEBUG"/>
</code>```

What gets flooded in Log files,

```<code>DEBUG 2019-05-30 17:10:27,841 [pool-70-thread-5] com.amazonaws.1.11.453.shade.request: Received successful response: 200, AWS Request ID: 3c336641-*******
DEBUG 2019-05-30 17:10:27,841 [pool-70-thread-5] com.amazonaws.1.11.453.shade.requestId: x-amzn-RequestId: 3c336641-*********** DEBUG 2019-05-30 17:10:27,853 [pool-70-thread-6] com.amazonaws.1.11.453.shade.request: Sending Request: POST https://sqs.us-east-1.amazonaws.com / *****
DEBUG 2019-05-30 17:10:27,853 [pool-70-thread-6] com.amazonaws.1.11.453.shade.auth.AWS4Signer: AWS4 Canonical Request: '"POST
</code>```

Please suggest, what we need to do to turn off these logs, we want the HTTP logger to be on for our other http request debugging.

答:
To minimize the logs, you two options.

Option-1
You have to add the below configuration in log4j2 configurations. You can add multiple packages after identifying.

```<code><logger name="com.amazonaws" level="OFF">
        <AppenderRef ref="Console"/>
        <AppenderRef ref="File"/>
</logger>
</code>```

Option-2
You can use the below in the config file.

```<code><AsyncLogger name="org.mule.module.http.internal.HttpMessageLogger" level="ERROR"/>
</code>```

In this case , only error details will be printed.

Body:
Issue we are facing is that our log files are getting flooded, when we turn on http logging in log4j.

What we turn on in log4j

<AsyncLogger name="org.mule.module.http.internal.HttpMessageLogger" level="DEBUG"/>

What gets flooded in Log files,

DEBUG 2019-05-30 17:10:27,841 [pool-70-thread-5] com.amazonaws.1.11.453.shade.request: Received successful response: 200, AWS Request ID: 3c336641-*******
DEBUG 2019-05-30 17:10:27,841 [pool-70-thread-5] com.amazonaws.1.11.453.shade.requestId: x-amzn-RequestId: 3c336641-*********** DEBUG 2019-05-30 17:10:27,853 [pool-70-thread-6] com.amazonaws.1.11.453.shade.request: Sending Request: POST https://sqs.us-east-1.amazonaws.com / *****
DEBUG 2019-05-30 17:10:27,853 [pool-70-thread-6] com.amazonaws.1.11.453.shade.auth.AWS4Signer: AWS4 Canonical Request: '"POST

Please suggest, what we need to do to turn off these logs, we want the HTTP logger to be on for our other http request debugging.

Body:
To minimize the logs, you two options.

Option-1
You have to add the below configuration in log4j2 configurations. You can add multiple packages after identifying.

<logger name="com.amazonaws" level="OFF">
        <AppenderRef ref="Console"/>
        <AppenderRef ref="File"/>
</logger>

Option-2
You can use the below in the config file.

<AsyncLogger name="org.mule.module.http.internal.HttpMessageLogger" level="ERROR"/>

In this case , only error details will be printed.


问:
Thorntail not running for integration testing but I have the same pom.xml of a working project
All this afternoon I've been trying to solve a mysterious problem about an error :

```<code>[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 9.783 s <<< FAILURE! - in api.rest.AdRestServiceTest
[ERROR] testGet  Time elapsed: 4.351 s  <<< ERROR!
java.net.ConnectException: Connection refused: connect
        at api.rest.AdRestServiceTest.testGet(AdRestServiceTest.java:32)

[ERROR] testCount  Time elapsed: 2.013 s  <<< ERROR!
java.net.ConnectException: Connection refused: connect
        at api.rest.AdRestServiceTest.testCount(AdRestServiceTest.java:27)

[ERROR] testGetAll  Time elapsed: 2.022 s  <<< ERROR!
java.net.ConnectException: Connection refused: connect
        at api.rest.AdRestServiceTest.testGetAll(AdRestServiceTest.java:21)
</code>```

I can successfully run a working project (https://github.com/hostettler/microservices/tree/integration_tests) with mvn clean install.

I have some nice Thorntail is ready for the working example.

```<code>2019-05-21 16:29:26,235 INFO  [org.wildfly.swarm] (main) THORN99999: Thorntail is Ready
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.2:prepare-agent (integration-tests-preaparation) @ counterparty-service ---
[INFO] argLineForIntegration set to -javaagent:C:\\Users\\Admin\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.2\\org.jacoco.agent-0.8.2-runtime.jar=destfile=C:\\Users\\Admin\\Desktop\\ProjetINFO\\microservices\\counterparty-service\\target\\jacoco-it.exec
[INFO]
[INFO] --- maven-failsafe-plugin:2.22.1:integration-test (default) @ counterparty-service ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running api.CounterpartyRestServiceIT
2019-05-21 16:29:34,220 INFO  [stdout] (default task-1) Hibernate: ...
</code>```

I just copied those pom.xml (Parent pom and counterparty-service's pom) but it still doesn't work ..

Here is the Parent pom.xml :

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ch.unige</groupId>
    <artifactId>PInfo2</artifactId>
    <version>0.2.0-SNAPSHOT</version>
    <name>Parent Pom of the PInfo2</name>

    <packaging>pom</packaging>

    <!--<scm>
        <url>https://github.com/hostettler/microservices</url>
        <connection>scm:git:git@github.com/hostettler/microservices.git</connection>
        <developerConnection>scm:git:git@github.com/hostettler/microservices</developerConnection>
    </scm> -->

    <properties>
        <version.thorntail>2.3.0.Final</version.thorntail>
        <version.h2>1.4.197</version.h2>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <skip-docker-build>true</skip-docker-build>
        <skip-docker-compose>false</skip-docker-compose>
        <dockerHost>tcp://localhost:2375</dockerHost>
    </properties>

    <modules>
        <module>image-service</module>
        <module>stats-service</module>
        <module>chat-service</module>
        <module>ad-service</module>
        <module>category-service</module>
        <module>user-service</module>
        <module>search-service</module>
        <module>api-gateway</module>
    </modules>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.thorntail</groupId>
                <artifactId>bom</artifactId>
                <version>${version.thorntail}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <!--<dependency>
                <groupId>org.aerogear.kafka</groupId>
                <artifactId>kafka-cdi-extension</artifactId>
                <version>0.1.0</version>
            </dependency> -->
            <dependency>
                <groupId>com.github.dadrus.jpa-unit</groupId>
                <artifactId>jpa-unit-bom</artifactId>
                <version>0.5.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.4</version>
            </dependency>
            <dependency>
                <groupId>javax.enterprise</groupId>
                <artifactId>cdi-api</artifactId>
                <version>1.2</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.spec.javax.ws.rs</groupId>
                <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
                <version>1.0.0.Final</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${version.h2}</version>
            </dependency>
            <dependency>
                <groupId>org.aerogear.kafka</groupId>
                <artifactId>kafka-cdi-extension</artifactId>
                <version>0.1.0</version>
            </dependency>
            <dependency>
                <groupId>io.thorntail</groupId>
                <artifactId>swagger</artifactId>
                <version>2.2.1.Final</version>
            </dependency>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>5.3.2</version>
                <scope>test</scope>
                <type>pom</type>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-api</artifactId>
                <version>5.3.2</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-engine</artifactId>
                <version>5.3.2</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-launcher</artifactId>
                <version>1.3.2</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>2.23.4</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-junit-jupiter</artifactId>
                <version>2.23.4</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.3.1</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.5.3</version>
                    <configuration>
                        <autoVersionSubmodules>true</autoVersionSubmodules>
                        <tagNameFormat>@{project.version}</tagNameFormat>
                        <releaseProfiles>release</releaseProfiles>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                    <configuration>
                        <configuration>
                            <source>${maven.compiler.source}</source>
                            <target>${maven.compiler.target}</target>
                        </configuration>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M3</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>3.0.0-M6</version>
                </plugin>

                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.2</version>
                </plugin>
                <plugin>
                    <groupId>io.thorntail</groupId>
                    <artifactId>thorntail-maven-plugin</artifactId>
                    <version>${version.thorntail}</version>
                </plugin>
                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>fabric8-maven-plugin</artifactId>
                    <version>4.0.0-M2</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>io.thorntail</groupId>
                <artifactId>thorntail-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unit-tests</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>integration-tests-preaparation</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <propertyName>argLineForIntegration</propertyName>
                            <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>merge</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>merge</goal>
                        </goals>
                        <configuration>
                            <fileSets>
                                <fileSet>
                                    <directory>${project.build.directory}</directory>
                                    <includes>
                                        <include>*.exec</include>
                                    </includes>
                                </fileSet>
                            </fileSets>
                            <destFile>${project.build.directory}/jacoco-merged.exec</destFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                        <dataFile>${project.build.directory}/jacoco-merged.exec</dataFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>activate_windows</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <dockerHost>tcp://localhost:2375</dockerHost>
            </properties>
        </profile>
        <profile>
            <id>activation_unix</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <dockerHost>unix:///var/run/docker.sock</dockerHost>
            </properties>
        </profile>
        <profile>
            <id>package-docker-image</id>
            <activation>
                <property>
                    <name>docker-build</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>fabric8-maven-plugin</artifactId>
                        <configuration>
                            <skip>${skip-docker-build}</skip>
                            <useColor>true</useColor>
                            <dockerHost>${dockerHost}</dockerHost>
                            <images>
                                <image>
                                    <name>%g/%a:%l</name>
                                    <run>
                                        <ports>
                                            <port>8080:8080</port>
                                        </ports>
                                    </run>
                                    <build>
                                        <from>java:openjdk-8-jdk</from>
                                        <ports>
                                            <port>8080</port>
                                        </ports>
                                        <assembly>
                                            <basedir>/</basedir>
                                            <inline>
                                                <files>
                                                    <file>
                                                        <source>${project.build.directory}/${project.build.finalName}-thorntail.jar</source>
                                                        <outputDirectory>/opt</outputDirectory>
                                                    </file>
                                                </files>
                                            </inline>
                                        </assembly>
                                        <entryPoint>
                                            <shell>java -Djava.net.preferIPv4Stack=true -jar \
                                                /opt/${project.build.finalName}-thorntail.jar</shell>
                                        </entryPoint>
                                    </build>
                                </image>
                            </images>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>

</code>```

And here is the pom.xml located in ad-service (our project's microservice) :

```<code><project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>ch.unige</groupId>
        <artifactId>PInfo2</artifactId>
        <version>0.2.0-SNAPSHOT</version>
    </parent>

    <artifactId>ad-service</artifactId>
    <name>Ad Service</name>
    <packaging>war</packaging>

    <properties>
        <skip-docker-build>false</skip-docker-build>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>jaxrs</artifactId>
        </dependency>

        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>cdi</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>transactions</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>datasources</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>logging</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.5</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.0.10.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.aerogear.kafka</groupId>
            <artifactId>kafka-cdi-extension</artifactId>
        </dependency>

        <dependency>
            <groupId>com.github.dadrus.jpa-unit</groupId>
            <artifactId>jpa-unit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.dadrus.jpa-unit</groupId>
            <artifactId>jpa-unit-rdbms</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>3.3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unit-tests-1</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                        <destFile>jacoco.exec</destFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unit-tests-2</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <append>false</append>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>io.thorntail</groupId>
                <artifactId>thorntail-maven-plugin</artifactId>
                <configuration>
                    <!--PLACEHOLDER:configuration -->
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>start</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                        <jvmArguments>${}</jvmArguments>
                            <properties>
                                <thorntail.port.offset>20000</thorntail.port.offset>
                            </properties>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

</code>```

They are nearly the same with the working repo (just added kafka dependencies and changed name).
I don't know why it doesn't launch a server in background for integration testing but it does for the working repo..

THE REPO I AM WORKING ON IS : https://github.com/bigotromain/PInfo2/tree/integration_tests

Here is my "dumb" test file :

```<code>package api.rest;

import static io.restassured.RestAssured.when;
import static org.hamcrest.Matchers.containsString;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import io.restassured.RestAssured;

public class AdRestServiceTest {

    @BeforeAll
    public static void setup() {
        RestAssured.baseURI = "http://localhost:28080/ad";
        RestAssured.port = 8080;
    }

    @Test
    public void testGetAll() {
        when().get("/").then().body(containsString("984500C2EEUEB4A0C629"));

    }

    @Test
    public void testCount() {
        when().get("/count").then().body(containsString("5"));
    }

    @Test
    public void testGet() {
        when().get("/984500C2EEUEB4A0C629").then().body(containsString("984500C2EEUEB4A0C629"));
    }

}

</code>```

I clearly don't see why Thorntail won't launch for the integration testing.. any help ??
Thanks

答:
By default, the Maven Surefire plugin (responsible for running unit tests in the test phase) recognizes classes called *Test. The Maven Failsafe plugin (responsible for running integration tests in the integration-test phase) recognizes classes called *IT.

Your test class is called AdRestServiceTest, which would be executed in the test phase. You want it to be executed in the integration-test phase, because it's the integration-test phase that is surrounded by pre-integration-test and post-integration-test phases.

So you need to rename AdRestServiceTest to AdRestServiceIT. (Another option would be to reconfigure the Surefire and Failsafe plugins.)

Body:
All this afternoon I've been trying to solve a mysterious problem about an error :

[ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 9.783 s <<< FAILURE! - in api.rest.AdRestServiceTest
[ERROR] testGet  Time elapsed: 4.351 s  <<< ERROR!
java.net.ConnectException: Connection refused: connect
        at api.rest.AdRestServiceTest.testGet(AdRestServiceTest.java:32)

[ERROR] testCount  Time elapsed: 2.013 s  <<< ERROR!
java.net.ConnectException: Connection refused: connect
        at api.rest.AdRestServiceTest.testCount(AdRestServiceTest.java:27)

[ERROR] testGetAll  Time elapsed: 2.022 s  <<< ERROR!
java.net.ConnectException: Connection refused: connect
        at api.rest.AdRestServiceTest.testGetAll(AdRestServiceTest.java:21)

I can successfully run a working project (https://github.com/hostettler/microservices/tree/integration_tests) with mvn clean install.

I have some nice Thorntail is ready for the working example.

2019-05-21 16:29:26,235 INFO  [org.wildfly.swarm] (main) THORN99999: Thorntail is Ready
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.2:prepare-agent (integration-tests-preaparation) @ counterparty-service ---
[INFO] argLineForIntegration set to -javaagent:C:\\Users\\Admin\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.2\\org.jacoco.agent-0.8.2-runtime.jar=destfile=C:\\Users\\Admin\\Desktop\\ProjetINFO\\microservices\\counterparty-service\\target\\jacoco-it.exec
[INFO]
[INFO] --- maven-failsafe-plugin:2.22.1:integration-test (default) @ counterparty-service ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running api.CounterpartyRestServiceIT
2019-05-21 16:29:34,220 INFO  [stdout] (default task-1) Hibernate: ...

I just copied those pom.xml (Parent pom and counterparty-service's pom) but it still doesn't work ..

Here is the Parent pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ch.unige</groupId>
    <artifactId>PInfo2</artifactId>
    <version>0.2.0-SNAPSHOT</version>
    <name>Parent Pom of the PInfo2</name>

    <packaging>pom</packaging>

    <properties>
        <version.thorntail>2.3.0.Final</version.thorntail>
        <version.h2>1.4.197</version.h2>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <skip-docker-build>true</skip-docker-build>
        <skip-docker-compose>false</skip-docker-compose>
        <dockerHost>tcp://localhost:2375</dockerHost>
    </properties>

    <modules>
        <module>image-service</module>
        <module>stats-service</module>
        <module>chat-service</module>
        <module>ad-service</module>
        <module>category-service</module>
        <module>user-service</module>
        <module>search-service</module>
        <module>api-gateway</module>
    </modules>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.thorntail</groupId>
                <artifactId>bom</artifactId>
                <version>${version.thorntail}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>

            <dependency>
                <groupId>com.github.dadrus.jpa-unit</groupId>
                <artifactId>jpa-unit-bom</artifactId>
                <version>0.5.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.4</version>
            </dependency>
            <dependency>
                <groupId>javax.enterprise</groupId>
                <artifactId>cdi-api</artifactId>
                <version>1.2</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.spec.javax.ws.rs</groupId>
                <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
                <version>1.0.0.Final</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${version.h2}</version>
            </dependency>
            <dependency>
                <groupId>org.aerogear.kafka</groupId>
                <artifactId>kafka-cdi-extension</artifactId>
                <version>0.1.0</version>
            </dependency>
            <dependency>
                <groupId>io.thorntail</groupId>
                <artifactId>swagger</artifactId>
                <version>2.2.1.Final</version>
            </dependency>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>5.3.2</version>
                <scope>test</scope>
                <type>pom</type>
            </dependency>

            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-api</artifactId>
                <version>5.3.2</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-engine</artifactId>
                <version>5.3.2</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-launcher</artifactId>
                <version>1.3.2</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>2.23.4</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-junit-jupiter</artifactId>
                <version>2.23.4</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.3.1</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.5.3</version>
                    <configuration>
                        <autoVersionSubmodules>true</autoVersionSubmodules>
                        <tagNameFormat>@{project.version}</tagNameFormat>
                        <releaseProfiles>release</releaseProfiles>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                    <configuration>
                        <configuration>
                            <source>${maven.compiler.source}</source>
                            <target>${maven.compiler.target}</target>
                        </configuration>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M3</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>3.0.0-M6</version>
                </plugin>

                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.2</version>
                </plugin>
                <plugin>
                    <groupId>io.thorntail</groupId>
                    <artifactId>thorntail-maven-plugin</artifactId>
                    <version>${version.thorntail}</version>
                </plugin>
                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>fabric8-maven-plugin</artifactId>
                    <version>4.0.0-M2</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>io.thorntail</groupId>
                <artifactId>thorntail-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unit-tests</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>integration-tests-preaparation</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <propertyName>argLineForIntegration</propertyName>
                            <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>merge</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>merge</goal>
                        </goals>
                        <configuration>
                            <fileSets>
                                <fileSet>
                                    <directory>${project.build.directory}</directory>
                                    <includes>
                                        <include>*.exec</include>
                                    </includes>
                                </fileSet>
                            </fileSets>
                            <destFile>${project.build.directory}/jacoco-merged.exec</destFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                        <dataFile>${project.build.directory}/jacoco-merged.exec</dataFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>activate_windows</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <dockerHost>tcp://localhost:2375</dockerHost>
            </properties>
        </profile>
        <profile>
            <id>activation_unix</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <dockerHost>unix:///var/run/docker.sock</dockerHost>
            </properties>
        </profile>
        <profile>
            <id>package-docker-image</id>
            <activation>
                <property>
                    <name>docker-build</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>fabric8-maven-plugin</artifactId>
                        <configuration>
                            <skip>${skip-docker-build}</skip>
                            <useColor>true</useColor>
                            <dockerHost>${dockerHost}</dockerHost>
                            <images>
                                <image>
                                    <name>%g/%a:%l</name>
                                    <run>
                                        <ports>
                                            <port>8080:8080</port>
                                        </ports>
                                    </run>
                                    <build>
                                        <from>java:openjdk-8-jdk</from>
                                        <ports>
                                            <port>8080</port>
                                        </ports>
                                        <assembly>
                                            <basedir>/</basedir>
                                            <inline>
                                                <files>
                                                    <file>
                                                        <source>${project.build.directory}/${project.build.finalName}-thorntail.jar</source>
                                                        <outputDirectory>/opt</outputDirectory>
                                                    </file>
                                                </files>
                                            </inline>
                                        </assembly>
                                        <entryPoint>
                                            <shell>java -Djava.net.preferIPv4Stack=true -jar \
                                                /opt/${project.build.finalName}-thorntail.jar</shell>
                                        </entryPoint>
                                    </build>
                                </image>
                            </images>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>

And here is the pom.xml located in ad-service (our project's microservice) :

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>ch.unige</groupId>
        <artifactId>PInfo2</artifactId>
        <version>0.2.0-SNAPSHOT</version>
    </parent>

    <artifactId>ad-service</artifactId>
    <name>Ad Service</name>
    <packaging>war</packaging>

    <properties>
        <skip-docker-build>false</skip-docker-build>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>jaxrs</artifactId>
        </dependency>

        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>cdi</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>transactions</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>datasources</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>logging</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.5</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.0.10.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.aerogear.kafka</groupId>
            <artifactId>kafka-cdi-extension</artifactId>
        </dependency>

        <dependency>
            <groupId>com.github.dadrus.jpa-unit</groupId>
            <artifactId>jpa-unit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.dadrus.jpa-unit</groupId>
            <artifactId>jpa-unit-rdbms</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>3.3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unit-tests-1</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                        <destFile>jacoco.exec</destFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unit-tests-2</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <append>false</append>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>io.thorntail</groupId>
                <artifactId>thorntail-maven-plugin</artifactId>
                <configuration>

                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>start</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                        <jvmArguments>${}</jvmArguments>
                            <properties>
                                <thorntail.port.offset>20000</thorntail.port.offset>
                            </properties>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

They are nearly the same with the working repo (just added kafka dependencies and changed name).
I don't know why it doesn't launch a server in background for integration testing but it does for the working repo..

THE REPO I AM WORKING ON IS : https://github.com/bigotromain/PInfo2/tree/integration_tests

Here is my "dumb" test file :

package api.rest;

import static io.restassured.RestAssured.when;
import static org.hamcrest.Matchers.containsString;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import io.restassured.RestAssured;

public class AdRestServiceTest {

    @BeforeAll
    public static void setup() {
        RestAssured.baseURI = "http://localhost:28080/ad";
        RestAssured.port = 8080;
    }

    @Test
    public void testGetAll() {
        when().get("/").then().body(containsString("984500C2EEUEB4A0C629"));

    }

    @Test
    public void testCount() {
        when().get("/count").then().body(containsString("5"));
    }

    @Test
    public void testGet() {
        when().get("/984500C2EEUEB4A0C629").then().body(containsString("984500C2EEUEB4A0C629"));
    }

}

I clearly don't see why Thorntail won't launch for the integration testing.. any help ??
Thanks


问:
Duplicati and Backup of live Pervasive Database Missing Data
We have recently started using Duplicati for backup of some of our data systems. We run an ERP solution that uses Pervasive (v10).

When Duplicati begins its backup process, to the best of my understanding, it's using either the file date, and or the file byte size to determine what to back up.

The problem that I see with that solution is that some of the data is missing from the table. For example, the workorders module we are certain had new rows of data on the server (source machine) that were NOT copied over to the new file.

Last night we backed up our ERP platform then restored to a new location so as to do a compare of what was backed up during the evening against what the source machine had. We noticed that there are rows missing from one table in the restored backup, that are there in the source table.

The backup is being created from the data directory. We are NOT using the integrated backup that came with the ERP suite.

What I personally believe is happening is that the database isn't writing out the data to the table until the last client disconnects from the ERP software. Also, the byte size of the file missing data and the source machine are the same, even though the source file holds more data.

Last week we did the same test that we did last night and I noticed when I closed the ERP suite, the file updates its modified stamp and the new rows are added to the table, but not before the client disconnects.

Can someone shed some light on why this is happening?

答:
Are the data files open according to Pervasive when the backup occurs?  If so, you should be using some sort of agent to close the files or put them into Continuous Operation mode or Backup Agent.
From the docs:

Continuous Operations provides the ability to backup data files while
  database applications are running and users are connected.

When Continuous Operation mode is started, a delta file (.^^^) is created and the original data file is 'closed' so backup programs can access the file and back it up.

Backup Agent puts a GUI front end to Continuous Operation mode but is only supported with PSQL v11 and newer.


问:
Java ExceptionInitializationError in static Block
I am trying to call the URL retrieving method inside the static block, the Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError.

I am trying to get a WSDL url from the config file. this configuration data stored DB.

```<code>static
{
    URL url = null;
    WebServiceException e = null;
    try
{
    url = getVertexConfiguration();
    } catch (MalformedURLException ex) {
            e = new WebServiceException(ex);
        }
    }

private static URL getVertexConfiguration() throws MalformedURLException
    {
        try {
            configuration = configurationDAO.getByRefName("tax/vertex",
                    SecureSession.getUser().getDataDomain() != null ?
                            SecureSession.getUser().getDataDomain() : "app.cantata");
        } catch (B2BTransactionFailed b2BTransactionFailed) {

        }

        Map<String, DynamicAttribute> vertexTaxConfig = configuration.getConfigs();
        vertexWsdlUrl = vertexTaxConfig.get("vertexWsdlUrl").getValue().toString();

        return new URL(vertexWsdlUrl);
    }

}
</code>```

I am getting static block, the Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError.

答:
Why should you even try this? I think your configurationDAO is not even initialized at the moment you're trying to access it.

As we discussed in the comments, I would definitely recommend you, author, to inject your dependencies correctly, like:

```<code>@Service
public class ConfigurationService {

    private final ConfigurationDao configurationDao;
    private URL url;

    public ConfigurationService(ConfigurationDao configurationDao) {
        this.configurationDao = configurationDao;
    }

    @PostConstruct
    private void init() {
        // your stuff here
    }
}
</code>```

Or you can even initialize your url in constructor:

```<code>@Service
public class ConfigurationService {

    private final ConfigurationDao configurationDao;
    private final URL url;

    public ConfigurationService(ConfigurationDao configurationDao) {
        this.configurationDao = configurationDao;
        this.url = getVertexConfiguration();
    }

    private URL getVertexConfiguration() {
        // your stuff here
    }
}
</code>```

Body:
I am trying to call the URL retrieving method inside the static block, the Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError.

I am trying to get a WSDL url from the config file. this configuration data stored DB.

static
{
    URL url = null;
    WebServiceException e = null;
    try
{
    url = getVertexConfiguration();
    } catch (MalformedURLException ex) {
            e = new WebServiceException(ex);
        }
    }

private static URL getVertexConfiguration() throws MalformedURLException
    {
        try {
            configuration = configurationDAO.getByRefName("tax/vertex",
                    SecureSession.getUser().getDataDomain() != null ?
                            SecureSession.getUser().getDataDomain() : "app.cantata");
        } catch (B2BTransactionFailed b2BTransactionFailed) {

        }

        Map<String, DynamicAttribute> vertexTaxConfig = configuration.getConfigs();
        vertexWsdlUrl = vertexTaxConfig.get("vertexWsdlUrl").getValue().toString();

        return new URL(vertexWsdlUrl);
    }

}

I am getting static block, the Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError.

Body:
Why should you even try this? I think your configurationDAO is not even initialized at the moment you're trying to access it.

As we discussed in the comments, I would definitely recommend you, author, to inject your dependencies correctly, like:

@Service
public class ConfigurationService {

    private final ConfigurationDao configurationDao;
    private URL url;

    public ConfigurationService(ConfigurationDao configurationDao) {
        this.configurationDao = configurationDao;
    }

    @PostConstruct
    private void init() {
        // your stuff here
    }
}

Or you can even initialize your url in constructor:

@Service
public class ConfigurationService {

    private final ConfigurationDao configurationDao;
    private final URL url;

    public ConfigurationService(ConfigurationDao configurationDao) {
        this.configurationDao = configurationDao;
        this.url = getVertexConfiguration();
    }

    private URL getVertexConfiguration() {
        // your stuff here
    }
}


问:
Error in R density bw.SJ
I am using the density function with the SJ method:

```<code>rdat <- rnorm(111111)
density(rdat, bw = "sj")
Error in bw.SJ(x, method = "ste") : sample is too sparse to find TD
</code>```

It seems to fail on large sample, stating the sample is too sparse. This has been asked before here, but has anything changed since 2008? Are there any fixes out there for this/ workarounds?

Edit: Limit seems to be 46341

答:
This bug was fixed in R 3.4.0 (April, 2017).

Here is the relevant fragment from svnlog:

```<code>r71965 | maechler | 2017-01-13 04:30:18 -0600 (Fri, 13 Jan 2017) | 1 line
Changed paths:
   M /trunk/doc/NEWS.Rd
   M /trunk/src/library/stats/R/bandwidths.R
   M /trunk/src/library/stats/man/bandwidth.Rd
   M /trunk/src/library/stats/man/density.Rd
   M /trunk/src/library/stats/src/bandwidths.c

fix bw.SJ() integer overflow for large n
</code>```

Here is the corresponding commit in a mirror of R source code: https://github.com/wch/r-source/commit/5af0f7200128315392cf813127a654153b5e7739

Here is the fragment from R 3.4.0 change log:

Bandwidth selectors bw.ucv(), bw.bcv() and bw.SJ() now avoid integer overflow for large sample sizes.

Title: Error in R density bw.SJ

Body:
I am using the density function with the SJ method:

rdat <- rnorm(111111)
density(rdat, bw = "sj")
Error in bw.SJ(x, method = "ste") : sample is too sparse to find TD

It seems to fail on large sample, stating the sample is too sparse. This has been asked before here, but has anything changed since 2008? Are there any fixes out there for this/ workarounds?

Edit: Limit seems to be 46341

Body:
This bug was fixed in R 3.4.0 (April, 2017).

Here is the relevant fragment from svnlog:

r71965 | maechler | 2017-01-13 04:30:18 -0600 (Fri, 13 Jan 2017) | 1 line
Changed paths:
   M /trunk/doc/NEWS.Rd
   M /trunk/src/library/stats/R/bandwidths.R
   M /trunk/src/library/stats/man/bandwidth.Rd
   M /trunk/src/library/stats/man/density.Rd
   M /trunk/src/library/stats/src/bandwidths.c

fix bw.SJ() integer overflow for large n

Here is the corresponding commit in a mirror of R source code: https://github.com/wch/r-source/commit/5af0f7200128315392cf813127a654153b5e7739

Here is the fragment from R 3.4.0 change log:

Bandwidth selectors bw.ucv(), bw.bcv() and bw.SJ() now avoid integer overflow for large sample sizes.