diff --git a/restcomm/restcomm.testsuite/pom.xml b/restcomm/restcomm.testsuite/pom.xml
index ffce23b07d..4f4b9b471f 100644
--- a/restcomm/restcomm.testsuite/pom.xml
+++ b/restcomm/restcomm.testsuite/pom.xml
@@ -27,23 +27,23 @@
+ ${project.version} war test
+ org.restcomm restcomm-connect.commons
+ ${project.version} provided
+ org.restcomm restcomm-connect.dao
+ ${project.version} provided
+ org.restcomm restcomm-connect.mgcp
+ ${project.version} provided
+ org.restcomm restcomm-connect.sms
+ ${project.version} provided
+ org.restcomm restcomm-connect.http
+ ${project.version} provided
+ org.restcomm restcomm-connect.telephony
+ ${project.version} provided
+ org.restcomm restcomm-connect.telephony.api
+ ${project.version} provided
+ org.restcomm restcomm-connect.interpreter
+ ${project.version} test -->
org.scala-lang
@@ -160,12 +160,12 @@
+ sip-servlets-catalina-6 ${sipservletapi.version}
+ test org.mobicents.servlet.sip.containers
+ sip-servlets-tomcat-jboss4 ${sipservletapi.version}
+ test org.mobicents.arquillian.container
+ mss-tomcat-embedded-6 ${mss.arquillian.version}
+ test -->
@@ -273,18 +273,18 @@
test
-
- org.mockito
- mockito-all
- 1.8.5
- test
-
-
+
+ org.mockito
+ mockito-all
+ 1.8.5
+ test
+
+
com.github.tomakehurst
@@ -423,23 +423,111 @@
2
-
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 2.18.1
+
+
+ **/CallLifecycleAnswerDelayTest.java
+ **/CallLifecycleTest.java
+ **/CallRegexSingleTest.java
+ **/CallRegexTest.java
+ **/ClientsDialAnswerDelayTest.java
+ **/ClientsDialTest.java
+ **/DialActionAnswerDelayTest.java
+ **/DialActionTest.java
+ **/DialForkAnswerDealyTest.java
+ **/DialForkTest.java
+ **/DialRecordingAnswerDelayTest.java
+ **/DialRecordingTest.java
+ **/DialStatusCallbackTest.java
+ **/ImsClientsDialAnswerDelayTest.java
+ **/ImsClientsDialTest.java
+ **/TestDialVerbPartOneAnswerDelay.java
+ **/TestDialVerbPartOne.java
+ **/TestDialVerbPartTwoAnswerDelay.java
+ **/TestDialVerbPartTwo.java
+ **/TestDialVerbPartThreeAnswerDelay.java
+ **/TestDialVerbPartThree.java
+
+ **/UserAgentManagerTest.java
+ **/sms/*Test.java
+ **/connect/testsuite/*Test.java
+
+ true
+ 2
+
+ false
+ classes
+ 5
+
+ -Xms256m -Xmx2048m -XX:MaxPermSize=512m
+
+
+ mss-tomcat-embedded-7-forked
+
+ ${surefire.forkNumber}509
+ ${surefire.forkNumber}508
+
+
+
+
+ failsafe-integration-tests
+ integration-test
+
+ integration-test
+ verify
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.19.1
+
+ -Xms1024m -Xmx2048m -XX:MaxPermSize=1024m
+
+ 1
+ false
+ ${skipUTs}
+
+ **/CallLifecycleAnswerDelayTest.java
+ **/CallLifecycleTest.java
+ **/CallRegexSingleTest.java
+ **/CallRegexTest.java
+ **/ClientsDialAnswerDelayTest.java
+ **/ClientsDialTest.java
+ **/DialActionAnswerDelayTest.java
+ **/DialActionTest.java
+ **/DialForkAnswerDealyTest.java
+ **/DialForkTest.java
+ **/DialRecordingAnswerDelayTest.java
+ **/DialRecordingTest.java
+ **/DialStatusCallbackTest.java
+ **/ImsClientsDialAnswerDelayTest.java
+ **/ImsClientsDialTest.java
+ **/TestDialVerbPartOneAnswerDelay.java
+ **/TestDialVerbPartOne.java
+ **/TestDialVerbPartTwoAnswerDelay.java
+ **/TestDialVerbPartTwo.java
+ **/TestDialVerbPartThreeAnswerDelay.java
+ **/TestDialVerbPartThree.java
+
+ **/UserAgentManagerTest.java
+ **/sms/*Test.java
+ **/connect/testsuite/*Test.java
+
+
+
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.19.1
-
- -Xms1024m -Xmx2048m -XX:MaxPermSize=1024m
-
- 1
- false
-
-
-
-
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/NetworkPortAssigner.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/NetworkPortAssigner.java
new file mode 100644
index 0000000000..508e464a54
--- /dev/null
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/NetworkPortAssigner.java
@@ -0,0 +1,111 @@
+package org.restcomm.connect.testsuite;
+
+import java.io.EOFException;
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.lang.management.ManagementFactory;
+import java.nio.channels.FileChannel;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.log4j.Logger;
+
+/**
+ * Allows integration tests to be run in parallel by assigning a free port.
+ *
+ * A port range will be assigned based in JVM PID, and a circular sequence
+ * around this range will be provided. JVM PID are expected to be sequenced, so
+ * incremental PID will be received. It is assumed that low number of forked
+ * JMVs will be used to run parallel tests ( near cores in system), so the
+ * PORT_RANGE dont provide much collisions.
+ *
+ */
+public class NetworkPortAssigner {
+
+ private static final Logger LOGGER = Logger.getLogger(NetworkPortAssigner.class);
+ private static final int PORT_RANGE = 150;
+
+ //provide ports above system reserved range
+ private static final int PORT_MAX_BASE = 65534;
+
+ private static final int INITIAL_PORT_VALUE;
+
+ private static final AtomicInteger PORT_SEQ = new AtomicInteger(0);
+
+ private static final int PID;
+
+ static {
+ final String jvmName = ManagementFactory.getRuntimeMXBean().getName();
+ final int index = jvmName.indexOf('@');
+
+ if (index < 1) {
+ // part before '@' empty (index = 0) / '@' not found (index = -1)
+ PID = 0;
+ } else {
+ PID = Integer.parseInt(jvmName.substring(0, index));
+ }
+
+ INITIAL_PORT_VALUE = PORT_MAX_BASE - ((PID % PORT_RANGE) * PORT_RANGE);
+ LOGGER.info("PID:" + PID);
+ LOGGER.info("PID:" + PID + ",INITIAL_PORT_VALUE:" + INITIAL_PORT_VALUE);
+ }
+
+ public synchronized static int retrieveNextPort() {
+ int nextPort = PORT_MAX_BASE;
+ nextPort = retrieveNextPortByFile();
+ LOGGER.info("PID:" + PID + ",nextPort:" + nextPort);
+ return nextPort;
+ }
+
+ public static int retrieveNextPortBySeq() {
+ int nextPort = INITIAL_PORT_VALUE - (PORT_SEQ.getAndAdd(1) % PORT_RANGE);
+ return nextPort;
+ }
+
+ public static int retrieveNextPortByFile() {
+ int nextPort = PORT_MAX_BASE;
+ //assume maven convention, create file under target so its cleaned
+ File portFile = new File("./target/portFile");
+ try {
+ if (!portFile.exists()) {
+ portFile.createNewFile();
+ LOGGER.info("PID:" + PID + ",portFile created");
+ } else {
+ LOGGER.info("PID:" + PID + ",portFile already exists");
+ }
+ } catch (IOException ex) {
+ LOGGER.info("PID:" + PID + ", there is problem when creating portFile");
+ }
+
+ RandomAccessFile aFile = null;
+ try {
+ aFile = new RandomAccessFile(portFile, "rwd");
+ FileChannel channel = aFile.getChannel();
+ channel.lock();
+ try {
+ int readInt = aFile.readInt();
+ nextPort = readInt - 1;
+ if (nextPort <= 0) {
+ nextPort = PORT_MAX_BASE - 1;
+ }
+ } catch (EOFException eExp) {
+ //file was empty, it was just created
+ nextPort = PORT_MAX_BASE - 1;
+ LOGGER.info("PID:" + PID + ",sequence resetted");
+ }
+ //rewrite existing value by resetting pointer to the start
+ aFile.seek(0);
+ aFile.writeInt(nextPort);
+ } catch (Exception ex) {
+ LOGGER.error("error getting port", ex);
+ } finally {
+ if (aFile != null) {
+ try {
+ aFile.close();
+ } catch (Exception e) {
+ LOGGER.error("error getting port", e);
+ }
+ }
+ }
+ return nextPort;
+ }
+}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceMigratedTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceMigratedTest.java
index e36d46e287..88dd66707b 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceMigratedTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceMigratedTest.java
@@ -37,9 +37,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -47,7 +45,13 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.icegreen.greenmail.util.GreenMail;
-import com.icegreen.greenmail.util.ServerSetupTest;
+import com.icegreen.greenmail.util.ServerSetup;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.BeforeClass;
import org.restcomm.connect.commons.Version;
/**
@@ -63,14 +67,31 @@ public class RvdProjectsMigratorWorkspaceMigratedTest {
private Deployer deployer;
@ArquillianResource
URL deploymentUrl;
+
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+ private static int smtpPort = NetworkPortAssigner.retrieveNextPortByFile();
private String adminUsername = "administrator@company.com";
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
private static GreenMail mailServer;
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+
+ public static void reconfigurePorts() throws Exception {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@AfterClass
- public static void after() {
+ public static void stopMailServer() {
mailServer.stop();
}
@@ -131,7 +152,7 @@ public void checkNotifications() {
@Test
public void checkEmail() throws IOException, MessagingException, InterruptedException {
- Thread.sleep(60000);
+ mailServer.waitForIncomingEmail(60000, 1);
MimeMessage[] messages = mailServer.getReceivedMessages();
assertNotNull(messages);
assertEquals(1, messages.length);
@@ -147,24 +168,29 @@ public void checkEmail() throws IOException, MessagingException, InterruptedExce
@Deployment(name = "RvdProjectsMigratorWorkspaceMigratedTest", managed = true, testable = false)
public static WebArchive createWebArchiveRestcomm() throws Exception {
- startEmailServer();
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm_workspaceMigration.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_projectMigratorWorkspaceMigratedTest", "data/hsql/restcomm.script");
+ logger.info("Packaging Test App");
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ replacements.put("3025", String.valueOf(smtpPort));
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+
+ List resources = new ArrayList(Arrays.asList(
+ ));
+
+ WebArchive archive = WebArchiveUtil.createWebArchiveNoGw("restcomm_workspaceMigration.xml",
+ "restcomm.script_projectMigratorWorkspaceMigratedTest",
+ resources, replacements);
+
String source = "src/test/resources/workspace-migration-scenarios/migrated";
String target = "workspace-migration";
File f = new File(source);
- addFiles(archive, f, source, target);
+ addFiles(archive, f, source, target);
return archive;
- }
+ }
private static void addFiles(WebArchive war, File dir, String source, String target) throws Exception {
if (!dir.isDirectory()) {
@@ -180,8 +206,10 @@ private static void addFiles(WebArchive war, File dir, String source, String tar
}
}
- private static void startEmailServer() {
- mailServer = new GreenMail(ServerSetupTest.SMTP);
+ @BeforeClass
+ public static void startEmailServer() {
+ ServerSetup setup = new ServerSetup(smtpPort, "127.0.0.1", "smtp");
+ mailServer = new GreenMail(setup);
mailServer.start();
mailServer.setUser("hascode@localhost", "hascode", "abcdef123");
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceMixedTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceMixedTest.java
index 76639318bf..406d0d5e20 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceMixedTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceMixedTest.java
@@ -38,9 +38,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -49,8 +47,13 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.icegreen.greenmail.util.GreenMail;
-import com.icegreen.greenmail.util.ServerSetupTest;
+import com.icegreen.greenmail.util.ServerSetup;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.restcomm.connect.commons.Version;
+import static org.restcomm.connect.testsuite.RvdProjectsMigratorWorkspaceMigratedTest.reconfigurePorts;
/**
* @author guilherme.jansen@telestax.com
@@ -65,6 +68,9 @@ public class RvdProjectsMigratorWorkspaceMixedTest {
private Deployer deployer;
@ArquillianResource
URL deploymentUrl;
+
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+ private static int smtpPort = NetworkPortAssigner.retrieveNextPortByFile();
private String adminUsername = "administrator@company.com";
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
@@ -75,7 +81,22 @@ public class RvdProjectsMigratorWorkspaceMixedTest {
private static ArrayList didSids;
private static ArrayList clientSids;
private static GreenMail mailServer;
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+
+ public static void reconfigurePorts() throws Exception {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
+
@BeforeClass
public static void before() {
applicationNames = new ArrayList();
@@ -97,7 +118,7 @@ public static void before() {
}
@AfterClass
- public static void after() {
+ public static void stopMailServer() {
mailServer.stop();
}
@@ -221,7 +242,7 @@ public void checkNotifications() {
@Test
public void checkEmail() throws IOException, MessagingException, InterruptedException {
- Thread.sleep(60000);
+ mailServer.waitForIncomingEmail(60000, 1);
MimeMessage[] messages = mailServer.getReceivedMessages();
assertNotNull(messages);
assertEquals(1, messages.length);
@@ -236,24 +257,28 @@ public void checkEmail() throws IOException, MessagingException, InterruptedExce
@Deployment(name = "RvdProjectsMigratorWorkspaceMixedTest", managed = true, testable = false)
public static WebArchive createWebArchiveRestcomm() throws Exception {
- startEmailServer();
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm_workspaceMigration.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_projectMigratorWorkspaceMixedTest", "data/hsql/restcomm.script");
+ logger.info("Packaging Test App");
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ replacements.put("3025", String.valueOf(smtpPort));
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+
+ List resources = new ArrayList(Arrays.asList(
+ ));
+
+ WebArchive archive = WebArchiveUtil.createWebArchiveNoGw("restcomm_workspaceMigration.xml",
+ "restcomm.script_projectMigratorWorkspaceMixedTest", resources, replacements);
+
String source = "src/test/resources/workspace-migration-scenarios/mixed";
String target = "workspace-migration";
File f = new File(source);
- addFiles(archive, f, source, target);
+ addFiles(archive, f, source, target);
return archive;
- }
+ }
private static void addFiles(WebArchive war, File dir, String source, String target) throws Exception {
if (!dir.isDirectory()) {
@@ -269,8 +294,10 @@ private static void addFiles(WebArchive war, File dir, String source, String tar
}
}
- private static void startEmailServer() {
- mailServer = new GreenMail(ServerSetupTest.SMTP);
+ @BeforeClass
+ public static void startEmailServer() {
+ ServerSetup setup = new ServerSetup(smtpPort, "127.0.0.1", "smtp");
+ mailServer = new GreenMail(setup);
mailServer.start();
mailServer.setUser("hascode@localhost", "hascode", "abcdef123");
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceOriginalTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceOriginalTest.java
index 8b03d47c91..e894e3c2f2 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceOriginalTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/RvdProjectsMigratorWorkspaceOriginalTest.java
@@ -38,9 +38,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -49,8 +47,13 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.icegreen.greenmail.util.GreenMail;
-import com.icegreen.greenmail.util.ServerSetupTest;
+import com.icegreen.greenmail.util.ServerSetup;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.restcomm.connect.commons.Version;
+import static org.restcomm.connect.testsuite.RvdProjectsMigratorWorkspaceMigratedTest.reconfigurePorts;
/**
* @author guilherme.jansen@telestax.com
@@ -65,6 +68,9 @@ public class RvdProjectsMigratorWorkspaceOriginalTest {
private Deployer deployer;
@ArquillianResource
URL deploymentUrl;
+
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+ private static int smtpPort = NetworkPortAssigner.retrieveNextPortByFile();
private String adminUsername = "administrator@company.com";
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
@@ -72,6 +78,20 @@ public class RvdProjectsMigratorWorkspaceOriginalTest {
private static ArrayList applicationNames;
private static GreenMail mailServer;
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+
+ public static void reconfigurePorts() throws Exception {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
+
@BeforeClass
public static void before() {
applicationNames = new ArrayList();
@@ -81,7 +101,7 @@ public static void before() {
}
@AfterClass
- public static void after() {
+ public static void stopMailServer() {
mailServer.stop();
}
@@ -158,7 +178,7 @@ public void checkNotifications() {
@Test
public void checkEmail() throws IOException, MessagingException, InterruptedException {
- Thread.sleep(60000);
+ mailServer.waitForIncomingEmail(60000, 1);
MimeMessage[] messages = mailServer.getReceivedMessages();
assertNotNull(messages);
assertEquals(1, messages.length);
@@ -173,24 +193,29 @@ public void checkEmail() throws IOException, MessagingException, InterruptedExce
@Deployment(name = "RvdProjectsMigratorWorkspaceOriginalTest", managed = true, testable = false)
public static WebArchive createWebArchiveRestcomm() throws Exception {
- startEmailServer();
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm_workspaceMigration.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_projectMigratorWorkspaceOriginalTest", "data/hsql/restcomm.script");
+ logger.info("Packaging Test App");
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ replacements.put("3025", String.valueOf(smtpPort));
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+
+ List resources = new ArrayList(Arrays.asList(
+ ));
+
+ WebArchive archive = WebArchiveUtil.createWebArchiveNoGw("restcomm_workspaceMigration.xml",
+ "restcomm.script_projectMigratorWorkspaceOriginalTest",
+ resources, replacements);
+
String source = "src/test/resources/workspace-migration-scenarios/original";
String target = "workspace-migration";
File f = new File(source);
- addFiles(archive, f, source, target);
+ addFiles(archive, f, source, target);
return archive;
- }
+ }
private static void addFiles(WebArchive war, File dir, String source, String target) throws Exception {
if (!dir.isDirectory()) {
@@ -206,8 +231,10 @@ private static void addFiles(WebArchive war, File dir, String source, String tar
}
}
- private static void startEmailServer() {
- mailServer = new GreenMail(ServerSetupTest.SMTP);
+ @BeforeClass
+ public static void startEmailServer() {
+ ServerSetup setup = new ServerSetup(smtpPort, "127.0.0.1", "smtp");
+ mailServer = new GreenMail(setup);
mailServer.start();
mailServer.setUser("hascode@localhost", "hascode", "abcdef123");
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/UssdPullTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/UssdPullTest.java
index c1bc4efb74..38676d567d 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/UssdPullTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/UssdPullTest.java
@@ -25,6 +25,11 @@
import static org.junit.Assert.assertTrue;
import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.sip.DialogState;
import javax.sip.RequestEvent;
@@ -43,9 +48,7 @@
import org.jboss.arquillian.container.mss.extension.SipStackTool;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -63,28 +66,49 @@ public class UssdPullTest {
private final static Logger logger = Logger.getLogger(UssdPullTest.class.getName());
private static final String version = Version.getVersion();
-
+
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
private static SipStackTool tool1;
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
-
- private String ussdPullDid = "sip:5544@127.0.0.1:5080";
- private String ussdPullDid2 = "sip:*777#@127.0.0.1:5080";
- private String ussdPullWithCollectDID = "sip:5555@127.0.0.1:5080";
- private String ussdPullMessageLengthExceeds = "sip:5566@127.0.0.1:5080";
- private String ussdPullDidNoHttpMethod = "sip:5577@127.0.0.1:5080";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private static String ussdPullDid = "sip:5544@" + restcommContact;
+ private static String ussdPullDid2 = "sip:*777#@" + restcommContact;
+ private static String ussdPullWithCollectDID = "sip:5555@" + restcommContact;
+ private static String ussdPullMessageLengthExceeds = "sip:5566@" + restcommContact;
+ private static String ussdPullDidNoHttpMethod = "sip:5577@" + restcommContact;
@BeforeClass
public static void beforeClass() throws Exception {
tool1 = new SipStackTool("UssdPullTest");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ ussdPullDid = "sip:5544@" + restcommContact;
+ ussdPullDid2 = "sip:*777#@" + restcommContact;
+ ussdPullWithCollectDID = "sip:5555@" + restcommContact;
+ ussdPullMessageLengthExceeds = "sip:5566@" + restcommContact;
+ ussdPullDidNoHttpMethod = "sip:5577@" + restcommContact;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
}
@After
@@ -113,15 +137,15 @@ public void testUssdPull() {
} else {
assertTrue(bobCall.getLastReceivedResponse().getStatusCode() == Response.RINGING);
}
-
+
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
assertTrue(bobCall.sendInviteOkAck());
-
- assertTrue(bobCall.getDialog().getState().getValue()==DialogState._CONFIRMED);
-
+
+ assertEquals(DialogState._CONFIRMED, bobCall.getDialog().getState().getValue());
+
assertTrue(bobCall.listenForDisconnect());
-
+
assertTrue(bobCall.waitForDisconnect(30 * 1000));
bobCall.respondToDisconnect();
SipRequest bye = bobCall.getLastReceivedRequest();
@@ -149,7 +173,7 @@ public void testUssdPullNoHttpMethod() {
assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
assertTrue(bobCall.sendInviteOkAck());
- assertTrue(bobCall.getDialog().getState().getValue()==DialogState._CONFIRMED);
+ assertTrue(bobCall.getDialog().getState().getValue() == DialogState._CONFIRMED);
assertTrue(bobCall.listenForDisconnect());
@@ -175,15 +199,15 @@ public void testUssdPull2() {
} else {
assertTrue(bobCall.getLastReceivedResponse().getStatusCode() == Response.RINGING);
}
-
+
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
assertTrue(bobCall.sendInviteOkAck());
-
- assertTrue(bobCall.getDialog().getState().getValue()==DialogState._CONFIRMED);
-
+
+ assertTrue(bobCall.getDialog().getState().getValue() == DialogState._CONFIRMED);
+
assertTrue(bobCall.listenForDisconnect());
-
+
assertTrue(bobCall.waitForDisconnect(30 * 1000));
bobCall.respondToDisconnect();
SipRequest bye = bobCall.getLastReceivedRequest();
@@ -191,7 +215,7 @@ public void testUssdPull2() {
assertTrue(receivedUssdPayload.equalsIgnoreCase(UssdPullTestMessages.ussdRestcommResponse.trim()));
bobCall.dispose();
}
-
+
@Test
public void testUssdPullWithCollect() throws InterruptedException, SipException, ParseException {
final SipCall bobCall = bobPhone.createSipCall();
@@ -206,35 +230,34 @@ public void testUssdPullWithCollect() throws InterruptedException, SipException,
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
}
-
+
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
assertTrue(bobCall.sendInviteOkAck());
-
- assertTrue(bobCall.getDialog().getState().getValue()==DialogState._CONFIRMED);
+
+ assertTrue(bobCall.getDialog().getState().getValue() == DialogState._CONFIRMED);
String toTag = bobCall.getDialog().getLocalTag();
Address bobAddress = bobPhone.getAddress();
-
+
assertTrue(bobPhone.listenRequestMessage());
- RequestEvent requestEvent = bobPhone.waitRequest(30*1000);
-
- assertNotNull(requestEvent);
+ RequestEvent requestEvent = bobPhone.waitRequest(30 * 1000);
+
+ assertNotNull(requestEvent);
assertTrue(requestEvent.getRequest().getMethod().equalsIgnoreCase("INFO"));
bobPhone.sendReply(requestEvent, 200, "OK", toTag, bobAddress, 0);
-
String receivedUssdPayload = new String(requestEvent.getRequest().getRawContent());
- System.out.println("receivedUssdPayload: \n"+receivedUssdPayload);
- System.out.println("UssdPullTestMessages.ussdRestcommResponseWithCollect: \n"+UssdPullTestMessages.ussdRestcommResponseWithCollect);
+ System.out.println("receivedUssdPayload: \n" + receivedUssdPayload);
+ System.out.println("UssdPullTestMessages.ussdRestcommResponseWithCollect: \n" + UssdPullTestMessages.ussdRestcommResponseWithCollect);
assertTrue(receivedUssdPayload.equals(UssdPullTestMessages.ussdRestcommResponseWithCollect.trim()));
-
+
Request infoResponse = requestEvent.getDialog().createRequest(Request.INFO);
ContentTypeHeader contentTypeHeader = bobCall.getHeaderFactory().createContentTypeHeader("application", "vnd.3gpp.ussd+xml");
infoResponse.setContent(UssdPullTestMessages.ussdClientResponseBodyToCollect.getBytes(), contentTypeHeader);
- bobPhone.sendRequestWithTransaction(infoResponse, false, requestEvent.getDialog());
+ bobPhone.sendRequestWithTransaction(infoResponse, false, requestEvent.getDialog());
- assertTrue(bobCall.listenForDisconnect());
+ assertTrue(bobCall.listenForDisconnect());
assertTrue(bobCall.waitForDisconnect(30 * 1000));
bobCall.respondToDisconnect();
SipRequest bye = bobCall.getLastReceivedRequest();
@@ -243,10 +266,11 @@ public void testUssdPullWithCollect() throws InterruptedException, SipException,
bobCall.dispose();
}
- @Test @Ignore
+ @Test
+ @Ignore
public void testUssdPullWithCollectFromRVD() throws InterruptedException, SipException, ParseException {
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:*888#@127.0.0.1:5080", null, UssdPullTestMessages.ussdClientRequestBodyForCollect, "application", "vnd.3gpp.ussd+xml", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:*888#@" + restcommContact, null, UssdPullTestMessages.ussdClientRequestBodyForCollect, "application", "vnd.3gpp.ussd+xml", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -262,21 +286,20 @@ public void testUssdPullWithCollectFromRVD() throws InterruptedException, SipExc
assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
assertTrue(bobCall.sendInviteOkAck());
- assertTrue(bobCall.getDialog().getState().getValue()==DialogState._CONFIRMED);
+ assertTrue(bobCall.getDialog().getState().getValue() == DialogState._CONFIRMED);
String toTag = bobCall.getDialog().getLocalTag();
Address bobAddress = bobPhone.getAddress();
assertTrue(bobPhone.listenRequestMessage());
- RequestEvent requestEvent = bobPhone.waitRequest(30*1000);
+ RequestEvent requestEvent = bobPhone.waitRequest(30 * 1000);
assertNotNull(requestEvent);
assertTrue(requestEvent.getRequest().getMethod().equalsIgnoreCase("INFO"));
bobPhone.sendReply(requestEvent, 200, "OK", toTag, bobAddress, 0);
-
String receivedUssdPayload = new String(requestEvent.getRequest().getRawContent());
- System.out.println("receivedUssdPayload: \n"+receivedUssdPayload);
- System.out.println("UssdPullTestMessages.ussdRestcommResponseWithCollect: \n"+UssdPullTestMessages.ussdRestcommResponseWithCollect);
+ System.out.println("receivedUssdPayload: \n" + receivedUssdPayload);
+ System.out.println("UssdPullTestMessages.ussdRestcommResponseWithCollect: \n" + UssdPullTestMessages.ussdRestcommResponseWithCollect);
assertTrue(receivedUssdPayload.equals(UssdPullTestMessages.ussdRestcommResponseWithCollect.trim()));
Request infoResponse = requestEvent.getDialog().createRequest(Request.INFO);
@@ -308,53 +331,52 @@ public void testUssdPullWithCollect_DisconnectFromUser() throws InterruptedExcep
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
}
-
+
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
assertTrue(bobCall.sendInviteOkAck());
-
- assertTrue(bobCall.getDialog().getState().getValue()==DialogState._CONFIRMED);
+
+ assertTrue(bobCall.getDialog().getState().getValue() == DialogState._CONFIRMED);
String toTag = bobCall.getDialog().getLocalTag();
Address bobAddress = bobPhone.getAddress();
-
+
assertTrue(bobPhone.listenRequestMessage());
- RequestEvent requestEvent = bobPhone.waitRequest(30*1000);
-
- assertNotNull(requestEvent);
+ RequestEvent requestEvent = bobPhone.waitRequest(30 * 1000);
+
+ assertNotNull(requestEvent);
assertTrue(requestEvent.getRequest().getMethod().equalsIgnoreCase("INFO"));
bobPhone.sendReply(requestEvent, 200, "OK", toTag, bobAddress, 0);
-
String receivedUssdPayload = new String(requestEvent.getRequest().getRawContent());
- System.out.println("receivedUssdPayload: \n"+receivedUssdPayload);
- System.out.println("UssdPullTestMessages.ussdRestcommResponseWithCollect: \n"+UssdPullTestMessages.ussdRestcommResponseWithCollect);
+ System.out.println("receivedUssdPayload: \n" + receivedUssdPayload);
+ System.out.println("UssdPullTestMessages.ussdRestcommResponseWithCollect: \n" + UssdPullTestMessages.ussdRestcommResponseWithCollect);
assertTrue(receivedUssdPayload.equals(UssdPullTestMessages.ussdRestcommResponseWithCollect.trim()));
-
+
bobCall.disconnect();
bobCall.waitForAnswer(10000);
assertTrue(bobCall.getLastReceivedResponse().getStatusCode() == 200);
-
+
}
-
-
- @Test @Ignore
+
+ @Test
+ @Ignore
public void testUssdPullWithCollect_CancelFromUser() throws InterruptedException, SipException, ParseException {
final SipCall bobCall = bobPhone.createSipCall();
bobCall.initiateOutgoingCall(bobContact, ussdPullWithCollectDID, null, UssdPullTestMessages.ussdClientRequestBodyForCollect, "application", "vnd.3gpp.ussd+xml", null, null);
assertLastOperationSuccess(bobCall);
bobCall.waitOutgoingCallResponse(1000);
// Thread.sleep(1000);
-
+
SipTransaction cancelTransaction = bobCall.sendCancel();
assertNotNull(cancelTransaction);
bobCall.waitForCancel(5 * 1000);
int lastResponseCode = bobCall.getLastReceivedResponse().getStatusCode();
- if (lastResponseCode != Response.REQUEST_TERMINATED){
+ if (lastResponseCode != Response.REQUEST_TERMINATED) {
bobCall.waitOutgoingCallResponse(1000);
}
assertEquals(Response.REQUEST_TERMINATED, bobCall.getLastReceivedResponse().getStatusCode());
-
+
Request ackRequest = cancelTransaction.getServerTransaction().getDialog().createRequest(Request.ACK);
ContentTypeHeader contentTypeHeader = bobCall.getHeaderFactory().createContentTypeHeader("application", "vnd.3gpp.ussd+xml");
ackRequest.setContent(null, contentTypeHeader);
@@ -378,7 +400,7 @@ public void testUssdPullWithCollect_CancelFromUser() throws InterruptedException
//
// assertNotNull(bobPhone.sendRequestWithTransaction(ackRequest, false, cancelTransaction.getServerTransaction().getDialog()));
// }
-
+
}
@Test
@@ -395,15 +417,15 @@ public void testUssdMessageLengthExceeds() {
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
}
-
+
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
assertTrue(bobCall.sendInviteOkAck());
-
- assertTrue(bobCall.getDialog().getState().getValue()==DialogState._CONFIRMED);
-
+
+ assertTrue(bobCall.getDialog().getState().getValue() == DialogState._CONFIRMED);
+
assertTrue(bobCall.listenForDisconnect());
-
+
assertTrue(bobCall.waitForDisconnect(30 * 1000));
bobCall.respondToDisconnect();
SipRequest bye = bobCall.getLastReceivedRequest();
@@ -411,26 +433,34 @@ public void testUssdMessageLengthExceeds() {
assertTrue(receivedUssdPayload.equalsIgnoreCase(UssdPullTestMessages.ussdRestcommResponseForMessageLengthExceeds.trim()));
bobCall.dispose();
}
-
+
@Deployment(name = "UssdPullTest", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("org/restcomm/connect/ussd/restcomm.script_ussdPullTest", "data/hsql/restcomm.script");
- archive.addAsWebResource("org/restcomm/connect/ussd/ussd-rcml.xml");
- archive.addAsWebResource("org/restcomm/connect/ussd/ussd-rcml-collect.xml");
- archive.addAsWebResource("org/restcomm/connect/ussd/ussd-rcml-character-limit-exceed.xml");
- logger.info("Packaged Test App");
- return archive;
+ reconfigurePorts();
+
+ Map webInfResources = new HashMap();
+ webInfResources.put("restcomm.xml", "conf/restcomm.xml");
+ webInfResources.put("org/restcomm/connect/ussd/restcomm.script_ussdPullTest", "data/hsql/restcomm.script");
+ webInfResources.put("akka_application.conf", "classes/application.conf");
+ webInfResources.put("sip.xml", "/sip.xml");
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5090", String.valueOf(bobPort));
+
+ List resources = new ArrayList(Arrays.asList(
+ "org/restcomm/connect/ussd/ussd-rcml.xml",
+ "org/restcomm/connect/ussd/ussd-rcml-collect.xml",
+ "org/restcomm/connect/ussd/ussd-rcml-character-limit-exceed.xml"
+ ));
+
+ return WebArchiveUtil.createWebArchiveNoGw(webInfResources,
+ resources,
+ replacements);
}
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/WebArchiveUtil.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/WebArchiveUtil.java
new file mode 100644
index 0000000000..29d26ae7f4
--- /dev/null
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/WebArchiveUtil.java
@@ -0,0 +1,74 @@
+package org.restcomm.connect.testsuite;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
+import org.restcomm.connect.commons.Version;
+
+
+public class WebArchiveUtil {
+
+ public static File tweakFilePorts(String filePath, Map portReplaments){
+ try {
+ InputStream resourceAsStream = WebArchiveUtil.class.getClassLoader().getResourceAsStream(filePath);
+ StringWriter writer = new StringWriter();
+ IOUtils.copy(resourceAsStream, writer, java.nio.charset.Charset.defaultCharset());
+ String confStr = writer.toString();
+ for (String key : portReplaments.keySet()) {
+ confStr = confStr.replace(key, portReplaments.get(key));
+ }
+ String targetFilePath = "target" + File.separator;
+ if (System.getProperty("arquillian_sip_port") != null) {
+ targetFilePath = targetFilePath + System.getProperty("arquillian_sip_port");
+ }
+ targetFilePath = targetFilePath + File.separator + filePath;
+ File f = new File(targetFilePath);
+ FileUtils.writeStringToFile(f, confStr);
+ return f;
+ } catch (IOException ex) {
+ return null;
+ }
+ }
+
+ public static WebArchive createWebArchiveNoGw(String restcommConf, String dbScript, Map replacements) {
+ return createWebArchiveNoGw(restcommConf, dbScript, new ArrayList(), replacements);
+ }
+ public static WebArchive createWebArchiveNoGw(String restcommConf, String dbScript, List resources, Map replacements) {
+ Map webInfResources = new HashMap();
+ webInfResources.put(restcommConf, "conf/restcomm.xml");
+ webInfResources.put(dbScript, "data/hsql/restcomm.script");
+ webInfResources.put("akka_application.conf", "classes/application.conf");
+ webInfResources.put("sip.xml", "/sip.xml");
+ return createWebArchiveNoGw(webInfResources, resources, replacements);
+ }
+ public static WebArchive createWebArchiveNoGw(Map webInfResources, List resources, Map replacements) {
+
+ WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
+ final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
+ .resolve("org.restcomm:restcomm-connect.application:war:" + Version.getVersion()).withoutTransitivity()
+ .asSingle(WebArchive.class);
+ archive = archive.merge(restcommArchive);
+ for (String webdInfFile : webInfResources.keySet()) {
+ File f = WebArchiveUtil.tweakFilePorts(webdInfFile,replacements );
+ archive.delete("/WEB-INF/" + webInfResources.get(webdInfFile));
+ archive.addAsWebInfResource(f, webInfResources.get(webdInfFile));
+ }
+ for (String rAux: resources) {
+ File rFile = WebArchiveUtil.tweakFilePorts(rAux,replacements );
+ //assume wherever the file comes from (dir depth),
+ //we will get it form context root
+ archive.addAsWebResource(rFile, rFile.getName());
+ }
+ return archive;
+ }
+}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/AccountsEndpointTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/AccountsEndpointTest.java
index 96edc10bcf..48de6f0a40 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/AccountsEndpointTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/AccountsEndpointTest.java
@@ -354,7 +354,7 @@ public void testCreateAccountCheckClientExisted() throws Exception {
assertNotNull(clientOfAccount);
CreateClientsTool.getInstance().updateClientVoiceUrl(deploymentUrl.toString(), subAccountResponse,
- clientOfAccount.get("sid").getAsString(), "http://127.0.0.1:8080/restcomm/demos/welcome.xml",
+ clientOfAccount.get("sid").getAsString(), deploymentUrl.toString() + "/demos/welcome.xml",
adminUsername, adminPassword);
JsonObject clientOfAccountUpdated = CreateClientsTool.getInstance().getClientOfAccount(deploymentUrl.toString(),
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/ClientsEndpointTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/ClientsEndpointTest.java
index 5e9627fcb0..a5e5638620 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/ClientsEndpointTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/ClientsEndpointTest.java
@@ -97,13 +97,13 @@ public void createClientTest() throws ClientProtocolException, IOException, Pars
SipURI reqUri = bobSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
String clientSID = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "bob", "RestComm1234",
- "http://127.0.0.1:8080/restcomm/demos/welcome.xml");
+ deploymentUrl.toString() + "/demos/welcome.xml");
assertNotNull(clientSID);
Thread.sleep(3000);
String clientSID2 = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "bob", "RestComm1234",
- "http://127.0.0.1:8080/restcomm/demos/welcome.xml");
+ deploymentUrl.toString() + "/demos/welcome.xml");
assertNotNull(clientSID2);
Thread.sleep(3000);
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/CreateCallsTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/CreateCallsTest.java
index 7ea87a5619..1b5b684cf8 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/CreateCallsTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/CreateCallsTest.java
@@ -155,7 +155,7 @@ public void createCallSipUriTest() throws InterruptedException {
String from = "+15126002188";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonElement callResult = RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -218,7 +218,7 @@ public void createCallSipUriAllowFromModificationTest() throws InterruptedExcept
String from = "sip:+15126002188@mobicents.org";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonElement callResult = RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -290,7 +290,7 @@ public void createCallClientTest() throws InterruptedException, ParseException {
String from = "+15126002188";
String to = "client:alice";
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonElement callResult = RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -408,7 +408,7 @@ public void createCallClientTestWithMultipleRegistrations() throws InterruptedEx
String from = "+15126002188";
String to = "client:alice";
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonArray callResult = (JsonArray) RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -481,7 +481,7 @@ public void createCallNumberTest() throws InterruptedException, ParseException {
String from = "+15126002188";
String to = "131313";
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-client-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-client-entry.xml";
JsonElement callResult = RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -724,7 +724,7 @@ public void createCallNumberTestWith500ErrorResponse() throws InterruptedExcepti
String from = "+15126002188";
String to = "131313";
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-client-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-client-entry.xml";
JsonElement callResult = RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/LiveCallModificationAnswerDelayTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/LiveCallModificationAnswerDelayTest.java
index 8319522716..3ac8309f57 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/LiveCallModificationAnswerDelayTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/LiveCallModificationAnswerDelayTest.java
@@ -143,7 +143,7 @@ public void terminateInProgressCall() throws Exception {
String from = "+15126002188";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonObject callResult = (JsonObject) RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -195,7 +195,7 @@ public void terminateInProgressCallAlreadyTerminated() throws Exception {
String from = "+15126002188";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonObject callResult = (JsonObject) RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -254,7 +254,7 @@ public void terminateRingingCall() throws Exception {
String from = "+15126002188";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry-lcm.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry-lcm.xml";
JsonObject callResult = (JsonObject) RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -301,7 +301,7 @@ public void redirectCall() throws Exception {
String from = "+15126002188";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonObject callResult = (JsonObject) RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -328,7 +328,7 @@ public void redirectCall() throws Exception {
Thread.sleep(10000);
System.out.println("\n ******************** \nAbout to redirect the call\n ********************\n");
- rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-client-entry.xml";
+ rcmlUrl = deploymentUrl.toString() + "/dial-client-entry.xml";
callResult = RestcommCallsTool.getInstance().modifyCall(deploymentUrl.toString(), adminAccountSid, adminAuthToken,
callSid, null, rcmlUrl);
@@ -436,7 +436,7 @@ public void redirectCallInConferenceMuted() throws Exception {
Thread.sleep(10000);
System.out.println("\n ******************** \nAbout to redirect the call\n ********************\n");
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-client-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-client-entry.xml";
JsonObject callResult = RestcommCallsTool.getInstance().modifyCall(deploymentUrl.toString(), adminAccountSid, adminAuthToken,
callSid, null, rcmlUrl);
@@ -605,7 +605,7 @@ public void redirectCallInvalidCallSid() throws Exception {
String from = "+15126002188";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonObject callResult = (JsonObject) RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -632,7 +632,7 @@ public void redirectCallInvalidCallSid() throws Exception {
Thread.sleep(10000);
System.out.println("\n ******************** \nAbout to redirect the call\n ********************\n");
- rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-client-entry.xml";
+ rcmlUrl = deploymentUrl.toString() + "/dial-client-entry.xml";
//String invalidCallSid = Sid.generate(Sid.Type.CALL).toString();
// restcomm-connect/1907
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/LiveCallModificationTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/LiveCallModificationTest.java
index 630183a24e..2e4d5a369f 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/LiveCallModificationTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/LiveCallModificationTest.java
@@ -142,7 +142,7 @@ public void terminateInProgressCall() throws Exception {
String from = "+15126002188";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonObject callResult = (JsonObject) RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -194,7 +194,7 @@ public void terminateInProgressCallAlreadyTerminated() throws Exception {
String from = "+15126002188";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonObject callResult = (JsonObject) RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -253,7 +253,7 @@ public void terminateRingingCall() throws Exception {
String from = "+15126002188";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry-lcm.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry-lcm.xml";
JsonObject callResult = (JsonObject) RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -300,7 +300,7 @@ public void redirectCall() throws Exception {
String from = "+15126002188";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonObject callResult = (JsonObject) RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -327,7 +327,7 @@ public void redirectCall() throws Exception {
Thread.sleep(10000);
System.out.println("\n ******************** \nAbout to redirect the call\n ********************\n");
- rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-client-entry.xml";
+ rcmlUrl = deploymentUrl.toString() + "/dial-client-entry.xml";
callResult = RestcommCallsTool.getInstance().modifyCall(deploymentUrl.toString(), adminAccountSid, adminAuthToken,
callSid, null, rcmlUrl);
@@ -435,7 +435,7 @@ public void redirectCallInConferenceMuted() throws Exception {
Thread.sleep(10000);
System.out.println("\n ******************** \nAbout to redirect the call\n ********************\n");
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-client-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-client-entry.xml";
JsonObject callResult = RestcommCallsTool.getInstance().modifyCall(deploymentUrl.toString(), adminAccountSid, adminAuthToken,
callSid, null, rcmlUrl);
@@ -604,7 +604,7 @@ public void redirectCallInvalidCallSid() throws Exception {
String from = "+15126002188";
String to = bobContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/dial-number-entry.xml";
JsonObject callResult = (JsonObject) RestcommCallsTool.getInstance().createCall(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -631,7 +631,7 @@ public void redirectCallInvalidCallSid() throws Exception {
Thread.sleep(10000);
System.out.println("\n ******************** \nAbout to redirect the call\n ********************\n");
- rcmlUrl = "http://127.0.0.1:8080/restcomm/dial-client-entry.xml";
+ rcmlUrl = deploymentUrl.toString() + "/dial-client-entry.xml";
//String invalidCallSid = Sid.generate(Sid.Type.CALL).toString();
// restcomm-connect/1907
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/OutboudProxyCallsTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/OutboudProxyCallsTest.java
index 89464ef242..5661fe2b05 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/OutboudProxyCallsTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/OutboudProxyCallsTest.java
@@ -127,7 +127,7 @@ public void createCallAndFallback() throws InterruptedException {
String from = "+15126002188";
String to = primaryProxyContact;
- String rcmlUrl = "http://127.0.0.1:8080/restcomm.application-"+version+"/dial-number-entry.xml";
+ String rcmlUrl = deploymentUrl.toString() + ".application-"+version+"/dial-number-entry.xml";
for (int i = 0; i < 20; i++) {
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/UssdPushTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/UssdPushTest.java
index e9f34dd4e8..b5703d4dc9 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/UssdPushTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/http/UssdPushTest.java
@@ -130,7 +130,7 @@ public void createUssdPushTestNotifyOnly() throws InterruptedException, SipExcep
String from = "+15126002188";
String to = "bob";
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/ussd-rcml.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/ussd-rcml.xml";
JsonObject callResult = RestcommUssdPushTool.getInstance().createUssdPush(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -178,7 +178,7 @@ public void createUssdPushTestNotifyOnlyFromIsRestcomm() throws InterruptedExcep
String from = "Restcomm";
String to = "bob";
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/ussd-rcml.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/ussd-rcml.xml";
JsonObject callResult = RestcommUssdPushTool.getInstance().createUssdPush(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
@@ -226,7 +226,7 @@ public void createUssdPushTestCollect() throws InterruptedException, SipExceptio
String from = "+15126002188";
String to = "bob";
- String rcmlUrl = "http://127.0.0.1:8080/restcomm/ussd-rcml-collect.xml";
+ String rcmlUrl = deploymentUrl.toString() + "/ussd-rcml-collect.xml";
JsonObject callResult = RestcommUssdPushTool.getInstance().createUssdPush(deploymentUrl.toString(), adminAccountSid,
adminAuthToken, from, to, rcmlUrl);
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsEndpointTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsEndpointTest.java
index 7ab5372b54..95ac533814 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsEndpointTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsEndpointTest.java
@@ -39,9 +39,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -49,7 +47,13 @@
import org.junit.runner.RunWith;
import com.google.gson.JsonObject;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
import org.restcomm.connect.commons.Version;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* @author gvagenas
@@ -64,26 +68,35 @@ public class SmsEndpointTest {
private Deployer deployer;
@ArquillianResource
URL deploymentUrl;
+
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
private static SipStackTool tool1;
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:1213@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:1213@127.0.0.1:" + bobPort;
private static SipStackTool tool2;
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
private static SipStackTool tool3;
private SipStack aliceSipStackOrg2;
private SipPhone alicePhoneOrg2;
- private String aliceContactOrg2 = "sip:alice@org2.restcomm.com";
+ private static String alicePort2 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContactOrg2 = "sip:alice@org2.restcomm.com:" + alicePort2;
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
private String adminAccountSidOrg2 = "ACae6e420f425248d6a26948c17a9e2acg";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
@BeforeClass
public static void beforeClass() throws Exception {
@@ -91,17 +104,26 @@ public static void beforeClass() throws Exception {
tool2 = new SipStackTool("SmsTest2");
tool3 = new SipStackTool("SmsTest3");
}
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- aliceSipStackOrg2 = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- alicePhoneOrg2 = aliceSipStackOrg2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContactOrg2);
+ aliceSipStackOrg2 = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort2, restcommContact);
+ alicePhoneOrg2 = aliceSipStackOrg2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContactOrg2);
}
@After
@@ -150,7 +172,7 @@ public void sendSmsTest() {
@Test
public void sendSmsTestToClientAlice() throws ParseException {
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -182,13 +204,13 @@ public void sendSmsTestToClientAlice() throws ParseException {
@Test
public void sendSmsTestToClientExistingInDifferentOrganizations() throws ParseException {
// Prepare alice org2 phone to receive call
- SipURI uri = aliceSipStackOrg2.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
- assertTrue(alicePhoneOrg2.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5092", 3600, 3600));
+ SipURI uri = aliceSipStackOrg2.getAddressFactory().createSipURI(null, restcommContact);
+ assertTrue(alicePhoneOrg2.register(uri, "alice", "1234", "sip:alice@127.0.0.1:" + alicePort2, 3600, 3600));
SipCall aliceCallOrg2 = alicePhoneOrg2.createSipCall();
aliceCallOrg2.listenForMessage();
// Prepare alice org1 phone to receive call
- SipURI urialiceSipStack = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI urialiceSipStack = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(urialiceSipStack, "alice", "1234", aliceContact, 3600, 3600));
SipCall aliceCall = alicePhone.createSipCall();
aliceCall.listenForMessage();
@@ -214,7 +236,7 @@ public void sendSmsTestToClientExistingInDifferentOrganizations() throws ParseEx
@Test
public void sendSmsTestToAlice() throws ParseException {
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -322,18 +344,29 @@ public void sendSmsTestWithCustomHeaders() {
@Deployment(name = "LiveCallModificationTest", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm_for_SMSEndpointTest.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialTest", "data/hsql/restcomm.script");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map webInfResources = new HashMap();
+ webInfResources.put("restcomm_for_SMSEndpointTest.xml", "conf/restcomm.xml");
+ webInfResources.put("restcomm.script_dialTest", "data/hsql/restcomm.script");
+ //webInfResources.put("restcomm.script_SmsTest", "data/hsql/restcomm.script");
+ webInfResources.put("akka_application.conf", "classes/application.conf");
+ webInfResources.put("sip.xml", "sip.xml");
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(alicePort2));
+
+
+ List resources = new ArrayList(Arrays.asList(
+ ));
+ return WebArchiveUtil.createWebArchiveNoGw(webInfResources,
+ resources,
+ replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsOutTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsOutTest.java
index 2ce48b5091..b8da12444c 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsOutTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsOutTest.java
@@ -22,6 +22,11 @@
import static org.junit.Assert.assertTrue;
import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.sip.address.SipURI;
@@ -33,15 +38,15 @@
import org.jboss.arquillian.container.mss.extension.SipStackTool;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.restcomm.connect.commons.Version;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* @author gvagenas
@@ -56,27 +61,44 @@ public class SmsOutTest {
private static SipStackTool tool1;
private static SipStackTool tool2;
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
private SipStack outboundDestSipStack;
private SipPhone outboundDestPhone;
- private String outboundDestContact = "sip:9898989@127.0.0.1:5094";
+ private static String outboundPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String outboundDestContact = "sip:9898989@127.0.0.1:" + outboundPort;
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+
@BeforeClass
public static void beforeClass() throws Exception {
tool1 = new SipStackTool("SmsTest1");
tool2 = new SipStackTool("SmsTest2");
}
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- aliceSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- outboundDestSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5094", "127.0.0.1:5080");
- outboundDestPhone = outboundDestSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, outboundDestContact);
+ outboundDestSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", outboundPort, restcommContact);
+ outboundDestPhone = outboundDestSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, outboundDestContact);
}
@After
@@ -101,14 +123,14 @@ public void testSendSmsToInvalidNumber() throws ParseException, InterruptedExcep
SipCall outboundDestCall = outboundDestPhone.createSipCall();
outboundDestCall.listenForMessage();
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
Credential credential = new Credential("127.0.0.1", "alice", "1234");
alicePhone.addUpdateCredential(credential);
SipCall aliceCall = alicePhone.createSipCall();
- aliceCall.initiateOutgoingMessage(aliceContact, "sip:9898989@127.0.0.1:5080", null, null, null, "Test message");
+ aliceCall.initiateOutgoingMessage(aliceContact, "sip:9898989@" + restcommContact, null, null, null, "Test message");
assertTrue(aliceCall.waitForAuthorisation(5000));
assertTrue(aliceCall.waitOutgoingMessageResponse(5000));
assertTrue(aliceCall.getLastReceivedResponse().getStatusCode() == 100);
@@ -127,14 +149,14 @@ public void testSendSmsToValidNumber() throws ParseException, InterruptedExcepti
SipCall outboundDestCall = outboundDestPhone.createSipCall();
outboundDestCall.listenForMessage();
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
Credential credential = new Credential("127.0.0.1", "alice", "1234");
alicePhone.addUpdateCredential(credential);
SipCall aliceCall = alicePhone.createSipCall();
- aliceCall.initiateOutgoingMessage(aliceContact, "sip:9898989@127.0.0.1:5080", null, null, null, "Test message");
+ aliceCall.initiateOutgoingMessage(aliceContact, "sip:9898989@" + restcommContact, null, null, null, "Test message");
assertTrue(aliceCall.waitForAuthorisation(5000));
assertTrue(aliceCall.waitOutgoingMessageResponse(5000));
assertTrue(aliceCall.getLastReceivedResponse().getStatusCode() == 100);
@@ -149,23 +171,29 @@ public void testSendSmsToValidNumber() throws ParseException, InterruptedExcepti
}
@Deployment(name = "SmsTest", managed = true, testable = false)
- public static WebArchive createWebArchiveNoGw() {
- logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- restcommArchive.addClass(SmsRcmlServlet.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/web.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("web_for_SmsTest.xml", "web.xml");
- archive.addAsWebInfResource("restcomm_SmsTest2.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_SmsTest", "data/hsql/restcomm.script");
- logger.info("Packaged Test App");
- return archive;
- }
+ public static WebArchive createWebArchive() {
+ reconfigurePorts();
+
+ Map webInfResources = new HashMap();
+ webInfResources.put("restcomm_SmsTest2.xml", "conf/restcomm.xml");
+ webInfResources.put("restcomm.script_SmsTest", "data/hsql/restcomm.script");
+ webInfResources.put("sip.xml", "sip.xml");
+ webInfResources.put("web_for_SmsTest.xml", "web.xml");
+ webInfResources.put("akka_application.conf", "classes/application.conf");
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5094", String.valueOf(outboundPort));
+
+
+ List resources = new ArrayList(Arrays.asList(
+ ));
+ return WebArchiveUtil.createWebArchiveNoGw(webInfResources,
+ resources,
+ replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsSessionTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsSessionTest.java
index f3328d3cf3..e4aca2902f 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsSessionTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsSessionTest.java
@@ -26,9 +26,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -40,7 +38,12 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
import org.restcomm.connect.commons.Version;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* @author quintana.thomas@gmail.com (Thomas Quintana)
@@ -55,21 +58,30 @@ public final class SmsSessionTest {
@ArquillianResource
URL deploymentUrl;
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
private static SipStackTool tool;
private SipStack receiver;
private SipPhone phone;
- private String phoneContact = "sip:+17778889999@127.0.0.1:5091";
+ private static String phonePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String phoneContact = "sip:+17778889999@127.0.0.1:" + phonePort;
private static SipStackTool tool2;
private SipStack alice;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5092";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
public SmsSessionTest() {
super();
@@ -80,14 +92,23 @@ public static void beforeClass() throws Exception {
tool = new SipStackTool("SmsSessionTest");
tool2 = new SipStackTool("SmsSessionTest2");
}
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- receiver = tool.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- phone = receiver.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, phoneContact);
+ receiver = tool.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", phonePort, restcommContact);
+ phone = receiver.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, phoneContact);
- alice = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- alicePhone = alice.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ alice = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = alice.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
}
@After
@@ -110,8 +131,8 @@ public void after() throws Exception {
@Test
public void testSendSmsRedirectReceiveSms() throws ParseException {
// Send restcomm an sms.
- final String proxy = phone.getStackAddress() + ":5080;lr/udp";
- final String to = "sip:+12223334450@127.0.0.1:5080";
+ final String proxy = phone.getStackAddress() + ":" + restcommPort + ";lr/udp";
+ final String to = "sip:+12223334450@" + restcommContact;
final String body = "Hello, waiting your response!";
final SipCall call = phone.createSipCall();
call.initiateOutgoingMessage(to, proxy, body);
@@ -129,8 +150,8 @@ public void testSendSmsRedirectReceiveSms() throws ParseException {
@Test
public void testSendSmsRedirectReceiveSms2() throws ParseException {
// Send restcomm an sms.
- final String proxy = phone.getStackAddress() + ":5080;lr/udp";
- final String to = "sip:2001@127.0.0.1:5080";
+ final String proxy = phone.getStackAddress() + ":" + restcommPort + ";lr/udp";
+ final String to = "sip:2001@" + restcommContact;
final String body = "Hello, waiting your response!";
final SipCall call = phone.createSipCall();
call.initiateOutgoingMessage(to, proxy, body);
@@ -148,8 +169,8 @@ public void testSendSmsRedirectReceiveSms2() throws ParseException {
@Test
public void testSendSmsRedirectReceiveSms3() throws ParseException {
// Send restcomm an sms.
- final String proxy = phone.getStackAddress() + ":5080;lr/udp";
- final String to = "sip:2001@127.0.0.1:5080";
+ final String proxy = phone.getStackAddress() + ":" + restcommPort + ";lr/udp";
+ final String to = "sip:2001@" + restcommContact;
final String body = "Hello, waiting your response!";
final SipCall call = phone.createSipCall();
call.initiateOutgoingMessage(to, proxy, body);
@@ -167,7 +188,7 @@ public void testSendSmsRedirectReceiveSms3() throws ParseException {
@Test
public void testAliceEchoTest() throws ParseException {
- SipURI uri = alice.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = alice.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
Credential credential = new Credential("127.0.0.1", "alice", "1234");
@@ -178,8 +199,8 @@ public void testAliceEchoTest() throws ParseException {
aliceCall.listenForMessage();
// // Send restcomm an sms.
- final String proxy = phone.getStackAddress() + ":5080;lr/udp";
- final String to = "sip:2002@127.0.0.1:5080";
+ final String proxy = phone.getStackAddress() + ":" + restcommPort + ";lr/udp";
+ final String to = "sip:2002@" + restcommContact;
final String body = "Hello, waiting your response!";
final SipCall call = phone.createSipCall();
call.initiateOutgoingMessage(to, proxy, body);
@@ -191,7 +212,7 @@ public void testAliceEchoTest() throws ParseException {
assertTrue(aliceCall.sendMessageResponse(202, "Alice-Accepted", -1));
String messageBody = new String(aliceCall.getLastReceivedMessageRequest().getRawContent());
assertTrue(messageBody.equals("Hello World!"));
- aliceCall.initiateOutgoingMessage("sip:+17778889999@127.0.0.1:5091", null, "Its great to hear from you!");
+ aliceCall.initiateOutgoingMessage(phoneContact, null, "Its great to hear from you!");
assertTrue(aliceCall.waitForAuthorisation(5000));
call.listenForMessage();
@@ -213,7 +234,7 @@ public void testSmsWithCustomHeaders() throws ParseException {
.withHeader("Content-Type", "text/xml")
.withBody(smsRcml)));
- SipURI uri = alice.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = alice.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
Credential credential = new Credential("127.0.0.1", "alice", "1234");
@@ -224,8 +245,8 @@ public void testSmsWithCustomHeaders() throws ParseException {
aliceCall.listenForMessage();
// // Send restcomm an sms.
- final String proxy = phone.getStackAddress() + ":5080;lr/udp";
- final String to = "sip:2003@127.0.0.1:5080";
+ final String proxy = phone.getStackAddress() + ":" + restcommPort + ";lr/udp";
+ final String to = "sip:2003@" + restcommContact;
final String body = "Hello, waiting your response!";
final SipCall call = phone.createSipCall();
ArrayList additionalHeaders = new ArrayList();
@@ -241,7 +262,7 @@ public void testSmsWithCustomHeaders() throws ParseException {
assertTrue(aliceCall.sendMessageResponse(202, "Alice-Accepted", -1));
String messageBody = new String(aliceCall.getLastReceivedMessageRequest().getRawContent());
assertTrue(messageBody.equals("Hello World!"));
- aliceCall.initiateOutgoingMessage("sip:+17778889999@127.0.0.1:5091", null, "Its great to hear from you!");
+ aliceCall.initiateOutgoingMessage(phoneContact, null, "Its great to hear from you!");
assertTrue(aliceCall.waitForAuthorisation(5000));
call.listenForMessage();
@@ -254,8 +275,8 @@ public void testSmsWithCustomHeaders() throws ParseException {
@Test
public void sendMessageUsingValidContentType() throws ParseException {
- final String proxy = phone.getStackAddress() + ":5080;lr/udp";
- final String to = "sip:+12223334450@127.0.0.1:5080";
+ final String proxy = phone.getStackAddress() + ":" + restcommPort + ";lr/udp";
+ final String to = "sip:+12223334450@" + restcommContact;
final String body = "VALID-CONTENT-TYPE";
final SipCall call = phone.createSipCall();
gov.nist.javax.sip.header.ContentType header = new gov.nist.javax.sip.header.ContentType();
@@ -279,8 +300,8 @@ public void sendMessageUsingValidContentType() throws ParseException {
@Test
public void sendMessageUsingInvalidContentType() throws ParseException {
- final String proxy = phone.getStackAddress() + ":5080;lr/udp";
- final String to = "sip:+12223334450@127.0.0.1:5080";
+ final String proxy = phone.getStackAddress() + ":" + restcommPort + ";lr/udp";
+ final String to = "sip:+12223334450@" + restcommContact;
final String body = "INVALID-CONTENT-TYPE-COMPOSING";
final SipCall call = phone.createSipCall();
gov.nist.javax.sip.header.ContentType header = new gov.nist.javax.sip.header.ContentType();
@@ -306,8 +327,8 @@ public void sendMessageUsingInvalidContentType() throws ParseException {
@Test
public void sendMessageUsingInvalidContentType2() throws ParseException {
- final String proxy = phone.getStackAddress() + ":5080;lr/udp";
- final String to = "sip:+12223334450@127.0.0.1:5080";
+ final String proxy = phone.getStackAddress() + ":" + restcommPort + ";lr/udp";
+ final String to = "sip:+12223334450@" + restcommContact;
final String body = "INVALID-CONTENT-TYPE-HTML";
final SipCall call = phone.createSipCall();
gov.nist.javax.sip.header.ContentType header = new gov.nist.javax.sip.header.ContentType();
@@ -333,20 +354,31 @@ public void sendMessageUsingInvalidContentType2() throws ParseException {
@Deployment(name = "SmsSessionTest", managed = true, testable = false)
public static WebArchive createWebArchive() {
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm_SmsTest.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_SmsTest", "data/hsql/restcomm.script");
- archive.addAsWebResource("entry.xml");
- archive.addAsWebResource("sms.xml");
- archive.addAsWebResource("sms_to_alice.xml");
- return archive;
- }
+ reconfigurePorts();
+
+ Map webInfResources = new HashMap();
+ webInfResources.put("restcomm_SmsTest.xml", "conf/restcomm.xml");
+ webInfResources.put("restcomm.script_SmsTest", "data/hsql/restcomm.script");
+ webInfResources.put("sip.xml", "sip.xml");
+ webInfResources.put("akka_application.conf", "classes/application.conf");
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5091", String.valueOf(phonePort));
+ replacements.put("5092", String.valueOf(alicePort));
+
+
+ List resources = new ArrayList(Arrays.asList(
+ "entry.xml",
+ "sms.xml",
+ "sms_to_alice.xml"
+ ));
+ return WebArchiveUtil.createWebArchiveNoGw(webInfResources,
+ resources,
+ replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsTest.java
index 80ae03a2cf..e13dc2b6a7 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/sms/SmsTest.java
@@ -27,7 +27,10 @@
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.sip.address.SipURI;
import javax.sip.header.Header;
@@ -44,15 +47,15 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.restcomm.connect.commons.Version;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* @author gvagenas
@@ -63,19 +66,21 @@ public class SmsTest {
private final static Logger logger = Logger.getLogger(SmsTest.class);
private static final String version = Version.getVersion();
-
- private static final byte[] bytes = new byte[] { 118, 61, 48, 13, 10, 111, 61, 117, 115, 101, 114, 49, 32, 53, 51, 54, 53,
+
+ private static final byte[] bytes = new byte[]{118, 61, 48, 13, 10, 111, 61, 117, 115, 101, 114, 49, 32, 53, 51, 54, 53,
53, 55, 54, 53, 32, 50, 51, 53, 51, 54, 56, 55, 54, 51, 55, 32, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46,
48, 46, 49, 13, 10, 115, 61, 45, 13, 10, 99, 61, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46, 48, 46, 49,
13, 10, 116, 61, 48, 32, 48, 13, 10, 109, 61, 97, 117, 100, 105, 111, 32, 54, 48, 48, 48, 32, 82, 84, 80, 47, 65,
- 86, 80, 32, 48, 13, 10, 97, 61, 114, 116, 112, 109, 97, 112, 58, 48, 32, 80, 67, 77, 85, 47, 56, 48, 48, 48, 13, 10 };
+ 86, 80, 32, 48, 13, 10, 97, 61, 114, 116, 112, 109, 97, 112, 58, 48, 32, 80, 67, 77, 85, 47, 56, 48, 48, 48, 13, 10};
private static final String body = new String(bytes);
-
+
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
@ArquillianResource
private Deployer deployer;
@ArquillianResource
URL deploymentUrl;
-
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -84,53 +89,64 @@ public class SmsTest {
private static SipStackTool tool6;
private static SipStackTool tool7;
private static SipStackTool tool8;
-
+
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
-
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
+
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:george@127.0.0.1:5092";
-
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
+
private SipStack fotiniSipStack;
private SipPhone fotiniPhone;
- private String fotiniContact = "sip:fotini@127.0.0.1:5093";
-
+ private static String fotiniPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String fotiniContact = "sip:fotini@127.0.0.1:" + fotiniPort;
+
private SipStack aliceSipStackOrg2;
private SipPhone alicePhoneOrg2;
+ private static String alicePort2 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
private String aliceContactOrg2 = "sip:alice@org2.restcomm.com";
-
+
private SipStack bobSipStackOrg2;
private SipPhone bobPhoneOrg2;
+ private static String bobPort2 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
private String bobContactOrg2 = "sip:bob@org2.restcomm.com";
private SipStack georgeSipStackOrg2;
private SipPhone georgePhoneOrg2;
+ private static String georgePort2 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
private String georgeContactOrg2 = "sip:george@org2.restcomm.com";
-
+
private SipStack fotiniSipStackOrg2;
private SipPhone fotiniPhoneOrg2;
+ private static String fotiniPort2 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
private String fotiniContactOrg2 = "sip:fotini@org2.restcomm.com";
-
- private String dialSendSMS = "sip:+12223334444@127.0.0.1:5080";
- private String dialSendSMS2 = "sip:+12223334445@127.0.0.1:5080";
- private String dialSendSMS2_Greek = "sip:+12223334447@127.0.0.1:5080";
- private String dialSendSMS2_Greek_Huge = "sip:+12223334448@127.0.0.1:5080";
- private String dialSendSMS3 = "sip:+12223334446@127.0.0.1:5080";
- private String dialSendSMSwithCustomHeaders = "sip:+12223334449@127.0.0.1:5080";
- private String dialSendSMS2Org2 = "sip:+12223334445@org2.restcomm.com";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private static String dialSendSMS = "sip:+12223334444@" + restcommContact;
+ private static String dialSendSMS2 = "sip:+12223334445@" + restcommContact;
+ private static String dialSendSMS2_Greek = "sip:+12223334447@" + restcommContact;
+ private static String dialSendSMS2_Greek_Huge = "sip:+12223334448@" + restcommContact;
+ private static String dialSendSMS3 = "sip:+12223334446@" + restcommContact;
+ private static String dialSendSMSwithCustomHeaders = "sip:+12223334449@" + restcommContact;
+ private static String dialSendSMS2Org2 = "sip:+12223334445@org2.restcomm.com";
private String greekHugeMessage = "Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα "
+ "Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα "
+ "Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα "
+ "Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα Καλημερα "
+ "Καλημερα Καλημερα Καλημερα";
-
+
@BeforeClass
public static void beforeClass() throws Exception {
tool1 = new SipStackTool("SmsTest1");
@@ -143,33 +159,49 @@ public static void beforeClass() throws Exception {
tool8 = new SipStackTool("SmsTest8");
}
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ dialSendSMS = "sip:+12223334444@" + restcommContact;
+ dialSendSMS2 = "sip:+12223334445@" + restcommContact;
+ dialSendSMS2_Greek = "sip:+12223334447@" + restcommContact;
+ dialSendSMS2_Greek_Huge = "sip:+12223334448@" + restcommContact;
+ dialSendSMS3 = "sip:+12223334446@" + restcommContact;
+ dialSendSMSwithCustomHeaders = "sip:+12223334449@" + restcommContact;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
+
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
-
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
-
- georgeSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
-
- fotiniSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5093", "127.0.0.1:5080");
- fotiniPhone = fotiniSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, fotiniContact);
-
- aliceSipStackOrg2 = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5094", "127.0.0.1:5080");
- alicePhoneOrg2 = aliceSipStackOrg2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContactOrg2);
-
- bobSipStackOrg2 = tool6.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5095", "127.0.0.1:5080");
- bobPhoneOrg2 = bobSipStackOrg2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContactOrg2);
-
- georgeSipStackOrg2 = tool7.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5096", "127.0.0.1:5080");
- georgePhoneOrg2 = georgeSipStackOrg2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContactOrg2);
-
- fotiniSipStackOrg2 = tool8.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5097", "127.0.0.1:5080");
- fotiniPhoneOrg2 = fotiniSipStackOrg2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, fotiniContactOrg2);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
+
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
+
+ georgeSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
+
+ fotiniSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", fotiniPort, restcommContact);
+ fotiniPhone = fotiniSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, fotiniContact);
+
+ aliceSipStackOrg2 = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort2, restcommContact);
+ alicePhoneOrg2 = aliceSipStackOrg2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContactOrg2);
+
+ bobSipStackOrg2 = tool6.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort2, restcommContact);
+ bobPhoneOrg2 = bobSipStackOrg2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContactOrg2);
+
+ georgeSipStackOrg2 = tool7.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort2, restcommContact);
+ georgePhoneOrg2 = georgeSipStackOrg2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContactOrg2);
+
+ fotiniSipStackOrg2 = tool8.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", fotiniPort2, restcommContact);
+ fotiniPhoneOrg2 = fotiniSipStackOrg2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, fotiniContactOrg2);
}
-
+
@After
public void after() throws Exception {
if (bobPhone != null) {
@@ -185,30 +217,30 @@ public void after() throws Exception {
if (alicePhone != null) {
alicePhone.dispose();
}
-
+
if (georgeSipStack != null) {
georgeSipStack.dispose();
}
if (georgePhone != null) {
georgePhone.dispose();
}
-
+
if (fotiniSipStack != null) {
fotiniSipStack.dispose();
}
if (fotiniPhone != null) {
fotiniPhone.dispose();
}
-
+
if (georgeSipStackOrg2 != null) {
georgeSipStackOrg2.dispose();
}
if (georgePhoneOrg2 != null) {
georgePhoneOrg2.dispose();
}
-
+
if (fotiniSipStackOrg2 != null) {
- fotiniSipStack.dispose();
+ fotiniSipStackOrg2.dispose();
}
if (fotiniPhoneOrg2 != null) {
fotiniPhoneOrg2.dispose();
@@ -227,11 +259,11 @@ public void after() throws Exception {
alicePhoneOrg2.dispose();
}
}
-
+
@Test
public void testAliceActsAsSMSGatewayAndReceivesSMS() throws ParseException {
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -260,7 +292,7 @@ public void testAliceActsAsSMSGatewayAndReceivesSMS() throws ParseException {
String msgReceived = new String(aliceCall.getLastReceivedMessageRequest().getRawContent());
assertTrue("Hello World!".equals(msgReceived));
aliceCall.sendMessageResponse(200, "OK-From-Alice", 3600);
-
+
assertTrue(bobCall.waitForDisconnect(40 * 1000));
assertTrue(bobCall.respondToDisconnect());
@@ -270,16 +302,16 @@ public void testAliceActsAsSMSGatewayAndReceivesSMS() throws ParseException {
exception.printStackTrace();
}
}
-
+
@Test
public void TestIncomingSmsSendToClientAlice() throws ParseException, InterruptedException {
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
SipCall aliceCall = alicePhone.createSipCall();
aliceCall.listenForMessage();
-
+
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
bobCall.initiateOutgoingMessage(dialSendSMS2, null, "Hello from Bob!");
@@ -290,22 +322,21 @@ public void TestIncomingSmsSendToClientAlice() throws ParseException, Interrupte
//Restcomm receives the SMS message from Bob, matches the DID with an RCML application, and executes it.
//The new RCML application sends an SMS to Alice with body "Hello World!"
-
assertTrue(aliceCall.waitForMessage(5 * 1000));
String msgReceived = new String(aliceCall.getLastReceivedMessageRequest().getRawContent());
assertTrue("Hello World!".equals(msgReceived));
aliceCall.sendMessageResponse(200, "OK-From-Alice", 3600);
}
-
+
@Test
public void TestIncomingSmsSendToClientAliceOfOrganization2() throws ParseException, InterruptedException {
- SipURI uri = aliceSipStackOrg2.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
- assertTrue(alicePhoneOrg2.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5094", 3600, 3600));
+ SipURI uri = aliceSipStackOrg2.getAddressFactory().createSipURI(null, restcommContact);
+ assertTrue(alicePhoneOrg2.register(uri, "alice", "1234", "sip:alice@127.0.0.1:" + alicePort2, 3600, 3600));
// Prepare second phone to receive call
SipCall aliceCallOrg2 = alicePhoneOrg2.createSipCall();
aliceCallOrg2.listenForMessage();
-
+
// Create outgoing call with first phone
final SipCall bobCallOrg2 = bobPhoneOrg2.createSipCall();
bobCallOrg2.initiateOutgoingMessage(dialSendSMS2Org2, null, "Hello from Bob!");
@@ -316,22 +347,21 @@ public void TestIncomingSmsSendToClientAliceOfOrganization2() throws ParseExcept
//Restcomm receives the SMS message from Bob, matches the DID with an RCML application, and executes it.
//The new RCML application sends an SMS to Alice with body "Hello World!"
-
assertTrue(aliceCallOrg2.waitForMessage(5 * 1000));
String msgReceived = new String(aliceCallOrg2.getLastReceivedMessageRequest().getRawContent());
assertTrue("Hello World!".equals(msgReceived));
aliceCallOrg2.sendMessageResponse(200, "OK-From-Alice", 3600);
}
-
+
@Test
public void TestIncomingSmsSendToClientAliceGreekHugeMessage() throws ParseException, InterruptedException {
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
SipCall aliceCall = alicePhone.createSipCall();
aliceCall.listenForMessage();
-
+
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
bobCall.initiateOutgoingMessage(dialSendSMS2_Greek_Huge, null, greekHugeMessage);
@@ -342,22 +372,21 @@ public void TestIncomingSmsSendToClientAliceGreekHugeMessage() throws ParseExcep
//Restcomm receives the SMS message from Bob, matches the DID with an RCML application, and executes it.
//The new RCML application sends an SMS to Alice with body "Hello World!"
-
assertTrue(aliceCall.waitForMessage(5 * 1000));
String msgReceived = new String(aliceCall.getLastReceivedMessageRequest().getRawContent());
assertTrue(greekHugeMessage.equals(msgReceived));
aliceCall.sendMessageResponse(200, "OK-From-Alice", 3600);
}
-
+
@Test
public void TestIncomingSmsSendToClientAliceGreek() throws ParseException, InterruptedException {
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
SipCall aliceCall = alicePhone.createSipCall();
aliceCall.listenForMessage();
-
+
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
bobCall.initiateOutgoingMessage(dialSendSMS2_Greek, null, "Καλώς τον Γιώργο!");
@@ -368,22 +397,21 @@ public void TestIncomingSmsSendToClientAliceGreek() throws ParseException, Inter
//Restcomm receives the SMS message from Bob, matches the DID with an RCML application, and executes it.
//The new RCML application sends an SMS to Alice with body "Hello World!"
-
assertTrue(aliceCall.waitForMessage(5 * 1000));
String msgReceived = new String(aliceCall.getLastReceivedMessageRequest().getRawContent());
assertTrue("Καλώς τον Γιώργο!".equals(msgReceived));
aliceCall.sendMessageResponse(200, "OK-From-Alice", 3600);
}
-
+
@Test
public void TestIncomingSmsSendToNumber1313() throws ParseException, InterruptedException {
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
- assertTrue(alicePhone.register(uri, "alice", "1234", "sip:1313@127.0.0.1:5091", 3600, 3600));
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
+ assertTrue(alicePhone.register(uri, "alice", "1234", "sip:1313@127.0.0.1:" + alicePort, 3600, 3600));
// Prepare second phone to receive call
SipCall aliceCall = alicePhone.createSipCall();
aliceCall.listenForMessage();
-
+
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
bobCall.initiateOutgoingMessage(dialSendSMS3, null, "Hello from Bob!");
@@ -394,7 +422,6 @@ public void TestIncomingSmsSendToNumber1313() throws ParseException, Interrupted
//Restcomm receives the SMS message from Bob, matches the DID with an RCML application, and executes it.
//The new RCML application sends an SMS to Alice with body "Hello World!"
-
assertTrue(aliceCall.waitForMessage(5 * 1000));
String msgReceived = new String(aliceCall.getLastReceivedMessageRequest().getRawContent());
assertTrue("Hello World!".equals(msgReceived));
@@ -405,26 +432,26 @@ public void TestIncomingSmsSendToNumber1313() throws ParseException, Interrupted
public void TestIncomingSmsSendToNumber1313WithCustomHeaders() throws ParseException, InterruptedException {
String myFirstHeaderName = "X-Custom-Header-1";
String myFirstHeaderValue = "X Custom Header Value 1";
-
+
String mySecondHeaderName = "X-Custom-Header-2";
String mySecondHeaderValue = "X Custom Header Value 2";
-
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
- assertTrue(alicePhone.register(uri, "alice", "1234", "sip:1313@127.0.0.1:5091", 3600, 3600));
+
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
+ assertTrue(alicePhone.register(uri, "alice", "1234", "sip:1313@127.0.0.1:" + alicePort, 3600, 3600));
// Prepare second phone to receive call
SipCall aliceCall = alicePhone.createSipCall();
aliceCall.listenForMessage();
-
+
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
-
+
ArrayList additionalHeaders = new ArrayList();
Header header1 = bobSipStack.getHeaderFactory().createHeader(myFirstHeaderName, myFirstHeaderValue);
Header header2 = bobSipStack.getHeaderFactory().createHeader(mySecondHeaderName, mySecondHeaderValue);
additionalHeaders.add(header1);
additionalHeaders.add(header2);
-
+
bobCall.initiateOutgoingMessage(bobContact, dialSendSMSwithCustomHeaders, null, additionalHeaders, null, "Hello from Bob!");
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -433,26 +460,25 @@ public void TestIncomingSmsSendToNumber1313WithCustomHeaders() throws ParseExcep
//Restcomm receives the SMS message from Bob, matches the DID with an RCML application, and executes it.
//The new RCML application sends an SMS to Alice with body "Hello World!"
-
assertTrue(aliceCall.waitForMessage(5 * 1000));
Request receivedRequest = aliceCall.getLastReceivedMessageRequest();
String msgReceived = new String(receivedRequest.getRawContent());
assertTrue("Hello World!".equals(msgReceived));
- SIPHeader myFirstHeader = (SIPHeader)receivedRequest.getHeader(myFirstHeaderName);
+ SIPHeader myFirstHeader = (SIPHeader) receivedRequest.getHeader(myFirstHeaderName);
assertTrue(myFirstHeader != null);
assertTrue(myFirstHeader.getValue().equalsIgnoreCase(myFirstHeaderValue));
-
- SIPHeader mySecondHeader = (SIPHeader)receivedRequest.getHeader(mySecondHeaderName);
+
+ SIPHeader mySecondHeader = (SIPHeader) receivedRequest.getHeader(mySecondHeaderName);
assertTrue(mySecondHeader != null);
assertTrue(mySecondHeader.getHeaderValue().equalsIgnoreCase(mySecondHeaderValue));
-
+
aliceCall.sendMessageResponse(200, "OK-From-Alice", 3600);
}
-
+
@Test
public void testP2PSendSMS_GeorgeClient_ToFotiniClient() throws ParseException {
- SipURI uri = georgeSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = georgeSipStack.getAddressFactory().createSipURI(null, restcommContact);
//Register George phone
assertTrue(georgePhone.register(uri, "george", "1234", georgeContact, 3600, 3600));
Credential georgeCredentials = new Credential("127.0.0.1", "george", "1234");
@@ -462,42 +488,42 @@ public void testP2PSendSMS_GeorgeClient_ToFotiniClient() throws ParseException {
assertTrue(fotiniPhone.register(uri, "fotini", "1234", fotiniContact, 3600, 3600));
Credential fotiniCredentials = new Credential("127.0.0.1", "fotini", "1234");
fotiniPhone.addUpdateCredential(fotiniCredentials);
-
+
//Prepare Fotini to receive message
SipCall fotiniCall = fotiniPhone.createSipCall();
fotiniCall.listenForMessage();
//Prepare George to send message
SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingMessage(georgeContact, "sip:fotini@127.0.0.1:5080", null, null, null, greekHugeMessage);
+ georgeCall.initiateOutgoingMessage(georgeContact, "sip:fotini@" + restcommContact, null, null, null, greekHugeMessage);
assertLastOperationSuccess(georgeCall);
georgeCall.waitForAuthorisation(30 * 1000);
assertTrue(georgeCall.waitOutgoingMessageResponse(3000));
- assertTrue(georgeCall.getLastReceivedResponse().getStatusCode()==Response.TRYING);
-
+ assertEquals(Response.TRYING, georgeCall.getLastReceivedResponse().getStatusCode());
+
assertTrue(fotiniCall.waitForMessage(30 * 1000));
assertTrue(fotiniCall.sendMessageResponse(200, "OK-Fotini-Mesasge-Receieved", 1800));
assertTrue(georgeCall.waitOutgoingMessageResponse(3000));
- assertTrue(georgeCall.getLastReceivedResponse().getStatusCode()==Response.OK);
+ assertTrue(georgeCall.getLastReceivedResponse().getStatusCode() == Response.OK);
List msgsFromGeorge = fotiniCall.getAllReceivedMessagesContent();
- assertTrue(msgsFromGeorge.size()>0);
+ assertTrue(msgsFromGeorge.size() > 0);
assertTrue(msgsFromGeorge.get(0).equals(greekHugeMessage));
}
-
+
@Test
public void testP2PSendSMS_GeorgeClient_ToFotiniClientOrg2() throws ParseException {
- SipURI uri = georgeSipStackOrg2.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = georgeSipStackOrg2.getAddressFactory().createSipURI(null, restcommContact);
//Register George phone
- assertTrue(georgePhoneOrg2.register(uri, "george", "1234", "sip:george@127.0.0.1:5096", 3600, 3600));
+ assertTrue(georgePhoneOrg2.register(uri, "george", "1234", "sip:george@127.0.0.1:" + georgePort2, 3600, 3600));
Credential georgeCredentialsOrg2 = new Credential("org2.restcomm.com", "george", "1234");
georgePhoneOrg2.addUpdateCredential(georgeCredentialsOrg2);
//Register Fotini phone
- assertTrue(fotiniPhoneOrg2.register(uri, "fotini", "1234", "sip:fotini@127.0.0.1:5097", 3600, 3600));
+ assertTrue(fotiniPhoneOrg2.register(uri, "fotini", "1234", "sip:fotini@127.0.0.1:" + fotiniPort2, 3600, 3600));
Credential fotiniCredentials = new Credential("org2.restcomm.com", "fotini", "1234");
fotiniPhoneOrg2.addUpdateCredential(fotiniCredentials);
-
+
//Prepare Fotini to receive message
SipCall fotiniCallOrg2 = fotiniPhoneOrg2.createSipCall();
fotiniCallOrg2.listenForMessage();
@@ -508,28 +534,28 @@ public void testP2PSendSMS_GeorgeClient_ToFotiniClientOrg2() throws ParseExcepti
assertLastOperationSuccess(georgeCallOrg2);
georgeCallOrg2.waitForAuthorisation(30 * 1000);
assertTrue(georgeCallOrg2.waitOutgoingMessageResponse(3000));
- assertTrue(georgeCallOrg2.getLastReceivedResponse().getStatusCode()==Response.TRYING);
-
+ assertTrue(georgeCallOrg2.getLastReceivedResponse().getStatusCode() == Response.TRYING);
+
assertTrue(fotiniCallOrg2.waitForMessage(30 * 1000));
assertTrue(fotiniCallOrg2.sendMessageResponse(200, "OK-Fotini-Mesasge-Receieved", 1800));
assertTrue(georgeCallOrg2.waitOutgoingMessageResponse(3000));
- assertTrue(georgeCallOrg2.getLastReceivedResponse().getStatusCode()==Response.OK);
+ assertTrue(georgeCallOrg2.getLastReceivedResponse().getStatusCode() == Response.OK);
List msgsFromGeorge = fotiniCallOrg2.getAllReceivedMessagesContent();
- assertTrue(msgsFromGeorge.size()>0);
+ assertTrue(msgsFromGeorge.size() > 0);
assertTrue(msgsFromGeorge.get(0).equals(greekHugeMessage));
}
@Test
public void testP2PSendSMS_GeorgeClient_ToFotiniClient_EmptyContent() throws ParseException {
- SipURI uri = georgeSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = georgeSipStack.getAddressFactory().createSipURI(null, restcommContact);
//Register George phone
assertTrue(georgePhone.register(uri, "george", "1234", georgeContact, 3600, 3600));
Credential georgeCredentials = new Credential("127.0.0.1", "george", "1234");
georgePhone.addUpdateCredential(georgeCredentials);
//Register Fotini phone
- assertTrue(fotiniPhone.register(uri, "fotini", "1234", fotiniContact, 3600, 3600));
+ assertTrue(fotiniPhone.register(uri, "fotini", "1234", "sip:fotini@" + restcommContact, 3600, 3600));
Credential fotiniCredentials = new Credential("127.0.0.1", "fotini", "1234");
fotiniPhone.addUpdateCredential(fotiniCredentials);
@@ -539,35 +565,49 @@ public void testP2PSendSMS_GeorgeClient_ToFotiniClient_EmptyContent() throws Par
//Prepare George to send message
SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingMessage(georgeContact, "sip:fotini@127.0.0.1:5080", null, null, null, null);
+ georgeCall.initiateOutgoingMessage(georgeContact, fotiniContact, null, null, null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingMessageResponse(5000));
- assertTrue(georgeCall.getLastReceivedResponse().getStatusCode()==Response.NOT_ACCEPTABLE);
+ assertTrue(georgeCall.getLastReceivedResponse().getStatusCode() == Response.NOT_ACCEPTABLE);
}
-
+
@Deployment(name = "SmsTest", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- restcommArchive.addClass(SmsRcmlServlet.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/web.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("web_for_SmsTest.xml", "web.xml");
- archive.addAsWebInfResource("restcomm_SmsTest.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_SmsTest", "data/hsql/restcomm.script");
- archive.addAsWebResource("send-sms-test.xml");
- archive.addAsWebResource("send-sms-test-greek.xml");
- archive.addAsWebResource("send-sms-test-greek_huge.xml");
- archive.addAsWebResource("send-sms-test2.xml");
- archive.addAsWebResource("dial-client-entry.xml");
- logger.info("Packaged Test App");
- return archive;
+ reconfigurePorts();
+
+ Map webInfResources = new HashMap();
+ webInfResources.put("restcomm_SmsTest.xml", "conf/restcomm.xml");
+ webInfResources.put("restcomm.script_SmsTest", "data/hsql/restcomm.script");
+ webInfResources.put("sip.xml", "sip.xml");
+ webInfResources.put("web_for_SmsTest.xml", "web.xml");
+ webInfResources.put("akka_application.conf", "classes/application.conf");
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(georgePort));
+ replacements.put("5093", String.valueOf(fotiniPort));
+
+ replacements.put("5094", String.valueOf(alicePort2));
+ replacements.put("5095", String.valueOf(bobPort2));
+ replacements.put("5096", String.valueOf(georgePort2));
+ replacements.put("5097", String.valueOf(fotiniPort2));
+
+
+ List resources = new ArrayList(Arrays.asList(
+ "send-sms-test.xml",
+ "send-sms-test-greek.xml",
+ "send-sms-test-greek_huge.xml",
+ "send-sms-test2.xml",
+ "dial-client-entry.xml"
+ ));
+ return WebArchiveUtil.createWebArchiveNoGw(webInfResources,
+ resources,
+ replacements);
}
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallLifecycleAnswerDelayTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallLifecycleAnswerDelayTest.java
index a8e1cffc0a..52d591d5d9 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallLifecycleAnswerDelayTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallLifecycleAnswerDelayTest.java
@@ -62,10 +62,15 @@
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Dial Action attribute. Reference: https://www.twilio.com/docs/api/twiml/dial#attributes-action The 'action'
@@ -92,10 +97,12 @@ public class CallLifecycleAnswerDelayTest {
@ArquillianResource
URL deploymentUrl;
- //Dial Action URL: http://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/DialAction Method: POST
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -104,23 +111,31 @@ public class CallLifecycleAnswerDelayTest {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// Henrique is a simple SIP Client. Will not register with Restcomm
private SipStack henriqueSipStack;
private SipPhone henriquePhone;
- private String henriqueContact = "sip:henrique@127.0.0.1:5092";
+ private static String henriquePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String henriqueContact = "sip:henrique@127.0.0.1:" + henriquePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
@@ -132,21 +147,32 @@ public static void beforeClass() throws Exception {
tool3 = new SipStackTool("CallLifecycleDelayAnswerTest3");
tool4 = new SipStackTool("CallLifecycleDelayAnswerTest");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, henriqueContact);
+ henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", henriquePort, restcommContact);
+ henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, henriqueContact);
+
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
}
@After
@@ -195,7 +221,7 @@ public void testDialCancelBeforeDialingClientAliceAfterRinging() throws ParseExc
assertTrue(MonitoringServiceTool.getInstance().getStatistics(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==0);
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==0);
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -204,7 +230,7 @@ public void testDialCancelBeforeDialingClientAliceAfterRinging() throws ParseExc
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -262,7 +288,7 @@ public void testDialClientAlice() throws ParseException, InterruptedException, M
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -271,7 +297,7 @@ public void testDialClientAlice() throws ParseException, InterruptedException, M
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -365,7 +391,7 @@ public void testDialNumberPstn() throws ParseException, InterruptedException, Ma
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -434,7 +460,7 @@ public void testDialNumberPstnRegisteredClientTimesOutCallDisconnects() throws P
SipCall georgeCall = georgePhone.createSipCall();
georgeCall.listenForIncomingCall();
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
Credential c = new Credential("127.0.0.1", "alice", "1234");
@@ -442,7 +468,7 @@ public void testDialNumberPstnRegisteredClientTimesOutCallDisconnects() throws P
// Create outgoing call with first phone
final SipCall aliceCall = alicePhone.createSipCall();
- aliceCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ aliceCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(aliceCall);
assertTrue(aliceCall.waitForAuthorisation(5000));
assertTrue(aliceCall.waitOutgoingCallResponse(5 * 1000));
@@ -512,7 +538,7 @@ public void testDialNumberPstnForbidden() throws ParseException, InterruptedExce
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -591,7 +617,7 @@ public void testDialNumberPstnBobDisconnects() throws ParseException, Interrupte
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -674,7 +700,7 @@ public void testDialNumberPstn_404NotHere() throws ParseException, InterruptedEx
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -757,7 +783,7 @@ public void testDialNumberPstnNoAnswer() throws ParseException, InterruptedExcep
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -826,7 +852,7 @@ public void testDialNumberPstn_500ServerInternalError() throws ParseException, I
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -887,7 +913,7 @@ public void testDialNumberPstn_BusyHere() throws ParseException, InterruptedExce
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -945,7 +971,7 @@ public void testDialClientAlice_InvalidRCML() throws ParseException, Interrupted
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcmlInvalidRCML)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -954,7 +980,7 @@ public void testDialClientAlice_InvalidRCML() throws ParseException, Interrupted
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1000,22 +1026,22 @@ public void testDialClientAlice_InvalidRCML() throws ParseException, Interrupted
@Deployment(name = "CallLifecycleDelayAnswerTest", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.delete("/WEB-INF/classes/application.conf");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm_calllifecycle-delay.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_callLifecycleTest", "data/hsql/restcomm.script");
- archive.addAsWebInfResource("akka_application.conf", "classes/application.conf");
- archive.addAsWebResource("dial-client-entry_wActionUrl.xml");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(henriquePort));
+
+ List resources = new ArrayList(Arrays.asList("dial-client-entry_wActionUrl.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm_calllifecycle-delay.xml",
+ "restcomm.script_callLifecycleTest",resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallLifecycleTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallLifecycleTest.java
index 245d9f1361..b8177a896b 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallLifecycleTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallLifecycleTest.java
@@ -55,9 +55,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -72,6 +70,10 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import com.google.gson.JsonObject;
+import java.util.HashMap;
+import java.util.Map;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Dial Action attribute. Reference: https://www.twilio.com/docs/api/twiml/dial#attributes-action The 'action'
@@ -98,10 +100,12 @@ public class CallLifecycleTest {
@ArquillianResource
URL deploymentUrl;
- //Dial Action URL: http://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/DialAction Method: POST
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -111,34 +115,43 @@ public class CallLifecycleTest {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// Henrique is a simple SIP Client. Will not register with Restcomm
private SipStack henriqueSipStack;
private SipPhone henriquePhone;
- private String henriqueContact = "sip:henrique@127.0.0.1:5092";
+ private static String henriquePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String henriqueContact = "sip:henrique@127.0.0.1:" + henriquePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
// subaccountclient is a simple SIP Client. Will register with Restcomm
private SipStack subAccountClientSipStack;
private SipPhone subAccountClientPhone;
- private String subAccountClientContact = "sip:subaccountclient@127.0.0.1:5093";
+ private static String subAccountPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String subAccountClientContact = "sip:subaccountclient@127.0.0.1:" + subAccountPort;
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
private String subAccountSid = "ACae6e420f425248d6a26948c17a9e2acg";
private String subAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
@BeforeClass
public static void beforeClass() throws Exception {
@@ -148,24 +161,34 @@ public static void beforeClass() throws Exception {
tool4 = new SipStackTool("DialActionTest4");
tool5 = new SipStackTool("DialActionTest5");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, henriqueContact);
+ henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", henriquePort, restcommContact);
+ henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, henriqueContact);
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
- subAccountClientSipStack = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5093", "127.0.0.1:5080");
- subAccountClientPhone = subAccountClientSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, subAccountClientContact);
+ subAccountClientSipStack = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", subAccountPort, restcommContact);
+ subAccountClientPhone = subAccountClientSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, subAccountClientContact);
}
@After
@@ -227,7 +250,7 @@ public void testDialCancelBeforeDialingClientAliceAfterTrying() throws ParseExce
assertTrue(MonitoringServiceTool.getInstance().getStatistics(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==0);
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==0);
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -236,7 +259,7 @@ public void testDialCancelBeforeDialingClientAliceAfterTrying() throws ParseExce
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -279,7 +302,7 @@ public void testDialCancelBeforeDialingClientAliceAfterRinging() throws ParseExc
assertTrue(MonitoringServiceTool.getInstance().getStatistics(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==0);
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==0);
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -288,7 +311,7 @@ public void testDialCancelBeforeDialingClientAliceAfterRinging() throws ParseExc
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -346,7 +369,7 @@ public void testDialClientAlice() throws ParseException, InterruptedException, M
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -355,7 +378,7 @@ public void testDialClientAlice() throws ParseException, InterruptedException, M
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -442,7 +465,7 @@ public void testDialClientAliceBehindLB() throws ParseException, InterruptedExce
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -451,7 +474,7 @@ public void testDialClientAliceBehindLB() throws ParseException, InterruptedExce
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -474,7 +497,7 @@ public void testDialClientAliceBehindLB() throws ParseException, InterruptedExce
String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
ArrayList additionalHeaders = new ArrayList();
Header lbIpAddr = aliceSipStack.getHeaderFactory().createHeader("X-Sip-Balancer-InitialRemoteAddr","127.0.0.1");
- Header lbPort = aliceSipStack.getHeaderFactory().createHeader("X-Sip-Balancer-InitialRemotePort","5091");
+ Header lbPort = aliceSipStack.getHeaderFactory().createHeader("X-Sip-Balancer-InitialRemotePort",alicePort);
additionalHeaders.add(lbIpAddr.toString());
additionalHeaders.add(lbPort.toString());
assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "Alice-OK", 3600, receivedBody, "application", "sdp",
@@ -543,7 +566,7 @@ public void testDialClient_CheckVIParameters() throws ParseException, Interrupte
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -552,7 +575,7 @@ public void testDialClient_CheckVIParameters() throws ParseException, Interrupte
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -617,7 +640,7 @@ public void testDialClientAliceWithTimeLimit() throws ParseException, Interrupte
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcmlWithTimeLimit)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -626,7 +649,7 @@ public void testDialClientAliceWithTimeLimit() throws ParseException, Interrupte
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -711,7 +734,7 @@ public void testDialInvalidClient() throws ParseException, InterruptedException,
.withHeader("Content-Type", "text/xml")
.withBody(dialInvalidClientRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -720,7 +743,7 @@ public void testDialInvalidClient() throws ParseException, InterruptedException,
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -778,7 +801,7 @@ public void testDialInvalidClientAndThenAlice() throws ParseException, Interrupt
.withHeader("Content-Type", "text/xml")
.withBody(dialInvalidClientRcmlAndThenAlice)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -787,7 +810,7 @@ public void testDialInvalidClientAndThenAlice() throws ParseException, Interrupt
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -858,7 +881,7 @@ public void testDialInvalidClientAndThenAlice() throws ParseException, Interrupt
assertTrue(jsonObj.get("status").getAsString().equalsIgnoreCase("completed"));
}
- private String dialInvalidClientRcmlAndThenAliceWithDialAction = "invalidClientalice";
+ private String dialInvalidClientRcmlAndThenAliceWithDialAction = "invalidClientalice";
private String dialActionRcml = "alice";
@@ -877,7 +900,7 @@ public void testDialInvalidClientAndThenAliceWithDialAction() throws ParseExcept
.withHeader("Content-Type", "text/xml")
.withBody(dialActionRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -886,7 +909,7 @@ public void testDialInvalidClientAndThenAliceWithDialAction() throws ParseExcept
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -972,7 +995,7 @@ public void testDialNumberPstn() throws ParseException, InterruptedException, Ma
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1050,7 +1073,7 @@ public void testDialNumberPstnAbortCallWith569() throws ParseException, Interrup
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, sdpToFailConnection, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, sdpToFailConnection, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1102,7 +1125,7 @@ public void testDialNumberPstnRegisteredClientTimesOutCallDisconnects() throws P
SipCall georgeCall = georgePhone.createSipCall();
georgeCall.listenForIncomingCall();
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
Credential c = new Credential("127.0.0.1", "alice", "1234");
@@ -1110,7 +1133,7 @@ public void testDialNumberPstnRegisteredClientTimesOutCallDisconnects() throws P
// Create outgoing call with first phone
final SipCall aliceCall = alicePhone.createSipCall();
- aliceCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ aliceCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(aliceCall);
assertTrue(aliceCall.waitForAuthorisation(5000));
assertTrue(aliceCall.waitOutgoingCallResponse(5 * 1000));
@@ -1180,7 +1203,7 @@ public void testDialNumberPstnForbidden() throws ParseException, InterruptedExce
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1264,7 +1287,7 @@ public void testDialNumberPstnBobDisconnects() throws ParseException, Interrupte
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1347,7 +1370,7 @@ public void testDialNumberPstn_404NotHere() throws ParseException, InterruptedEx
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1430,7 +1453,7 @@ public void testDialNumberPstnNoAnswer() throws ParseException, InterruptedExcep
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1500,7 +1523,7 @@ public void testDialNumberPstn_500ServerInternalError() throws ParseException, I
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1564,7 +1587,7 @@ public void testDialNumberPstn_BusyHere() throws ParseException, InterruptedExce
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1625,7 +1648,7 @@ public void testDialClientAlice_InvalidRCML() throws ParseException, Interrupted
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcmlInvalidRCML)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1634,7 +1657,7 @@ public void testDialClientAlice_InvalidRCML() throws ParseException, Interrupted
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1698,7 +1721,7 @@ public void testSubAccountClientDialsParentAccountNumber() throws ParseException
SipCall georgeCall = georgePhone.createSipCall();
georgeCall.listenForIncomingCall();
- SipURI uri = subAccountClientSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = subAccountClientSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(subAccountClientPhone.register(uri, "subaccountclient", "1234", subAccountClientContact, 3600, 3600));
Credential c = new Credential("127.0.0.1", "subaccountclient", "1234");
@@ -1706,7 +1729,7 @@ public void testSubAccountClientDialsParentAccountNumber() throws ParseException
// Create outgoing call with subAccountClient phone to parent number
final SipCall subAccountClientCall = subAccountClientPhone.createSipCall();
- subAccountClientCall.initiateOutgoingCall(subAccountClientContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ subAccountClientCall.initiateOutgoingCall(subAccountClientContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(subAccountClientCall);
assertTrue(subAccountClientCall.waitForAuthorisation(5000));
assertTrue(subAccountClientCall.waitOutgoingCallResponse(5 * 1000));
@@ -1862,22 +1885,22 @@ public void testDialClientAlice_DownloaderError_408Timeout() throws ParseExcepti
@Deployment(name = "DialAction", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.delete("/WEB-INF/classes/application.conf");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm_calllifecycle.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_callLifecycleTest", "data/hsql/restcomm.script");
- archive.addAsWebInfResource("akka_application.conf", "classes/application.conf");
- archive.addAsWebResource("dial-client-entry_wActionUrl.xml");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(henriquePort));
+ replacements.put("5093", String.valueOf(subAccountPort));
+ List resources = new ArrayList(Arrays.asList("dial-client-entry_wActionUrl.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm_calllifecycle.xml",
+ "restcomm.script_callLifecycleTest",resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallRegexSingleTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallRegexSingleTest.java
index 4809a53b6b..30b620cca2 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallRegexSingleTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallRegexSingleTest.java
@@ -62,10 +62,15 @@
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Regex for IncomingPhoneNumbers
@@ -91,9 +96,12 @@ public class CallRegexSingleTest {
@ArquillianResource
URL deploymentUrl;
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -103,34 +111,43 @@ public class CallRegexSingleTest {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// Henrique is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStackOrg1;
private SipPhone bobPhoneOrg1;
+ private static String bobPort2 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
private String bobContactOrg1 = "sip:bob@org1.restcomm.com";
// George is a simple SIP Client. Will not register with Restcomm
private SipStack aliceSipStackOrg1;
private SipPhone alicePhoneOrg1;
+ private static String alicePort2 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
private String aliceContactOrg1 = "sip:alice@org1.restcomm.com";
// subaccountclient is a simple SIP Client. Will register with Restcomm
private SipStack subAccountClientSipStack;
private SipPhone subAccountClientPhone;
- private String subAccountClientContact = "sip:subaccountclient@127.0.0.1:5093";
+ private static String subaccountPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String subAccountClientContact = "sip:subaccountclient@127.0.0.1:" + subaccountPort;
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
private String subAccountSid = "ACae6e420f425248d6a26948c17a9e2acg";
private String subAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
@BeforeClass
public static void beforeClass() throws Exception {
@@ -140,23 +157,33 @@ public static void beforeClass() throws Exception {
tool4 = new SipStackTool("DialActionTest4");
tool5 = new SipStackTool("DialActionTest5");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- bobSipStackOrg1 = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- bobPhoneOrg1 = bobSipStackOrg1.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContactOrg1);
+ bobSipStackOrg1 = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort2, restcommContact);
+ bobPhoneOrg1 = bobSipStackOrg1.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContactOrg1);
- aliceSipStackOrg1 = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- alicePhoneOrg1 = aliceSipStackOrg1.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContactOrg1);
+ aliceSipStackOrg1 = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort2, restcommContact);
+ alicePhoneOrg1 = aliceSipStackOrg1.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContactOrg1);
- subAccountClientSipStack = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5093", "127.0.0.1:5080");
- subAccountClientPhone = subAccountClientSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, subAccountClientContact);
+ subAccountClientSipStack = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", subaccountPort, restcommContact);
+ subAccountClientPhone = subAccountClientSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, subAccountClientContact);
}
@After
@@ -226,7 +253,7 @@ public void testDial7777RegexOfDifferentOrganization() throws ParseException, In
// Create outgoing call with first phone
final SipCall bobCallOrg1 = bobPhoneOrg1.createSipCall();
- bobCallOrg1.initiateOutgoingCall(bobContactOrg1, "sip:7777@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCallOrg1.initiateOutgoingCall(bobContactOrg1, "sip:7777@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCallOrg1);
assertTrue(bobCallOrg1.waitOutgoingCallResponse(5 * 1000));
final int response = bobCallOrg1.getLastReceivedResponse().getStatusCode();
@@ -249,7 +276,7 @@ public void testDialClientAlice7777() throws ParseException, InterruptedExceptio
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -258,7 +285,7 @@ public void testDialClientAlice7777() throws ParseException, InterruptedExceptio
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:7777@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:7777@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -344,7 +371,7 @@ public void testDialClientAlice8888() throws ParseException, InterruptedExceptio
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -353,7 +380,7 @@ public void testDialClientAlice8888() throws ParseException, InterruptedExceptio
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:8888@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:8888@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -433,22 +460,22 @@ public void testDialClientAlice8888() throws ParseException, InterruptedExceptio
@Deployment(name = "DialAction", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.delete("/WEB-INF/classes/application.conf");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm_callRegex.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_callRegexTest2", "data/hsql/restcomm.script");
- archive.addAsWebInfResource("akka_application.conf", "classes/application.conf");
- archive.addAsWebResource("dial-client-entry_wActionUrl.xml");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(alicePort2));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(bobPort2));
+ replacements.put("5093", String.valueOf(subaccountPort));
+ List resources = new ArrayList(Arrays.asList("dial-client-entry_wActionUrl.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm_callRegex.xml",
+ "restcomm.script_callRegexTest2",resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallRegexTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallRegexTest.java
index fae26a5cd3..0896e030dc 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallRegexTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/CallRegexTest.java
@@ -68,6 +68,11 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import com.google.gson.JsonObject;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Regex for IncomingPhoneNumbers
@@ -93,9 +98,12 @@ public class CallRegexTest {
@ArquillianResource
URL deploymentUrl;
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -105,34 +113,43 @@ public class CallRegexTest {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// Henrique is a simple SIP Client. Will not register with Restcomm
private SipStack henriqueSipStack;
private SipPhone henriquePhone;
- private String henriqueContact = "sip:henrique@127.0.0.1:5092";
+ private static String henriquePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String henriqueContact = "sip:henrique@127.0.0.1:" + henriquePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
// subaccountclient is a simple SIP Client. Will register with Restcomm
private SipStack subAccountClientSipStack;
private SipPhone subAccountClientPhone;
- private String subAccountClientContact = "sip:subaccountclient@127.0.0.1:5093";
+ private static String subAccountPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String subAccountClientContact = "sip:subaccountclient@127.0.0.1:" + subAccountPort;
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
private String subAccountSid = "ACae6e420f425248d6a26948c17a9e2acg";
private String subAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
@BeforeClass
public static void beforeClass() throws Exception {
@@ -142,23 +159,34 @@ public static void beforeClass() throws Exception {
tool4 = new SipStackTool("DialActionTest4");
tool5 = new SipStackTool("DialActionTest5");
}
+
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, henriqueContact);
+ henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", henriquePort, restcommContact);
+ henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, henriqueContact);
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
- subAccountClientSipStack = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5093", "127.0.0.1:5080");
- subAccountClientPhone = subAccountClientSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, subAccountClientContact);
+ subAccountClientSipStack = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", subAccountPort, restcommContact);
+ subAccountClientPhone = subAccountClientSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, subAccountClientContact);
}
@After
@@ -219,7 +247,7 @@ public void testDialClientAlice7777() throws ParseException, InterruptedExceptio
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -228,7 +256,7 @@ public void testDialClientAlice7777() throws ParseException, InterruptedExceptio
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:7777@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:7777@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -314,7 +342,7 @@ public void testDialClientAlice8888() throws ParseException, InterruptedExceptio
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -323,7 +351,7 @@ public void testDialClientAlice8888() throws ParseException, InterruptedExceptio
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:8888@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:8888@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -409,7 +437,7 @@ public void testDialClientAlice7711133() throws ParseException, InterruptedExcep
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -418,7 +446,7 @@ public void testDialClientAlice7711133() throws ParseException, InterruptedExcep
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:*7711133#@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:*7711133#@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -504,7 +532,7 @@ public void testDialClientAlice7722233() throws ParseException, InterruptedExcep
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -513,7 +541,7 @@ public void testDialClientAlice7722233() throws ParseException, InterruptedExcep
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:*7722233#@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:*7722233#@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -599,7 +627,7 @@ public void testDialClientAlice12233() throws ParseException, InterruptedExcepti
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -608,7 +636,7 @@ public void testDialClientAlice12233() throws ParseException, InterruptedExcepti
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:12233#@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:12233#@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -694,7 +722,7 @@ public void testDialClientAlice22233() throws ParseException, InterruptedExcepti
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -703,7 +731,7 @@ public void testDialClientAlice22233() throws ParseException, InterruptedExcepti
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:22233#@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:22233#@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -789,7 +817,7 @@ public void testDialClientAlice222_888_999_500() throws ParseException, Interrup
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -798,7 +826,7 @@ public void testDialClientAlice222_888_999_500() throws ParseException, Interrup
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:*222*888*999*500#@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:*222*888*999*500#@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -885,7 +913,7 @@ public void testDialClientAlice222_333_444_500() throws ParseException, Interrup
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -894,7 +922,7 @@ public void testDialClientAlice222_333_444_500() throws ParseException, Interrup
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:*222*333*444*500#@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:*222*333*444*500#@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -981,7 +1009,7 @@ public void testDialClientAlice42342() throws ParseException, InterruptedExcepti
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -990,7 +1018,7 @@ public void testDialClientAlice42342() throws ParseException, InterruptedExcepti
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:42342@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:42342@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1076,7 +1104,7 @@ public void testDialClientAlice52343() throws ParseException, InterruptedExcepti
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1085,7 +1113,7 @@ public void testDialClientAlice52343() throws ParseException, InterruptedExcepti
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:52343@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:52343@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1171,7 +1199,7 @@ public void testDialClientAlice999111() throws ParseException, InterruptedExcept
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1180,7 +1208,7 @@ public void testDialClientAlice999111() throws ParseException, InterruptedExcept
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:999111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:999111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1266,7 +1294,7 @@ public void testDialClientAlice999222() throws ParseException, InterruptedExcept
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1275,7 +1303,7 @@ public void testDialClientAlice999222() throws ParseException, InterruptedExcept
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:999222@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:999222@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1361,7 +1389,7 @@ public void testDialClientAliceNoRegex() throws ParseException, InterruptedExcep
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1370,7 +1398,7 @@ public void testDialClientAliceNoRegex() throws ParseException, InterruptedExcep
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1313@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1313@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1456,7 +1484,7 @@ public void testDialClientAliceStar() throws ParseException, InterruptedExceptio
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1465,7 +1493,7 @@ public void testDialClientAliceStar() throws ParseException, InterruptedExceptio
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:987654321@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:987654321@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1569,7 +1597,7 @@ public void testUssdPull() {
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:*777#@127.0.0.1:5080", null, ussdClientRequestBody, "application", "vnd.3gpp.ussd+xml", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:*777#@" + restcommContact, null, ussdClientRequestBody, "application", "vnd.3gpp.ussd+xml", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1602,22 +1630,22 @@ public void testUssdPull() {
@Deployment(name = "DialAction", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.delete("/WEB-INF/classes/application.conf");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm_callRegex.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_callRegexTest", "data/hsql/restcomm.script");
- archive.addAsWebInfResource("akka_application.conf", "classes/application.conf");
- archive.addAsWebResource("dial-client-entry_wActionUrl.xml");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(henriquePort));
+ replacements.put("5093", String.valueOf(subAccountPort));
+ List resources = new ArrayList(Arrays.asList("dial-client-entry_wActionUrl.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm_callRegex.xml",
+ "restcomm.script_callRegexTest",resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ClientsDialAnswerDelayTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ClientsDialAnswerDelayTest.java
index f468412d78..446bf7acde 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ClientsDialAnswerDelayTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ClientsDialAnswerDelayTest.java
@@ -1,8 +1,6 @@
package org.restcomm.connect.testsuite.telephony;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
import org.cafesip.sipunit.Credential;
import org.cafesip.sipunit.SipCall;
import org.cafesip.sipunit.SipPhone;
@@ -14,24 +12,17 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.restcomm.connect.commons.Version;
import org.restcomm.connect.testsuite.http.CreateClientsTool;
-import org.restcomm.connect.testsuite.http.RestcommCallsTool;
-import org.restcomm.connect.testsuite.tools.MonitoringServiceTool;
import javax.sip.Dialog;
-import javax.sip.InvalidArgumentException;
-import javax.sip.SipException;
import javax.sip.address.SipURI;
import javax.sip.header.UserAgentHeader;
import javax.sip.message.Response;
@@ -45,10 +36,15 @@
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for clients with or without VoiceURL (Bitbucket issue 115). Clients without VoiceURL can dial anything.
@@ -171,9 +167,12 @@ public class ClientsDialAnswerDelayTest {
@ArquillianResource
URL deploymentUrl;
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -191,51 +190,65 @@ public class ClientsDialAnswerDelayTest {
// Maria is a Restcomm Client **without** VoiceURL. This Restcomm Client can dial anything.
private SipStack mariaSipStack;
private SipPhone mariaPhone;
- private String mariaContact = "sip:maria@127.0.0.1:5092";
+ private static String mariaPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String mariaContact = "sip:maria@127.0.0.1:" + mariaPort;
private String mariaRestcommClientSid;
// Dimitris is a Restcomm Client **without** VoiceURL. This Restcomm Client can dial anything.
private SipStack dimitriSipStack;
private SipPhone dimitriPhone;
- private String dimitriContact = "sip:dimitri@127.0.0.1:5093";
+ private static String dimitriPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String dimitriContact = "sip:dimitri@127.0.0.1:" + dimitriPort;
private String dimitriRestcommClientSid;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
+
private SipStack aliceSipStack2;
private SipPhone alicePhone2;
- private String aliceContact2 = "sip:alice@127.0.0.1:5094";
+ private static String alicePort2 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact2 = "sip:alice@127.0.0.1:" + alicePort2;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:"+pstnNumber+"@127.0.0.1:5070";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:"+pstnNumber+"@127.0.0.1:" + georgePort;
private SipStack clientWithAppSipStack;
private SipPhone clientWithAppPhone;
- private String clientWithAppContact = "sip:clientWithApp@127.0.0.1:5095";
+ private static String clientWithAppPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String clientWithAppContact = "sip:clientWithApp@127.0.0.1:" + clientWithAppPort;
private String clientWithAppClientSid;
private SipStack fotiniSipStackTcp;
private SipPhone fotiniPhoneTcp;
- private String fotiniContactTcp = "sip:fotini@127.0.0.1:5096";
+ private static String fotiniPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String fotiniContactTcp = "sip:fotini@127.0.0.1:" + fotiniPort;
private String fotiniClientSid;
private SipStack bobSipStackTcp;
private SipPhone bobPhoneTcp;
- private String bobContactTcp = "sip:bob@127.0.0.1:5097";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContactTcp = "sip:bob@127.0.0.1:" + bobPort;
private SipStack leftySipStack;
private SipPhone leftyPhone;
- private String leftyContact = "sip:lefty@127.0.0.1:5098";
+ private static String leftyPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String leftyContact = "sip:lefty@127.0.0.1:" + leftyPort;
private String leftyRestcommClientSid;
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
@BeforeClass
public static void beforeClass() throws Exception {
@@ -249,41 +262,51 @@ public static void beforeClass() throws Exception {
tool8 = new SipStackTool("ClientsDialAnswerDelayTest8");
tool9 = new SipStackTool("ClientsDialAnswerDelayTest9");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- aliceSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- aliceSipStack2 = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5094", "127.0.0.1:5080");
- alicePhone2 = aliceSipStack2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact2);
+ aliceSipStack2 = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort2, restcommContact);
+ alicePhone2 = aliceSipStack2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact2);
- mariaSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- mariaPhone = mariaSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, mariaContact);
+ mariaSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", mariaPort, restcommContact);
+ mariaPhone = mariaSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, mariaContact);
- dimitriSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5093", "127.0.0.1:5080");
- dimitriPhone = dimitriSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, dimitriContact);
+ dimitriSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", dimitriPort, restcommContact);
+ dimitriPhone = dimitriSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, dimitriContact);
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
- clientWithAppSipStack = tool6.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5095", "127.0.0.1:5080");
- clientWithAppPhone = clientWithAppSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, clientWithAppContact);
+ clientWithAppSipStack = tool6.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", clientWithAppPort, restcommContact);
+ clientWithAppPhone = clientWithAppSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, clientWithAppContact);
mariaRestcommClientSid = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "maria", clientPassword, null);
dimitriRestcommClientSid = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "dimitri", clientPassword, null);
- clientWithAppClientSid = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "clientWithApp", clientPassword, "http://127.0.0.1:8090/1111");
+ clientWithAppClientSid = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "clientWithApp", clientPassword, "http://127.0.0.1:" + mockPort + "/1111");
- fotiniSipStackTcp = tool7.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", "5096", "127.0.0.1:5080");
- fotiniPhoneTcp = fotiniSipStackTcp.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, 5080, fotiniContactTcp);
+ fotiniSipStackTcp = tool7.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", fotiniPort, restcommContact);
+ fotiniPhoneTcp = fotiniSipStackTcp.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, restcommPort, fotiniContactTcp);
fotiniClientSid = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "fotini", clientPassword, null);
- bobSipStackTcp = tool8.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", "5097", "127.0.0.1:5080");
- bobPhoneTcp = bobSipStackTcp.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, 5080, bobContactTcp);
+ bobSipStackTcp = tool8.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", bobPort, restcommContact);
+ bobPhoneTcp = bobSipStackTcp.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, restcommPort, bobContactTcp);
- leftySipStack = tool9.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5098", "127.0.0.1:5080");
- leftyPhone = leftySipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, leftyContact);
+ leftySipStack = tool9.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", leftyPort, restcommContact);
+ leftyPhone = leftySipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, leftyContact);
}
@After
@@ -345,7 +368,7 @@ public void testClientDialOutPstnSimulateWebRTCClient() throws ParseException, I
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 14400, 3600));
Thread.sleep(3000);
@@ -367,7 +390,7 @@ public void testClientDialOutPstnSimulateWebRTCClient() throws ParseException, I
// Maria initiates a call to Dimitri
final SipCall mariaCall = mariaPhone.createSipCall();
- mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@127.0.0.1:5080", null, body, "application", "sdp", null, replaceHeaders);
+ mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@" + restcommContact, null, body, "application", "sdp", null, replaceHeaders);
assertLastOperationSuccess(mariaCall);
assertTrue(mariaCall.waitForAuthorisation(3000));
@@ -413,7 +436,7 @@ public void testClientDialOutPstnSimulateWebRTCClientBusy() throws ParseExceptio
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 14400, 3600));
Thread.sleep(3000);
@@ -435,7 +458,7 @@ public void testClientDialOutPstnSimulateWebRTCClientBusy() throws ParseExceptio
// Maria initiates a call to Dimitri
final SipCall mariaCall = mariaPhone.createSipCall();
- mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@127.0.0.1:5080", null, body, "application", "sdp", null, replaceHeaders);
+ mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@" + restcommContact, null, body, "application", "sdp", null, replaceHeaders);
assertLastOperationSuccess(mariaCall);
assertTrue(mariaCall.waitForAuthorisation(3000));
@@ -469,7 +492,7 @@ public void testClientDialOutPstnSimulateWebRTCClientNoAnswer() throws ParseExce
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 14400, 3600));
Thread.sleep(3000);
@@ -491,7 +514,7 @@ public void testClientDialOutPstnSimulateWebRTCClientNoAnswer() throws ParseExce
// Maria initiates a call to Dimitri
final SipCall mariaCall = mariaPhone.createSipCall();
- mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@127.0.0.1:5080", null, body, "application", "sdp", null, replaceHeaders);
+ mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@" + restcommContact, null, body, "application", "sdp", null, replaceHeaders);
assertLastOperationSuccess(mariaCall);
assertTrue(mariaCall.waitForAuthorisation(3000));
@@ -524,7 +547,7 @@ public void testClientDialOutPstnSimulateWebRTCClientServiceUnavailable() throws
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 14400, 3600));
Thread.sleep(3000);
@@ -546,7 +569,7 @@ public void testClientDialOutPstnSimulateWebRTCClientServiceUnavailable() throws
// Maria initiates a call to Dimitri
final SipCall mariaCall = mariaPhone.createSipCall();
- mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@127.0.0.1:5080", null, body, "application", "sdp", null, replaceHeaders);
+ mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@" + restcommContact, null, body, "application", "sdp", null, replaceHeaders);
assertLastOperationSuccess(mariaCall);
assertTrue(mariaCall.waitForAuthorisation(3000));
@@ -580,7 +603,7 @@ public void testClientDialOutPstnSimulateWebRTCClientCancelBefore200() throws Pa
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 14400, 3600));
Thread.sleep(3000);
@@ -602,7 +625,7 @@ public void testClientDialOutPstnSimulateWebRTCClientCancelBefore200() throws Pa
// Maria initiates a call to Dimitri
final SipCall mariaCall = mariaPhone.createSipCall();
- mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@127.0.0.1:5080", null, body, "application", "sdp", null, replaceHeaders);
+ mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@" + restcommContact, null, body, "application", "sdp", null, replaceHeaders);
assertLastOperationSuccess(mariaCall);
assertTrue(mariaCall.waitForAuthorisation(3000));
@@ -642,7 +665,7 @@ public synchronized void testDialClientAlice() throws InterruptedException, Pars
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -651,7 +674,7 @@ public synchronized void testDialClientAlice() throws InterruptedException, Pars
// Create outgoing call with first phone
final SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingCallResponse(5 * 1000));
final int response = georgeCall.getLastReceivedResponse().getStatusCode();
@@ -693,7 +716,7 @@ public synchronized void testDialClientForkWithWebRTCAliceFromAnotherInstance()
.withBody(dialWebRTCClientForkRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -702,7 +725,7 @@ public synchronized void testDialClientForkWithWebRTCAliceFromAnotherInstance()
// Create outgoing call with first phone
final SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingCallResponse(5 * 1000));
final int response = georgeCall.getLastReceivedResponse().getStatusCode();
@@ -746,7 +769,7 @@ public synchronized void testDialForkClient_AliceMultipleRegistrations_George()
.withBody(dialAliceDimitriRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
assertTrue(alicePhone2.register(uri, "alice", "1234", aliceContact2, 3600, 3600));
@@ -763,7 +786,7 @@ public synchronized void testDialForkClient_AliceMultipleRegistrations_George()
// Create outgoing call with first phone
final SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingCallResponse(5 * 1000));
final int response = georgeCall.getLastReceivedResponse().getStatusCode();
@@ -826,7 +849,7 @@ public synchronized void testDialForkClientWebRTCBob_And_AliceWithMultipleRegist
.withBody(dialWebRTCClientForkRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
assertTrue(alicePhone2.register(uri, "alice", "1234", aliceContact2, 3600, 3600));
@@ -839,7 +862,7 @@ public synchronized void testDialForkClientWebRTCBob_And_AliceWithMultipleRegist
// Create outgoing call with first phone
final SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingCallResponse(5 * 1000));
final int response = georgeCall.getLastReceivedResponse().getStatusCode();
@@ -895,7 +918,7 @@ public synchronized void testDialForkClientWebRTCBob_And_AliceWithMultipleRegist
.withBody(dialWebRTCClientForkRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
assertTrue(alicePhone2.register(uri, "alice", "1234", aliceContact2, 3600, 3600));
@@ -908,7 +931,7 @@ public synchronized void testDialForkClientWebRTCBob_And_AliceWithMultipleRegist
// Create outgoing call with first phone
final SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingCallResponse(5 * 1000));
final int response = georgeCall.getLastReceivedResponse().getStatusCode();
@@ -948,7 +971,7 @@ public synchronized void testClientWithHostedApplication() throws InterruptedExc
assertNotNull(clientWithAppClientSid);
- SipURI uri = clientWithAppSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = clientWithAppSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(clientWithAppPhone.register(uri, "clientWithApp", clientPassword, clientWithAppContact, 3600, 3600));
Credential c = new Credential("127.0.0.1", "clientWithApp", clientPassword);
clientWithAppPhone.addUpdateCredential(c);
@@ -957,7 +980,7 @@ public synchronized void testClientWithHostedApplication() throws InterruptedExc
georgeCall.listenForIncomingCall();
SipCall clientWithAppCall = clientWithAppPhone.createSipCall();
- clientWithAppCall.initiateOutgoingCall(clientWithAppContact, "sip:3090909090@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ clientWithAppCall.initiateOutgoingCall(clientWithAppContact, "sip:3090909090@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(clientWithAppCall);
assertTrue(clientWithAppCall.waitForAuthorisation(5000));
assertTrue(clientWithAppCall.waitOutgoingCallResponse(5000));
@@ -994,23 +1017,37 @@ public synchronized void testClientWithHostedApplication() throws InterruptedExc
@Deployment(name = "ClientsDialAnswerDelayTest", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm-delay.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialTest", "data/hsql/restcomm.script");
- archive.addAsWebResource("dial-conference-entry.xml");
- archive.addAsWebResource("dial-fork-entry.xml");
- archive.addAsWebResource("dial-uri-entry.xml");
- archive.addAsWebResource("dial-client-entry.xml");
- archive.addAsWebResource("dial-number-entry.xml");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(mariaPort));
+ replacements.put("5093", String.valueOf(dimitriPort));
+ replacements.put("5094", String.valueOf(alicePort2));
+ replacements.put("5095", String.valueOf(clientWithAppPort));
+ replacements.put("5096", String.valueOf(fotiniPort));
+ replacements.put("5097", String.valueOf(bobPort));
+ replacements.put("5098", String.valueOf(leftyPort));
+
+ List resources = new ArrayList(
+ Arrays.asList(
+ "dial-conference-entry.xml",
+ "dial-fork-entry.xml",
+ "dial-uri-entry.xml",
+ "dial-client-entry.xml",
+ "dial-number-entry.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw(
+ "restcomm-delay.xml",
+ "restcomm.script_dialTest",
+ resources,
+ replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ClientsDialTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ClientsDialTest.java
index dce26376cd..21ecd169a9 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ClientsDialTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ClientsDialTest.java
@@ -46,10 +46,16 @@
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
+import static org.restcomm.connect.testsuite.telephony.ClientsDialAnswerDelayTest.reconfigurePorts;
/**
* Test for clients with or without VoiceURL (Bitbucket issue 115). Clients without VoiceURL can dial anything.
@@ -172,9 +178,12 @@ public class ClientsDialTest {
@ArquillianResource
URL deploymentUrl;
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -193,56 +202,71 @@ public class ClientsDialTest {
// Maria is a Restcomm Client **without** VoiceURL. This Restcomm Client can dial anything.
private SipStack mariaSipStack;
private SipPhone mariaPhone;
- private String mariaContact = "sip:maria@127.0.0.1:5092";
+ private static String mariaPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String mariaContact = "sip:maria@127.0.0.1:" + mariaPort;
private String mariaRestcommClientSid;
// Dimitris is a Restcomm Client **without** VoiceURL. This Restcomm Client can dial anything.
private SipStack dimitriSipStack;
private SipPhone dimitriPhone;
- private String dimitriContact = "sip:dimitri@127.0.0.1:5093";
+ private static String dimitriPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String dimitriContact = "sip:dimitri@127.0.0.1:" + dimitriPort;
private String dimitriRestcommClientSid;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
+
private SipStack aliceSipStack2;
private SipPhone alicePhone2;
- private String aliceContact2 = "sip:alice@127.0.0.1:5094";
+ private static String alicePort2 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact2 = "sip:alice@127.0.0.1:" + alicePort2;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:"+pstnNumber+"@127.0.0.1:5070";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:"+pstnNumber+"@127.0.0.1:" + georgePort;
private SipStack clientWithAppSipStack;
private SipPhone clientWithAppPhone;
- private String clientWithAppContact = "sip:clientWithApp@127.0.0.1:5095";
+ private static String clientWithAppPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String clientWithAppContact = "sip:clientWithApp@127.0.0.1:" + clientWithAppPort;
private String clientWithAppClientSid;
private SipStack fotiniSipStackTcp;
private SipPhone fotiniPhoneTcp;
- private String fotiniContactTcp = "sip:fotini@127.0.0.1:5096";
+ private static String fotiniPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String fotiniContactTcp = "sip:fotini@127.0.0.1:" + fotiniPort;
private String fotiniClientSid;
private SipStack bobSipStackTcp;
private SipPhone bobPhoneTcp;
- private String bobContactTcp = "sip:bob@127.0.0.1:5097";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContactTcp = "sip:bob@127.0.0.1:" + bobPort;
private SipStack leftySipStack;
private SipPhone leftyPhone;
- private String leftyContact = "sip:lefty@127.0.0.1:5098";
+ private static String leftyPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String leftyContact = "sip:lefty@127.0.0.1:" + leftyPort;
private String leftyRestcommClientSid;
private SipStack externalSipStack;
private SipPhone externalPhone;
- private String externalContact = "sip:external@127.0.0.1:5099";
+ private static String externalPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String externalContact = "sip:external@127.0.0.1:" + externalPort;
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+
@BeforeClass
public static void beforeClass() throws Exception {
tool1 = new SipStackTool("ClientsDialTest1");
@@ -256,44 +280,54 @@ public static void beforeClass() throws Exception {
tool9 = new SipStackTool("ClientsDialTest9");
tool10 = new SipStackTool("ClientsDialTest10");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- aliceSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- aliceSipStack2 = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5094", "127.0.0.1:5080");
- alicePhone2 = aliceSipStack2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact2);
+ aliceSipStack2 = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort2, restcommContact);
+ alicePhone2 = aliceSipStack2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact2);
- mariaSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- mariaPhone = mariaSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, mariaContact);
+ mariaSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", mariaPort, restcommContact);
+ mariaPhone = mariaSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, mariaContact);
- dimitriSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5093", "127.0.0.1:5080");
- dimitriPhone = dimitriSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, dimitriContact);
+ dimitriSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", dimitriPort, restcommContact);
+ dimitriPhone = dimitriSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, dimitriContact);
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
- clientWithAppSipStack = tool6.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5095", "127.0.0.1:5080");
- clientWithAppPhone = clientWithAppSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, clientWithAppContact);
+ clientWithAppSipStack = tool6.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", clientWithAppPort, restcommContact);
+ clientWithAppPhone = clientWithAppSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, clientWithAppContact);
mariaRestcommClientSid = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "maria", clientPassword, null);
dimitriRestcommClientSid = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "dimitri", clientPassword, null);
- clientWithAppClientSid = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "clientWithApp", clientPassword, "http://127.0.0.1:8090/1111");
+ clientWithAppClientSid = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "clientWithApp", clientPassword, "http://127.0.0.1:" + mockPort + "/1111");
- fotiniSipStackTcp = tool7.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", "5096", "127.0.0.1:5080");
- fotiniPhoneTcp = fotiniSipStackTcp.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, 5080, fotiniContactTcp);
+ fotiniSipStackTcp = tool7.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", fotiniPort, restcommContact);
+ fotiniPhoneTcp = fotiniSipStackTcp.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, restcommPort, fotiniContactTcp);
fotiniClientSid = CreateClientsTool.getInstance().createClient(deploymentUrl.toString(), "fotini", clientPassword, null);
- bobSipStackTcp = tool8.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", "5097", "127.0.0.1:5080");
- bobPhoneTcp = bobSipStackTcp.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, 5080, bobContactTcp);
-
- leftySipStack = tool9.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5098", "127.0.0.1:5080");
- leftyPhone = leftySipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, leftyContact);
+ bobSipStackTcp = tool8.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", bobPort, restcommContact);
+ bobPhoneTcp = bobSipStackTcp.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, restcommPort, bobContactTcp);
- externalSipStack = tool10.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5099", "127.0.0.1:5080");
- externalPhone = externalSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, externalContact);
+ leftySipStack = tool9.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", leftyPort, restcommContact);
+ leftyPhone = leftySipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, leftyContact);
+
+ externalSipStack = tool10.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", externalPort, restcommContact);
+ externalPhone = externalSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, externalContact);
}
@After
@@ -355,7 +389,7 @@ public void testRegisterClients() throws ParseException, InterruptedException {
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 3600, 3600));
@@ -374,7 +408,7 @@ public void testClientsCallEachOther() throws ParseException, InterruptedExcepti
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 3600, 3600));
assertTrue(dimitriPhone.register(uri, "dimitri", clientPassword, dimitriContact, 3600, 3600));
@@ -452,7 +486,7 @@ public void testClientsCallEachOtherWithFriendlyNameSetKouKouRouKou() throws Par
assertNotNull(mariaRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
Thread.sleep(1000);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 3600, 3600));
Thread.sleep(3000);
@@ -538,7 +572,7 @@ public void testClientDialOutPstn() throws ParseException, InterruptedException
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 14400, 3600));
Thread.sleep(3000);
@@ -549,7 +583,7 @@ public void testClientDialOutPstn() throws ParseException, InterruptedException
// Maria initiates a call to Dimitri
final SipCall mariaCall = mariaPhone.createSipCall();
- mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(mariaCall);
assertTrue(mariaCall.waitForAuthorisation(3000));
@@ -595,7 +629,7 @@ public void testDialClientFromPstn() throws ParseException, InterruptedException
assertNotNull(mariaRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 14400, 3600));
Thread.sleep(3000);
@@ -603,7 +637,7 @@ public void testDialClientFromPstn() throws ParseException, InterruptedException
mariaCall.listenForIncomingCall();
final SipCall externalCall = externalPhone.createSipCall();
- externalCall.initiateOutgoingCall(leftyContact, "sip:maria@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ externalCall.initiateOutgoingCall(leftyContact, "sip:maria@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(externalCall);
assertTrue(externalCall.waitOutgoingCallResponse(5 * 1000));
final int response = externalCall.getLastReceivedResponse().getStatusCode();
@@ -647,7 +681,7 @@ public void testClientDialOutPstnSimulateWebRTCClient() throws ParseException, I
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 14400, 3600));
Thread.sleep(3000);
@@ -669,7 +703,7 @@ public void testClientDialOutPstnSimulateWebRTCClient() throws ParseException, I
// Maria initiates a call to Dimitri
final SipCall mariaCall = mariaPhone.createSipCall();
- mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@127.0.0.1:5080", null, body, "application", "sdp", null, replaceHeaders);
+ mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@" + restcommContact, null, body, "application", "sdp", null, replaceHeaders);
assertLastOperationSuccess(mariaCall);
assertTrue(mariaCall.waitForAuthorisation(3000));
@@ -714,7 +748,7 @@ public void testClientDialOutPstnWebRTCClientwithSDP() throws ParseException, In
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 14400, 3600));
Thread.sleep(3000);
@@ -729,7 +763,7 @@ public void testClientDialOutPstnWebRTCClientwithSDP() throws ParseException, In
// Maria initiates a call to Dimitri
final SipCall mariaCall = mariaPhone.createSipCall();
- mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@127.0.0.1:5080", null, webRtcBody, "application", "sdp", null, null);
+ mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@" + restcommContact, null, webRtcBody, "application", "sdp", null, null);
assertLastOperationSuccess(mariaCall);
assertTrue(mariaCall.waitForAuthorisation(3000));
@@ -771,12 +805,12 @@ public void testClientDialOutPstnWebRTCClientwithSDP() throws ParseException, In
@Test
public void testClientDialToInvalidNumber() throws ParseException, InterruptedException, InvalidArgumentException, SipException {
String invalidNumber = "+123456789";
- SipPhone outboundProxy = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, "sip:"+invalidNumber+"@127.0.0.1:5070");
+ SipPhone outboundProxy = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, "sip:"+invalidNumber+"@127.0.0.1:" + georgePort);
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 14400, 3600));
Thread.sleep(3000);
@@ -787,7 +821,7 @@ public void testClientDialToInvalidNumber() throws ParseException, InterruptedEx
// Maria initiates a call to invalid number
final SipCall mariaCall = mariaPhone.createSipCall();
- mariaCall.initiateOutgoingCall(mariaContact, "sip:"+invalidNumber+"@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ mariaCall.initiateOutgoingCall(mariaContact, "sip:"+invalidNumber+"@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(mariaCall);
assertTrue(mariaCall.waitForAuthorisation(3000));
@@ -818,7 +852,7 @@ public void testClientDialOutPstnCancelBefore200() throws ParseException, Interr
assertNotNull(mariaRestcommClientSid);
assertNotNull(dimitriRestcommClientSid);
- SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = mariaSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(mariaPhone.register(uri, "maria", clientPassword, mariaContact, 14400, 3600));
Thread.sleep(3000);
@@ -829,7 +863,7 @@ public void testClientDialOutPstnCancelBefore200() throws ParseException, Interr
// Maria initiates a call to Dimitri
final SipCall mariaCall = mariaPhone.createSipCall();
- mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ mariaCall.initiateOutgoingCall(mariaContact, "sip:"+pstnNumber+"@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(mariaCall);
assertTrue(mariaCall.waitForAuthorisation(3000));
@@ -877,7 +911,7 @@ public synchronized void testDialClientAlice() throws InterruptedException, Pars
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -886,7 +920,7 @@ public synchronized void testDialClientAlice() throws InterruptedException, Pars
// Create outgoing call with first phone
final SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingCallResponse(5 * 1000));
final int response = georgeCall.getLastReceivedResponse().getStatusCode();
@@ -934,7 +968,7 @@ public synchronized void testDialClientAliceWithExtraParamsAtContactHeader() thr
String extraParamValue2 = "test";
aliceContact = aliceContact+";"+extraParamName1+"="+extraParamValue1+";"+extraParamName2+"="+extraParamValue2;
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -943,7 +977,7 @@ public synchronized void testDialClientAliceWithExtraParamsAtContactHeader() thr
// Create outgoing call with first phone
final SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingCallResponse(5 * 1000));
final int response = georgeCall.getLastReceivedResponse().getStatusCode();
@@ -998,7 +1032,7 @@ public synchronized void testDialClientWebRTCAliceFromAnotherInstance() throws I
// Create outgoing call with first phone
final SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingCallResponse(5 * 1000));
final int response = georgeCall.getLastReceivedResponse().getStatusCode();
@@ -1032,7 +1066,7 @@ public synchronized void testDialClientForkWithWebRTCAliceFromAnotherInstance()
.withBody(dialWebRTCClientForkRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1041,7 +1075,7 @@ public synchronized void testDialClientForkWithWebRTCAliceFromAnotherInstance()
// Create outgoing call with first phone
final SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingCallResponse(5 * 1000));
final int response = georgeCall.getLastReceivedResponse().getStatusCode();
@@ -1085,7 +1119,7 @@ public synchronized void testDialForkClient_AliceMultipleRegistrations_George()
.withBody(dialAliceDimitriRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
assertTrue(alicePhone2.register(uri, "alice", "1234", aliceContact2, 3600, 3600));
@@ -1102,7 +1136,7 @@ public synchronized void testDialForkClient_AliceMultipleRegistrations_George()
// Create outgoing call with first phone
final SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingCallResponse(5 * 1000));
final int response = georgeCall.getLastReceivedResponse().getStatusCode();
@@ -1174,7 +1208,7 @@ public synchronized void testDialForkClientWebRTCBob_And_AliceWithMultipleRegist
.withBody(dialWebRTCClientForkRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
assertTrue(alicePhone2.register(uri, "alice", "1234", aliceContact2, 3600, 3600));
@@ -1187,7 +1221,7 @@ public synchronized void testDialForkClientWebRTCBob_And_AliceWithMultipleRegist
// Create outgoing call with first phone
final SipCall georgeCall = georgePhone.createSipCall();
- georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ georgeCall.initiateOutgoingCall(georgeContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(georgeCall);
assertTrue(georgeCall.waitOutgoingCallResponse(5 * 1000));
final int response = georgeCall.getLastReceivedResponse().getStatusCode();
@@ -1253,7 +1287,7 @@ public synchronized void testClientWithHostedApplication() throws InterruptedExc
assertNotNull(clientWithAppClientSid);
- SipURI uri = clientWithAppSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = clientWithAppSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(clientWithAppPhone.register(uri, "clientWithApp", clientPassword, clientWithAppContact, 3600, 3600));
Credential c = new Credential("127.0.0.1", "clientWithApp", clientPassword);
clientWithAppPhone.addUpdateCredential(c);
@@ -1262,7 +1296,7 @@ public synchronized void testClientWithHostedApplication() throws InterruptedExc
georgeCall.listenForIncomingCall();
SipCall clientWithAppCall = clientWithAppPhone.createSipCall();
- clientWithAppCall.initiateOutgoingCall(clientWithAppContact, "sip:3090909090@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ clientWithAppCall.initiateOutgoingCall(clientWithAppContact, "sip:3090909090@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(clientWithAppCall);
assertTrue(clientWithAppCall.waitForAuthorisation(5000));
assertTrue(clientWithAppCall.waitOutgoingCallResponse(5000));
@@ -1300,7 +1334,7 @@ public synchronized void testClientWithHostedApplication() throws InterruptedExc
@Test @Ignore //This will fail because SipUnit when working on TCP will pick an ephemeral port different than the one at Contact header
public void testClientsCallEachOtherOnTcp() throws ParseException, InterruptedException {
- SipURI uri = fotiniSipStackTcp.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = fotiniSipStackTcp.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(fotiniPhoneTcp.register(uri, "fotini", clientPassword, fotiniContactTcp, 3600, 3600));
Thread.sleep(3000);
@@ -1368,23 +1402,38 @@ public void testClientsCallEachOtherOnTcp() throws ParseException, InterruptedEx
@Deployment(name = "ClientsDialTest", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialTest", "data/hsql/restcomm.script");
- archive.addAsWebResource("dial-conference-entry.xml");
- archive.addAsWebResource("dial-fork-entry.xml");
- archive.addAsWebResource("dial-uri-entry.xml");
- archive.addAsWebResource("dial-client-entry.xml");
- archive.addAsWebResource("dial-number-entry.xml");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(mariaPort));
+ replacements.put("5093", String.valueOf(dimitriPort));
+ replacements.put("5094", String.valueOf(alicePort2));
+ replacements.put("5095", String.valueOf(clientWithAppPort));
+ replacements.put("5096", String.valueOf(fotiniPort));
+ replacements.put("5097", String.valueOf(bobPort));
+ replacements.put("5098", String.valueOf(leftyPort));
+ replacements.put("5099", String.valueOf(externalPort));
+
+ List resources = new ArrayList(
+ Arrays.asList(
+ "dial-conference-entry.xml",
+ "dial-fork-entry.xml",
+ "dial-uri-entry.xml",
+ "dial-client-entry.xml",
+ "dial-number-entry.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw(
+ "restcomm.xml",
+ "restcomm.script_dialTest",
+ resources,
+ replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialActionAnswerDelayTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialActionAnswerDelayTest.java
index abd6ccdd73..e9fd20645e 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialActionAnswerDelayTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialActionAnswerDelayTest.java
@@ -52,9 +52,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -67,6 +65,10 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import com.google.gson.JsonObject;
+import java.util.HashMap;
+import java.util.Map;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Dial Action attribute. Reference: https://www.twilio.com/docs/api/twiml/dial#attributes-action The 'action'
@@ -93,10 +95,12 @@ public class DialActionAnswerDelayTest {
@ArquillianResource
URL deploymentUrl;
- //Dial Action URL: http://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/DialAction Method: POST
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -105,28 +109,36 @@ public class DialActionAnswerDelayTest {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
-
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
+
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// Henrique is a simple SIP Client. Will not register with Restcomm
private SipStack henriqueSipStack;
private SipPhone henriquePhone;
- private String henriqueContact = "sip:henrique@127.0.0.1:5092";
+ private static String henriquePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String henriqueContact = "sip:henrique@127.0.0.1:" + henriquePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
- private String dialClientWithActionUrl = "sip:+12223334455@127.0.0.1:5080"; // Application: dial-client-entry_wActionUrl.xml
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private static String dialClientWithActionUrl = "sip:+12223334455@" + restcommContact; // Application: dial-client-entry_wActionUrl.xml
@BeforeClass
public static void beforeClass() throws Exception {
@@ -135,20 +147,32 @@ public static void beforeClass() throws Exception {
tool3 = new SipStackTool("DialActionAnswerDelayTest3");
tool4 = new SipStackTool("DialActionAnswerDelayTest4");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ dialClientWithActionUrl = "sip:+12223334455@" + restcommContact;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, henriqueContact);
+ henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", henriquePort, restcommContact);
+ henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, henriqueContact);
+
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
}
@After
@@ -297,7 +321,7 @@ public void testDialActionAliceAnswers() throws ParseException, InterruptedExcep
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -377,7 +401,7 @@ public void testDialActionAliceAnswersAliceHangup() throws ParseException, Inter
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -455,7 +479,7 @@ public void testDialActionAliceAnswersBobDisconnects() throws ParseException, In
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -533,7 +557,7 @@ public void testDialActionAliceNOAnswer() throws ParseException, InterruptedExce
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -603,7 +627,7 @@ public void testDialActionAliceBusy() throws ParseException, InterruptedExceptio
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -671,7 +695,7 @@ public void testSipInviteCustomHeaders() throws ParseException, InterruptedExcep
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -763,7 +787,7 @@ public void testDialCallDurationAliceAnswers() throws ParseException, Interrupte
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -860,7 +884,7 @@ public void testDialCallDurationAliceBusy() throws ParseException, InterruptedEx
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
@@ -938,20 +962,21 @@ public void testDialCallDurationAliceBusy() throws ParseException, InterruptedEx
@Deployment(name = "DialActionAnswerDelay", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm-delay.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialActionTest", "data/hsql/restcomm.script");
- archive.addAsWebResource("dial-client-entry_wActionUrl.xml");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(henriquePort));
+ List resources = new ArrayList(Arrays.asList("dial-client-entry_wActionUrl.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm-delay.xml",
+ "restcomm.script_dialActionTest",resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialActionTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialActionTest.java
index 6dced96fad..8c5acc6a8a 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialActionTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialActionTest.java
@@ -52,9 +52,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -67,6 +65,10 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import com.google.gson.JsonObject;
+import java.util.HashMap;
+import java.util.Map;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Dial Action attribute. Reference: https://www.twilio.com/docs/api/twiml/dial#attributes-action The 'action'
@@ -93,10 +95,12 @@ public class DialActionTest {
@ArquillianResource
URL deploymentUrl;
- //Dial Action URL: http://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/DialAction Method: POST
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -105,29 +109,37 @@ public class DialActionTest {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// Henrique is a simple SIP Client. Will not register with Restcomm
private SipStack henriqueSipStack;
private SipPhone henriquePhone;
- private String henriqueContact = "sip:henrique@127.0.0.1:5092";
+ private static String henriquePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String henriqueContact = "sip:henrique@127.0.0.1:" + henriquePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
-
- private String dialClientWithActionUrl = "sip:+12223334455@127.0.0.1:5080"; // Application: dial-client-entry_wActionUrl.xml
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private static String dialClientWithActionUrl = "sip:+12223334455@" + restcommContact; // Application: dial-client-entry_wActionUrl.xml
+
+
@BeforeClass
public static void beforeClass() throws Exception {
tool1 = new SipStackTool("DialActionTest1");
@@ -135,20 +147,32 @@ public static void beforeClass() throws Exception {
tool3 = new SipStackTool("DialActionTest3");
tool4 = new SipStackTool("DialActionTest4");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ dialClientWithActionUrl = "sip:+12223334455@" + restcommContact;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
+
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", henriquePort, restcommContact);
+ henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, henriqueContact);
- henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, henriqueContact);
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
}
@After
@@ -312,7 +336,7 @@ public void testDialActionAliceAnswers() throws ParseException, InterruptedExcep
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -392,7 +416,7 @@ public void testDialActionAliceAnswersAliceHangup() throws ParseException, Inter
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -470,7 +494,7 @@ public void testDialActionAliceAnswersBobDisconnects() throws ParseException, In
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -548,7 +572,7 @@ public void testDialActionAliceNOAnswer() throws ParseException, InterruptedExce
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -623,7 +647,7 @@ public void testDialActionAliceBusy() throws ParseException, InterruptedExceptio
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -698,7 +722,7 @@ public void testDialActionHangupWithLCM() throws Exception {
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -771,7 +795,7 @@ public void testSipInviteDiversionHeader() throws ParseException, InterruptedExc
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -857,7 +881,7 @@ public void testSipInviteCustomHeaders() throws ParseException, InterruptedExcep
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -949,7 +973,7 @@ public void testDialCallDurationAliceAnswers() throws ParseException, Interrupte
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1046,7 +1070,7 @@ public void testDialCallDurationAliceBusy() throws ParseException, InterruptedEx
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
@@ -1131,20 +1155,21 @@ public void testDialCallDurationAliceBusy() throws ParseException, InterruptedEx
@Deployment(name = "DialAction", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialActionTest", "data/hsql/restcomm.script");
- archive.addAsWebResource("dial-client-entry_wActionUrl.xml");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(henriquePort));
+ List resources = new ArrayList(Arrays.asList("dial-client-entry_wActionUrl.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm.xml",
+ "restcomm.script_dialActionTest",resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialForkAnswerDelayTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialForkAnswerDelayTest.java
index ea49f34264..e25924f9ef 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialForkAnswerDelayTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialForkAnswerDelayTest.java
@@ -31,10 +31,15 @@
import java.util.List;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Tests for the Dial forking
@@ -58,10 +63,12 @@ public class DialForkAnswerDelayTest {
@ArquillianResource
URL deploymentUrl;
- //Dial Action URL: http://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/DialAction Method: POST
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -71,31 +78,41 @@ public class DialForkAnswerDelayTest {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// Henrique is a simple SIP Client. Will not register with Restcomm
private SipStack henriqueSipStack;
private SipPhone henriquePhone;
- private String henriqueContact = "sip:henrique@127.0.0.1:5092";
+ private static String henriquePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String henriqueContact = "sip:henrique@127.0.0.1:" + henriquePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
// Fotini is a simple SIP Client. Will not register with Restcomm
private SipStack fotiniSipStack;
private SipPhone fotiniPhone;
- private String fotiniContact = "sip:fotini@127.0.0.1:5093";
+ private static String fotiniPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String fotiniContact = "sip:fotini@127.0.0.1:" + fotiniPort;
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private String dialAliceRcmlWithPlay;
@BeforeClass
public static void beforeClass() throws Exception {
@@ -105,24 +122,36 @@ public static void beforeClass() throws Exception {
tool4 = new SipStackTool("DialForkAnswerDelay4");
tool5 = new SipStackTool("DialForkAnswerDelay5");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ dialAliceRcmlWithPlay = "" + deploymentUrl.toString() + "/audio/demo-prompt.wavalice";
+
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, henriqueContact);
+ henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", henriquePort, restcommContact);
+ henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, henriqueContact);
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
- fotiniSipStack = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5093", "127.0.0.1:5080");
- fotiniPhone = fotiniSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, fotiniContact);
+ fotiniSipStack = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", fotiniPort, restcommContact);
+ fotiniPhone = fotiniSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, fotiniContact);
}
@After
@@ -166,7 +195,7 @@ public void after() throws Exception {
Thread.sleep(4000);
}
- private String dialFork = "alicesip:henrique@127.0.0.1:5092+131313";
+ private String dialFork = "alicesip:henrique@127.0.0.1:" + henriquePort + "+131313";
@Test
public synchronized void testDialForkNoAnswerButHenrique() throws InterruptedException, ParseException, MalformedURLException {
@@ -630,7 +659,7 @@ public synchronized void testDialForkWithDecline() throws InterruptedException,
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialForkWithTimeout = "alicesip:henrique@127.0.0.1:5092+131313";
+ private String dialForkWithTimeout = "alicesip:henrique@127.0.0.1:" + henriquePort + "+131313";
@Test
public synchronized void testDialForkNoAnswer() throws InterruptedException, ParseException, MalformedURLException {
@@ -856,7 +885,7 @@ public synchronized void testDialForkNoAnswerAndNoResponseFromAlice() throws Int
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialForkWithTimeout15 = "alicesip:henrique@127.0.0.1:5092+131313";
+ private String dialForkWithTimeout15 = "alicesip:henrique@127.0.0.1:" + henriquePort + "+131313";
@Test
public synchronized void testDialForkNoAnswerWith183() throws InterruptedException, ParseException, MalformedURLException {
@@ -962,9 +991,9 @@ public synchronized void testDialForkNoAnswerWith183() throws InterruptedExcepti
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialForkWithActionUrl = "" +
- "+131313sip:henrique@127.0.0.1:5092alice";
- private String rcmlToReturn = "sip:fotini@127.0.0.1:5093";
+ private String dialForkWithActionUrl = "" +
+ "+131313sip:henrique@127.0.0.1:" + henriquePort + "alice";
+ private String rcmlToReturn = "sip:fotini@127.0.0.1:" + fotiniPort + "";
//Non regression test for https://telestax.atlassian.net/browse/RESTCOMM-585
@Test //TODO Fails when the whole test class runs but Passes when run individually
public synchronized void testDialForkNoAnswerExecuteRCML_ReturnedFromActionURL() throws InterruptedException, ParseException, MalformedURLException {
@@ -1177,8 +1206,6 @@ public void testDialClientAlice() throws ParseException, InterruptedException, M
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialAliceRcmlWithPlay = "http://127.0.0.1:8080/restcomm/audio/demo-prompt.wavalice";
-
@Test
public void testDialClientAliceWithPlay() throws ParseException, InterruptedException, MalformedURLException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -1253,7 +1280,7 @@ public void testDialClientAliceWithPlay() throws ParseException, InterruptedExce
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialSequential = "sip:nonexistent@127.0.0.1:5566sip:nonexistent2@127.0.0.1:6655sip:henrique@127.0.0.1:5092";
+ private String dialSequential = "sip:nonexistent@127.0.0.1:5566sip:nonexistent2@127.0.0.1:6655sip:henrique@127.0.0.1:" + henriquePort + "";
@Test
public synchronized void testDialSequentialFirstCallTimeouts() throws InterruptedException, ParseException, MalformedURLException {
@@ -1344,7 +1371,7 @@ public synchronized void testDialSequentialFirstCallTimeouts() throws Interrupte
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialForkTwoSipUrisRcml = "sip:fotini@127.0.0.1:5093sip:henrique@127.0.0.1:5092";
+ private String dialForkTwoSipUrisRcml = "sip:fotini@127.0.0.1:" + fotiniPort + "sip:henrique@127.0.0.1:" + henriquePort + "";
@Test
public synchronized void testDialForkWithServerErrorReponse() throws InterruptedException, ParseException, MalformedURLException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -1441,18 +1468,22 @@ public synchronized void testDialForkWithServerErrorReponse() throws Interrupted
@Deployment(name = "DialForkAnswerDelayTest", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm-delay.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialForkTest", "data/hsql/restcomm.script");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(henriquePort));
+ replacements.put("5093", String.valueOf(fotiniPort));
+
+ List resources = new ArrayList(Arrays.asList("hello-play.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw("rrestcomm-delay.xml",
+ "restcomm.script_dialForkTest",resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialForkTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialForkTest.java
index 51b04f046c..c4c9a71fec 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialForkTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialForkTest.java
@@ -13,9 +13,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.*;
import org.junit.runner.RunWith;
import org.restcomm.connect.commons.Version;
@@ -31,10 +29,15 @@
import java.util.List;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Tests for the Dial forking
@@ -58,10 +61,23 @@ public class DialForkTest {
@ArquillianResource
URL deploymentUrl;
- //Dial Action URL: http://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/DialAction Method: POST
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+ private String dialForkWithActionUrl = "" +
+ "+131313sip:henrique@127.0.0.1:" + henriquePort +"alice";
+ private String rcmlToReturn = "sip:fotini@127.0.0.1:" + fotiniPort + "";
+ private String dialForkToNotRegisteredClientDialClientFirst = "alicesip:henrique@127.0.0.1:" + henriquePort + "";
+ private String dialFork = "alicesip:henrique@127.0.0.1:" + henriquePort + "+131313";
+ private String dialForkToNotRegisteredClientSipFirst = "sip:henrique@127.0.0.1:" + henriquePort + "alice";
+ private String dialForkWithTimeout15 = "alicesip:henrique@127.0.0.1:" + henriquePort + "+131313";
+ private String dialSequential = "sip:nonexistent@127.0.0.1:5566sip:nonexistent2@127.0.0.1:6655sip:henrique@127.0.0.1:" + henriquePort + "";
+ private String dialForkTwoSipUrisRcml = "sip:fotini@127.0.0.1:" + fotiniPort + "sip:henrique@127.0.0.1:" + henriquePort + "";
+
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -71,31 +87,44 @@ public class DialForkTest {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// Henrique is a simple SIP Client. Will not register with Restcomm
private SipStack henriqueSipStack;
private SipPhone henriquePhone;
- private String henriqueContact = "sip:henrique@127.0.0.1:5092";
+ private static String henriquePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String henriqueContact = "sip:henrique@127.0.0.1:" + henriquePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
// Fotini is a simple SIP Client. Will not register with Restcomm
private SipStack fotiniSipStack;
private SipPhone fotiniPhone;
- private String fotiniContact = "sip:fotini@127.0.0.1:5093";
+ private static String fotiniPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String fotiniContact = "sip:fotini@127.0.0.1:" + fotiniPort;
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private static String dialAliceRcmlWithPlay;
+ private static String dialAliceRcmlWithInvalidPlay;
+ private String dialForkWithTimeout = "alicesip:henrique@127.0.0.1:" + henriquePort + "+131313";
+
@BeforeClass
public static void beforeClass() throws Exception {
@@ -105,24 +134,38 @@ public static void beforeClass() throws Exception {
tool4 = new SipStackTool("DialFork4");
tool5 = new SipStackTool("DialFork5");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+
+ dialAliceRcmlWithPlay = "" + deploymentUrl.toString() + "/audio/demo-prompt.wavalice";
+ dialAliceRcmlWithInvalidPlay = "" + deploymentUrl.toString() + "/audio/demo-prompt13.wavalice";
+
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, henriqueContact);
+ henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", henriquePort, restcommContact);
+ henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, henriqueContact);
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
- fotiniSipStack = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5093", "127.0.0.1:5080");
- fotiniPhone = fotiniSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, fotiniContact);
+ fotiniSipStack = tool5.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", fotiniPort, restcommContact);
+ fotiniPhone = fotiniSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, fotiniContact);
}
@After
@@ -166,8 +209,6 @@ public void after() throws Exception {
Thread.sleep(4000);
}
- private String dialFork = "alicesip:henrique@127.0.0.1:5092+131313";
-
@Test
public synchronized void testDialForkNoAnswerButHenrique() throws InterruptedException, ParseException, MalformedURLException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -177,7 +218,7 @@ public synchronized void testDialForkNoAnswerButHenrique() throws InterruptedExc
.withBody(dialFork)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -196,7 +237,7 @@ public synchronized void testDialForkNoAnswerButHenrique() throws InterruptedExc
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -296,7 +337,7 @@ public synchronized void testDialForkNoAnswerButFromAliceClient() throws Interru
.withBody(dialFork)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -315,7 +356,7 @@ public synchronized void testDialForkNoAnswerButFromAliceClient() throws Interru
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -406,7 +447,6 @@ public synchronized void testDialForkNoAnswerButFromAliceClient() throws Interru
}
// Non regression test for https://github.com/RestComm/Restcomm-Connect/issues/1972
- private String dialForkToNotRegisteredClientSipFirst = "sip:henrique@127.0.0.1:5092alice";
@Test
public synchronized void testDialForkToNotRegisteredClientDialSipFirst() throws InterruptedException, ParseException, MalformedURLException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -424,7 +464,7 @@ public synchronized void testDialForkToNotRegisteredClientDialSipFirst() throws
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -498,7 +538,6 @@ public synchronized void testDialForkToNotRegisteredClientDialSipFirst() throws
//Non regression test for https://github.com/RestComm/Restcomm-Connect/issues/1972
//When Dial Client is first its working fine
- private String dialForkToNotRegisteredClientDialClientFirst = "alicesip:henrique@127.0.0.1:5092";
@Test
public synchronized void testDialForkToNotRegisteredClientDialClientFirst() throws InterruptedException, ParseException, MalformedURLException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -516,7 +555,7 @@ public synchronized void testDialForkToNotRegisteredClientDialClientFirst() thro
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -597,7 +636,7 @@ public synchronized void testDialForkWithBusy() throws InterruptedException, Par
.withBody(dialFork)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -616,7 +655,7 @@ public synchronized void testDialForkWithBusy() throws InterruptedException, Par
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -712,7 +751,7 @@ public synchronized void testDialForkWithDecline() throws InterruptedException,
.withBody(dialFork)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -731,7 +770,7 @@ public synchronized void testDialForkWithDecline() throws InterruptedException,
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -823,7 +862,7 @@ public synchronized void testDialForkBobSendsBye() throws InterruptedException,
.withBody(dialFork)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -842,7 +881,7 @@ public synchronized void testDialForkBobSendsBye() throws InterruptedException,
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -924,7 +963,6 @@ public synchronized void testDialForkBobSendsBye() throws InterruptedException,
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialForkWithTimeout = "alicesip:henrique@127.0.0.1:5092+131313";
@Test
public synchronized void testDialForkNoAnswer() throws InterruptedException, ParseException, MalformedURLException {
@@ -936,7 +974,7 @@ public synchronized void testDialForkNoAnswer() throws InterruptedException, Par
.withBody(dialForkWithTimeout)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -959,7 +997,7 @@ public synchronized void testDialForkNoAnswer() throws InterruptedException, Par
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1061,7 +1099,7 @@ public synchronized void testDialForkWithReInviteBeforeDialForkStarts_CancelCall
.withBody(dialForkWithTimeout)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -1084,7 +1122,7 @@ public synchronized void testDialForkWithReInviteBeforeDialForkStarts_CancelCall
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1193,7 +1231,7 @@ public synchronized void testDialForkWithReInviteAfterDialStarts_CancelCall() th
.withBody(dialClientAlice)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -1204,7 +1242,7 @@ public synchronized void testDialForkWithReInviteAfterDialStarts_CancelCall() th
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1296,7 +1334,7 @@ public synchronized void testDialForkNoAnswerWith183FromAlice() throws Interrupt
.withBody(dialForkWithTimeout)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -1319,7 +1357,7 @@ public synchronized void testDialForkNoAnswerWith183FromAlice() throws Interrupt
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1413,7 +1451,7 @@ public synchronized void testDialForkNoAnswerAndNoResponseFromAlice() throws Int
.withBody(dialForkWithTimeout)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -1436,7 +1474,7 @@ public synchronized void testDialForkNoAnswerAndNoResponseFromAlice() throws Int
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1521,7 +1559,6 @@ public synchronized void testDialForkNoAnswerAndNoResponseFromAlice() throws Int
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialForkWithTimeout15 = "alicesip:henrique@127.0.0.1:5092+131313";
@Test
public synchronized void testDialForkNoAnswerWith183() throws InterruptedException, ParseException, MalformedURLException {
@@ -1533,7 +1570,7 @@ public synchronized void testDialForkNoAnswerWith183() throws InterruptedExcepti
.withBody(dialForkWithTimeout15)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -1556,7 +1593,7 @@ public synchronized void testDialForkNoAnswerWith183() throws InterruptedExcepti
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1634,9 +1671,6 @@ public synchronized void testDialForkNoAnswerWith183() throws InterruptedExcepti
- private String dialForkWithActionUrl = "" +
- "+131313sip:henrique@127.0.0.1:5092alice";
- private String rcmlToReturn = "sip:fotini@127.0.0.1:5093";
//Non regression test for https://telestax.atlassian.net/browse/RESTCOMM-585
@Test //TODO Fails when the whole test class runs but Passes when run individually
public synchronized void testDialForkNoAnswerExecuteRCML_ReturnedFromActionURL() throws InterruptedException, ParseException, MalformedURLException {
@@ -1654,7 +1688,7 @@ public synchronized void testDialForkNoAnswerExecuteRCML_ReturnedFromActionURL()
.withBody(rcmlToReturn)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -1677,7 +1711,7 @@ public synchronized void testDialForkNoAnswerExecuteRCML_ReturnedFromActionURL()
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1789,7 +1823,7 @@ public synchronized void testDialForkEveryoneBusyExecuteRCML_ReturnedFromActionU
.withBody(rcmlToReturn)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -1812,7 +1846,7 @@ public synchronized void testDialForkEveryoneBusyExecuteRCML_ReturnedFromActionU
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1932,7 +1966,7 @@ public void testDialClientAlice() throws ParseException, InterruptedException, M
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcml)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1941,7 +1975,7 @@ public void testDialClientAlice() throws ParseException, InterruptedException, M
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1998,7 +2032,6 @@ public void testDialClientAlice() throws ParseException, InterruptedException, M
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialAliceRcmlWithPlay = "http://127.0.0.1:8080/restcomm/audio/demo-prompt.wavalice";
@Test
public void testDialClientAliceWithPlay() throws ParseException, InterruptedException, MalformedURLException {
@@ -2008,7 +2041,7 @@ public void testDialClientAliceWithPlay() throws ParseException, InterruptedExce
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcmlWithPlay)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -2017,7 +2050,7 @@ public void testDialClientAliceWithPlay() throws ParseException, InterruptedExce
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -2074,7 +2107,6 @@ public void testDialClientAliceWithPlay() throws ParseException, InterruptedExce
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialAliceRcmlWithInvalidPlay = "http://127.0.0.1:8080/restcomm/audio/demo-prompt13.wavalice";
@Test //Test that Restcomm cleans up calls when an error from MMS happens
public void testDialClientAliceWithInvalidPlayFile() throws ParseException, InterruptedException, MalformedURLException {
@@ -2084,7 +2116,7 @@ public void testDialClientAliceWithInvalidPlayFile() throws ParseException, Inte
.withHeader("Content-Type", "text/xml")
.withBody(dialAliceRcmlWithInvalidPlay)));
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -2093,7 +2125,7 @@ public void testDialClientAliceWithInvalidPlayFile() throws ParseException, Inte
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -2139,7 +2171,6 @@ public void testDialClientAliceWithInvalidPlayFile() throws ParseException, Inte
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialSequential = "sip:nonexistent@127.0.0.1:5566sip:nonexistent2@127.0.0.1:6655sip:henrique@127.0.0.1:5092";
@Test
public synchronized void testDialSequentialFirstCallTimeouts() throws InterruptedException, ParseException, MalformedURLException {
@@ -2157,7 +2188,7 @@ public synchronized void testDialSequentialFirstCallTimeouts() throws Interrupte
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -2230,7 +2261,6 @@ public synchronized void testDialSequentialFirstCallTimeouts() throws Interrupte
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialForkTwoSipUrisRcml = "sip:fotini@127.0.0.1:5093sip:henrique@127.0.0.1:5092";
@Test
public synchronized void testDialForkWithServerErrorReponse() throws InterruptedException, ParseException, MalformedURLException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -2251,7 +2281,7 @@ public synchronized void testDialForkWithServerErrorReponse() throws Interrupted
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -2328,18 +2358,22 @@ public synchronized void testDialForkWithServerErrorReponse() throws Interrupted
@Deployment(name = "DialForkTest", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialForkTest", "data/hsql/restcomm.script");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(henriquePort));
+ replacements.put("5093", String.valueOf(fotiniPort));
+
+ List resources = new ArrayList(Arrays.asList("hello-play.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm.xml",
+ "restcomm.script_dialForkTest",resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialRecordingAnswerDelayTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialRecordingAnswerDelayTest.java
index 478e1dde8f..a13c461fe9 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialRecordingAnswerDelayTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialRecordingAnswerDelayTest.java
@@ -32,10 +32,17 @@
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
+import static org.restcomm.connect.testsuite.telephony.DialRecordingTest.reconfigurePorts;
/**
* Created by gvagenas on 08/01/2017.
@@ -43,255 +50,276 @@
@RunWith(Arquillian.class)
public class DialRecordingAnswerDelayTest {
- private final static Logger logger = Logger.getLogger(DialRecordingAnswerDelayTest.class.getName());
-
- private static final String version = Version.getVersion();
- private static final byte[] bytes = new byte[] { 118, 61, 48, 13, 10, 111, 61, 117, 115, 101, 114, 49, 32, 53, 51, 54, 53,
- 53, 55, 54, 53, 32, 50, 51, 53, 51, 54, 56, 55, 54, 51, 55, 32, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46,
- 48, 46, 49, 13, 10, 115, 61, 45, 13, 10, 99, 61, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46, 48, 46, 49,
- 13, 10, 116, 61, 48, 32, 48, 13, 10, 109, 61, 97, 117, 100, 105, 111, 32, 54, 48, 48, 48, 32, 82, 84, 80, 47, 65,
- 86, 80, 32, 48, 13, 10, 97, 61, 114, 116, 112, 109, 97, 112, 58, 48, 32, 80, 67, 77, 85, 47, 56, 48, 48, 48, 13, 10 };
- private static final String body = new String(bytes);
-
- @ArquillianResource
- private Deployer deployer;
- @ArquillianResource
- URL deploymentUrl;
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
- private static SipStackTool tool1;
- private static SipStackTool tool2;
- private static SipStackTool tool3;
- private static SipStackTool tool4;
-
- // Bob is a simple SIP Client. Will not register with Restcomm
- private SipStack bobSipStack;
- private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
-
- // Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
- // of the VoiceURL will be executed.
- private SipStack aliceSipStack;
- private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
-
- // Henrique is a simple SIP Client. Will not register with Restcomm
- private SipStack henriqueSipStack;
- private SipPhone henriquePhone;
- private String henriqueContact = "sip:henrique@127.0.0.1:5092";
-
- // George is a simple SIP Client. Will not register with Restcomm
- private SipStack georgeSipStack;
- private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
-
- private String dialRestcomm = "sip:1111@127.0.0.1:5080";
-
- private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
- private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- tool1 = new SipStackTool("DialActionTest1");
- tool2 = new SipStackTool("DialActionTest2");
- tool3 = new SipStackTool("DialActionTest3");
- tool4 = new SipStackTool("DialActionTest4");
- }
-
-
- @Before
- public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
-
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
-
- henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, henriqueContact);
-
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
- }
-
- @After
- public void after() throws Exception {
- if (bobPhone != null) {
- bobPhone.dispose();
- }
- if (bobSipStack != null) {
- bobSipStack.dispose();
- }
-
- if (aliceSipStack != null) {
- aliceSipStack.dispose();
- }
- if (alicePhone != null) {
- alicePhone.dispose();
- }
-
- if (henriqueSipStack != null) {
- henriqueSipStack.dispose();
- }
- if (henriquePhone != null) {
- henriquePhone.dispose();
- }
-
- if (georgePhone != null) {
- georgePhone.dispose();
- }
- if (georgeSipStack != null) {
- georgeSipStack.dispose();
- }
- Thread.sleep(1000);
- wireMockRule.resetRequests();
- Thread.sleep(4000);
- }
-
- private String dialClientRcml = "alice";
-
- @Test
- public synchronized void testDialClientAlice_BobDisconnects() throws InterruptedException, ParseException {
- stubFor(get(urlPathEqualTo("/1111"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(dialClientRcml)));
-
- // Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
- assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
-
- // Prepare second phone to receive call
- SipCall aliceCall = alicePhone.createSipCall();
- aliceCall.listenForIncomingCall();
-
- // Create outgoing call with first phone
- final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
- assertLastOperationSuccess(bobCall);
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- final int response = bobCall.getLastReceivedResponse().getStatusCode();
- assertTrue(response == Response.TRYING || response == Response.RINGING);
-
- if (response == Response.TRYING) {
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
- }
-
- bobCall.sendInviteOkAck();
- assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
- String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
-
- assertTrue(aliceCall.waitForIncomingCall(30 * 1000));
- assertTrue(aliceCall.sendIncomingCallResponse(Response.RINGING, "Ringing-Alice", 3600));
- String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
- assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "OK-Alice", 3600, receivedBody, "application", "sdp", null,
- null));
- assertTrue(aliceCall.waitForAck(50 * 1000));
-
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
-
- Thread.sleep(3000);
-
- // hangup.
- aliceCall.listenForDisconnect();
- bobCall.disconnect();
-
- assertTrue(aliceCall.waitForDisconnect(30 * 1000));
- assertTrue(aliceCall.respondToDisconnect());
-
- //Check recording
- JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(),adminAccountSid,adminAuthToken,callSid);
- assertNotNull(recording);
- assertEquals(1, recording.size());
- double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
- assertTrue(duration==3.0);
- }
-
-
- @Test
- public synchronized void testDialClientAlice_AliceDisconnects() throws InterruptedException, ParseException {
- stubFor(get(urlPathEqualTo("/1111"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(dialClientRcml)));
-
- // Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
- assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
-
- // Prepare second phone to receive call
- SipCall aliceCall = alicePhone.createSipCall();
- aliceCall.listenForIncomingCall();
-
- // Create outgoing call with first phone
- final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
- assertLastOperationSuccess(bobCall);
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- final int response = bobCall.getLastReceivedResponse().getStatusCode();
- assertTrue(response == Response.TRYING || response == Response.RINGING);
-
- if (response == Response.TRYING) {
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
- }
-
- bobCall.sendInviteOkAck();
- assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
- String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
-
- assertTrue(aliceCall.waitForIncomingCall(30 * 1000));
- assertTrue(aliceCall.sendIncomingCallResponse(Response.RINGING, "Ringing-Alice", 3600));
- String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
- assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "OK-Alice", 3600, receivedBody, "application", "sdp", null,
- null));
- assertTrue(aliceCall.waitForAck(50 * 1000));
-
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
-
- Thread.sleep(3000);
-
- // hangup.
- bobCall.listenForDisconnect();
- aliceCall.disconnect();
-
- assertTrue(bobCall.waitForDisconnect(30 * 1000));
- assertTrue(bobCall.respondToDisconnect());
-
- //Check recording
- JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(),adminAccountSid,adminAuthToken,callSid);
- assertNotNull(recording);
- assertEquals(1, recording.size());
- double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
- assertTrue(duration==3.0);
- }
-
-
- @Deployment(name = "DialRecordingTest", managed = true, testable = false)
- public static WebArchive createWebArchiveNoGw() {
- logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.delete("/WEB-INF/classes/application.conf");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm-delay.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialTest_new", "data/hsql/restcomm.script");
- archive.addAsWebInfResource("akka_application.conf", "classes/application.conf");
- logger.info("Packaged Test App");
- return archive;
- }
+ private final static Logger logger = Logger.getLogger(DialRecordingAnswerDelayTest.class.getName());
+
+ private static final String version = Version.getVersion();
+ private static final byte[] bytes = new byte[]{118, 61, 48, 13, 10, 111, 61, 117, 115, 101, 114, 49, 32, 53, 51, 54, 53,
+ 53, 55, 54, 53, 32, 50, 51, 53, 51, 54, 56, 55, 54, 51, 55, 32, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46,
+ 48, 46, 49, 13, 10, 115, 61, 45, 13, 10, 99, 61, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46, 48, 46, 49,
+ 13, 10, 116, 61, 48, 32, 48, 13, 10, 109, 61, 97, 117, 100, 105, 111, 32, 54, 48, 48, 48, 32, 82, 84, 80, 47, 65,
+ 86, 80, 32, 48, 13, 10, 97, 61, 114, 116, 112, 109, 97, 112, 58, 48, 32, 80, 67, 77, 85, 47, 56, 48, 48, 48, 13, 10};
+ private static final String body = new String(bytes);
+
+ @ArquillianResource
+ private Deployer deployer;
+ @ArquillianResource
+ URL deploymentUrl;
+
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
+ private static SipStackTool tool1;
+ private static SipStackTool tool2;
+ private static SipStackTool tool3;
+ private static SipStackTool tool4;
+
+ // Bob is a simple SIP Client. Will not register with Restcomm
+ private SipStack bobSipStack;
+ private SipPhone bobPhone;
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
+
+ // Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
+ // of the VoiceURL will be executed.
+ private SipStack aliceSipStack;
+ private SipPhone alicePhone;
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
+
+ // Henrique is a simple SIP Client. Will not register with Restcomm
+ private SipStack henriqueSipStack;
+ private SipPhone henriquePhone;
+ private static String henriquePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String henriqueContact = "sip:henrique@127.0.0.1:" + henriquePort;
+
+ // George is a simple SIP Client. Will not register with Restcomm
+ private SipStack georgeSipStack;
+ private SipPhone georgePhone;
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
+
+
+ private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
+ private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private String dialRestcomm = "sip:1111@" + restcommContact;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ tool1 = new SipStackTool("DialActionTest1");
+ tool2 = new SipStackTool("DialActionTest2");
+ tool3 = new SipStackTool("DialActionTest3");
+ tool4 = new SipStackTool("DialActionTest4");
+ }
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
+
+ @Before
+ public void before() throws Exception {
+
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
+
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
+
+ henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", henriquePort, restcommContact);
+ henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, henriqueContact);
+
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
+
+ }
+
+ @After
+ public void after() throws Exception {
+ if (bobPhone != null) {
+ bobPhone.dispose();
+ }
+ if (bobSipStack != null) {
+ bobSipStack.dispose();
+ }
+
+ if (aliceSipStack != null) {
+ aliceSipStack.dispose();
+ }
+ if (alicePhone != null) {
+ alicePhone.dispose();
+ }
+
+ if (henriqueSipStack != null) {
+ henriqueSipStack.dispose();
+ }
+ if (henriquePhone != null) {
+ henriquePhone.dispose();
+ }
+
+ if (georgePhone != null) {
+ georgePhone.dispose();
+ }
+ if (georgeSipStack != null) {
+ georgeSipStack.dispose();
+ }
+ Thread.sleep(1000);
+ wireMockRule.resetRequests();
+ Thread.sleep(4000);
+ }
+
+ private String dialClientRcml = "alice";
+
+ @Test
+ public synchronized void testDialClientAlice_BobDisconnects() throws InterruptedException, ParseException {
+ stubFor(get(urlPathEqualTo("/1111"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBody(dialClientRcml)));
+
+ // Phone2 register as alice
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
+ assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
+
+ // Prepare second phone to receive call
+ SipCall aliceCall = alicePhone.createSipCall();
+ aliceCall.listenForIncomingCall();
+
+ // Create outgoing call with first phone
+ final SipCall bobCall = bobPhone.createSipCall();
+ bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
+ assertLastOperationSuccess(bobCall);
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ final int response = bobCall.getLastReceivedResponse().getStatusCode();
+ assertTrue(response == Response.TRYING || response == Response.RINGING);
+
+ if (response == Response.TRYING) {
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
+ }
+
+ bobCall.sendInviteOkAck();
+ assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
+ String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
+
+ assertTrue(aliceCall.waitForIncomingCall(30 * 1000));
+ assertTrue(aliceCall.sendIncomingCallResponse(Response.RINGING, "Ringing-Alice", 3600));
+ String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
+ assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "OK-Alice", 3600, receivedBody, "application", "sdp", null,
+ null));
+ assertTrue(aliceCall.waitForAck(50 * 1000));
+
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
+
+ Thread.sleep(3000);
+
+ // hangup.
+ aliceCall.listenForDisconnect();
+ bobCall.disconnect();
+
+ assertTrue(aliceCall.waitForDisconnect(30 * 1000));
+ assertTrue(aliceCall.respondToDisconnect());
+
+ //Check recording
+ JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken, callSid);
+ assertNotNull(recording);
+ assertEquals(1, recording.size());
+ double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
+ assertTrue(duration == 3.0);
+ }
+
+ @Test
+ public synchronized void testDialClientAlice_AliceDisconnects() throws InterruptedException, ParseException {
+ stubFor(get(urlPathEqualTo("/1111"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBody(dialClientRcml)));
+
+ // Phone2 register as alice
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
+ assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
+
+ // Prepare second phone to receive call
+ SipCall aliceCall = alicePhone.createSipCall();
+ aliceCall.listenForIncomingCall();
+
+ // Create outgoing call with first phone
+ final SipCall bobCall = bobPhone.createSipCall();
+ bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
+ assertLastOperationSuccess(bobCall);
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ final int response = bobCall.getLastReceivedResponse().getStatusCode();
+ assertTrue(response == Response.TRYING || response == Response.RINGING);
+
+ if (response == Response.TRYING) {
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
+ }
+
+ bobCall.sendInviteOkAck();
+ assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
+ String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
+
+ assertTrue(aliceCall.waitForIncomingCall(30 * 1000));
+ assertTrue(aliceCall.sendIncomingCallResponse(Response.RINGING, "Ringing-Alice", 3600));
+ String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
+ assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "OK-Alice", 3600, receivedBody, "application", "sdp", null,
+ null));
+ assertTrue(aliceCall.waitForAck(50 * 1000));
+
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
+
+ Thread.sleep(3000);
+
+ // hangup.
+ bobCall.listenForDisconnect();
+ aliceCall.disconnect();
+
+ assertTrue(bobCall.waitForDisconnect(30 * 1000));
+ assertTrue(bobCall.respondToDisconnect());
+
+ //Check recording
+ JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken, callSid);
+ assertNotNull(recording);
+ assertEquals(1, recording.size());
+ double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
+ assertTrue(duration == 3.0);
+ }
+
+ @Deployment(name = "DialRecordingTest", managed = true, testable = false)
+ public static WebArchive createWebArchiveNoGw() {
+ logger.info("Packaging Test App");
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(henriquePort));
+
+ List resources = new ArrayList();
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm-delay.xml",
+ "restcomm.script_dialTest_new", resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialRecordingTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialRecordingTest.java
index f77077155f..4471d47fc4 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialRecordingTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialRecordingTest.java
@@ -45,10 +45,18 @@
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
+import static org.restcomm.connect.testsuite.telephony.DialForkTest.reconfigurePorts;
/**
* Created by gvagenas on 08/01/2017.
@@ -56,557 +64,580 @@
@RunWith(Arquillian.class)
public class DialRecordingTest {
- private final static Logger logger = Logger.getLogger(DialRecordingTest.class.getName());
-
- private static final String version = Version.getVersion();
- private static final byte[] bytes = new byte[] { 118, 61, 48, 13, 10, 111, 61, 117, 115, 101, 114, 49, 32, 53, 51, 54, 53,
- 53, 55, 54, 53, 32, 50, 51, 53, 51, 54, 56, 55, 54, 51, 55, 32, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46,
- 48, 46, 49, 13, 10, 115, 61, 45, 13, 10, 99, 61, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46, 48, 46, 49,
- 13, 10, 116, 61, 48, 32, 48, 13, 10, 109, 61, 97, 117, 100, 105, 111, 32, 54, 48, 48, 48, 32, 82, 84, 80, 47, 65,
- 86, 80, 32, 48, 13, 10, 97, 61, 114, 116, 112, 109, 97, 112, 58, 48, 32, 80, 67, 77, 85, 47, 56, 48, 48, 48, 13, 10 };
- private static final String body = new String(bytes);
-
- @ArquillianResource
- private Deployer deployer;
- @ArquillianResource
- URL deploymentUrl;
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
- private static SipStackTool tool1;
- private static SipStackTool tool2;
- private static SipStackTool tool3;
- private static SipStackTool tool4;
-
- // Bob is a simple SIP Client. Will not register with Restcomm
- private SipStack bobSipStack;
- private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
-
- // Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
- // of the VoiceURL will be executed.
- private SipStack aliceSipStack;
- private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
-
- // Henrique is a simple SIP Client. Will not register with Restcomm
- private SipStack henriqueSipStack;
- private SipPhone henriquePhone;
- private String henriqueContact = "sip:henrique@127.0.0.1:5092";
-
- // George is a simple SIP Client. Will not register with Restcomm
- private SipStack georgeSipStack;
- private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
-
- private String dialRestcomm = "sip:1111@127.0.0.1:5080";
-
- private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
- private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- tool1 = new SipStackTool("DialActionTest1");
- tool2 = new SipStackTool("DialActionTest2");
- tool3 = new SipStackTool("DialActionTest3");
- tool4 = new SipStackTool("DialActionTest4");
- }
-
-
- @Before
- public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
-
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
-
- henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, henriqueContact);
-
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
- }
-
- @After
- public void after() throws Exception {
- if (bobPhone != null) {
- bobPhone.dispose();
- }
- if (bobSipStack != null) {
- bobSipStack.dispose();
- }
-
- if (aliceSipStack != null) {
- aliceSipStack.dispose();
- }
- if (alicePhone != null) {
- alicePhone.dispose();
- }
-
- if (henriqueSipStack != null) {
- henriqueSipStack.dispose();
- }
- if (henriquePhone != null) {
- henriquePhone.dispose();
- }
-
- if (georgePhone != null) {
- georgePhone.dispose();
- }
- if (georgeSipStack != null) {
- georgeSipStack.dispose();
- }
- Thread.sleep(1000);
- wireMockRule.resetRequests();
- Thread.sleep(4000);
- }
-
- private String dialClientRcml = "alice";
-
- @Test
- public synchronized void testDialClientAlice_BobDisconnects() throws InterruptedException, ParseException {
- stubFor(get(urlPathEqualTo("/1111"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(dialClientRcml)));
-
- // Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
- assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
-
- // Prepare second phone to receive call
- SipCall aliceCall = alicePhone.createSipCall();
- aliceCall.listenForIncomingCall();
-
- // Create outgoing call with first phone
- final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
- assertLastOperationSuccess(bobCall);
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- final int response = bobCall.getLastReceivedResponse().getStatusCode();
- assertTrue(response == Response.TRYING || response == Response.RINGING);
-
- if (response == Response.TRYING) {
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
- }
-
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
-
- bobCall.sendInviteOkAck();
- assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
- String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
-
- assertTrue(aliceCall.waitForIncomingCall(30 * 1000));
- assertTrue(aliceCall.sendIncomingCallResponse(Response.RINGING, "Ringing-Alice", 3600));
- String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
- assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "OK-Alice", 3600, receivedBody, "application", "sdp", null,
- null));
- assertTrue(aliceCall.waitForAck(50 * 1000));
-
- Thread.sleep(3000);
-
- // hangup.
- aliceCall.listenForDisconnect();
- bobCall.disconnect();
-
- assertTrue(aliceCall.waitForDisconnect(30 * 1000));
- assertTrue(aliceCall.respondToDisconnect());
-
- Thread.sleep(500);
- //Check recording
- JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(),adminAccountSid,adminAuthToken,callSid);
- assertNotNull(recording);
- assertEquals(1, recording.size());
- double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
- assertEquals(3.0, duration, 1.0);
-
- JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(),adminAccountSid, adminAuthToken);
- assertNotNull(metrics);
- int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
- logger.info("LiveCalls: "+liveCalls);
- int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
- logger.info("LiveCallsArraySize: "+liveCallsArraySize);
- assertEquals(0,liveCalls);
- assertEquals(0, liveCallsArraySize);
- }
-
- @Test
- public synchronized void testDialClientAliceGerRecordindNoFile() throws InterruptedException, ParseException {
- stubFor(get(urlPathEqualTo("/1111"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(dialClientRcml)));
-
- // Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
- assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
-
- // Prepare second phone to receive call
- SipCall aliceCall = alicePhone.createSipCall();
- aliceCall.listenForIncomingCall();
-
- // Create outgoing call with first phone
- final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
- assertLastOperationSuccess(bobCall);
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- final int response = bobCall.getLastReceivedResponse().getStatusCode();
- assertTrue(response == Response.TRYING || response == Response.RINGING);
-
- if (response == Response.TRYING) {
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
- }
-
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
-
- bobCall.sendInviteOkAck();
- assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
- String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
-
- assertTrue(aliceCall.waitForIncomingCall(30 * 1000));
- assertTrue(aliceCall.sendIncomingCallResponse(Response.RINGING, "Ringing-Alice", 3600));
- String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
- assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "OK-Alice", 3600, receivedBody, "application", "sdp", null,
- null));
- assertTrue(aliceCall.waitForAck(50 * 1000));
-
- Thread.sleep(3000);
-
- // hangup.
- aliceCall.listenForDisconnect();
- bobCall.disconnect();
-
- assertTrue(aliceCall.waitForDisconnect(30 * 1000));
- assertTrue(aliceCall.respondToDisconnect());
-
- //Check recording
- JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(),adminAccountSid,adminAuthToken,callSid);
- assertNotNull(recording);
- assertEquals(1, recording.size());
- double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
- assertTrue(duration==3.0);
-
- RequestConfig requestConfig = RequestConfig.custom()
- .setConnectTimeout(6000)
- .setConnectionRequestTimeout(6000)
- .setSocketTimeout(6000)
- .setCookieSpec(CookieSpecs.STANDARD).build();
-
- CloseableHttpClient client = HttpClients.custom().setDefaultRequestConfig(requestConfig).build();
- String recordingUri = recording.get(0).getAsJsonObject().get("file_uri").getAsString();
- HttpRequest request = new HttpGet(recordingUri);
- CloseableHttpResponse httpResponse = null;
- try {
- httpResponse = client.execute((HttpUriRequest) request);
- } catch (IOException e) {
- e.printStackTrace();
- }
- assertTrue(httpResponse != null);
- int code = httpResponse.getStatusLine().getStatusCode();
- assertEquals(404, code);
-
- JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(),adminAccountSid, adminAuthToken);
- assertNotNull(metrics);
- int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
- logger.info("LiveCalls: "+liveCalls);
- int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
- logger.info("LiveCallsArraySize: "+liveCallsArraySize);
- assertEquals(0,liveCalls);
- assertEquals(0, liveCallsArraySize);
-
- }
-
- @Test
- public synchronized void testDialClientAlice_AliceDisconnects() throws InterruptedException, ParseException {
- stubFor(get(urlPathEqualTo("/1111"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(dialClientRcml)));
-
- // Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
- assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
-
- // Prepare second phone to receive call
- SipCall aliceCall = alicePhone.createSipCall();
- aliceCall.listenForIncomingCall();
-
- // Create outgoing call with first phone
- final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
- assertLastOperationSuccess(bobCall);
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- final int response = bobCall.getLastReceivedResponse().getStatusCode();
- assertTrue(response == Response.TRYING || response == Response.RINGING);
-
- if (response == Response.TRYING) {
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
- }
-
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
-
- bobCall.sendInviteOkAck();
- assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
- String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
-
- assertTrue(aliceCall.waitForIncomingCall(30 * 1000));
- assertTrue(aliceCall.sendIncomingCallResponse(Response.RINGING, "Ringing-Alice", 3600));
- String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
- assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "OK-Alice", 3600, receivedBody, "application", "sdp", null,
- null));
- assertTrue(aliceCall.waitForAck(50 * 1000));
-
- Thread.sleep(3000);
-
- // hangup.
- bobCall.listenForDisconnect();
- aliceCall.disconnect();
-
- assertTrue(bobCall.waitForDisconnect(30 * 1000));
- assertTrue(bobCall.respondToDisconnect());
-
- //Check recording
- JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(),adminAccountSid,adminAuthToken,callSid);
- assertNotNull(recording);
- assertEquals(1, recording.size());
- double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
- assertTrue(duration==3.0);
-
- JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(),adminAccountSid, adminAuthToken);
- assertNotNull(metrics);
- int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
- logger.info("LiveCalls: "+liveCalls);
- int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
- logger.info("LiveCallsArraySize: "+liveCallsArraySize);
- assertEquals(0,liveCalls);
- assertEquals(0, liveCallsArraySize);
- }
-
- final String recordCall = "";
- @Test
- public synchronized void testRecordCall() throws InterruptedException, ParseException {
- stubFor(get(urlPathEqualTo("/1111"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(recordCall)));
-
- // Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
- assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
-
- // Prepare second phone to receive call
- SipCall aliceCall = alicePhone.createSipCall();
- aliceCall.listenForIncomingCall();
-
- // Create outgoing call with first phone
- final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
- assertLastOperationSuccess(bobCall);
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- final int response = bobCall.getLastReceivedResponse().getStatusCode();
- assertTrue(response == Response.TRYING || response == Response.RINGING);
-
- if (response == Response.TRYING) {
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
- }
-
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
-
- bobCall.sendInviteOkAck();
- assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
- String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
-
- JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(),adminAccountSid, adminAuthToken);
- assertNotNull(metrics);
- int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
- logger.info("LiveCalls: "+liveCalls);
- int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
- logger.info("LiveCallsArraySize: "+liveCallsArraySize);
- assertEquals(1,liveCalls);
- assertEquals(1, liveCallsArraySize);
-
- Thread.sleep(3000);
-
- bobCall.disconnect();
-
- Thread.sleep(3000);
-
- //Check recording
- JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(),adminAccountSid,adminAuthToken,callSid);
- assertNotNull(recording);
- assertEquals(1, recording.size());
- double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
- assertEquals(3.0, duration,1);
-
- metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(),adminAccountSid, adminAuthToken);
- assertNotNull(metrics);
- liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
- logger.info("LiveCalls: "+liveCalls);
- liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
- logger.info("LiveCallsArraySize: "+liveCallsArraySize);
- assertEquals(0,liveCalls);
- assertEquals(0, liveCallsArraySize);
- }
-
- final String recordCallWithAction = "";
- final String hangupRcml = "";
- @Test
- public synchronized void testRecordCallWithAction() throws InterruptedException, ParseException {
- stubFor(get(urlPathEqualTo("/1111"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(recordCallWithAction)));
-
- stubFor(post(urlPathEqualTo("/record-action"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(hangupRcml)));
-
- // Create outgoing call with first phone
- final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
- assertLastOperationSuccess(bobCall);
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- final int response = bobCall.getLastReceivedResponse().getStatusCode();
- assertTrue(response == Response.TRYING || response == Response.RINGING);
-
- if (response == Response.TRYING) {
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
- }
-
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
-
- bobCall.sendInviteOkAck();
- DateTime start = DateTime.now();
- assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
- String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
-
- JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(),adminAccountSid, adminAuthToken);
- assertNotNull(metrics);
- int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
- logger.info("LiveCalls: "+liveCalls);
- int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
- logger.info("LiveCallsArraySize: "+liveCallsArraySize);
- assertEquals(1,liveCalls);
- assertEquals(1, liveCallsArraySize);
-
- Thread.sleep(3000);
-
- bobCall.disconnect();
- DateTime end = DateTime.now();
-
- Thread.sleep(500);
-
- //Check recording
- JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(),adminAccountSid,adminAuthToken,callSid);
- assertNotNull(recording);
- assertEquals(1, recording.size());
- double recordedDuration = (end.getMillis() - start.getMillis())/1000;
- double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
- assertEquals(recordedDuration, duration,0);
-
- logger.info("\n\n &&&&&& About to check liveCalls &&&&&& \n");
-
- metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(),adminAccountSid, adminAuthToken);
- assertNotNull(metrics);
- liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
- logger.info("LiveCalls: "+liveCalls);
- liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
- logger.info("LiveCallsArraySize: "+liveCallsArraySize);
- assertEquals(0,liveCalls);
- assertEquals(0, liveCallsArraySize);
- }
-
- @Test
- public synchronized void testRecordCallWithActionWithMaxRecordingReached() throws InterruptedException, ParseException {
- stubFor(get(urlPathEqualTo("/1111"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(recordCallWithAction)));
-
- stubFor(post(urlPathEqualTo("/record-action"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(hangupRcml)));
-
- // Create outgoing call with first phone
- final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
- assertLastOperationSuccess(bobCall);
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- final int response = bobCall.getLastReceivedResponse().getStatusCode();
- assertTrue(response == Response.TRYING || response == Response.RINGING);
-
- if (response == Response.TRYING) {
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
- }
-
- assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
-
- bobCall.sendInviteOkAck();
- DateTime start = DateTime.now();
- assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
- String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
-
- JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(),adminAccountSid, adminAuthToken);
- assertNotNull(metrics);
- int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
- logger.info("LiveCalls: "+liveCalls);
- int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
- logger.info("LiveCallsArraySize: "+liveCallsArraySize);
- assertEquals(1,liveCalls);
- assertEquals(1, liveCallsArraySize);
-
- bobCall.listenForDisconnect();
- assertTrue(bobCall.waitForDisconnect(70000));
- assertTrue(bobCall.respondToDisconnect());
- DateTime end = DateTime.now();
-
- Thread.sleep(500);
-
- //Check recording
- JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(),adminAccountSid,adminAuthToken,callSid);
- assertNotNull(recording);
- assertEquals(1, recording.size());
- double recordedDuration = (end.getMillis() - start.getMillis())/1000;
- double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
- assertEquals(recordedDuration, duration,0);
-
- logger.info("\n\n &&&&&& About to check liveCalls &&&&&& \n");
-
- metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(),adminAccountSid, adminAuthToken);
- assertNotNull(metrics);
- liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
- logger.info("LiveCalls: "+liveCalls);
- liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
- logger.info("LiveCallsArraySize: "+liveCallsArraySize);
- assertEquals(0,liveCalls);
- assertEquals(0, liveCallsArraySize);
- }
-
- final String recordCallWithTimeLimit = "";
+ private final static Logger logger = Logger.getLogger(DialRecordingTest.class.getName());
+
+ private static final String version = Version.getVersion();
+ private static final byte[] bytes = new byte[]{118, 61, 48, 13, 10, 111, 61, 117, 115, 101, 114, 49, 32, 53, 51, 54, 53,
+ 53, 55, 54, 53, 32, 50, 51, 53, 51, 54, 56, 55, 54, 51, 55, 32, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46,
+ 48, 46, 49, 13, 10, 115, 61, 45, 13, 10, 99, 61, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46, 48, 46, 49,
+ 13, 10, 116, 61, 48, 32, 48, 13, 10, 109, 61, 97, 117, 100, 105, 111, 32, 54, 48, 48, 48, 32, 82, 84, 80, 47, 65,
+ 86, 80, 32, 48, 13, 10, 97, 61, 114, 116, 112, 109, 97, 112, 58, 48, 32, 80, 67, 77, 85, 47, 56, 48, 48, 48, 13, 10};
+ private static final String body = new String(bytes);
+
+ @ArquillianResource
+ private Deployer deployer;
+ @ArquillianResource
+ URL deploymentUrl;
+
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
+ private static SipStackTool tool1;
+ private static SipStackTool tool2;
+ private static SipStackTool tool3;
+ private static SipStackTool tool4;
+
+ // Bob is a simple SIP Client. Will not register with Restcomm
+ private SipStack bobSipStack;
+ private SipPhone bobPhone;
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
+
+ // Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
+ // of the VoiceURL will be executed.
+ private SipStack aliceSipStack;
+ private SipPhone alicePhone;
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
+
+ // Henrique is a simple SIP Client. Will not register with Restcomm
+ private SipStack henriqueSipStack;
+ private SipPhone henriquePhone;
+ private static String henriquePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String henriqueContact = "sip:henrique@127.0.0.1:" + henriquePort;
+
+ // George is a simple SIP Client. Will not register with Restcomm
+ private SipStack georgeSipStack;
+ private SipPhone georgePhone;
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
+
+ private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
+ private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private String dialRestcomm = "sip:1111@" + restcommContact;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ tool1 = new SipStackTool("DialActionTest1");
+ tool2 = new SipStackTool("DialActionTest2");
+ tool3 = new SipStackTool("DialActionTest3");
+ tool4 = new SipStackTool("DialActionTest4");
+ }
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
+
+ @Before
+ public void before() throws Exception {
+
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
+
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
+
+ henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", henriquePort, restcommContact);
+ henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, henriqueContact);
+
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
+
+ }
+
+ @After
+ public void after() throws Exception {
+ if (bobPhone != null) {
+ bobPhone.dispose();
+ }
+ if (bobSipStack != null) {
+ bobSipStack.dispose();
+ }
+
+ if (aliceSipStack != null) {
+ aliceSipStack.dispose();
+ }
+ if (alicePhone != null) {
+ alicePhone.dispose();
+ }
+
+ if (henriqueSipStack != null) {
+ henriqueSipStack.dispose();
+ }
+ if (henriquePhone != null) {
+ henriquePhone.dispose();
+ }
+
+ if (georgePhone != null) {
+ georgePhone.dispose();
+ }
+ if (georgeSipStack != null) {
+ georgeSipStack.dispose();
+ }
+ Thread.sleep(1000);
+ wireMockRule.resetRequests();
+ Thread.sleep(4000);
+ }
+
+ private String dialClientRcml = "alice";
+
+ @Test
+ public synchronized void testDialClientAlice_BobDisconnects() throws InterruptedException, ParseException {
+ stubFor(get(urlPathEqualTo("/1111"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBody(dialClientRcml)));
+
+ // Phone2 register as alice
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
+ assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
+
+ // Prepare second phone to receive call
+ SipCall aliceCall = alicePhone.createSipCall();
+ aliceCall.listenForIncomingCall();
+
+ // Create outgoing call with first phone
+ final SipCall bobCall = bobPhone.createSipCall();
+ bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
+ assertLastOperationSuccess(bobCall);
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ final int response = bobCall.getLastReceivedResponse().getStatusCode();
+ assertTrue(response == Response.TRYING || response == Response.RINGING);
+
+ if (response == Response.TRYING) {
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
+ }
+
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
+
+ bobCall.sendInviteOkAck();
+ assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
+ String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
+
+ assertTrue(aliceCall.waitForIncomingCall(30 * 1000));
+ assertTrue(aliceCall.sendIncomingCallResponse(Response.RINGING, "Ringing-Alice", 3600));
+ String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
+ assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "OK-Alice", 3600, receivedBody, "application", "sdp", null,
+ null));
+ assertTrue(aliceCall.waitForAck(50 * 1000));
+
+ Thread.sleep(3000);
+
+ // hangup.
+ aliceCall.listenForDisconnect();
+ bobCall.disconnect();
+
+ assertTrue(aliceCall.waitForDisconnect(30 * 1000));
+ assertTrue(aliceCall.respondToDisconnect());
+
+ Thread.sleep(500);
+ //Check recording
+ JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken, callSid);
+ assertNotNull(recording);
+ assertEquals(1, recording.size());
+ double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
+ assertEquals(3.0, duration, 1.0);
+
+ JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
+ assertNotNull(metrics);
+ int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
+ logger.info("LiveCalls: " + liveCalls);
+ int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
+ logger.info("LiveCallsArraySize: " + liveCallsArraySize);
+ assertEquals(0, liveCalls);
+ assertEquals(0, liveCallsArraySize);
+ }
+
+ @Test
+ public synchronized void testDialClientAliceGerRecordindNoFile() throws InterruptedException, ParseException {
+ stubFor(get(urlPathEqualTo("/1111"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBody(dialClientRcml)));
+
+ // Phone2 register as alice
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
+ assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
+
+ // Prepare second phone to receive call
+ SipCall aliceCall = alicePhone.createSipCall();
+ aliceCall.listenForIncomingCall();
+
+ // Create outgoing call with first phone
+ final SipCall bobCall = bobPhone.createSipCall();
+ bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
+ assertLastOperationSuccess(bobCall);
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ final int response = bobCall.getLastReceivedResponse().getStatusCode();
+ assertTrue(response == Response.TRYING || response == Response.RINGING);
+
+ if (response == Response.TRYING) {
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
+ }
+
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
+
+ bobCall.sendInviteOkAck();
+ assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
+ String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
+
+ assertTrue(aliceCall.waitForIncomingCall(30 * 1000));
+ assertTrue(aliceCall.sendIncomingCallResponse(Response.RINGING, "Ringing-Alice", 3600));
+ String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
+ assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "OK-Alice", 3600, receivedBody, "application", "sdp", null,
+ null));
+ assertTrue(aliceCall.waitForAck(50 * 1000));
+
+ Thread.sleep(3000);
+
+ // hangup.
+ aliceCall.listenForDisconnect();
+ bobCall.disconnect();
+
+ assertTrue(aliceCall.waitForDisconnect(30 * 1000));
+ assertTrue(aliceCall.respondToDisconnect());
+
+ //Check recording
+ JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken, callSid);
+ assertNotNull(recording);
+ assertEquals(1, recording.size());
+ double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
+ assertTrue(duration == 3.0);
+
+ RequestConfig requestConfig = RequestConfig.custom()
+ .setConnectTimeout(6000)
+ .setConnectionRequestTimeout(6000)
+ .setSocketTimeout(6000)
+ .setCookieSpec(CookieSpecs.STANDARD).build();
+
+ CloseableHttpClient client = HttpClients.custom().setDefaultRequestConfig(requestConfig).build();
+ String recordingUri = recording.get(0).getAsJsonObject().get("file_uri").getAsString();
+ HttpRequest request = new HttpGet(recordingUri);
+ CloseableHttpResponse httpResponse = null;
+ try {
+ httpResponse = client.execute((HttpUriRequest) request);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertTrue(httpResponse != null);
+ int code = httpResponse.getStatusLine().getStatusCode();
+ assertEquals(404, code);
+
+ JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
+ assertNotNull(metrics);
+ int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
+ logger.info("LiveCalls: " + liveCalls);
+ int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
+ logger.info("LiveCallsArraySize: " + liveCallsArraySize);
+ assertEquals(0, liveCalls);
+ assertEquals(0, liveCallsArraySize);
+
+ }
+
+ @Test
+ public synchronized void testDialClientAlice_AliceDisconnects() throws InterruptedException, ParseException {
+ stubFor(get(urlPathEqualTo("/1111"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBody(dialClientRcml)));
+
+ // Phone2 register as alice
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
+ assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
+
+ // Prepare second phone to receive call
+ SipCall aliceCall = alicePhone.createSipCall();
+ aliceCall.listenForIncomingCall();
+
+ // Create outgoing call with first phone
+ final SipCall bobCall = bobPhone.createSipCall();
+ bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
+ assertLastOperationSuccess(bobCall);
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ final int response = bobCall.getLastReceivedResponse().getStatusCode();
+ assertTrue(response == Response.TRYING || response == Response.RINGING);
+
+ if (response == Response.TRYING) {
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
+ }
+
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
+
+ bobCall.sendInviteOkAck();
+ assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
+ String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
+
+ assertTrue(aliceCall.waitForIncomingCall(30 * 1000));
+ assertTrue(aliceCall.sendIncomingCallResponse(Response.RINGING, "Ringing-Alice", 3600));
+ String receivedBody = new String(aliceCall.getLastReceivedRequest().getRawContent());
+ assertTrue(aliceCall.sendIncomingCallResponse(Response.OK, "OK-Alice", 3600, receivedBody, "application", "sdp", null,
+ null));
+ assertTrue(aliceCall.waitForAck(50 * 1000));
+
+ Thread.sleep(3000);
+
+ // hangup.
+ bobCall.listenForDisconnect();
+ aliceCall.disconnect();
+
+ assertTrue(bobCall.waitForDisconnect(30 * 1000));
+ assertTrue(bobCall.respondToDisconnect());
+
+ //Check recording
+ JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken, callSid);
+ assertNotNull(recording);
+ assertEquals(1, recording.size());
+ double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
+ assertTrue(duration == 3.0);
+
+ JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
+ assertNotNull(metrics);
+ int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
+ logger.info("LiveCalls: " + liveCalls);
+ int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
+ logger.info("LiveCallsArraySize: " + liveCallsArraySize);
+ assertEquals(0, liveCalls);
+ assertEquals(0, liveCallsArraySize);
+ }
+
+ final String recordCall = "";
+
+ @Test
+ public synchronized void testRecordCall() throws InterruptedException, ParseException {
+ stubFor(get(urlPathEqualTo("/1111"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBody(recordCall)));
+
+ // Phone2 register as alice
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
+ assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
+
+ // Prepare second phone to receive call
+ SipCall aliceCall = alicePhone.createSipCall();
+ aliceCall.listenForIncomingCall();
+
+ // Create outgoing call with first phone
+ final SipCall bobCall = bobPhone.createSipCall();
+ bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
+ assertLastOperationSuccess(bobCall);
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ final int response = bobCall.getLastReceivedResponse().getStatusCode();
+ assertTrue(response == Response.TRYING || response == Response.RINGING);
+
+ if (response == Response.TRYING) {
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
+ }
+
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
+
+ bobCall.sendInviteOkAck();
+ assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
+ String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
+
+ JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
+ assertNotNull(metrics);
+ int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
+ logger.info("LiveCalls: " + liveCalls);
+ int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
+ logger.info("LiveCallsArraySize: " + liveCallsArraySize);
+ assertEquals(1, liveCalls);
+ assertEquals(1, liveCallsArraySize);
+
+ Thread.sleep(3000);
+
+ bobCall.disconnect();
+
+ Thread.sleep(3000);
+
+ //Check recording
+ JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken, callSid);
+ assertNotNull(recording);
+ assertEquals(1, recording.size());
+ double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
+ assertEquals(3.0, duration, 1);
+
+ metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
+ assertNotNull(metrics);
+ liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
+ logger.info("LiveCalls: " + liveCalls);
+ liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
+ logger.info("LiveCallsArraySize: " + liveCallsArraySize);
+ assertEquals(0, liveCalls);
+ assertEquals(0, liveCallsArraySize);
+ }
+
+ final String recordCallWithAction = "";
+ final String hangupRcml = "";
+
+ @Test
+ public synchronized void testRecordCallWithAction() throws InterruptedException, ParseException {
+ stubFor(get(urlPathEqualTo("/1111"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBody(recordCallWithAction)));
+
+ stubFor(post(urlPathEqualTo("/record-action"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBody(hangupRcml)));
+
+ // Create outgoing call with first phone
+ final SipCall bobCall = bobPhone.createSipCall();
+ bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
+ assertLastOperationSuccess(bobCall);
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ final int response = bobCall.getLastReceivedResponse().getStatusCode();
+ assertTrue(response == Response.TRYING || response == Response.RINGING);
+
+ if (response == Response.TRYING) {
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
+ }
+
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
+
+ bobCall.sendInviteOkAck();
+ DateTime start = DateTime.now();
+ assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
+ String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
+
+ JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
+ assertNotNull(metrics);
+ int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
+ logger.info("LiveCalls: " + liveCalls);
+ int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
+ logger.info("LiveCallsArraySize: " + liveCallsArraySize);
+ assertEquals(1, liveCalls);
+ assertEquals(1, liveCallsArraySize);
+
+ Thread.sleep(3000);
+
+ bobCall.disconnect();
+ DateTime end = DateTime.now();
+
+ Thread.sleep(500);
+
+ //Check recording
+ JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken, callSid);
+ assertNotNull(recording);
+ assertEquals(1, recording.size());
+ double recordedDuration = (end.getMillis() - start.getMillis()) / 1000;
+ double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
+ assertEquals(recordedDuration, duration, 0);
+
+ logger.info("\n\n &&&&&& About to check liveCalls &&&&&& \n");
+
+ metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
+ assertNotNull(metrics);
+ liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
+ logger.info("LiveCalls: " + liveCalls);
+ liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
+ logger.info("LiveCallsArraySize: " + liveCallsArraySize);
+ assertEquals(0, liveCalls);
+ assertEquals(0, liveCallsArraySize);
+ }
+
+ @Test
+ public synchronized void testRecordCallWithActionWithMaxRecordingReached() throws InterruptedException, ParseException {
+ stubFor(get(urlPathEqualTo("/1111"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBody(recordCallWithAction)));
+
+ stubFor(post(urlPathEqualTo("/record-action"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBody(hangupRcml)));
+
+ // Create outgoing call with first phone
+ final SipCall bobCall = bobPhone.createSipCall();
+ bobCall.initiateOutgoingCall(bobContact, dialRestcomm, null, body, "application", "sdp", null, null);
+ assertLastOperationSuccess(bobCall);
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ final int response = bobCall.getLastReceivedResponse().getStatusCode();
+ assertTrue(response == Response.TRYING || response == Response.RINGING);
+
+ if (response == Response.TRYING) {
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.RINGING, bobCall.getLastReceivedResponse().getStatusCode());
+ }
+
+ assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
+ assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
+
+ bobCall.sendInviteOkAck();
+ DateTime start = DateTime.now();
+ assertTrue(!(bobCall.getLastReceivedResponse().getStatusCode() >= 400));
+ String callSid = bobCall.getLastReceivedResponse().getMessage().getHeader("X-RestComm-CallSid").toString().split(":")[1].trim();
+
+ JsonObject metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
+ assertNotNull(metrics);
+ int liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
+ logger.info("LiveCalls: " + liveCalls);
+ int liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
+ logger.info("LiveCallsArraySize: " + liveCallsArraySize);
+ assertEquals(1, liveCalls);
+ assertEquals(1, liveCallsArraySize);
+
+ bobCall.listenForDisconnect();
+ assertTrue(bobCall.waitForDisconnect(70000));
+ assertTrue(bobCall.respondToDisconnect());
+ DateTime end = DateTime.now();
+
+ Thread.sleep(500);
+
+ //Check recording
+ JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken, callSid);
+ assertNotNull(recording);
+ assertEquals(1, recording.size());
+ double recordedDuration = (end.getMillis() - start.getMillis()) / 1000;
+ double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
+ assertEquals(recordedDuration, duration, 0);
+
+ logger.info("\n\n &&&&&& About to check liveCalls &&&&&& \n");
+
+ metrics = MonitoringServiceTool.getInstance().getMetrics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
+ assertNotNull(metrics);
+ liveCalls = metrics.getAsJsonObject("Metrics").get("LiveCalls").getAsInt();
+ logger.info("LiveCalls: " + liveCalls);
+ liveCallsArraySize = metrics.getAsJsonArray("LiveCallDetails").size();
+ logger.info("LiveCallsArraySize: " + liveCallsArraySize);
+ assertEquals(0, liveCalls);
+ assertEquals(0, liveCallsArraySize);
+ }
+
+ final String recordCallWithTimeLimit = "";
@Test
public synchronized void testRecordWithErrorOnRecordAction() throws InterruptedException, ParseException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -681,39 +712,40 @@ public synchronized void testRecordWithErrorOnRecordAction() throws InterruptedE
logger.info("LiveCallsArraySize: "+liveCallsArraySize);
assertEquals(0,liveCalls);
assertEquals(0, liveCallsArraySize);
- }
-
- @Test
- public void testGetRecordingWithOldS3Url() {
- String callSid = "CA2d3f6354e75e46b3ac76f534129ff511";
- JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(),adminAccountSid,adminAuthToken,callSid);
- assertNotNull(recording);
- assertEquals(1, recording.size());
- double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
- assertTrue(duration==3.0);
- //Since for this test the S3Accesstoll is not enabled, the file_uri will still point to the old S3 URL.
- //Check test org.restcomm.connect.testsuite.telephony.DialRecordingS3UploadTest_NoneSecurity.testGetRecordingWithOldS3Url()
- assertTrue(recording.get(0).getAsJsonObject().get("file_uri").getAsString().startsWith("https://s3.amazonaws.com"));
- }
-
- @Deployment(name = "DialRecordingTest", managed = true, testable = false)
- public static WebArchive createWebArchiveNoGw() {
- logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.delete("/WEB-INF/classes/application.conf");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm_dialrecording.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_DialRecording", "data/hsql/restcomm.script");
- archive.addAsWebInfResource("akka_application.conf", "classes/application.conf");
- logger.info("Packaged Test App");
- return archive;
- }
+}
+
+ @Test
+ public void testGetRecordingWithOldS3Url() {
+ String callSid = "CA2d3f6354e75e46b3ac76f534129ff511";
+ JsonArray recording = RestcommCallsTool.getInstance().getCallRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken, callSid);
+ assertNotNull(recording);
+ assertEquals(1, recording.size());
+ double duration = recording.get(0).getAsJsonObject().get("duration").getAsDouble();
+ assertTrue(duration == 3.0);
+ //Since for this test the S3Accesstoll is not enabled, the file_uri will still point to the old S3 URL.
+ //Check test org.restcomm.connect.testsuite.telephony.DialRecordingS3UploadTest_NoneSecurity.testGetRecordingWithOldS3Url()
+ assertTrue(recording.get(0).getAsJsonObject().get("file_uri").getAsString().startsWith("https://s3.amazonaws.com"));
+ }
+
+ @Deployment(name = "DialRecordingTest", managed = true, testable = false)
+ public static WebArchive createWebArchiveNoGw() {
+ logger.info("Packaging Test App");
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(henriquePort));
+
+ List resources = new ArrayList();
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm_dialrecording.xml",
+ "restcomm.script_DialRecording", resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialStatusCallbackTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialStatusCallbackTest.java
index 5638a08080..f1484cc4b2 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialStatusCallbackTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/DialStatusCallbackTest.java
@@ -66,10 +66,13 @@
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import java.util.ArrayList;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Dial status callback attribute. Reference: The 'statuscallback'
@@ -96,9 +99,11 @@ public class DialStatusCallbackTest {
@ArquillianResource
URL deploymentUrl;
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -107,28 +112,36 @@ public class DialStatusCallbackTest {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// Henrique is a simple SIP Client. Will not register with Restcomm
private SipStack henriqueSipStack;
private SipPhone henriquePhone;
- private String henriqueContact = "sip:henrique@127.0.0.1:5092";
+ private static String henriquePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String henriqueContact = "sip:henrique@127.0.0.1:" + henriquePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
- private String dialRestcomm = "sip:1111@127.0.0.1:5080"; // Application: dial-client-entry_wActionUrl.xml
+ private String dialRestcomm = "sip:1111@" + restcommContact; // Application: dial-client-entry_wActionUrl.xml
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
@BeforeClass
public static void beforeClass() throws Exception {
@@ -137,20 +150,30 @@ public static void beforeClass() throws Exception {
tool3 = new SipStackTool("DialActionTest3");
tool4 = new SipStackTool("DialActionTest4");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, henriqueContact);
+ henriqueSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", henriquePort, restcommContact);
+ henriquePhone = henriqueSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, henriqueContact);
- georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
+ georgeSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
}
@After
@@ -187,7 +210,7 @@ public void after() throws Exception {
Thread.sleep(4000);
}
- private String dialStatusCallback = "alice";
+ private String dialStatusCallback = "alice";
@Test
public void testDialStatusCallbackAliceDisconnects() throws ParseException, InterruptedException {
@@ -202,7 +225,7 @@ public void testDialStatusCallbackAliceDisconnects() throws ParseException, Inte
.withStatus(200)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -284,7 +307,7 @@ public void testDialStatusCallbackAliceDisconnects() throws ParseException, Inte
assertTrue(liveCallsArraySize==0);
}
- private String dialStatusCallbackGetMethod = "alice";
@Test
public void testDialStatusCallbackMethodGET() throws ParseException, InterruptedException {
@@ -300,7 +323,7 @@ public void testDialStatusCallbackMethodGET() throws ParseException, Interrupted
.withStatus(200)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -383,7 +406,7 @@ public void testDialStatusCallbackMethodGET() throws ParseException, Interrupted
assertTrue(liveCallsArraySize==0);
}
- private String dialStatusCallbackGet = "alice";
+ private String dialStatusCallbackGet = "alice";
@Test
public void testDialStatusCallbackBobDisconnects() throws ParseException, InterruptedException {
@@ -402,7 +425,7 @@ public void testDialStatusCallbackBobDisconnects() throws ParseException, Interr
.withStatus(200)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -485,7 +508,7 @@ public void testDialStatusCallbackBobDisconnects() throws ParseException, Interr
assertTrue(liveCallsArraySize==0);
}
- private String dialStatusCallbackOnlyInitiatedAndAnswer = "alice";
@Test
public void testDialStatusCallbackOnlyInitiatedAnswerEvent() throws ParseException, InterruptedException {
@@ -501,7 +524,7 @@ public void testDialStatusCallbackOnlyInitiatedAnswerEvent() throws ParseExcepti
.withStatus(200)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -575,7 +598,7 @@ public void testDialStatusCallbackOnlyInitiatedAnswerEvent() throws ParseExcepti
assertTrue(liveCallsArraySize==0);
}
- private String dialStatusCallbackOnlyRingingCompleted = "alice";
@Test
public void testDialStatusCallbackOnlyRingingCompleted() throws ParseException, InterruptedException {
@@ -591,7 +614,7 @@ public void testDialStatusCallbackOnlyRingingCompleted() throws ParseException,
.withStatus(200)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -665,7 +688,7 @@ public void testDialStatusCallbackOnlyRingingCompleted() throws ParseException,
assertTrue(liveCallsArraySize==0);
}
- private String dialStatusCallbackForSip = "sip:henrique@127.0.0.1:5092";
+ private String dialStatusCallbackForSip = "sip:henrique@127.0.0.1:" + henriquePort + "";
@Test
public void testDialStatusCallbackDialSip() throws ParseException, InterruptedException {
@@ -757,7 +780,7 @@ public void testDialStatusCallbackDialSip() throws ParseException, InterruptedEx
assertTrue(liveCallsArraySize==0);
}
- private String dialStatusCallbackForNumber = "+131313";
+ private String dialStatusCallbackForNumber = "+131313";
@Test
public void testDialStatusCallbackDialNumber() throws ParseException, InterruptedException {
@@ -849,7 +872,7 @@ public void testDialStatusCallbackDialNumber() throws ParseException, Interrupte
assertTrue(liveCallsArraySize==0);
}
- private String dialFork = "alicesip:henrique@127.0.0.1:5092+131313";
+ private String dialFork = "alicesip:henrique@127.0.0.1:" + henriquePort + "+131313";
@Test
public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAll() throws InterruptedException, ParseException, MalformedURLException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -863,7 +886,7 @@ public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAll() th
.withStatus(200)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -882,7 +905,7 @@ public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAll() th
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -997,7 +1020,7 @@ public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAll() th
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialForkStatusCallbackWithPost = "alicesip:henrique@127.0.0.1:5092+131313";
+ private String dialForkStatusCallbackWithPost = "alicesip:henrique@127.0.0.1:" + henriquePort + "+131313";
@Test
public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAllPost() throws InterruptedException, ParseException, MalformedURLException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -1011,7 +1034,7 @@ public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAllPost(
.withStatus(200)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -1030,7 +1053,7 @@ public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAllPost(
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1145,7 +1168,7 @@ public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAllPost(
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialForkWithTimeoutStatusCallbackWithPost = "alicesip:henrique@127.0.0.1:5092+131313";
+ private String dialForkWithTimeoutStatusCallbackWithPost = "alicesip:henrique@127.0.0.1:" + henriquePort + "+131313";
@Test
public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAllPostWithTimeout() throws InterruptedException, ParseException, MalformedURLException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -1159,7 +1182,7 @@ public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAllPostW
.withStatus(200)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -1178,7 +1201,7 @@ public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAllPostW
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1293,11 +1316,11 @@ public synchronized void testDialForkNoAnswerButHenriqueStatusCallbackOnAllPostW
assertTrue(MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken) == 0);
}
- private String dialForkWithActionUrl = "" +
- "+131313" +
- "sip:henrique@127.0.0.1:5092" +
- "alice";
- private String rcmlToReturn = "alice ";
+ private String dialForkWithActionUrl = "" +
+ "+131313" +
+ "sip:henrique@127.0.0.1:" + henriquePort + "" +
+ "alice";
+ private String rcmlToReturn = "alice ";
//Non regression test for https://telestax.atlassian.net/browse/RESTCOMM-585
@Test //TODO Fails when the whole test class runs but Passes when run individually
public synchronized void testDialForkNoAnswerExecuteRCML_ReturnedFromActionURLWithStatusCallbacks_BobDisconnects() throws InterruptedException, ParseException, MalformedURLException {
@@ -1319,7 +1342,7 @@ public synchronized void testDialForkNoAnswerExecuteRCML_ReturnedFromActionURLWi
.withStatus(200)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -1339,7 +1362,7 @@ public synchronized void testDialForkNoAnswerExecuteRCML_ReturnedFromActionURLWi
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1462,7 +1485,7 @@ public synchronized void testDialForkNoAnswerExecuteRCML_ReturnedFromActionURLWi
.withStatus(200)));
// Register Alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare Alice to receive call
@@ -1482,7 +1505,7 @@ public synchronized void testDialForkNoAnswerExecuteRCML_ReturnedFromActionURLWi
// Initiate a call using Bob
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
@@ -1609,21 +1632,22 @@ private Map getRequestMap(final List requestList)
@Deployment(name = "DialAction", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.delete("/WEB-INF/classes/application.conf");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialStatusCallbackTest", "data/hsql/restcomm.script");
- archive.addAsWebInfResource("akka_application.conf", "classes/application.conf");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ replacements.put("5092", String.valueOf(henriquePort));
+
+ List resources = new ArrayList();
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm.xml",
+ "restcomm.script_dialStatusCallbackTest",resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ImsClientsDialAnswerDelayTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ImsClientsDialAnswerDelayTest.java
index 6820c5abd2..3df0c9d679 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ImsClientsDialAnswerDelayTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ImsClientsDialAnswerDelayTest.java
@@ -45,9 +45,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -61,9 +59,13 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.google.gson.JsonObject;
+import java.util.Arrays;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
- * Test for clients with or without VoiceURL (Bitbucket issue 115). Clients without VoiceURL can dial anything.
+ * Test for clients with or without VoiceURL (Bitbucket issue 115). Clients
+ * without VoiceURL can dial anything.
*
* @author gvagenas
*/
@@ -74,11 +76,11 @@ public class ImsClientsDialAnswerDelayTest {
private static Logger logger = Logger.getLogger(ImsClientsDialAnswerDelayTest.class);
- private static final byte[] bytes = new byte[] { 118, 61, 48, 13, 10, 111, 61, 117, 115, 101, 114, 49, 32, 53, 51, 54, 53,
+ private static final byte[] bytes = new byte[]{118, 61, 48, 13, 10, 111, 61, 117, 115, 101, 114, 49, 32, 53, 51, 54, 53,
53, 55, 54, 53, 32, 50, 51, 53, 51, 54, 56, 55, 54, 51, 55, 32, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46,
48, 46, 49, 13, 10, 115, 61, 45, 13, 10, 99, 61, 73, 78, 32, 73, 80, 52, 32, 49, 50, 55, 46, 48, 46, 48, 46, 49,
13, 10, 116, 61, 48, 32, 48, 13, 10, 109, 61, 97, 117, 100, 105, 111, 32, 54, 48, 48, 48, 32, 82, 84, 80, 47, 65,
- 86, 80, 32, 48, 13, 10, 97, 61, 114, 116, 112, 109, 97, 112, 58, 48, 32, 80, 67, 77, 85, 47, 56, 48, 48, 48, 13, 10 };
+ 86, 80, 32, 48, 13, 10, 97, 61, 114, 116, 112, 109, 97, 112, 58, 48, 32, 80, 67, 77, 85, 47, 56, 48, 48, 48, 13, 10};
private static final String body = new String(bytes);
@ArquillianResource
@@ -86,8 +88,11 @@ public class ImsClientsDialAnswerDelayTest {
@ArquillianResource
URL deploymentUrl;
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
private static SipStackTool tool1;
private static SipStackTool tool2;
@@ -95,29 +100,35 @@ public class ImsClientsDialAnswerDelayTest {
private String pstnNumber = "+151261006100";
-
// Maria is a Restcomm Client **without** VoiceURL. This Restcomm Client can dial anything.
private SipStack augustSipStack;
private SipPhone augustPhone;
- private String augustContact = "sip:august@127.0.0.1:5092";
+ private static String augustPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String augustContact = "sip:august@127.0.0.1:" + augustPort;
private boolean isAugustRegistered = false;
private SipStack juliusSipStack;
private SipPhone juliusPhone;
- private String juliusContact = "sip:julius@127.0.0.1:5094";
+ private static String juliusPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String juliusContact = "sip:julius@127.0.0.1:" + juliusPort;
private boolean isJuliusRegistered = false;
private SipStack imsSipStack;
private SipPhone imsAugustPhone;
private SipPhone imsJuliusPhone;
- private String imsContact = "sip:127.0.0.1";
+ private static String imsPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String imsContact = "sip:127.0.0.1:" + imsPort;
private SipPhone pstnPhone;
- private String pstnContact = "sip:"+pstnNumber+"@127.0.0.1:5060";
+ private String pstnContact = "sip:" + pstnNumber + "@127.0.0.1:" + imsPort;
private String adminAccountSid = "AC27f2dd02ab51ba5d5a9ff7fc5537a09a";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+
@BeforeClass
public static void beforeClass() throws Exception {
tool1 = new SipStackTool("ImsClientsDialTest1");
@@ -127,29 +138,39 @@ public static void beforeClass() throws Exception {
Class.forName("org.hsqldb.jdbc.JDBCDriver");
}
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
+
@Before
public void before() throws Exception {
- imsSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5060", "127.0.0.1:5080");
+ imsSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", imsPort, restcommContact);
- augustSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- augustPhone = augustSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, augustContact);
- imsAugustPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, augustContact);
+ augustSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", augustPort, restcommContact);
+ augustPhone = augustSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, augustContact);
+ imsAugustPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, augustContact);
imsAugustPhone.setLoopback(true);
- juliusSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5094", "127.0.0.1:5080");
- juliusPhone = juliusSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, juliusContact);
- imsJuliusPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, juliusContact);
+ juliusSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", juliusPort, restcommContact);
+ juliusPhone = juliusSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, juliusContact);
+ imsJuliusPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, juliusContact);
imsJuliusPhone.setLoopback(true);
- pstnPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, pstnContact);
+ pstnPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, pstnContact);
- if(isAugustRegistered){
- unregisterAugust();
+ if (isAugustRegistered) {
+ unregisterAugust();
}
- if(isJuliusRegistered){
- unregisterJulius();
+ if (isJuliusRegistered) {
+ unregisterJulius();
}
}
@@ -167,10 +188,10 @@ public void after() throws Exception {
imsSipStack.dispose();
}
if (imsAugustPhone != null) {
- imsAugustPhone.dispose();
+ imsAugustPhone.dispose();
}
if (imsJuliusPhone != null) {
- imsJuliusPhone.dispose();
+ imsJuliusPhone.dispose();
}
Thread.sleep(3000);
@@ -180,23 +201,23 @@ public void after() throws Exception {
@Test
public void testRegisterClients() throws ParseException, InterruptedException, SQLException {
- logger.info("testRegisterClients");
- SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ logger.info("testRegisterClients");
+ SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, restcommContact);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@Override
public void run() {
- imsAugustPhone.listenRequestMessage();
+ imsAugustPhone.listenRequestMessage();
RequestEvent requestEvent = imsAugustPhone.waitRequest(10000);
assertNotNull(requestEvent);
try {
Response response = imsSipStack.getMessageFactory().createResponse(401, requestEvent.getRequest());
- WWWAuthenticateHeader wwwAuthenticateHeader = imsSipStack.getHeaderFactory().createWWWAuthenticateHeader("Digest realm=\"ims.tp.pl\",\n" +
- " nonce=\"b7c9036dbf357f7683f054aea940e9703dc8f84c1108\",\n" +
- " opaque=\"ALU:QbkRBthOEgEQAkgVEwwHRAIBHgkdHwQCQ1lFRkZWDhMyIXBqLCs0Zj06ZTwhdHpgZmI_\",\n" +
- " algorithm=MD5,\n" +
- " qop=\"auth\"");
+ WWWAuthenticateHeader wwwAuthenticateHeader = imsSipStack.getHeaderFactory().createWWWAuthenticateHeader("Digest realm=\"ims.tp.pl\",\n"
+ + " nonce=\"b7c9036dbf357f7683f054aea940e9703dc8f84c1108\",\n"
+ + " opaque=\"ALU:QbkRBthOEgEQAkgVEwwHRAIBHgkdHwQCQ1lFRkZWDhMyIXBqLCs0Zj06ZTwhdHpgZmI_\",\n"
+ + " algorithm=MD5,\n"
+ + " qop=\"auth\"");
response.setHeader(wwwAuthenticateHeader);
ContactHeader contactHeader = augustSipStack.getHeaderFactory().createContactHeader();
contactHeader.setAddress(augustSipStack.getAddressFactory().createAddress(imsContact));
@@ -212,7 +233,7 @@ public void run() {
} catch (ParseException e) {
e.printStackTrace();
fail(e.getMessage());
- }catch (InvalidArgumentException e) {
+ } catch (InvalidArgumentException e) {
e.printStackTrace();
fail(e.getMessage());
}
@@ -229,7 +250,7 @@ public void run() {
executorService.execute(new Runnable() {
@Override
public void run() {
- imsAugustPhone.listenRequestMessage();
+ imsAugustPhone.listenRequestMessage();
RequestEvent requestEvent = imsAugustPhone.waitRequest(10000);
assertNotNull(requestEvent);
try {
@@ -242,7 +263,7 @@ public void run() {
} catch (ParseException e) {
e.printStackTrace();
fail(e.getMessage());
- }catch (InvalidArgumentException e) {
+ } catch (InvalidArgumentException e) {
e.printStackTrace();
fail(e.getMessage());
}
@@ -261,7 +282,7 @@ public void testWebRTCClientOutgoingAdisconnect() throws ParseException, Interru
SipCall pstnCall = pstnPhone.createSipCall();
final SipCall augustCall = augustPhone.createSipCall();
- initiateAugust(pstnCall,pstnContact,augustCall);
+ initiateAugust(pstnCall, pstnContact, augustCall);
assertTrue(pstnCall.waitForIncomingCall(5 * 1000));
assertTrue(pstnCall.sendIncomingCallResponse(Response.RINGING, "RINGING-Pstn", 3600));
@@ -274,18 +295,18 @@ public void testWebRTCClientOutgoingAdisconnect() throws ParseException, Interru
null));
int responseAugust = augustCall.getLastReceivedResponse().getStatusCode();
- while(responseAugust != Response.OK){
- assertTrue(augustCall.waitOutgoingCallResponse(5 * 1000));
- responseAugust = augustCall.getLastReceivedResponse().getStatusCode();
- }
+ while (responseAugust != Response.OK) {
+ assertTrue(augustCall.waitOutgoingCallResponse(5 * 1000));
+ responseAugust = augustCall.getLastReceivedResponse().getStatusCode();
+ }
assertTrue(augustCall.sendInviteOkAck());
Thread.sleep(1000);
int liveCalls = MonitoringServiceTool.getInstance().getStatistics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
int liveCallsArraySize = MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
- assertTrue( liveCalls == 2);
- assertTrue(liveCallsArraySize == 2);
+ assertTrue(liveCalls == 2);
+ assertTrue(liveCallsArraySize == 2);
Map filters = new HashMap();
JsonObject filteredCallsByStatusObject = RestcommCallsTool.getInstance().getCallsUsingFilter(deploymentUrl.toString(),
@@ -307,8 +328,6 @@ public void testWebRTCClientOutgoingAdisconnect() throws ParseException, Interru
unregisterAugust();
}
-
-
@Test
public void testWebRTCClientOutgoingAHold() throws SipException, ParseException, InterruptedException, InvalidArgumentException {
@@ -317,7 +336,7 @@ public void testWebRTCClientOutgoingAHold() throws SipException, ParseException,
SipCall pstnCall = pstnPhone.createSipCall();
final SipCall augustCall = augustPhone.createSipCall();
- initiateAugust(pstnCall,pstnContact,augustCall);
+ initiateAugust(pstnCall, pstnContact, augustCall);
assertTrue(pstnCall.waitForIncomingCall(5 * 1000));
assertTrue(pstnCall.sendIncomingCallResponse(Response.RINGING, "RINGING-Pstn", 3600));
@@ -330,7 +349,7 @@ public void testWebRTCClientOutgoingAHold() throws SipException, ParseException,
null));
int responseAugust = augustCall.getLastReceivedResponse().getStatusCode();
- while(responseAugust != Response.OK){
+ while (responseAugust != Response.OK) {
assertTrue(augustCall.waitOutgoingCallResponse(5 * 1000));
responseAugust = augustCall.getLastReceivedResponse().getStatusCode();
}
@@ -340,8 +359,8 @@ public void testWebRTCClientOutgoingAHold() throws SipException, ParseException,
int liveCalls = MonitoringServiceTool.getInstance().getStatistics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
int liveCallsArraySize = MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
- assertTrue( liveCalls == 2);
- assertTrue(liveCallsArraySize == 2);
+ assertTrue(liveCalls == 2);
+ assertTrue(liveCallsArraySize == 2);
Map filters = new HashMap();
JsonObject filteredCallsByStatusObject = RestcommCallsTool.getInstance().getCallsUsingFilter(deploymentUrl.toString(),
@@ -400,7 +419,7 @@ public void testWebRTCClientOutgoingBHold() throws SipException, ParseException,
SipCall pstnCall = pstnPhone.createSipCall();
final SipCall augustCall = augustPhone.createSipCall();
- initiateAugust(pstnCall,pstnContact,augustCall);
+ initiateAugust(pstnCall, pstnContact, augustCall);
assertTrue(pstnCall.waitForIncomingCall(5 * 1000));
assertTrue(pstnCall.sendIncomingCallResponse(Response.RINGING, "RINGING-Pstn", 3600));
@@ -413,7 +432,7 @@ public void testWebRTCClientOutgoingBHold() throws SipException, ParseException,
null));
int responseAugust = Response.RINGING;
- while(responseAugust != Response.OK){
+ while (responseAugust != Response.OK) {
assertTrue(augustCall.waitOutgoingCallResponse(5 * 1000));
responseAugust = augustCall.getLastReceivedResponse().getStatusCode();
}
@@ -423,8 +442,8 @@ public void testWebRTCClientOutgoingBHold() throws SipException, ParseException,
int liveCalls = MonitoringServiceTool.getInstance().getStatistics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
int liveCallsArraySize = MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
- assertTrue( liveCalls == 2);
- assertTrue(liveCallsArraySize == 2);
+ assertTrue(liveCalls == 2);
+ assertTrue(liveCallsArraySize == 2);
Map filters = new HashMap();
JsonObject filteredCallsByStatusObject = RestcommCallsTool.getInstance().getCallsUsingFilter(deploymentUrl.toString(),
@@ -463,7 +482,6 @@ public void testWebRTCClientOutgoingBHold() throws SipException, ParseException,
augustMessageTx.getServerTransaction().sendResponse(augustMessageAccepted);
//HOLD - end
-
Thread.sleep(1000);
augustCall.listenForDisconnect();
assertTrue(pstnCall.disconnect());
@@ -485,12 +503,10 @@ public void testWebRTCClientIncomingADisconnect() throws InterruptedException, P
registerAugust();
-
SipCall augustCall = augustPhone.createSipCall();
SipCall pstnCall = pstnPhone.createSipCall();
initiatePstn(pstnCall, augustCall);
-
assertTrue(augustCall.waitForIncomingCall(30 * 1000));
assertTrue(augustCall.sendIncomingCallResponse(Response.RINGING, "Ringing-August", 3600));
String receivedBody = new String(augustCall.getLastReceivedRequest().getRawContent());
@@ -499,7 +515,7 @@ public void testWebRTCClientIncomingADisconnect() throws InterruptedException, P
assertTrue(augustCall.waitForAck(50 * 1000));
int responsePstn = Response.RINGING;
- while(responsePstn != Response.OK){
+ while (responsePstn != Response.OK) {
assertTrue(pstnCall.waitOutgoingCallResponse(5 * 1000));
responsePstn = pstnCall.getLastReceivedResponse().getStatusCode();
}
@@ -509,8 +525,8 @@ public void testWebRTCClientIncomingADisconnect() throws InterruptedException, P
int liveCalls = MonitoringServiceTool.getInstance().getStatistics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
int liveCallsArraySize = MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
- assertTrue( liveCalls == 2);
- assertTrue(liveCallsArraySize == 2);
+ assertTrue(liveCalls == 2);
+ assertTrue(liveCallsArraySize == 2);
Map filters = new HashMap();
JsonObject filteredCallsByStatusObject = RestcommCallsTool.getInstance().getCallsUsingFilter(deploymentUrl.toString(),
@@ -539,19 +555,16 @@ public void testWebRTCClientIncomingBusy() throws InterruptedException, ParseExc
registerAugust();
-
SipCall augustCall = augustPhone.createSipCall();
SipCall pstnCall = pstnPhone.createSipCall();
initiatePstn(pstnCall, augustCall);
-
assertTrue(augustCall.waitForIncomingCall(30 * 1000));
assertTrue(augustCall.sendIncomingCallResponse(Response.BUSY_HERE, "Busy-August", 3600));
assertTrue(augustCall.waitForAck(50 * 1000));
-
int responsePstn = Response.RINGING;
- while(responsePstn != Response.BUSY_HERE){
+ while (responsePstn != Response.BUSY_HERE) {
assertTrue(pstnCall.waitOutgoingCallResponse(5 * 1000));
responsePstn = pstnCall.getLastReceivedResponse().getStatusCode();
}
@@ -571,19 +584,16 @@ public void testWebRTCClientIncomingFail() throws InterruptedException, ParseExc
registerAugust();
-
SipCall augustCall = augustPhone.createSipCall();
SipCall pstnCall = pstnPhone.createSipCall();
initiatePstn(pstnCall, augustCall);
-
assertTrue(augustCall.waitForIncomingCall(30 * 1000));
assertTrue(augustCall.sendIncomingCallResponse(Response.SERVICE_UNAVAILABLE, "ServiceUnavailable-August", 3600));
assertTrue(augustCall.waitForAck(50 * 1000));
-
int responsePstn = Response.RINGING;
- while(responsePstn != Response.SERVICE_UNAVAILABLE){
+ while (responsePstn != Response.SERVICE_UNAVAILABLE) {
assertTrue(pstnCall.waitOutgoingCallResponse(5 * 1000));
responsePstn = pstnCall.getLastReceivedResponse().getStatusCode();
}
@@ -603,12 +613,10 @@ public void testWebRTCClientIncomingAHold() throws SipException, InterruptedExce
registerAugust();
-
SipCall augustCall = augustPhone.createSipCall();
SipCall pstnCall = pstnPhone.createSipCall();
initiatePstn(pstnCall, augustCall);
-
assertTrue(augustCall.waitForIncomingCall(30 * 1000));
assertTrue(augustCall.sendIncomingCallResponse(Response.RINGING, "Ringing-August", 3600));
String receivedBody = new String(augustCall.getLastReceivedRequest().getRawContent());
@@ -617,7 +625,7 @@ public void testWebRTCClientIncomingAHold() throws SipException, InterruptedExce
assertTrue(augustCall.waitForAck(50 * 1000));
int responsePstn = Response.RINGING;
- while(responsePstn != Response.OK){
+ while (responsePstn != Response.OK) {
assertTrue(pstnCall.waitOutgoingCallResponse(5 * 1000));
responsePstn = pstnCall.getLastReceivedResponse().getStatusCode();
}
@@ -627,8 +635,8 @@ public void testWebRTCClientIncomingAHold() throws SipException, InterruptedExce
int liveCalls = MonitoringServiceTool.getInstance().getStatistics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
int liveCallsArraySize = MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
- assertTrue( liveCalls == 2);
- assertTrue(liveCallsArraySize == 2);
+ assertTrue(liveCalls == 2);
+ assertTrue(liveCallsArraySize == 2);
Map filters = new HashMap();
JsonObject filteredCallsByStatusObject = RestcommCallsTool.getInstance().getCallsUsingFilter(deploymentUrl.toString(),
@@ -686,12 +694,10 @@ public void testWebRTCClientIncomingBHold() throws SipException, InvalidArgument
registerAugust();
-
SipCall augustCall = augustPhone.createSipCall();
SipCall pstnCall = pstnPhone.createSipCall();
initiatePstn(pstnCall, augustCall);
-
assertTrue(augustCall.waitForIncomingCall(30 * 1000));
assertTrue(augustCall.sendIncomingCallResponse(Response.RINGING, "Ringing-August", 3600));
String receivedBody = new String(augustCall.getLastReceivedRequest().getRawContent());
@@ -700,7 +706,7 @@ public void testWebRTCClientIncomingBHold() throws SipException, InvalidArgument
assertTrue(augustCall.waitForAck(50 * 1000));
int responsePstn = Response.RINGING;
- while(responsePstn != Response.OK){
+ while (responsePstn != Response.OK) {
assertTrue(pstnCall.waitOutgoingCallResponse(5 * 1000));
responsePstn = pstnCall.getLastReceivedResponse().getStatusCode();
}
@@ -710,8 +716,8 @@ public void testWebRTCClientIncomingBHold() throws SipException, InvalidArgument
int liveCalls = MonitoringServiceTool.getInstance().getStatistics(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
int liveCallsArraySize = MonitoringServiceTool.getInstance().getLiveCallsArraySize(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
- assertTrue( liveCalls == 2);
- assertTrue(liveCallsArraySize == 2);
+ assertTrue(liveCalls == 2);
+ assertTrue(liveCallsArraySize == 2);
Map filters = new HashMap();
JsonObject filteredCallsByStatusObject = RestcommCallsTool.getInstance().getCallsUsingFilter(deploymentUrl.toString(),
@@ -771,7 +777,6 @@ public void testWebRTCClientIncomingRequestTimeout() throws InterruptedException
registerAugust();
-
SipCall augustCall = augustPhone.createSipCall();
SipCall pstnCall = pstnPhone.createSipCall();
initiatePstn(pstnCall, augustCall);
@@ -789,10 +794,10 @@ public void testWebRTCClientIncomingRequestTimeout() throws InterruptedException
assertTrue(pstnCall.waitOutgoingCallResponse(5 * 1000));
assertEquals(Response.REQUEST_TIMEOUT, pstnCall.getLastReceivedResponse().getStatusCode());
- Map filters = new HashMap();
- JsonObject filteredCallsByStatusObject = RestcommCallsTool.getInstance().getCallsUsingFilter(deploymentUrl.toString(),
- adminAccountSid, adminAuthToken, filters);
- assertEquals(0, filteredCallsByStatusObject.get("calls").getAsJsonArray().size());
+ Map filters = new HashMap();
+ JsonObject filteredCallsByStatusObject = RestcommCallsTool.getInstance().getCallsUsingFilter(deploymentUrl.toString(),
+ adminAccountSid, adminAuthToken, filters);
+ assertEquals(0, filteredCallsByStatusObject.get("calls").getAsJsonArray().size());
unregisterAugust();
}
@@ -803,18 +808,15 @@ public void testWebRTCClientOutgoingBusy() throws ParseException, InterruptedExc
logger.info("testWebRTCClientOutgoingBusy");
registerAugust();
-
SipCall pstnCall = pstnPhone.createSipCall();
final SipCall augustCall = augustPhone.createSipCall();
- initiateAugust(pstnCall,pstnContact,augustCall);
-
+ initiateAugust(pstnCall, pstnContact, augustCall);
assertTrue(pstnCall.waitForIncomingCall(5 * 1000));
assertTrue(pstnCall.sendIncomingCallResponse(Response.BUSY_HERE, "Busy-Pstn", 3600));
-
int responseAugust = Response.RINGING;
- while(responseAugust != Response.BUSY_HERE){
+ while (responseAugust != Response.BUSY_HERE) {
assertTrue(augustCall.waitOutgoingCallResponse(5 * 1000));
responseAugust = augustCall.getLastReceivedResponse().getStatusCode();
}
@@ -835,18 +837,15 @@ public void testWebRTCClientOutgoingFail() throws ParseException, InterruptedExc
logger.info("testWebRTCClientOutgoingFail");
registerAugust();
-
SipCall pstnCall = pstnPhone.createSipCall();
final SipCall augustCall = augustPhone.createSipCall();
- initiateAugust(pstnCall,pstnContact,augustCall);
-
+ initiateAugust(pstnCall, pstnContact, augustCall);
assertTrue(pstnCall.waitForIncomingCall(5 * 1000));
assertTrue(pstnCall.sendIncomingCallResponse(Response.SERVICE_UNAVAILABLE, "ServiceUnavailable-Pstn", 3600));
-
int responseAugust = Response.RINGING;
- while(responseAugust != Response.SERVICE_UNAVAILABLE){
+ while (responseAugust != Response.SERVICE_UNAVAILABLE) {
assertTrue(augustCall.waitOutgoingCallResponse(5 * 1000));
responseAugust = augustCall.getLastReceivedResponse().getStatusCode();
}
@@ -873,7 +872,7 @@ public void testUnregisteredWebRTCClientOutgoing() throws ParseException, Interr
// August initiates a call to pstn
final SipCall augustCall = augustPhone.createSipCall();
- URI uri1 = augustSipStack.getAddressFactory().createURI("sip:127.0.0.1:5080");
+ URI uri1 = augustSipStack.getAddressFactory().createURI("sip:" + restcommContact);
SipURI sipURI = (SipURI) uri1;
sipURI.setLrParam();
Address address = augustSipStack.getAddressFactory().createAddress(uri1);
@@ -884,7 +883,7 @@ public void testUnregisteredWebRTCClientOutgoing() throws ParseException, Interr
Header pass = augustSipStack.getHeaderFactory().createHeader("X-RestComm-Ims-Password", "myPass");
replaceHeaders.add(user.toString());
replaceHeaders.add(pass.toString());
- augustCall.initiateOutgoingCall(augustContact, "sip:"+pstnNumber+"@127.0.0.1:5060", null, body, "application", "sdp", null, replaceHeaders);
+ augustCall.initiateOutgoingCall(augustContact, "sip:" + pstnNumber + "@127.0.0.1:5060", null, body, "application", "sdp", null, replaceHeaders);
assertLastOperationSuccess(augustCall);
assertTrue(augustCall.waitOutgoingCallResponse(5 * 1000));
@@ -926,11 +925,9 @@ public void testWebRTCClientOutgoingRequestTimeout() throws ParseException, Inte
logger.info("testWebRTCClientOutgoingRequestTimeout");
registerAugust();
-
-
SipCall pstnCall = pstnPhone.createSipCall();
final SipCall augustCall = augustPhone.createSipCall();
- initiateAugust(pstnCall,pstnContact,augustCall);
+ initiateAugust(pstnCall, pstnContact, augustCall);
assertTrue(pstnCall.waitForIncomingCall(5 * 1000));
assertTrue(pstnCall.sendIncomingCallResponse(Response.RINGING, "RINGING-pstn", 3600));
@@ -945,15 +942,15 @@ public void testWebRTCClientOutgoingRequestTimeout() throws ParseException, Inte
assertTrue(augustCall.waitOutgoingCallResponse(5 * 1000));
assertEquals(Response.REQUEST_TIMEOUT, augustCall.getLastReceivedResponse().getStatusCode());
- Map filters = new HashMap();
- JsonObject filteredCallsByStatusObject = RestcommCallsTool.getInstance().getCallsUsingFilter(deploymentUrl.toString(),
- adminAccountSid, adminAuthToken, filters);
- assertEquals(0, filteredCallsByStatusObject.get("calls").getAsJsonArray().size());
+ Map filters = new HashMap();
+ JsonObject filteredCallsByStatusObject = RestcommCallsTool.getInstance().getCallsUsingFilter(deploymentUrl.toString(),
+ adminAccountSid, adminAuthToken, filters);
+ assertEquals(0, filteredCallsByStatusObject.get("calls").getAsJsonArray().size());
unregisterAugust();
}
- private void unregisterAugust() throws InterruptedException{
+ private void unregisterAugust() throws InterruptedException {
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@Override
@@ -984,7 +981,7 @@ public void run() {
Thread.sleep(1000);
}
- private void unregisterJulius() throws InterruptedException{
+ private void unregisterJulius() throws InterruptedException {
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@Override
@@ -1015,8 +1012,8 @@ public void run() {
Thread.sleep(1000);
}
- private void registerAugust() throws ParseException, InterruptedException{
- SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ private void registerAugust() throws ParseException, InterruptedException {
+ SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, restcommContact);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@@ -1054,7 +1051,6 @@ public void run() {
private void initiateAugust(SipCall toCall, String toUri, SipCall augustCall) throws ParseException, InterruptedException {
toCall.listenForIncomingCall();
-
Thread.sleep(1000);
//Change UserAgent header to "sipunit" so CallManager
@@ -1065,7 +1061,7 @@ private void initiateAugust(SipCall toCall, String toUri, SipCall augustCall) th
replaceHeaders.add(userAgentHeader.toString());
// August initiates a call to pstn
- URI uri1 = augustSipStack.getAddressFactory().createURI("sip:127.0.0.1:5080");
+ URI uri1 = augustSipStack.getAddressFactory().createURI("sip:" + restcommContact);
SipURI sipURI = (SipURI) uri1;
sipURI.setLrParam();
Address address = augustSipStack.getAddressFactory().createAddress(uri1);
@@ -1119,43 +1115,52 @@ private void initiatePstn(SipCall pstnCall, SipCall augustCall) throws ParseExce
// Create outgoing call with pstn phone
ArrayList replaceHeaders = new ArrayList();
- URI uri1 = augustSipStack.getAddressFactory().createURI("sip:august@127.0.0.1:5080");
+ URI uri1 = augustSipStack.getAddressFactory().createURI(augustContact);
SipURI sipURI = (SipURI) uri1;
sipURI.setLrParam();
Address address = augustSipStack.getAddressFactory().createAddress(uri1);
ToHeader toHeader = augustSipStack.getHeaderFactory().createToHeader(address, null);
replaceHeaders.add(toHeader.toString());
- pstnCall.initiateOutgoingCall(pstnContact, "sip:127.0.0.1:5080", null, body, "application", "sdp", null, replaceHeaders);
+ pstnCall.initiateOutgoingCall(pstnContact, "sip:" + restcommContact, null, body, "application", "sdp", null, replaceHeaders);
assertLastOperationSuccess(pstnCall);
assertTrue(pstnCall.waitOutgoingCallResponse(5 * 1000));
int responsePstn = pstnCall.getLastReceivedResponse().getStatusCode();
assertTrue(responsePstn == Response.TRYING || responsePstn == Response.RINGING);
-
- if (responsePstn == Response.TRYING) {
- assertTrue(pstnCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.RINGING, pstnCall.getLastReceivedResponse().getStatusCode());
- }
}
@Deployment(name = "ImsClientsDialTest", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip-ims.xml", "/sip.xml");
- archive.addAsWebInfResource("restcomm-ims-delay.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_imsDialTest", "data/hsql/restcomm.script");
- archive.addAsWebResource("dial-conference-entry.xml");
- archive.addAsWebResource("dial-fork-entry.xml");
- archive.addAsWebResource("dial-uri-entry.xml");
- archive.addAsWebResource("dial-client-entry.xml");
- archive.addAsWebResource("dial-number-entry.xml");
- return archive;
+ logger.info("Packaging Test App");
+ reconfigurePorts();
+
+ Map webInfResources = new HashMap();
+ webInfResources.put("restcomm-ims-delay.xml", "conf/restcomm.xml");
+ webInfResources.put("restcomm.script_imsDialTest", "data/hsql/restcomm.script");
+ webInfResources.put("sip-ims.xml", "/sip.xml");
+ webInfResources.put("akka_application.conf", "classes/application.conf");
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5092", String.valueOf(augustPort));
+ replacements.put("5094", String.valueOf(juliusPort));
+ replacements.put("5060", String.valueOf(imsPort));
+ replacements.put("9999", String.valueOf(imsPort));
+
+
+ List resources = new ArrayList(Arrays.asList(
+ "dial-conference-entry.xml",
+ "dial-fork-entry.xml",
+ "dial-number-entry.xml",
+ "dial-client-entry.xml",
+ "dial-uri-entry.xml"
+ ));
+ return WebArchiveUtil.createWebArchiveNoGw(
+ webInfResources, resources,
+ replacements);
}
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ImsClientsDialTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ImsClientsDialTest.java
index abc7749414..f35376e6ab 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ImsClientsDialTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ImsClientsDialTest.java
@@ -51,9 +51,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -67,6 +65,9 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.google.gson.JsonObject;
+import java.util.Arrays;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for clients with or without VoiceURL (Bitbucket issue 115). Clients without VoiceURL can dial anything.
@@ -92,9 +93,12 @@ public class ImsClientsDialTest {
@ArquillianResource
URL deploymentUrl;
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -106,17 +110,20 @@ public class ImsClientsDialTest {
// Maria is a Restcomm Client **without** VoiceURL. This Restcomm Client can dial anything.
private SipStack augustSipStack;
private SipPhone augustPhone;
- private String augustContact = "sip:august@127.0.0.1:5092";
+ private static String augustPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String augustContact = "sip:august@127.0.0.1:" + augustPort;
private boolean isAugustRegistered = false;
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@bob.com:5095";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@bob.com:" + bobPort;
private boolean isBobRegistered = false;
private SipStack juliusSipStack;
private SipPhone juliusPhone;
- private String juliusContact = "sip:julius@127.0.0.1:5094";
+ private static String juliusPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String juliusContact = "sip:julius@127.0.0.1:" + juliusPort;
private boolean isJuliusRegistered = false;
private SipStack imsSipStack;
@@ -125,13 +132,18 @@ public class ImsClientsDialTest {
private SipPhone imsJuliusPhone;
private SipPhone imsBobPhone;
- private String imsContact = "sip:127.0.0.1";
+ private static String imsPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String imsContact = "sip:127.0.0.1:" + imsPort;
private SipPhone pstnPhone;
- private String pstnContact = "sip:"+pstnNumber+"@127.0.0.1:5060";
+ private String pstnContact = "sip:" + pstnNumber + "@127.0.0.1:" + imsPort;
private String adminAccountSid = "AC27f2dd02ab51ba5d5a9ff7fc5537a09a";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
@BeforeClass
public static void beforeClass() throws Exception {
@@ -142,31 +154,42 @@ public static void beforeClass() throws Exception {
Class.forName("org.hsqldb.jdbc.JDBCDriver");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
+
@Before
public void before() throws Exception {
- imsSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5060", "127.0.0.1:5080");
+ imsSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", imsPort, restcommContact);
- augustSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5092", "127.0.0.1:5080");
- augustPhone = augustSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, augustContact);
- imsAugustPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, augustContact);
+ augustSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", augustPort, restcommContact);
+ augustPhone = augustSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, augustContact);
+ imsAugustPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, augustContact);
imsAugustPhone.setLoopback(true);
- imsAugustPhone2 = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, "sip:august@ims.com");
+ imsAugustPhone2 = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, "sip:august@ims.com");
imsAugustPhone2.setLoopback(true);
- juliusSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5094", "127.0.0.1:5080");
- juliusPhone = juliusSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, juliusContact);
- imsJuliusPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, juliusContact);
+ juliusSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", juliusPort, restcommContact);
+ juliusPhone = juliusSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, juliusContact);
+ imsJuliusPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, juliusContact);
imsJuliusPhone.setLoopback(true);
- bobSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5095", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
- imsBobPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
+ imsBobPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
imsBobPhone.setLoopback(true);
- pstnPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, pstnContact);
+ pstnPhone = imsSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, pstnContact);
if(isAugustRegistered){
unregisterAugust();
@@ -224,7 +247,7 @@ public void after() throws Exception {
@Test
public void testRegisterClients() throws ParseException, InterruptedException, SQLException {
logger.info("testRegisterClients");
- SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, restcommContact);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@@ -302,7 +325,7 @@ public void run() {
@Test
public void testRegisterClientForbidden() throws ParseException, InterruptedException, SQLException {
logger.info("testRegisterClients");
- SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, restcommContact);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@@ -351,7 +374,7 @@ public void run() {
@Test
public void testReRegisterClientForbidden() throws ParseException, InterruptedException, SQLException {
logger.info("testRegisterClients");
- SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, restcommContact);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@@ -432,7 +455,7 @@ public void run() {
public void testReRegisterClientForbidden2() throws ParseException, InterruptedException, SQLException, InvalidArgumentException {
try{
logger.info("testReRegisterImsClientForbidden");
- SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, restcommContact);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@@ -471,13 +494,13 @@ public void run() {
"from_tag");
CallIdHeader callId = (CallIdHeader)augustSipStack.getHeaderFactory().createHeader("Call-ID", "12345");
CSeqHeader cseq = augustSipStack.getHeaderFactory().createCSeqHeader((long)1, "REGISTER");
- ViaHeader via = augustSipStack.getHeaderFactory().createViaHeader("127.0.0.1", 5092, "wss", "branch_12345");
+ ViaHeader via = augustSipStack.getHeaderFactory().createViaHeader("127.0.0.1", Integer.valueOf(augustPort), "wss", "branch_12345");
List vias = new ArrayList();
vias.add(via);
MaxForwardsHeader maxForwards = (MaxForwardsHeader)augustSipStack.getHeaderFactory().createHeader("Max-Forwards", "70");
Header expires = augustSipStack.getHeaderFactory().createHeader("Expires", "600");
ContactHeader contact = augustSipStack.getHeaderFactory().createContactHeader(augustSipStack.getAddressFactory().createAddress(
- augustSipStack.getAddressFactory().createSipURI(null, "august@127.0.0.1:5092")));
+ augustSipStack.getAddressFactory().createSipURI(null, "august@127.0.0.1:" + augustPort)));
Request register = augustSipStack.getMessageFactory().createRequest(uri, "REGISTER", callId, cseq, from, to, vias, maxForwards);
register.addHeader(expires);
@@ -1087,7 +1110,7 @@ public void testUnregisteredWebRTCClientOutgoing() throws ParseException, Interr
// August initiates a call to pstn
final SipCall augustCall = augustPhone.createSipCall();
- URI uri1 = augustSipStack.getAddressFactory().createURI("sip:127.0.0.1:5080");
+ URI uri1 = augustSipStack.getAddressFactory().createURI("sip:" + restcommContact);
SipURI sipURI = (SipURI) uri1;
sipURI.setLrParam();
Address address = augustSipStack.getAddressFactory().createAddress(uri1);
@@ -1274,7 +1297,7 @@ public void run() {
}
private void registerAugust() throws ParseException, InterruptedException{
- SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = augustSipStack.getAddressFactory().createSipURI(null, restcommContact);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@@ -1310,7 +1333,7 @@ public void run() {
}
private void registerBob() throws ParseException, InterruptedException{
- SipURI uri = bobSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = bobSipStack.getAddressFactory().createSipURI(null, restcommContact);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@@ -1359,7 +1382,7 @@ private void initiateAugust(SipCall toCall, String toUri, SipCall augustCall) th
replaceHeaders.add(userAgentHeader.toString());
// August initiates a call to pstn
- URI uri1 = augustSipStack.getAddressFactory().createURI("sip:127.0.0.1:5080");
+ URI uri1 = augustSipStack.getAddressFactory().createURI("sip:" + restcommContact);
SipURI sipURI = (SipURI) uri1;
sipURI.setLrParam();
Address address = augustSipStack.getAddressFactory().createAddress(uri1);
@@ -1424,7 +1447,7 @@ private void initiateBob(SipCall toCall, String toUri, SipCall bobCall) throws P
replaceHeaders.add(userAgentHeader.toString());
// Bob initiates a call to pstn
- URI uri1 = bobSipStack.getAddressFactory().createURI("sip:127.0.0.1:5080");
+ URI uri1 = bobSipStack.getAddressFactory().createURI("sip:" + restcommContact);
SipURI sipURI = (SipURI) uri1;
sipURI.setLrParam();
Address address = bobSipStack.getAddressFactory().createAddress(uri1);
@@ -1482,14 +1505,14 @@ private void initiatePstn(SipCall pstnCall, SipCall augustCall) throws ParseExce
// Create outgoing call with pstn phone
ArrayList replaceHeaders = new ArrayList();
- URI uri1 = augustSipStack.getAddressFactory().createURI("sip:august@127.0.0.1:5080");
+ URI uri1 = augustSipStack.getAddressFactory().createURI("sip:august@" + restcommContact);
SipURI sipURI = (SipURI) uri1;
sipURI.setLrParam();
Address address = augustSipStack.getAddressFactory().createAddress(uri1);
ToHeader toHeader = augustSipStack.getHeaderFactory().createToHeader(address, null);
replaceHeaders.add(toHeader.toString());
- pstnCall.initiateOutgoingCall(pstnContact, "sip:127.0.0.1:5080", null, body, "application", "sdp", null, replaceHeaders);
+ pstnCall.initiateOutgoingCall(pstnContact, "sip:" + restcommContact, null, body, "application", "sdp", null, replaceHeaders);
assertLastOperationSuccess(pstnCall);
assertTrue(pstnCall.waitOutgoingCallResponse(5 * 1000));
int responsePstn = pstnCall.getLastReceivedResponse().getStatusCode();
@@ -1500,29 +1523,41 @@ private void initiatePstn(SipCall pstnCall, SipCall augustCall) throws ParseExce
assertEquals(Response.RINGING, pstnCall.getLastReceivedResponse().getStatusCode());
}
- assertTrue(pstnCall.waitOutgoingCallResponse(5 * 1000));
- assertEquals(Response.OK, pstnCall.getLastReceivedResponse().getStatusCode());
- assertTrue(pstnCall.sendInviteOkAck());
}
@Deployment(name = "ImsClientsDialTest", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip-ims.xml", "/sip.xml");
- archive.addAsWebInfResource("restcomm-ims.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_imsDialTest", "data/hsql/restcomm.script");
- archive.addAsWebResource("dial-conference-entry.xml");
- archive.addAsWebResource("dial-fork-entry.xml");
- archive.addAsWebResource("dial-uri-entry.xml");
- archive.addAsWebResource("dial-client-entry.xml");
- archive.addAsWebResource("dial-number-entry.xml");
- return archive;
- }
+ logger.info("Packaging Test App");
+ reconfigurePorts();
+
+ Map webInfResources = new HashMap();
+ webInfResources.put("restcomm-ims.xml", "conf/restcomm.xml");
+ webInfResources.put("restcomm.script_imsDialTest", "data/hsql/restcomm.script");
+ webInfResources.put("sip-ims.xml", "/sip.xml");
+ webInfResources.put("akka_application.conf", "classes/application.conf");
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5092", String.valueOf(augustPort));
+ replacements.put("5094", String.valueOf(juliusPort));
+ replacements.put("5095", String.valueOf(bobPort));
+ replacements.put("5060", String.valueOf(imsPort));
+ replacements.put("9999", String.valueOf(imsPort));
+
+
+ List resources = new ArrayList(Arrays.asList(
+ "dial-conference-entry.xml",
+ "dial-fork-entry.xml",
+ "dial-number-entry.xml",
+ "dial-client-entry.xml",
+ "dial-uri-entry.xml"
+ ));
+ return WebArchiveUtil.createWebArchiveNoGw(
+ webInfResources, resources,
+ replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartOne.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartOne.java
index f3eb0d7da7..ade8f418f5 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartOne.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartOne.java
@@ -13,9 +13,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -34,10 +32,14 @@
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import java.util.HashMap;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Dial verb. Will test Dial Conference, Dial URI, Dial Client, Dial Number and Dial Fork
@@ -84,8 +86,14 @@ public class TestDialVerbPartOne {
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+ private String dialClientRcmlWithScreeningRelative = "alice";
+ private String dialClientRcmlWithScreening = "alice";
+
private static SipStackTool tool1;
private static SipStackTool tool2;
@@ -95,26 +103,33 @@ public class TestDialVerbPartOne {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
// Fotini is a simple SIP Client. Will not register with Restcomm
private SipStack fotiniSipStack;
private SipPhone fotiniPhone;
- private String fotiniContact = "sip:fotini@127.0.0.1";
+ private static String fotiniPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String fotiniContact = "sip:fotini@127.0.0.1:" + fotiniPort;
- private String dialRestcomm = "sip:1111@127.0.0.1:5080";
- private String notFoundDialNumber = "sip:+12223334457@127.0.0.1:5080";
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private static String dialRestcomm = "sip:1111@" + restcommContact;
+ private static String notFoundDialNumber = "sip:+12223334457@" + restcommContact;
@BeforeClass
public static void beforeClass() throws Exception {
@@ -123,20 +138,32 @@ public static void beforeClass() throws Exception {
tool3 = new SipStackTool("DialTest1Tool3");
tool4 = new SipStackTool("DialTest1Tool4");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ dialRestcomm = "sip:1111@" + restcommContact;
+ notFoundDialNumber = "sip:+12223334457@" + restcommContact;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- georgeSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
+ georgeSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
- fotiniSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5060", "127.0.0.1:5080");
- fotiniPhone = fotiniSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, fotiniContact);
+ fotiniSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", fotiniPort, restcommContact);
+ fotiniPhone = fotiniSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, fotiniContact);
}
@After
@@ -610,7 +637,7 @@ public void run() {
public synchronized void testDialApplicationInvalidURL() throws InterruptedException, ParseException {
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -630,7 +657,7 @@ public synchronized void testDialApplicationInvalidURL() throws InterruptedExcep
assertEquals(500, lastResponse.getStatusCode());
}
- private String dialUriRcml = "sip:alice@127.0.0.1:5091";
+ private String dialUriRcml = "sip:alice@127.0.0.1:" + alicePort + "";
@Test
public synchronized void testDialUriAliceHangup() throws InterruptedException, ParseException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -640,7 +667,7 @@ public synchronized void testDialUriAliceHangup() throws InterruptedException, P
.withBody(dialUriRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -708,13 +735,13 @@ public synchronized void testDialUriBobHangup() throws InterruptedException, Par
int initialCdrSize = 0;
//Check CDR
- JsonObject cdrs = RestcommCallsTool.getInstance().getCalls("http://127.0.0.1:8080/restcomm", adminAccountSid, adminAuthToken);
+ JsonObject cdrs = RestcommCallsTool.getInstance().getCalls("http://127.0.0.1:" +restcommHTTPPort + "/restcomm", adminAccountSid, adminAuthToken);
if (cdrs != null) {
initialCdrSize = cdrs.get("calls").getAsJsonArray().size();
}
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -761,7 +788,7 @@ public synchronized void testDialUriBobHangup() throws InterruptedException, Par
Thread.sleep(3000);
//Check CDR
- cdrs = RestcommCallsTool.getInstance().getCalls("http://127.0.0.1:8080/restcomm", adminAccountSid, adminAuthToken);
+ cdrs = RestcommCallsTool.getInstance().getCalls("http://127.0.0.1:" + restcommHTTPPort + "/restcomm", adminAccountSid, adminAuthToken);
assertNotNull(cdrs);
JsonArray cdrsArray = cdrs.get("calls").getAsJsonArray();
System.out.println("cdrsArray.size(): " + cdrsArray.size());
@@ -777,7 +804,7 @@ public synchronized void testDialUriBobHangupCheckCDRs() throws InterruptedExcep
.withBody(dialUriRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -849,7 +876,7 @@ public synchronized void testDialClientAlice() throws InterruptedException, Pars
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -901,7 +928,7 @@ public synchronized void testDialClientAliceNoSDP() throws InterruptedException,
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -927,7 +954,7 @@ public synchronized void testDialClientAliceNullSDP() throws InterruptedExceptio
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -944,7 +971,6 @@ public synchronized void testDialClientAliceNullSDP() throws InterruptedExceptio
}
final String screeningResponse = "";
- final String dialClientRcmlWithScreening = "alice";
@Test
public synchronized void testDialClientAliceWithScreeningAbsoluteURL() throws InterruptedException, ParseException {
@@ -962,7 +988,7 @@ public synchronized void testDialClientAliceWithScreeningAbsoluteURL() throws In
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1005,7 +1031,6 @@ public synchronized void testDialClientAliceWithScreeningAbsoluteURL() throws In
assertTrue(aliceCall.respondToDisconnect());
}
- private String dialClientRcmlWithScreeningRelative = "alice";
private String screeningRcml = "Hi bob. Someone wants to talk to you";
@Test
public synchronized void testDialClientAliceWithScreeningRelativeURL() throws InterruptedException, ParseException {
@@ -1023,7 +1048,7 @@ public synchronized void testDialClientAliceWithScreeningRelativeURL() throws In
.withBody(screeningRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1065,25 +1090,25 @@ public synchronized void testDialClientAliceWithScreeningRelativeURL() throws In
assertTrue(aliceCall.waitForDisconnect(30 * 1000));
assertTrue(aliceCall.respondToDisconnect());
}
+
+
@Deployment(name = "TestDialVerbPartOne", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.delete("/WEB-INF/classes/application.conf");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialTest_new", "data/hsql/restcomm.script");
- archive.addAsWebInfResource("akka_application.conf", "classes/application.conf");
- logger.info("Packaged Test App");
- return archive;
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm.xml", "restcomm.script_dialTest_new", replacements);
}
-}
+}
\ No newline at end of file
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartOneAnswerDelay.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartOneAnswerDelay.java
index 7e89d2f09c..f772f1a049 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartOneAnswerDelay.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartOneAnswerDelay.java
@@ -6,16 +6,12 @@
import org.apache.log4j.Logger;
import org.cafesip.sipunit.SipCall;
import org.cafesip.sipunit.SipPhone;
-import org.cafesip.sipunit.SipResponse;
import org.cafesip.sipunit.SipStack;
-import org.cafesip.sipunit.SipTransaction;
import org.jboss.arquillian.container.mss.extension.SipStackTool;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -34,10 +30,14 @@
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import java.util.HashMap;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Dial verb. Will test Dial Conference, Dial URI, Dial Client, Dial Number and Dial Fork
@@ -84,9 +84,15 @@ public class TestDialVerbPartOneAnswerDelay {
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+ private String dialClientRcmlWithScreeningRelative = "alice";
+ private String dialClientRcmlWithScreening = "alice";
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -95,26 +101,34 @@ public class TestDialVerbPartOneAnswerDelay {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
// Fotini is a simple SIP Client. Will not register with Restcomm
private SipStack fotiniSipStack;
private SipPhone fotiniPhone;
- private String fotiniContact = "sip:fotini@127.0.0.1";
+ private static String fotiniPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String fotiniContact = "sip:fotini@127.0.0.1:" + fotiniPort;
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private static String dialRestcomm = "sip:1111@" + restcommContact;
+ private static String notFoundDialNumber = "sip:+12223334457@" + restcommContact;
- private String dialRestcomm = "sip:1111@127.0.0.1:5080";
- private String notFoundDialNumber = "sip:+12223334457@127.0.0.1:5080";
@BeforeClass
public static void beforeClass() throws Exception {
@@ -123,20 +137,32 @@ public static void beforeClass() throws Exception {
tool3 = new SipStackTool("DialTest1Tool3");
tool4 = new SipStackTool("DialTest1Tool4");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ dialRestcomm = "sip:1111@" + restcommContact;
+ notFoundDialNumber = "sip:+12223334457@" + restcommContact;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- georgeSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
+ georgeSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
- fotiniSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5060", "127.0.0.1:5080");
- fotiniPhone = fotiniSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, fotiniContact);
+ fotiniSipStack = tool4.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", fotiniPort, restcommContact);
+ fotiniPhone = fotiniSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, fotiniContact);
}
@After
@@ -173,7 +199,7 @@ public void after() throws Exception {
Thread.sleep(2000);
}
- private String dialUriRcml = "sip:alice@127.0.0.1:5091";
+ private String dialUriRcml = "sip:alice@127.0.0.1:" + alicePort + "";
@Test
public synchronized void testDialUriAliceHangup() throws InterruptedException, ParseException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -183,7 +209,7 @@ public synchronized void testDialUriAliceHangup() throws InterruptedException, P
.withBody(dialUriRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -251,13 +277,13 @@ public synchronized void testDialUriBobHangup() throws InterruptedException, Par
int initialCdrSize = 0;
//Check CDR
- JsonObject cdrs = RestcommCallsTool.getInstance().getCalls("http://127.0.0.1:8080/restcomm", adminAccountSid, adminAuthToken);
+ JsonObject cdrs = RestcommCallsTool.getInstance().getCalls(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
if (cdrs != null) {
initialCdrSize = cdrs.get("calls").getAsJsonArray().size();
}
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -304,7 +330,7 @@ public synchronized void testDialUriBobHangup() throws InterruptedException, Par
Thread.sleep(3000);
//Check CDR
- cdrs = RestcommCallsTool.getInstance().getCalls("http://127.0.0.1:8080/restcomm", adminAccountSid, adminAuthToken);
+ cdrs = RestcommCallsTool.getInstance().getCalls(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
assertNotNull(cdrs);
JsonArray cdrsArray = cdrs.get("calls").getAsJsonArray();
System.out.println("cdrsArray.size(): " + cdrsArray.size());
@@ -320,7 +346,7 @@ public synchronized void testDialUriBobHangupCheckCDRs() throws InterruptedExcep
.withBody(dialUriRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -392,7 +418,7 @@ public synchronized void testDialClientAlice() throws InterruptedException, Pars
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -439,21 +465,20 @@ public synchronized void testDialClientAlice() throws InterruptedException, Pars
@Deployment(name = "TestDialVerbPartOneAnswerDelay", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.delete("/WEB-INF/classes/application.conf");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm-delay.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialTest_new", "data/hsql/restcomm.script");
- archive.addAsWebInfResource("akka_application.conf", "classes/application.conf");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm-delay.xml",
+ "restcomm.script_dialTest_new", replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartThree.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartThree.java
index 5ef1da5eaf..c6fb961c59 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartThree.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartThree.java
@@ -10,9 +10,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -37,10 +35,14 @@
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import java.util.HashMap;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Dial verb. Will test Dial Conference, Dial URI, Dial Client, Dial Number and Dial Fork
@@ -66,9 +68,24 @@ public class TestDialVerbPartThree {
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort); // No-args constructor defaults to port 8080
+ private final String recordWithActionRcml = "";
+ private final String recordWithActionRcmNullFinishOnKey = "";
+ private final String dialSipTagScreeningRcml = "\n" +
+ "\t\n" +
+ "\t sip:alice@127.0.0.1:" + alicePort + "?mycustomheader=foo&myotherheader=bar\n" +
+ "\t\n" +
+ "";
+ private final String dialSipDialScreeningRcml = "\n" +
+ "\t\n" +
+ "\t sip:alice@127.0.0.1:" + alicePort + "?mycustomheader=foo&myotherheader=bar\n" +
+ "\t\n" +
+ "";
+
private static SipStackTool tool1;
private static SipStackTool tool2;
// private static SipStackTool tool3;
@@ -77,29 +94,50 @@ public class TestDialVerbPartThree {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
-
- private String dialRestcomm = "sip:1111@127.0.0.1:5080";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
+ private final String actionUrlRcml = "sip:alice@127.0.0.1:" + alicePort + "";
+ private final String dialSipRcml = "sip:alice@127.0.0.1:" + alicePort + "?mycustomheader=foo&myotherheader=bar";
+ private final String dialSipAuthRcml = "sip:alice@127.0.0.1:" + alicePort + "?mycustomheader=foo&myotherheader=bar";
+
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private static String dialRestcomm = "sip:1111@" + restcommContact;
+
@BeforeClass
public static void beforeClass() throws Exception {
tool1 = new SipStackTool("DialTest3Tool1");
tool2 = new SipStackTool("DialTest3Tool2");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ dialRestcomm = "sip:1111@" + restcommContact;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
}
@After
@@ -123,8 +161,6 @@ public void after() throws Exception {
}
- private String recordWithActionRcml = "";
- private String actionUrlRcml = "sip:alice@127.0.0.1:5091";
//Non regression test for https://github.com/Mobicents/RestComm/issues/612
@Test
public synchronized void testRecord_ExecuteRCML_ReturnedFromActionURL() throws InterruptedException, ParseException {
@@ -186,7 +222,6 @@ public synchronized void testRecord_ExecuteRCML_ReturnedFromActionURL() throws I
assertTrue(aliceCall.respondToDisconnect());
}
- private String recordWithActionRcmNullFinishOnKey = "";
//Non regression test for https://github.com/Mobicents/RestComm/issues/612
@Test
public synchronized void testRecord_ExecuteRCML_ReturnedFromActionURLWithNullFinishOnKey() throws InterruptedException, ParseException {
@@ -294,7 +329,6 @@ public synchronized void testDialWithCustomHeaders() throws InterruptedException
assertTrue(bobCall.respondToDisconnect());
}
- private String dialSipRcml = "sip:alice@127.0.0.1:5091?mycustomheader=foo&myotherheader=bar";
@Test
// Non regression test for https://bitbucket.org/telestax/telscale-restcomm/issue/132/implement-twilio-sip-out
public synchronized void testDialSip() throws InterruptedException, ParseException {
@@ -305,7 +339,7 @@ public synchronized void testDialSip() throws InterruptedException, ParseExcepti
.withBody(dialSipRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -356,7 +390,6 @@ public synchronized void testDialSip() throws InterruptedException, ParseExcepti
}
- private String dialSipAuthRcml = "sip:alice@127.0.0.1:5091?mycustomheader=foo&myotherheader=bar";
// @Ignore
@Test
// Non regression test for https://bitbucket.org/telestax/telscale-restcomm/issue/132/implement-twilio-sip-out
@@ -369,7 +402,7 @@ public synchronized void testDialSipAuth() throws InterruptedException, ParseExc
.withBody(dialSipAuthRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -445,11 +478,6 @@ public synchronized void testDialSipAuth() throws InterruptedException, ParseExc
assertTrue(aliceCall.waitForDisconnect(30 * 1000));
}
- private String dialSipTagScreeningRcml = "\n" +
- "\t\n" +
- "\t sip:alice@127.0.0.1:5091?mycustomheader=foo&myotherheader=bar\n" +
- "\t\n" +
- "";
private String screeningRcml = "";
@Test
// Non regression test for https://bitbucket.org/telestax/telscale-restcomm/issue/132/implement-twilio-sip-out
@@ -468,7 +496,7 @@ public synchronized void testDialSipTagScreening() throws InterruptedException,
.withBody(screeningRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -523,11 +551,7 @@ public synchronized void testDialSipTagScreening() throws InterruptedException,
assertTrue(aliceCall.waitForDisconnect(30 * 1000));
}
- private String dialSipDialScreeningRcml = "\n" +
- "\t\n" +
- "\t sip:alice@127.0.0.1:5091?mycustomheader=foo&myotherheader=bar\n" +
- "\t\n" +
- "";
+
private String sipDialUrlActionRcml = "";
@Test
// Non regression test for https://bitbucket.org/telestax/telscale-restcomm/issue/132/implement-twilio-sip-out
@@ -552,7 +576,7 @@ public synchronized void testDialSipDialTagScreening() throws InterruptedExcepti
.withBody(sipDialUrlActionRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -627,7 +651,7 @@ public synchronized void testDialSipDialTagScreening180Decline() throws Interrup
.withBody(sipDialUrlActionRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -692,7 +716,7 @@ public synchronized void testDialClientAliceWithPlusSign() throws InterruptedExc
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -701,7 +725,7 @@ public synchronized void testDialClientAliceWithPlusSign() throws InterruptedExc
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:+1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:+1111@" + restcommContact + "", null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -744,7 +768,7 @@ public synchronized void testDialClientAliceWithoutPlusSign() throws Interrupted
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -753,7 +777,7 @@ public synchronized void testDialClientAliceWithoutPlusSign() throws Interrupted
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:2222@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:2222@" + restcommContact + "", null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -790,19 +814,18 @@ public synchronized void testDialClientAliceWithoutPlusSign() throws Interrupted
@Deployment(name = "TestDialVerbPartThree", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialTest_new", "data/hsql/restcomm.script");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm.xml", "restcomm.script_dialTest_new", replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartThreeAnswerDelay.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartThreeAnswerDelay.java
index aa0a3c76f2..3b11931d43 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartThreeAnswerDelay.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartThreeAnswerDelay.java
@@ -10,9 +10,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -37,10 +35,14 @@
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import java.util.HashMap;
+import java.util.Map;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Dial verb. Will test Dial Conference, Dial URI, Dial Client, Dial Number and Dial Fork
@@ -66,9 +68,17 @@ public class TestDialVerbPartThreeAnswerDelay {
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+ private String dialSipDialScreeningRcml = "\n" +
+ "\t\n" +
+ "\t sip:alice@127.0.0.1:" + alicePort + "?mycustomheader=foo&myotherheader=bar\n" +
+ "\t\n" +
+ "";
+
private static SipStackTool tool1;
private static SipStackTool tool2;
// private static SipStackTool tool3;
@@ -77,17 +87,26 @@ public class TestDialVerbPartThreeAnswerDelay {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
-
- private String dialRestcomm = "sip:1111@127.0.0.1:5080";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
+ private final String actionUrlRcml = "sip:alice@127.0.0.1:" + alicePort + "";
+ private final String dialSipRcml = "sip:alice@127.0.0.1:" + alicePort + "?mycustomheader=foo&myotherheader=bar";
+
+ private final String dialSipAuthRcml = "sip:alice@127.0.0.1:" + alicePort + "?mycustomheader=foo&myotherheader=bar";
+
- private String dialRestcomm_httpError = "sip:6666@127.0.0.1:5080";
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private static String dialRestcomm = "sip:1111@" + restcommContact;
+ private String dialRestcomm_httpError = "sip:6666@" + restcommContact;
@BeforeClass
public static void beforeClass() throws Exception {
@@ -95,13 +114,24 @@ public static void beforeClass() throws Exception {
tool2 = new SipStackTool("DialTest3Tool2");
}
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ dialRestcomm = "sip:1111@" + restcommContact;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
+
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
}
@After
@@ -124,7 +154,6 @@ public void after() throws Exception {
Thread.sleep(2000);
}
- private String dialSipRcml = "sip:alice@127.0.0.1:5091?mycustomheader=foo&myotherheader=bar";
@Test
// Non regression test for https://bitbucket.org/telestax/telscale-restcomm/issue/132/implement-twilio-sip-out
public synchronized void testDialSip() throws InterruptedException, ParseException {
@@ -135,7 +164,7 @@ public synchronized void testDialSip() throws InterruptedException, ParseExcepti
.withBody(dialSipRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -187,7 +216,6 @@ public synchronized void testDialSip() throws InterruptedException, ParseExcepti
}
- private String dialSipAuthRcml = "sip:alice@127.0.0.1:5091?mycustomheader=foo&myotherheader=bar";
// @Ignore
@Test
// Non regression test for https://bitbucket.org/telestax/telscale-restcomm/issue/132/implement-twilio-sip-out
@@ -200,7 +228,7 @@ public synchronized void testDialSipAuth() throws InterruptedException, ParseExc
.withBody(dialSipAuthRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -276,11 +304,6 @@ public synchronized void testDialSipAuth() throws InterruptedException, ParseExc
assertTrue(aliceCall.waitForDisconnect(30 * 1000));
}
- private String dialSipDialScreeningRcml = "\n" +
- "\t\n" +
- "\t sip:alice@127.0.0.1:5091?mycustomheader=foo&myotherheader=bar\n" +
- "\t\n" +
- "";
private String sipDialUrlActionRcml = "";
private String screeningRcml = "";
@Test
@@ -306,7 +329,7 @@ public synchronized void testDialSipDialTagScreening() throws InterruptedExcepti
.withBody(sipDialUrlActionRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -372,7 +395,7 @@ public synchronized void testDialSipDialTagScreening180Decline() throws Interrup
.withBody(sipDialUrlActionRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -429,7 +452,7 @@ public synchronized void testDialClientAliceWithPlusSign() throws InterruptedExc
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -438,7 +461,7 @@ public synchronized void testDialClientAliceWithPlusSign() throws InterruptedExc
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:+1111@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:+1111@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -481,7 +504,7 @@ public synchronized void testDialClientAliceWithoutPlusSign() throws Interrupted
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -490,7 +513,7 @@ public synchronized void testDialClientAliceWithoutPlusSign() throws Interrupted
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:2222@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:2222@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -612,19 +635,18 @@ public synchronized void testDialWithCustomHeadersHttpError() throws Interrupted
@Deployment(name = "TestDialVerbPartThreeAnswerDelay", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm-delay.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialTest_new", "data/hsql/restcomm.script");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm-delay.xml", "restcomm.script_dialTest_new", replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartTwo.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartTwo.java
index 4e7d5ca7da..3ddd7fce41 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartTwo.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartTwo.java
@@ -15,9 +15,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -47,10 +45,14 @@
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import java.util.ArrayList;
+import java.util.Arrays;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Dial verb. Will test Dial Conference, Dial URI, Dial Client, Dial Number and Dial Fork
@@ -76,9 +78,19 @@ public class TestDialVerbPartTwo {
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort); // No-args constructor defaults to port 8080
+ private String dialClientWithRecordingRcml = "alice";
+ private String dialConferenceWithDialActionRcml = "test";
+ private String dialClientWithRecordingRcml2 = "alice";
+ private String dialRecordWithActionRcml = "";
+ private String dialClientWithActionRcml = "alice";
+ private String dialTimeOutClientWithActionRcml = "alice";
+
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -86,21 +98,30 @@ public class TestDialVerbPartTwo {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + georgePort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
-
- private String dialRestcomm = "sip:1111@127.0.0.1:5080";
- private String dialRestcommWithStatusCallback = "sip:7777@127.0.0.1:5080";
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private static String dialRestcomm = "sip:1111@" + restcommContact;
+ private static String dialRestcommWithStatusCallback = "sip:7777@" + restcommContact;
+ private static String dialNumberNoCallerId = "131313";
+ private static String dialNumberRcml = "131313";
+
@BeforeClass
public static void beforeClass() throws Exception {
@@ -108,17 +129,31 @@ public static void beforeClass() throws Exception {
tool2 = new SipStackTool("DialTest2Tool2");
tool3 = new SipStackTool("DialTest2Tool3");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ dialRestcomm = "sip:1111@" + restcommContact;
+ dialRestcommWithStatusCallback = "sip:7777@" + restcommContact;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ dialNumberNoCallerId = "131313";
+ dialNumberRcml = "131313";
+ }
+ }
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- georgeSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
+ georgeSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
}
@After
@@ -145,8 +180,9 @@ public void after() throws Exception {
}
Thread.sleep(3000);
wireMockRule.resetRequests();
+ /* these will only work in Java8, but seems unccesary
wireMockRule.resetMappings();
- wireMockRule.resetScenarios();
+ wireMockRule.resetScenarios();*/
Thread.sleep(2000);
}
@@ -162,7 +198,7 @@ public synchronized void testDialClientAliceToBigDID() throws InterruptedExcepti
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -205,7 +241,6 @@ public synchronized void testDialClientAliceToBigDID() throws InterruptedExcepti
assertTrue(aliceCall.respondToDisconnect());
}
- private String dialClientWithRecordingRcml = "alice";
private String sendSmsActionRcml = "\n" +
"\t\t\tHello World!\n" +
"";
@@ -224,7 +259,7 @@ public synchronized void testDialClientAliceWithRecord() throws InterruptedExcep
.withBody(sendSmsActionRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -274,14 +309,12 @@ public synchronized void testDialClientAliceWithRecord() throws InterruptedExcep
Thread.sleep(5000);
- final String deploymentUrl = "http://127.0.0.1:8080/restcomm/";
- JsonArray recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl, adminAccountSid, adminAuthToken);
+ JsonArray recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
assertNotNull(recordings);
assertTrue("7.0".equalsIgnoreCase(((JsonObject)recordings.get(0)).get("duration").getAsString()));
assertNotNull(((JsonObject)recordings.get(0)).get("uri").getAsString());
}
- private String dialClientWithRecordingRcml2 = "alice";
@Test
public synchronized void testDialClientAliceWithRecord2() throws InterruptedException, ParseException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -297,7 +330,7 @@ public synchronized void testDialClientAliceWithRecord2() throws InterruptedExce
.withBody(sendSmsActionRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -349,14 +382,12 @@ public synchronized void testDialClientAliceWithRecord2() throws InterruptedExce
Thread.sleep(5000);
- final String deploymentUrl = "http://127.0.0.1:8080/restcomm/";
- JsonArray recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl, adminAccountSid, adminAuthToken);
+ JsonArray recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
assertNotNull(recordings);
assertTrue("7.0".equalsIgnoreCase(((JsonObject)recordings.get(0)).get("duration").getAsString()));
assertNotNull(((JsonObject)recordings.get(0)).get("uri").getAsString());
}
- private String dialConferenceWithDialActionRcml = "test";
@Test
public synchronized void testDialConferenceWithDialActionSms() throws InterruptedException, ParseException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -372,7 +403,7 @@ public synchronized void testDialConferenceWithDialActionSms() throws Interrupte
.withBody(sendSmsActionRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -425,7 +456,7 @@ public synchronized void testDialConferenceWithDialActionNoRcml() throws Interru
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -472,7 +503,7 @@ public synchronized void testDialConferenceNoDialAction_SendSms() throws Interru
.withBody(dialConferenceNoDialActionSendSMSRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -522,7 +553,7 @@ public synchronized void testDialConferenceNoDialAction_NoSms() throws Interrupt
.withBody(dialConferenceNoDialActionRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -576,7 +607,7 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForApp()
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -678,7 +709,7 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForAppFor
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -732,8 +763,7 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForAppFor
Thread.sleep(5000);
- final String deploymentUrl = "http://127.0.0.1:8080/restcomm/";
- JsonArray recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl, adminAccountSid, adminAuthToken);
+ JsonArray recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
assertNotNull(recordings);
int recordingsSize = recordings.size();
logger.info("Recording Size: "+recordingsSize);
@@ -792,7 +822,7 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForAppFor
Thread.sleep(3000);
- recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl, adminAccountSid, adminAuthToken);
+ recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
assertNotNull(recordings);
assertTrue(recordings.size() >= 2);
assertTrue("7.0".equalsIgnoreCase(((JsonObject)recordings.get(1)).get("duration").getAsString()));
@@ -850,7 +880,7 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForAppFor
Thread.sleep(3000);
- recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl, adminAccountSid, adminAuthToken);
+ recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
assertNotNull(recordings);
assertTrue(recordings.size() >= 3);
assertTrue("7.0".equalsIgnoreCase(((JsonObject)recordings.get(2)).get("duration").getAsString()));
@@ -879,7 +909,6 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForAppFor
// }
}
- private String dialRecordWithActionRcml = "";
@Test //Test case for github issue 859
public synchronized void testRecordWithActionAndStatusCallbackForAppWithDisconnectFromBob() throws InterruptedException, ParseException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -899,7 +928,7 @@ public synchronized void testRecordWithActionAndStatusCallbackForAppWithDisconne
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -974,7 +1003,7 @@ public synchronized void testRecordWithActionAndStatusCallbackForAppWithBobSends
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1050,7 +1079,6 @@ public synchronized void testRecordWithActionAndStatusCallbackForAppWithBobSends
assertTrue(recordActionRequests.size()==1);
}
- private String dialNumberRcml = "131313";
@Test
public synchronized void testDialNumberGeorge() throws InterruptedException, ParseException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -1091,7 +1119,7 @@ public synchronized void testDialNumberGeorge() throws InterruptedException, Par
null, null));
// the number dialed uses a callerId of "+13055872294", which is what George should receive
String contactHeader = georgeCall.getLastReceivedRequest().getMessage().getHeader("Contact").toString().replaceAll("\r\n","");
- assertTrue(contactHeader.equalsIgnoreCase("Contact: \"+13055872294\" "));
+ assertTrue(contactHeader.equalsIgnoreCase("Contact: \"+13055872294\" "));
assertTrue(georgeCall.waitForAck(50 * 1000));
Thread.sleep(3000);
@@ -1144,7 +1172,7 @@ public synchronized void testDialNumberGeorgeWithWrongScreeningUrl() throws Inte
null, null));
// the number dialed uses a callerId of "+13055872294", which is what George should receive
String contactHeader = georgeCall.getLastReceivedRequest().getMessage().getHeader("Contact").toString().replaceAll("\r\n","");
- assertTrue(contactHeader.equalsIgnoreCase("Contact: \"+13055872294\" "));
+ assertTrue(contactHeader.equalsIgnoreCase("Contact: \"+13055872294\" "));
assertTrue(georgeCall.waitForAck(50 * 1000));
//Since the Screening URL is not valid, Restcomm will disconnect call
@@ -1175,7 +1203,7 @@ public synchronized void testDialNumberGeorge_403Forbidden() throws InterruptedE
.withHeader("Content-Type", "text/xml")
.withBody(dialNumberRcml)));
-// SipURI uri = bobSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+// SipURI uri = bobSipStack.getAddressFactory().createSipURI(null, restcommContact);
// assertTrue(bobPhone.register(uri, "bob", "1234", bobContact, 3600, 3600));
//
// Credential c = new Credential("127.0.0.1", "bob", "1234");
@@ -1263,7 +1291,6 @@ public synchronized void testDialNumberGeorge_404_OnBye() throws InterruptedExce
georgeCall.disposeNoBye();
}
- final String dialNumberNoCallerId = "131313";
//Test for Issue 210: https://telestax.atlassian.net/browse/RESTCOMM-210
//Bob callerId should pass to the call created by Dial Number
@Test
@@ -1332,7 +1359,7 @@ public synchronized void testDialNumberWithPlusSign() throws InterruptedExceptio
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:+12349876543@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:+12349876543@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1370,7 +1397,7 @@ public synchronized void testDialNumberWithOUTPlusSign() throws InterruptedExcep
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:12349876543@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:12349876543@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1408,7 +1435,7 @@ public synchronized void testDialNumberNoCountryAccessCode() throws InterruptedE
// Create outgoing call with first phone
final SipCall bobCall = bobPhone.createSipCall();
- bobCall.initiateOutgoingCall(bobContact, "sip:2349876543@127.0.0.1:5080", null, body, "application", "sdp", null, null);
+ bobCall.initiateOutgoingCall(bobContact, "sip:2349876543@" + restcommContact, null, body, "application", "sdp", null, null);
assertLastOperationSuccess(bobCall);
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
final int response = bobCall.getLastReceivedResponse().getStatusCode();
@@ -1483,7 +1510,6 @@ public synchronized void testDialNumberRejectBusyRcml() throws InterruptedExcept
assertEquals(Response.BUSY_HERE, bobCall.getLastReceivedResponse().getStatusCode());
}
- private String dialClientWithActionRcml = "alice";
private String hangupActionRcml = "";
@Test // (customised from testDialClientAliceWithRecordAndStatusCallbackForApp)
@@ -1505,7 +1531,7 @@ public synchronized void testDialClientAliceWithActionAndStatusCallbackForApp()
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1558,7 +1584,6 @@ public synchronized void testDialClientAliceWithActionAndStatusCallbackForApp()
assertTrue(requests.size()==3);
}
- private String dialTimeOutClientWithActionRcml = "alice";
@Test // (customised from testDialClientAliceWithRecordAndStatusCallbackForApp)
public synchronized void testDialTimeOutClientAliceWithActionAndStatusCallbackForApp() throws InterruptedException, ParseException {
@@ -1579,7 +1604,7 @@ public synchronized void testDialTimeOutClientAliceWithActionAndStatusCallbackFo
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -1634,20 +1659,19 @@ public synchronized void testDialTimeOutClientAliceWithActionAndStatusCallbackFo
@Deployment(name = "TestDialVerbPartTwo", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialTest_new", "data/hsql/restcomm.script");
- archive.addAsWebResource("hello-play.xml");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ List resources = new ArrayList(Arrays.asList("hello-play.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm.xml", "restcomm.script_dialTest_new",resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartTwoAnswerDelay.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartTwoAnswerDelay.java
index 1fa6287cb9..6ff06f326e 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartTwoAnswerDelay.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/TestDialVerbPartTwoAnswerDelay.java
@@ -4,20 +4,16 @@
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
-import gov.nist.javax.sip.header.ContentType;
import org.apache.log4j.Logger;
import org.cafesip.sipunit.SipCall;
import org.cafesip.sipunit.SipPhone;
import org.cafesip.sipunit.SipRequest;
import org.cafesip.sipunit.SipStack;
-import org.cafesip.sipunit.SipTransaction;
import org.jboss.arquillian.container.mss.extension.SipStackTool;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -27,13 +23,10 @@
import org.restcomm.connect.commons.Version;
import org.restcomm.connect.testsuite.http.RestcommCallsTool;
-import javax.sip.Dialog;
-import javax.sip.SipException;
import javax.sip.address.SipURI;
import javax.sip.header.FromHeader;
import javax.sip.message.Request;
import javax.sip.message.Response;
-import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;
import java.util.HashMap;
@@ -47,10 +40,14 @@
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import java.util.ArrayList;
+import java.util.Arrays;
import static org.cafesip.sipunit.SipAssert.assertLastOperationSuccess;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
/**
* Test for Dial verb. Will test Dial Conference, Dial URI, Dial Client, Dial Number and Dial Fork
@@ -76,9 +73,20 @@ public class TestDialVerbPartTwoAnswerDelay {
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
+
+ private static int mockPort = NetworkPortAssigner.retrieveNextPortByFile();
@Rule
- public WireMockRule wireMockRule = new WireMockRule(8090); // No-args constructor defaults to port 8080
-
+ public WireMockRule wireMockRule = new WireMockRule(mockPort);
+ private String dialClientWithRecordingRcml = "alice";
+ private String dialConferenceWithDialActionRcml = "test";
+ private String dialClientWithRecordingRcml2 = "alice";
+ private String dialRecordWithActionRcml = "";
+ private String dialClientWithActionRcml = "alice";
+ private String dialTimeOutClientWithActionRcml = "alice";
+
+
+
private static SipStackTool tool1;
private static SipStackTool tool2;
private static SipStackTool tool3;
@@ -86,22 +94,30 @@ public class TestDialVerbPartTwoAnswerDelay {
// Bob is a simple SIP Client. Will not register with Restcomm
private SipStack bobSipStack;
private SipPhone bobPhone;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + georgePort;
// Alice is a Restcomm Client with VoiceURL. This Restcomm Client can register with Restcomm and whatever will dial the RCML
// of the VoiceURL will be executed.
private SipStack aliceSipStack;
private SipPhone alicePhone;
- private String aliceContact = "sip:alice@127.0.0.1:5091";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort;
// George is a simple SIP Client. Will not register with Restcomm
private SipStack georgeSipStack;
private SipPhone georgePhone;
- private String georgeContact = "sip:+131313@127.0.0.1:5070";
-
- private String dialRestcomm = "sip:1111@127.0.0.1:5080";
- private String dialRestcommWithStatusCallback = "sip:7777@127.0.0.1:5080";
-
+ private static String georgePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String georgeContact = "sip:+131313@127.0.0.1:" + georgePort;
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
+ private static String dialRestcomm = "sip:1111@" + restcommContact;
+ private static String dialRestcommWithStatusCallback = "sip:7777@" + restcommContact;
+ private static String dialNumberNoCallerId = "131313";
+ private static String dialNumberRcml = "131313";
+
@BeforeClass
public static void beforeClass() throws Exception {
tool1 = new SipStackTool("DialTest2Tool1");
@@ -109,16 +125,30 @@ public static void beforeClass() throws Exception {
tool3 = new SipStackTool("DialTest2Tool3");
}
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ dialRestcomm = "sip:1111@" + restcommContact;
+ dialRestcommWithStatusCallback = "sip:7777@" + restcommContact;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ dialNumberNoCallerId = "131313";
+ dialNumberRcml = "131313";
+ }
+ }
+
@Before
public void before() throws Exception {
- bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ bobSipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ bobPhone = bobSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5091", "127.0.0.1:5080");
- alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ aliceSipStack = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ alicePhone = aliceSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- georgeSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, georgeContact);
+ georgeSipStack = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", georgePort, restcommContact);
+ georgePhone = georgeSipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, georgeContact);
}
@After
@@ -159,7 +189,7 @@ public synchronized void testDialClientAliceToBigDID() throws InterruptedExcepti
.withBody(dialClientRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -202,7 +232,6 @@ public synchronized void testDialClientAliceToBigDID() throws InterruptedExcepti
assertTrue(aliceCall.respondToDisconnect());
}
- private String dialClientWithRecordingRcml = "alice";
private String sendSmsActionRcml = "\n" +
"\t\t\tHello World!\n" +
"";
@@ -221,7 +250,7 @@ public synchronized void testDialClientAliceWithRecord() throws InterruptedExcep
.withBody(sendSmsActionRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -271,14 +300,12 @@ public synchronized void testDialClientAliceWithRecord() throws InterruptedExcep
Thread.sleep(5000);
- final String deploymentUrl = "http://127.0.0.1:8080/restcomm/";
- JsonArray recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl, adminAccountSid, adminAuthToken);
+ JsonArray recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
assertNotNull(recordings);
assertTrue("7.0".equalsIgnoreCase(((JsonObject)recordings.get(0)).get("duration").getAsString()));
assertNotNull(((JsonObject)recordings.get(0)).get("uri").getAsString());
}
- private String dialClientWithRecordingRcml2 = "alice";
@Test
public synchronized void testDialClientAliceWithRecord2() throws InterruptedException, ParseException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -294,7 +321,7 @@ public synchronized void testDialClientAliceWithRecord2() throws InterruptedExce
.withBody(sendSmsActionRcml)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -346,8 +373,7 @@ public synchronized void testDialClientAliceWithRecord2() throws InterruptedExce
Thread.sleep(5000);
- final String deploymentUrl = "http://127.0.0.1:8080/restcomm/";
- JsonArray recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl, adminAccountSid, adminAuthToken);
+ JsonArray recordings = RestcommCallsTool.getInstance().getRecordings(deploymentUrl.toString(), adminAccountSid, adminAuthToken);
assertNotNull(recordings);
assertTrue("7.0".equalsIgnoreCase(((JsonObject)recordings.get(0)).get("duration").getAsString()));
assertNotNull(((JsonObject)recordings.get(0)).get("uri").getAsString());
@@ -372,7 +398,7 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForApp()
.withStatus(200)));
// Phone2 register as alice
- SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = aliceSipStack.getAddressFactory().createSipURI(null, restcommContact);
assertTrue(alicePhone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
// Prepare second phone to receive call
@@ -455,7 +481,6 @@ public synchronized void testDialClientAliceWithRecordAndStatusCallbackForApp()
// }
}
- private String dialNumberRcml = "131313";
@Test
public synchronized void testDialNumberGeorge() throws InterruptedException, ParseException {
stubFor(get(urlPathEqualTo("/1111"))
@@ -490,7 +515,7 @@ public synchronized void testDialNumberGeorge() throws InterruptedException, Par
null, null));
// the number dialed uses a callerId of "+13055872294", which is what George should receive
String contactHeader = georgeCall.getLastReceivedRequest().getMessage().getHeader("Contact").toString().replaceAll("\r\n","");
- assertTrue(contactHeader.equalsIgnoreCase("Contact: \"+13055872294\" "));
+ assertTrue(contactHeader.equalsIgnoreCase("Contact: \"+13055872294\" "));
assertTrue(bobCall.waitOutgoingCallResponse(5 * 1000));
assertEquals(Response.OK, bobCall.getLastReceivedResponse().getStatusCode());
@@ -517,7 +542,7 @@ public synchronized void testDialNumberGeorge_403Forbidden() throws InterruptedE
.withHeader("Content-Type", "text/xml")
.withBody(dialNumberRcml)));
-// SipURI uri = bobSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+// SipURI uri = bobSipStack.getAddressFactory().createSipURI(null, restcommContact);
// assertTrue(bobPhone.register(uri, "bob", "1234", bobContact, 3600, 3600));
//
// Credential c = new Credential("127.0.0.1", "bob", "1234");
@@ -598,7 +623,6 @@ public synchronized void testDialNumberGeorge_404_OnBye() throws InterruptedExce
georgeCall.disposeNoBye();
}
- final String dialNumberNoCallerId = "131313";
//Test for Issue 210: https://telestax.atlassian.net/browse/RESTCOMM-210
//Bob callerId should pass to the call created by Dial Number
@Test
@@ -654,20 +678,19 @@ public synchronized void testDialNumberGeorgePassInitialCallerId() throws Interr
@Deployment(name = "TestDialVerbPartTwo", managed = true, testable = false)
public static WebArchive createWebArchiveNoGw() {
logger.info("Packaging Test App");
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm-delay.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_dialTest_new", "data/hsql/restcomm.script");
- archive.addAsWebResource("hello-play.xml");
- logger.info("Packaged Test App");
- return archive;
- }
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("8090", String.valueOf(mockPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(georgePort));
+ replacements.put("5090", String.valueOf(bobPort));
+ replacements.put("5091", String.valueOf(alicePort));
+ List resources = new ArrayList(Arrays.asList("hello-play.xml"));
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm-delay.xml", "restcomm.script_dialTest_new",resources, replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ua/UserAgentManagerTest.java b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ua/UserAgentManagerTest.java
index ba9cc9a74c..60f703500c 100644
--- a/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ua/UserAgentManagerTest.java
+++ b/restcomm/restcomm.testsuite/src/test/java/org/restcomm/connect/testsuite/telephony/ua/UserAgentManagerTest.java
@@ -30,13 +30,10 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.ShrinkWrapMaven;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.restcomm.connect.commons.Version;
@@ -44,19 +41,21 @@
import javax.sip.InvalidArgumentException;
import javax.sip.RequestEvent;
-import javax.sip.address.Address;
import javax.sip.address.SipURI;
import javax.sip.header.Header;
-import javax.sip.header.ToHeader;
import javax.sip.message.Response;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import java.util.logging.Logger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.restcomm.connect.testsuite.NetworkPortAssigner;
+import org.restcomm.connect.testsuite.WebArchiveUtil;
//import org.restcomm.connect.telephony.Version;
/**
@@ -76,41 +75,55 @@ public final class UserAgentManagerTest {
private String adminAccountSid = "ACae6e420f425248d6a26948c17a9e2acf";
private String adminAuthToken = "77f8c12cc7b8f8423e5c38b035249166";
+
+ private static int mediaPort = NetworkPortAssigner.retrieveNextPortByFile();
private static SipStackTool tool1;
private SipStack sipStack;
private SipPhone phone;
- private String aliceContact = "sip:alice@127.0.0.1:5070;transport=udp";
+ private static String alicePort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact = "sip:alice@127.0.0.1:" + alicePort + ";transport=udp";
private static SipStackTool tool2;
private SipStack sipStack2;
private SipPhone phone2;
- private String bobContact = "sip:bob@127.0.0.1:5090";
+ private static String bobPort = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String bobContact = "sip:bob@127.0.0.1:" + bobPort;
private static SipStackTool tool3;
private SipStack sipStack3;
private SipPhone phone3;
- private String aliceContact3 = "sip:alice@127.0.0.1:5071;transport=udp;rc-id=7616";
+ private static String alicePort3 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact3 = "sip:alice@127.0.0.1:" + alicePort3 + ";transport=udp;rc-id=7616";
private static SipStackTool tool4;
private SipStack sipStack4;
private SipPhone phone4;
- private String aliceContact4 = "sip:alice@127.0.0.1:5072";
+ private static String alicePort4 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact4 = "sip:alice@127.0.0.1:" + alicePort4;
+
private static SipStackTool tool5;
private SipStack sipStack5;
private SipPhone phone5;
- private String mariaContact5 = "sip:maria.test%40telestax.com@127.0.0.1:5072";
+ private static String mariaPort5 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String mariaContact5 = "sip:maria.test%40telestax.com@127.0.0.1:" + mariaPort5;
private static SipStackTool tool6;
private SipStack sipStack6;
private SipPhone phone6;
- private String aliceContact6 = "sip:alice@testdomain2.restcomm.com";
+ private static String alicePort6 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact6 = "sip:alice@testdomain2.restcomm.com:" + alicePort6;
private static SipStackTool tool7;
private SipStack sipStack7;
private SipPhone phone7;
- private String aliceContact7 = "sip:alice@127.0.0.1:5075";
+ private static String alicePort7 = String.valueOf(NetworkPortAssigner.retrieveNextPortByFile());
+ private String aliceContact7 = "sip:alice@127.0.0.1:" + alicePort7;
+
+ private static int restcommPort = 5080;
+ private static int restcommHTTPPort = 8080;
+ private static String restcommContact = "127.0.0.1:" + restcommPort;
public UserAgentManagerTest() {
super();
@@ -126,29 +139,39 @@ public static void beforeClass() throws Exception {
tool6 = new SipStackTool("UserAgentTest6");
tool7 = new SipStackTool("UserAgentTest7");
}
+
+ public static void reconfigurePorts() {
+ if (System.getProperty("arquillian_sip_port") != null) {
+ restcommPort = Integer.valueOf(System.getProperty("arquillian_sip_port"));
+ restcommContact = "127.0.0.1:" + restcommPort;
+ }
+ if (System.getProperty("arquillian_http_port") != null) {
+ restcommHTTPPort = Integer.valueOf(System.getProperty("arquillian_http_port"));
+ }
+ }
@Before
public void before() throws Exception {
- sipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5070", "127.0.0.1:5080");
- phone = sipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact);
+ sipStack = tool1.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort, restcommContact);
+ phone = sipStack.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact);
- sipStack2 = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5090", "127.0.0.1:5080");
- phone2 = sipStack2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, bobContact);
+ sipStack2 = tool2.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", bobPort, restcommContact);
+ phone2 = sipStack2.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, bobContact);
- sipStack3 = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", "5071", "127.0.0.1:5080");
- phone3 = sipStack3.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, 5080, aliceContact3);
+ sipStack3 = tool3.initializeSipStack(SipStack.PROTOCOL_UDP, "127.0.0.1", alicePort3, restcommContact);
+ phone3 = sipStack3.createSipPhone("127.0.0.1", SipStack.PROTOCOL_UDP, restcommPort, aliceContact3);
- sipStack4 = tool4.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", "5072", "127.0.0.1:5080");
- phone4 = sipStack4.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, 5080, aliceContact4);
+ sipStack4 = tool4.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", alicePort4, restcommContact);
+ phone4 = sipStack4.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, restcommPort, aliceContact4);
- sipStack5 = tool5.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", "5073", "127.0.0.1:5080");
- phone5 = sipStack5.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, 5080, mariaContact5);
+ sipStack5 = tool5.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", mariaPort5, restcommContact);
+ phone5 = sipStack5.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, restcommPort, mariaContact5);
- sipStack6 = tool6.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", "5074", "127.0.0.1:5080");
- phone6 = sipStack6.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, 5080, aliceContact6);
+ sipStack6 = tool6.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", alicePort6, restcommContact);
+ phone6 = sipStack6.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, restcommPort, aliceContact6);
- sipStack7 = tool7.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", "5075", "127.0.0.1:5080");
- phone7 = sipStack7.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, 5080, aliceContact7);
+ sipStack7 = tool7.initializeSipStack(SipStack.PROTOCOL_TCP, "127.0.0.1", alicePort7, restcommContact);
+ phone7 = sipStack7.createSipPhone("127.0.0.1", SipStack.PROTOCOL_TCP, restcommPort, aliceContact7);
}
@After
@@ -185,40 +208,40 @@ public void after() throws Exception {
@Test
public void registerUserAgent() throws Exception {
- SipURI uri = sipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","alice", "1234");
phone.addUpdateCredential(c);
- assertTrue(phone.register(uri, "alice", "1234", "sip:127.0.0.1:5070", 3600, 3600));
+ assertTrue(phone.register(uri, "alice", "1234", "sip:127.0.0.1:" + alicePort, 3600, 3600));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==1);
- assertTrue(phone.unregister("sip:127.0.0.1:5070", 0));
+ assertTrue(phone.unregister("sip:127.0.0.1:" + alicePort, 0));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==0);
}
@Test
public void registerUserAgentWithTransport() throws Exception {
- SipURI uri = sipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","alice", "1234");
phone.addUpdateCredential(c);
- assertTrue(phone.register(uri, "alice", "1234", "sip:127.0.0.1:5070;transport=udp", 3600, 3600));
+ assertTrue(phone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==1);
- assertTrue(phone.unregister("sip:127.0.0.1:5070;transport=udp", 0));
+ assertTrue(phone.unregister(aliceContact, 0));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==0);
}
@Test
public void registerUserAgentWithSecureTransport() throws Exception {
- SipURI uri = sipStack4.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack4.getAddressFactory().createSipURI(null, restcommContact);
uri.setSecure(true);
Credential c = new Credential("127.0.0.1","alice", "1234");
phone4.addUpdateCredential(c);
- assertTrue(phone4.register(uri, "alice", "1234", "sip:127.0.0.1:5072", 3600, 3600));
+ assertTrue(phone4.register(uri, "alice", "1234", aliceContact4, 3600, 3600));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==1);
- assertTrue(phone4.unregister("sip:127.0.0.1:5072", 0));
+ assertTrue(phone4.unregister(aliceContact4, 0));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==0);
}
@@ -226,16 +249,16 @@ public void registerUserAgentWithSecureTransport() throws Exception {
@Test
public void registerUserAgentWithReRegister() throws Exception {
// deployer.deploy("UserAgentTest");
- SipURI uri = sipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","alice", "1234");
phone.addUpdateCredential(c);
- assertTrue(phone.register(uri, "alice", "1234", "sip:127.0.0.1:5070", 3600, 3600));
+ assertTrue(phone.register(uri, "alice", "1234", "sip:127.0.0.1:" + alicePort, 3600, 3600));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==1);
- assertTrue(phone.register(uri, "alice", "1234", "sip:127.0.0.1:5070", 3600, 3600));
+ assertTrue(phone.register(uri, "alice", "1234", "sip:127.0.0.1:" + alicePort, 3600, 3600));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==1);
- assertTrue(phone.unregister("sip:127.0.0.1:5070", 0));
+ assertTrue(phone.unregister("sip:127.0.0.1:" + alicePort, 0));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==0);
}
@@ -244,10 +267,10 @@ public void registerUserAgentWithReRegister() throws Exception {
public void registerUserAgentWithOptionsPing() throws ParseException, InterruptedException {
// deployer.deploy("UserAgentTest");
// Register the phone so we can get OPTIONS pings from RestComm.
- SipURI uri = sipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","alice", "1234");
phone.addUpdateCredential(c);
- assertTrue(phone.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5070;transport=udp", 3600, 3600));
+ assertTrue(phone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==1);
// This is necessary for SipUnit to accept unsolicited requests.
@@ -261,17 +284,17 @@ public void registerUserAgentWithOptionsPing() throws ParseException, Interrupte
phone.sendReply(requestEvent, response);
Thread.sleep(1000);
// Clean up (Unregister).
- assertTrue(phone.unregister("sip:127.0.0.1:5070;transport=udp", 0));
+ assertTrue(phone.unregister(aliceContact, 0));
}
@Test
public void registerUserAgentWithExtraParamsAndOptionsPing() throws ParseException, InterruptedException {
// deployer.deploy("UserAgentTest");
// Register the phone so we can get OPTIONS pings from RestComm.
- SipURI uri = sipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","alice", "1234");
phone.addUpdateCredential(c);
- assertTrue(phone.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5070;transport=udp;rc-id=7616", 3600, 3600));
+ assertTrue(phone.register(uri, "alice", "1234", "sip:alice@127.0.0.1:" + alicePort + ";transport=udp;rc-id=7616", 3600, 3600));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==1);
// This is necessary for SipUnit to accept unsolicited requests.
@@ -287,17 +310,17 @@ public void registerUserAgentWithExtraParamsAndOptionsPing() throws ParseExcepti
phone.sendReply(requestEvent, response);
Thread.sleep(1000);
// Clean up (Unregister).
- assertTrue(phone.unregister("sip:127.0.0.1:5070;transport=udp", 0));
+ assertTrue(phone.unregister(aliceContact, 0));
}
@Test
public void registerUserAgentWithExceptionOnOptionsPing() throws ParseException, InterruptedException {
// deployer.deploy("UserAgentTest");
// Register the phone so we can get OPTIONS pings from RestComm.
- SipURI uri = sipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","alice", "1234");
phone.addUpdateCredential(c);
- assertTrue(phone.register(uri, "alice", "1234", "sip:127.0.0.1:5070;transport=udp", 3600, 3600));
+ assertTrue(phone.register(uri, "alice", "1234", aliceContact, 3600, 3600));
Thread.sleep(500);
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==1);
@@ -314,7 +337,7 @@ public void registerUserAgentWithExceptionOnOptionsPing() throws ParseException,
public void registerUserAgentWith503ErrorResponse() throws ParseException, InterruptedException, InvalidArgumentException {
// deployer.deploy("UserAgentTest");
// Register the phone so we can get OPTIONS pings from RestComm.
- SipURI uri = sipStack2.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack2.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","bob", "1234");
phone2.addUpdateCredential(c);
assertTrue(phone2.register(uri, "bob", "1234", bobContact, 3600, 3600));
@@ -343,7 +366,7 @@ public void registerUserAgentWith503ErrorResponse() throws ParseException, Inter
public void registerUserAgentWithExtraParamsAnd503ToOptionsPing() throws ParseException, InterruptedException, InvalidArgumentException {
// deployer.deploy("UserAgentTest");
// Register the phone so we can get OPTIONS pings from RestComm.
- SipURI uri = sipStack3.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack3.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","alice", "1234");
phone3.addUpdateCredential(c);
@@ -380,7 +403,7 @@ public void registerUserAgentWithExtraParamsAnd503ToOptionsPing() throws ParseEx
public void registerUserAgentWithExtraParamsAnd503ToOptionsPingNoTransport() throws ParseException, InterruptedException, InvalidArgumentException {
// deployer.deploy("UserAgentTest");
// Register the phone so we can get OPTIONS pings from RestComm.
- SipURI uri = sipStack3.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack3.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","alice", "1234");
phone3.addUpdateCredential(c);
@@ -401,7 +424,7 @@ public void registerUserAgentWithExtraParamsAnd503ToOptionsPingNoTransport() thr
additionalHeader.add(reason);
ArrayList replaceHeaders = new ArrayList();
//The To Header will not contain the transport
- Header toHeader = sipStack3.getHeaderFactory().createToHeader(sipStack3.getAddressFactory().createAddress("sip:alice@127.0.0.1:5071;rc-id=7616"), null);
+ Header toHeader = sipStack3.getHeaderFactory().createToHeader(sipStack3.getAddressFactory().createAddress("sip:alice@127.0.0.1:" + alicePort3 + ";rc-id=7616"), null);
replaceHeaders.add(toHeader);
phone3.sendReply(requestEvent, 503, "Service unavailable", null, null, 3600, additionalHeader, replaceHeaders, null);
@@ -418,7 +441,7 @@ public void registerUserAgentWithExtraParamsAnd503ToOptionsPingNoTransport() thr
public void registerUserAgentWithExtraParamsAnd408ToOptionsPing() throws ParseException, InterruptedException, InvalidArgumentException {
// deployer.deploy("UserAgentTest");
// Register the phone so we can get OPTIONS pings from RestComm.
- SipURI uri = sipStack3.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack3.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","alice", "1234");
phone3.addUpdateCredential(c);
@@ -455,7 +478,7 @@ public void registerUserAgentWithExtraParamsAnd408ToOptionsPing() throws ParseEx
public void registerUserAgentWith408ErrorResponse() throws ParseException, InterruptedException, InvalidArgumentException {
// deployer.deploy("UserAgentTest");
// Register the phone so we can get OPTIONS pings from RestComm.
- SipURI uri = sipStack2.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack2.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","bob", "1234");
phone2.addUpdateCredential(c);
assertTrue(phone2.register(uri, "bob", "1234", bobContact, 3600, 3600));
@@ -490,7 +513,7 @@ public void registerUserAgentWith408ErrorResponse() throws ParseException, Inter
*/
@Test
public void registerUserAgentWithAtTheRateSignInLogin() throws ParseException, InterruptedException, InvalidArgumentException {
- SipURI uri = sipStack5.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack5.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("127.0.0.1","maria.test@telestax.com", "1234");
phone5.addUpdateCredential(c);
assertTrue(phone5.register(uri, "maria.test@telestax.com", "1234", mariaContact5, 3600, 3600));
@@ -519,19 +542,19 @@ public void registerUserAgentWithAtTheRateSignInLogin() throws ParseException, I
public void registerMultipleUsersWithSameLoginUnderDifferentOrganizations() throws ParseException, InterruptedException, InvalidArgumentException {
//register alice of organization (testdomain2.restcomm.com)
- SipURI uri = sipStack6.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ SipURI uri = sipStack6.getAddressFactory().createSipURI(null, restcommContact);
Credential c = new Credential("testdomain2.restcomm.com","alice", "1234");
phone6.addUpdateCredential(c);
- assertTrue(phone6.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5074", 3600, 3600));
+ assertTrue(phone6.register(uri, "alice", "1234", aliceContact6, 3600, 3600));
Thread.sleep(500);
//alice should be registered successfully
assertTrue(MonitoringServiceTool.getInstance().getRegisteredUsers(deploymentUrl.toString(),adminAccountSid, adminAuthToken)==1);
//register another alice of organization (127.0.0.1)
- uri = sipStack7.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
+ uri = sipStack7.getAddressFactory().createSipURI(null, restcommContact);
c = new Credential("127.0.0.1","alice", "1234");
phone7.addUpdateCredential(c);
- assertTrue(phone7.register(uri, "alice", "1234", "sip:alice@127.0.0.1:5075", 3600, 3600));
+ assertTrue(phone7.register(uri, "alice", "1234", aliceContact7, 3600, 3600));
Thread.sleep(500);
//both users should be registered successfully
@@ -551,20 +574,27 @@ public void registerMultipleUsersWithSameLoginUnderDifferentOrganizations() thro
}
@Deployment(name = "UserAgentTest", managed = true, testable = false)
- public static WebArchive createWebArchive() {
- WebArchive archive = ShrinkWrap.create(WebArchive.class, "restcomm.war");
- final WebArchive restcommArchive = ShrinkWrapMaven.resolver()
- .resolve("org.restcomm:restcomm-connect.application:war:" + version).withoutTransitivity()
- .asSingle(WebArchive.class);
- archive = archive.merge(restcommArchive);
- archive.delete("/WEB-INF/sip.xml");
- archive.delete("/WEB-INF/conf/restcomm.xml");
- archive.delete("/WEB-INF/data/hsql/restcomm.script");
- archive.delete("/WEB-INF/classes/application.conf");
- archive.addAsWebInfResource("sip.xml");
- archive.addAsWebInfResource("restcomm_UserAgentManagerTest.xml", "conf/restcomm.xml");
- archive.addAsWebInfResource("restcomm.script_UserAgentTest", "data/hsql/restcomm.script");
- archive.addAsWebInfResource("akka_application.conf", "classes/application.conf");
- return archive;
- }
+ public static WebArchive createWebArchiveNoGw() {
+ logger.info("Packaging Test App");
+ reconfigurePorts();
+
+ Map replacements = new HashMap();
+ //replace mediaport 2727
+ replacements.put("2727", String.valueOf(mediaPort));
+ replacements.put("8080", String.valueOf(restcommHTTPPort));
+ replacements.put("5080", String.valueOf(restcommPort));
+ replacements.put("5070", String.valueOf(alicePort));
+ replacements.put("5071", String.valueOf(alicePort3));
+ replacements.put("5072", String.valueOf(alicePort4));
+ replacements.put("5073", String.valueOf(mariaPort5));
+ replacements.put("5074", String.valueOf(alicePort6));
+ replacements.put("5075", String.valueOf(alicePort7));
+
+ replacements.put("5090", String.valueOf(bobPort));
+
+
+ return WebArchiveUtil.createWebArchiveNoGw("restcomm_UserAgentManagerTest.xml",
+ "restcomm.script_UserAgentTest",
+ replacements);
+ }
}
diff --git a/restcomm/restcomm.testsuite/src/test/resources/arquillian.xml b/restcomm/restcomm.testsuite/src/test/resources/arquillian.xml
index d9e0064dfa..f05b229236 100644
--- a/restcomm/restcomm.testsuite/src/test/resources/arquillian.xml
+++ b/restcomm/restcomm.testsuite/src/test/resources/arquillian.xml
@@ -14,4 +14,15 @@
org.mobicents.servlet.sip.router.DefaultApplicationRouterProvider
+
+
+ target/${arquillian_sip_port}-mss-tomcat-embedded-7
+ work
+ ${arquillian_http_port}
+ true
+ :${arquillian_sip_port},:${arquillian_sip_port}/TCP
+ 127.0.0.1
+ org.mobicents.servlet.sip.router.DefaultApplicationRouterProvider
+
+
diff --git a/restcomm/restcomm.testsuite/src/test/resources/log4j.xml b/restcomm/restcomm.testsuite/src/test/resources/log4j.xml
index aaa7a0654e..2458ae96f8 100644
--- a/restcomm/restcomm.testsuite/src/test/resources/log4j.xml
+++ b/restcomm/restcomm.testsuite/src/test/resources/log4j.xml
@@ -3,8 +3,10 @@
-
-
+
+
+
+
@@ -12,18 +14,13 @@
-
-
-
-
-
-
+
-
diff --git a/restcomm/restcomm.testsuite/src/test/resources/restcomm-ims-delay.xml b/restcomm/restcomm.testsuite/src/test/resources/restcomm-ims-delay.xml
index 5b8c478595..31c2343b6f 100644
--- a/restcomm/restcomm.testsuite/src/test/resources/restcomm-ims-delay.xml
+++ b/restcomm/restcomm.testsuite/src/test/resources/restcomm-ims-delay.xml
@@ -56,7 +56,7 @@
true
127.0.0.1
127.0.0.1
- 0
+ 9999
WebRTCGW__1@
WebRTCGW/1.0
ims
diff --git a/restcomm/restcomm.testsuite/src/test/resources/restcomm-ims.xml b/restcomm/restcomm.testsuite/src/test/resources/restcomm-ims.xml
index 746c3c9b46..c9eb3660f4 100644
--- a/restcomm/restcomm.testsuite/src/test/resources/restcomm-ims.xml
+++ b/restcomm/restcomm.testsuite/src/test/resources/restcomm-ims.xml
@@ -56,7 +56,7 @@
true
127.0.0.1
127.0.0.1
- 0
+ 9999
WebRTCGW__1@
WebRTCGW/1.0
ims