UriUtils { public URI resolve(final URI uri) { return resolve(uri, null); } UriUtils(final DaoManager daoManager);  UriUtils(final DaoManager daoManager, final JBossConnectorDiscover jBossConnectorDiscover, boolean useHostnameToResolve); URI resolveWithBase(final URI base, final URI uri); URI resolve(final URI uri); URI resolve(final URI uri, final Sid accountSid); HttpConnector getHttpConnector();  }
@Test public void testResolveRelativeUrlWithAccount() throws MalformedObjectNameException, UnknownHostException, InstanceNotFoundException, AttributeNotFoundException, MBeanException, ReflectionException { String domainName = "amazing.restcomm.com"; HttpConnector httpConnector = new HttpConnector("http","127.0.0.1", 8080, false); HttpConnectorList httpConnectorList = new HttpConnectorList(Arrays.asList(new HttpConnector[]{httpConnector})); when(jBossConnectorDiscover.findConnectors()).thenReturn(httpConnectorList); when(daoManager.getAccountsDao()).thenReturn(accountsDao); when(daoManager.getOrganizationsDao()).thenReturn(organizationsDao); when(accountsDao.getAccount(any(Sid.class))).thenReturn(account); when(account.getOrganizationSid()).thenReturn(orgSid); when(organizationsDao.getOrganization(orgSid)).thenReturn(organization); when(organization.getDomainName()).thenReturn(domainName); URI relativeUri = URI.create("/restcomm/recording.wav"); Assert.assertEquals("http: uriUtils.resolve(relativeUri, Sid.generate(Sid.Type.ACCOUNT)).toString()); }
@Test public void testResolveRelativeUrl() throws Exception { URL url = this.getClass().getResource("/restcomm.xml"); XMLConfiguration xml = new XMLConfiguration(); xml.setDelimiterParsingDisabled(true); xml.setAttributeSplittingDisabled(true); xml.load(url); RestcommConfiguration conf = new RestcommConfiguration(xml); String domainName = "amazing.restcomm.com"; HttpConnector httpConnector = new HttpConnector("http","127.0.0.1", 8080, false); HttpConnectorList httpConnectorList = new HttpConnectorList(Arrays.asList(new HttpConnector[]{httpConnector})); when(jBossConnectorDiscover.findConnectors()).thenReturn(httpConnectorList); URI relativeUri = URI.create("/restcomm/recording.wav"); Assert.assertEquals("http: uriUtils.resolve(relativeUri).toString()); }