1 package com.atlassian.maven.plugins.amps;
2
3 import junit.framework.TestCase;
4
5 import java.io.IOException;
6 import java.net.ServerSocket;
7
8 import org.apache.maven.plugin.PluginManager;
9
10
11
12
13 public class TestMavenGoals extends TestCase
14 {
15 public void testPickFreePort() throws IOException
16 {
17 MavenContext ctx = new MavenContext(null, null, null, (PluginManager) null, null);
18 MavenGoals goals = new MavenGoals(ctx);
19 ServerSocket socket = null;
20 try
21 {
22 socket = new ServerSocket(16829);
23
24
25 int port = goals.pickFreePort(0);
26 assertTrue(16829 != port);
27 assertTrue(port > 0);
28
29
30 port = goals.pickFreePort(16829);
31 assertTrue(16829 != port);
32 assertTrue(port > 0);
33
34
35 assertEquals(16828, goals.pickFreePort(16828));
36 }
37 finally
38 {
39 socket.close();
40 }
41 }
42 }