0

I have a simple game which consists of two projects: Client and server. Now I want to test if they interact correctly. Setup is: One Maven-parent project, and server/client/integetion-test as child-modules.
I tried to follow this guide http://docs.codehaus.org/display/MAVENUSER/Maven+and+Integration+Testing, which is integration-testin using the maven-failsafe-plugin. Alas it is only describing how to start the jetty-server, which is available as a plugin.

How and where do I start my own client and server in this configuration (or is there a better one) for testing? I wanted to do something like this: First I want client and server to be started before the test. In the jUnittest I want to have a Socket and a Serversocket, one connected to the server and one to the client. Then I want to pipe the client/server-interaction through this setup and verify it in between, or send specific messages to them individually, verifying the answer.

Is something like that possible, or is there a better way?

user2368505
  • 416
  • 3
  • 16

1 Answers1

1

I have done similar stuff earlier but sadly i do not have the code available now. But it was something like below. Here in pre-integration-test start your server using ant exec task and in post-integration-test stop your server.

<plugin>  
    <artifactId>maven-antrun-plugin</artifactId>  
    <version>1.7</version>  
    <executions>  
        <execution>  
            <id>start-server</id>  
            <phase>pre-integration-test</phase>  
            <configuration>  
                <target>  
                    <exec executable="command to start your server">
                </target>  
            </configuration>  
            <goals>  
                <goal>run</goal>  
            </goals>  
        </execution>  
        <execution>  
            <id>stop-server</id>  
            <phase>post-integration-test</phase>  
            <configuration>  
                <target>  
                    <exec executable="command to stop your server"> 
                </target>  
            </configuration>  
            <goals>  
                <goal>run</goal>  
            </goals>  
       </execution>  
    </executions>  
</plugin>
Bhushan Bhangale
  • 10,921
  • 5
  • 43
  • 71