OpenLiberty 20.0.0.1 AdoptOpenJDK 8
Вот примеры кодов .
arquillian. xml config.
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<defaultProtocol type="Servlet 3.0"/>
<engine>
<property name="deploymentExportPath">target/</property>
</engine>
<container qualifier="liberty-remote">
<configuration>
<property name="hostName">localhost</property>
<property name="serverName">defaultServer</property>
<property name="username">admin</property>
<property name="password">admin</property>
<property name="httpPort">9080</property>
<property name="httpsPort">9443</property>
</configuration>
</container>
</arquillian>
Сервер . xml, используемый для сервера OpenLiberty.
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>javaee-8.0</feature>
<feature>restConnector-2.0</feature>
</featureManager>
<!-- This template enables security. To get the full use of all the capabilities, a keystore and user registry are required. -->
<!-- For the keystore, default keys are generated and stored in a keystore. To provide the keystore password, generate an
encoded password using bin/securityUtility encode and add it below in the password attribute of the keyStore element.
Then uncomment the keyStore element. -->
<!--
<keyStore password=""/>
-->
<!-- userName and password should also be set in arquillian.xml to these values -->
<quickStartSecurity userName="admin" userPassword="admin" />
<!-- Enable the keystore -->
<!-- Start/restart the server, there are two files being created, keys.jks and ltpa.keys
in the folder <OpenLiberty server>/usr/servers/test/resources/security -->
<!-- Check the certificate:
keytool -list -v -keystore key.jks-->
<!-- Export the cert:
keytool -export -alias default -file testwlp.crt -keystore key.jks -->
<!-- Import into JDK:
keytool -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -alias testwlp -import -file testwlp.crt -->
<keyStore id="defaultKeyStore" password="password" />
<applicationMonitor updateTrigger="mbean" />
<logging consoleLogLevel="INFO" />
<!-- This section is needed to allow upload of files to the dropins directory, the remote container adapter relies on this configuration -->
<remoteFileAccess>
<writeDir>${server.config.dir}/dropins</writeDir>
</remoteFileAccess>
<!--For a user registry configuration, configure your user registry. For example, configure a basic user registry using the
basicRegistry element. Specify your own user name below in the name attribute of the user element. For the password,
generate an encoded password using bin/securityUtility encode and add it in the password attribute of the user element.
Then uncomment the user element. -->
<!-- <basicRegistry id="basic" realm="BasicRealm"> -->
<!-- <user name="yourUserName" password="" /> -->
<!-- </basicRegistry>-->
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint"
httpPort="9080"
httpsPort="9443" />
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
</server>
Я поместил этот сервер. xml в wlp / usr / servers / defalutServer / и запустить сервер OpenLiberty с помощью wlp/bin/server start defaultServer
.
Затем я экспортировал сертификат из файла jks, сгенерированного OpenLiberty, и импортировал его в мои локальные сертификаты JDK.
Когда Я запустил следующую команду для запуска тестов.
mvn clean verify -Parq-liberty-remote
Не удалось, в консоли была показана следующая ошибка.
[INFO] Running com.example.it.GreetingResourceTest
Feb 19, 2020 3:40:53 PM io.openliberty.arquillian.remote.WLPRemoteContainer setup
FINER: ENTRY
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Feb 19, 2020 3:40:54 PM io.openliberty.arquillian.remote.WLPRemoteContainer setup
FINER: RETURN
Feb 19, 2020 3:40:54 PM io.openliberty.arquillian.remote.WLPRestClient isServerUp
FINER: ENTRY
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.795 s <<< FAILURE! - in com.example.it.GreetingResourceTest
[ERROR] com.example.it.GreetingResourceTest Time elapsed: 2.771 s <<< ERROR!
org.jboss.arquillian.container.spi.client.container.LifecycleException: Could not determine remote server status : Could not successfully connect to REST endpoint, server returned response: HttpResponseProxy{HTTP/1.1 401 Unauthorized [X-Powered-By: Servlet/4.0, WWW-Authenticate: Basic realm="IBMJMXConnectorREST", Content-Language: en-US, Content-Length: 0, Date: Wed, 19 Feb 2020 07:40:55 GMT] [Content-Type: text/plain; charset=ISO-8859-1,Content-Length: 0,Chunked: false]}
Caused by: org.apache.http.client.ClientProtocolException: Could not successfully connect to REST endpoint, server returned response: HttpResponseProxy{HTTP/1.1 401 Unauthorized [X-Powered-By: Servlet/4.0, WWW-Authenticate: Basic realm="IBMJMXConnectorREST", Content-Language: en-US, Content-Length: 0, Date: Wed, 19 Feb 2020 07:40:55 GMT] [Content-Type: text/plain; charset=ISO-8859-1,Content-Length: 0,Chunked: false]}