Тест Arquillian выполняется на локальном сервере, а не на удаленном сервере Wildfly.

Я пытаюсь проверить свое приложение с помощью arquillian framework. Поэтому я настроил pom и arquillian.xml для запуска моего тестового примера в удаленном контейнере wildfly. Даже если я указал удаленный адрес в arquillian.xml, тестовый пример выполняется на локальном сервере wildfly. Я настроил профили сервера и провел тесты с профилем сервера удаленного доступа.

тестовый класс

@RunWith(Arquillian.class)
public class BasicTest {

@Deployment
public static JavaArchive createDeployment() {
    return ShrinkWrap.create(JavaArchive.class).addClass(Greeter.class)
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}

@Inject
private Greeter greeter;

@Test
public void shouldBeAbleTo() {
    assertEquals("Hello, aliens!", greeter.createGreeting("aliens"));
}

}

pom.xml

<?xml version="1.0"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.aerogear</groupId>
<artifactId>arquillian-wildfly-example</artifactId>
<packaging>jar</packaging>
<version>0.0.1</version>


<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <version.org.jboss.arquillian>1.1.5.Final</version.org.jboss.arquillian>
    <version.org.wildfly>8.1.0.Final</version.org.wildfly>
    <version.junit>4.11</version.junit>
</properties>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
            </plugin>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-dependency-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.1,)
                                    </versionRange>
                                    <goals>
                                        <goal>unpack</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<dependencyManagement>
    <dependencies>

        <!-- Arquillian BOM (Bill Of Materials). -->
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-bom</artifactId>
            <version>${version.org.jboss.arquillian}</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>

        <!-- JUnit regression testing framework. -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit}</version>
        </dependency>

    </dependencies>
</dependencyManagement>

<profiles>

    <!-- Arquillian WildFly remote profile -->
    <profile>
        <id>arq-widlfly-remote</id>
        <dependencies>
            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-arquillian-container-remote</artifactId>
                <version>8.2.0.Final</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>
</profiles>


<dependencies>

    <!-- JUnit regression testing framework. -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>

    <!-- JUnit Container Implementation for the Arquillian Project -->
    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.arquillian.protocol</groupId>
        <artifactId>arquillian-protocol-servlet</artifactId>
        <scope>test</scope>
    </dependency>

</dependencies>

arquillian.xml

<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">

<!-- Sets the protocol which is how Arquillian talks and executes the tests inside the container -->
<defaultProtocol type="Servlet 3.0" />

<!-- Configuration to be used when the WidlFly remote profile is active -->
<container qualifier="widlfly-remote">
    <configuration>
        <property name="managementAddress">xxxxx</property>
        <property name="managementPort">xxxx</property>
        <property name="username">xxxx</property>
        <property name="password">xxxx</property>
    </configuration>
</container>

But the test case is running on 127.0.0.1:9990 wildfly server, Not running on the remote wildfly server which I was specified in arquillian.xml. What configuration I have to do/change. please help me.


person Sri    schedule 27.05.2015    source источник


Ответы (1)


Вам нужно указать Arquillian, с каким квалификатором контейнера arquillian.xml вы хотите работать, так как вы можете определить многие из них в одном XML-файле. Если у вас есть только один элемент и только он когда-либо нужен, вы можете определить для него атрибут default=true, и в этом случае Arquillian будет использовать его, если не определено что-либо еще.

<container qualifier="widlfly-remote" default="true">
   ...
</container> 

В противном случае вы можете определить -Darquillian.launch=widlfly-remote как системное свойство в вашем исполнении Maven Surefire, чтобы установить его динамически.

По сути, в вашей текущей настройке вы не сообщаете Arquillian, какой квалификатор использовать, что означает, что он будет работать со значениями по умолчанию для адаптера контейнера, который у вас есть в пути к классам (поэтому вы видите, что 127.0.0.1 используется.).

person Aslak Knutsen    schedule 28.05.2015
comment
Я определил -Darquillian.launch=widlfly-remote как системное свойство в maven surefire. Теперь я получаю сообщение об ошибке, например java.lang.RuntimeException: Не удалось создать новый экземпляр класса org.jboss.arquillian.test.impl.EventTestRunnerAdaptor, см. причину. на org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:170) - person Sri; 28.05.2015
comment
У вас есть остальная часть этого исключения? - person Aslak Knutsen; 29.05.2015
comment
Попробуйте обновиться до Arquillian 1.1.8.Final. Посмотрите, есть ли у исключения дополнительная информация. - person Aslak Knutsen; 30.05.2015
comment
Спасибо за ответ. Мне не удалось обновить версию 1.1.8. Я попытался протестировать веб-сайт с помощью seleniumhq (www.seleniumhq.org). Это работает для меня и легко. что предпочтительнее arquillian-selenium или selenium для тестирования веб-интерфейса? - person Sri; 31.05.2015
comment
Не уверен, почему у вас это не получится, ваш пример pom и тестовый пример работают нормально здесь, на WildFly 8.2.0.Final. Может попробовать распаковать новый свежий экземпляр WildFly.. - person Aslak Knutsen; 04.06.2015