@Override public void contextInitialized(ServletContextEvent sce) { ParallelInit.loggerAgentThread = new LoggerAgentThread(sce.getServletContext()); log.info("registering to all inbound XMPP messages.. "); ArrayList<AdapterConfig> adapters = AdapterConfig.findAdapters(AdapterAgent.ADAPTER_TYPE_XMPP, null, null); XMPPServlet xmppServlet = new XMPPServlet(); for (AdapterConfig adapterConfig : adapters) { try { xmppServlet.listenForIncomingChats(adapterConfig); } catch (XMPPException e) { log.severe( "Exception thrown while trying to register inbound XMPP service for: " + adapterConfig.getMyAddress()); } } log.info("registering to all inbound Email messages.. "); adapters = AdapterConfig.findAdapters(AdapterAgent.ADAPTER_TYPE_EMAIL, null, null); for (AdapterConfig adapterConfig : adapters) { if (!adapterConfig.getMyAddress().endsWith("appspotmail.com")) { MailServlet mailServlet = new MailServlet(adapterConfig); try { mailServlet.listenForIncomingEmails(); } catch (MessagingException e) { log.severe( "Exception thrown while trying to register inbound Email service for: " + adapterConfig.getMyAddress()); } } } }
@Test public void inboundPhoneCall_CommentTest() throws Exception { new DDRRecordAgent().generateDefaultDDRTypes(); String tenantKey = UUID.randomUUID().toString(); String callSid = UUID.randomUUID().toString(); TPSimulator simulator = new TPSimulator(TestFramework.host, tenantKey); // TwilioSimulator simulator = new TwilioSimulator(TestFramework.host, accountSid); String url = ServerUtils.getURLWithQueryParams( TestServlet.TEST_SERVLET_PATH, "questionType", QuestionInRequest.SIMPLE_COMMENT.name()); url = ServerUtils.getURLWithQueryParams(url, "question", TEST_MESSAGE_1); url = ServerUtils.getURLWithQueryParams(url, "lang", Language.ENGLISH_UNITEDSTATES.getCode()); String callback = ServerUtils.getURLWithQueryParams( TestServlet.TEST_SERVLET_PATH, "questionType", QuestionInRequest.SIMPLE_COMMENT.name()); callback = ServerUtils.getURLWithQueryParams(callback, "question", TEST_MESSAGE_2); url = ServerUtils.getURLWithQueryParams(url, "callback", callback); // create a dialog Dialog createDialog = Dialog.createDialog("Test secured dialog", url, TEST_PUBLIC_KEY); // create SMS adapter AdapterConfig adapterConfig = createAdapterConfig( AdapterAgent.ADAPTER_TYPE_CALL, AdapterProviders.TP, TEST_ACCOUNT_ID, localAddressBroadsoft, localAddressBroadsoft, url); adapterConfig.setPreferred_language(Language.ENGLISH_UNITEDSTATES.getCode()); adapterConfig.setDialogId(createDialog.getId()); adapterConfig.update(); simulator.initiateInboundCall(callSid, remoteAddressVoice, localAddressBroadsoft); StrowgerAction actual = simulator.getReponse(); assertEquals(2, actual.getData().size()); Action action = actual.getData().get(0); assertTrue(action instanceof Play); Play play = (Play) action; assertTrue(play.getLocation().toString().startsWith("http://tts.ask-fast.com")); action = actual.getData().get(1); assertTrue(action instanceof Include); simulator.nextQuestion(null); actual = simulator.getReponse(); assertEquals(1, actual.getData().size()); action = actual.getData().get(0); assertTrue(action instanceof Play); // check all the ddrs created List<DDRRecord> ddrRecords = getAllDdrRecords(TEST_ACCOUNT_ID); assertEquals(ddrRecords.size(), 1); for (DDRRecord ddrRecord : ddrRecords) { assertEquals("inbound", ddrRecord.getDirection()); assertEquals( adapterConfig.getFormattedMyAddress(), ddrRecord.getToAddress().keySet().iterator().next()); assertEquals( PhoneNumberUtils.formatNumber(remoteAddressVoice, null), ddrRecord.getFromAddress()); } }