Example usage for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY

List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY.

Prototype

String[] EMPTY_STRING_ARRAY

To view the source code for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY.

Click Source Link

Document

An empty immutable String array.

Usage

From source file:org.sipfoundry.sipxconfig.admin.dialplan.config.FallbackRulesTest.java

public void testGenerateRuleWithGateways() throws Exception {
    FullTransform t1 = new FullTransform();
    t1.setUser("333");
    t1.setHost("10.1.1.14");
    t1.setFieldParams("Q=0.97");
    t1.addHeaderParams("expires=60");

    IDialingRule rule = createStrictMock(IDialingRule.class);
    rule.isInternal();/* www .jav a 2s .  com*/
    expectLastCall().andReturn(false);
    rule.getHostPatterns();
    expectLastCall().andReturn(ArrayUtils.EMPTY_STRING_ARRAY);
    rule.getName();
    expectLastCall().andReturn("my test name");
    rule.getDescription();
    expectLastCall().andReturn("my test description");
    rule.getCallTag();
    expectLastCall().andReturn(CallTag.CUST).anyTimes();
    rule.getPatterns();
    expectLastCall().andReturn(array("x."));
    rule.getSiteTransforms();
    Map<String, List<? extends Transform>> siteMap = new HashMap<String, List<? extends Transform>>();
    siteMap.put(StringUtils.EMPTY, Arrays.asList(t1));
    expectLastCall().andReturn(siteMap);

    replay(rule);

    IDialingRule emergencyRule = createStrictMock(IDialingRule.class);
    emergencyRule.isInternal();
    expectLastCall().andReturn(false);
    emergencyRule.getHostPatterns();
    expectLastCall().andReturn(ArrayUtils.EMPTY_STRING_ARRAY);
    emergencyRule.getName();
    expectLastCall().andReturn("emergency name");
    emergencyRule.getDescription();
    expectLastCall().andReturn("emergency description");
    emergencyRule.getCallTag();
    expectLastCall().andReturn(CallTag.EMERG).anyTimes();
    emergencyRule.getPatterns();
    expectLastCall().andReturn(array("sos", "911", "9911"));
    emergencyRule.getSiteTransforms();
    Map<String, List<? extends Transform>> emergencySiteMap = new HashMap<String, List<? extends Transform>>();
    emergencySiteMap.put(StringUtils.EMPTY, Arrays.asList(t1));
    expectLastCall().andReturn(emergencySiteMap);

    replay(emergencyRule);

    m_out.begin();
    m_out.generate(rule);
    m_out.generate(emergencyRule);
    m_out.end();
    m_out.localizeDocument(TestUtil.createDefaultLocation());

    Document document = m_out.getDocument();

    assertElementInNamespace(document.getRootElement(),
            "http://www.sipfoundry.org/sipX/schema/xml/fallback-00-00");

    String domDoc = TestUtil.asString(document);
    InputStream referenceXmlStream = getClass().getResourceAsStream("fallbackrules.test.xml");
    assertEquals(IOUtils.toString(referenceXmlStream), domDoc);

    verify(rule);
}

From source file:org.sipfoundry.sipxconfig.admin.dialplan.config.FallbackRulesTest.java

public void testGenerateRuleWithGatewaysAndSite() throws Exception {
    Transform t1 = createTransform("444", "montreal.example.org", "q=0.95", "expires=60");
    Transform t2 = createTransform("9444", "lisbon.example.org", "q=0.95", "expires=60");

    Map<String, List<Transform>> siteTr = new LinkedHashMap<String, List<Transform>>();
    siteTr.put("Montreal", Arrays.asList(t1));
    siteTr.put("Lisbon", Arrays.asList(t2));

    IDialingRule rule = createStrictMock(IDialingRule.class);
    rule.isInternal();/*from   w ww . ja v  a 2  s .  c o m*/
    expectLastCall().andReturn(false);
    rule.getHostPatterns();
    expectLastCall().andReturn(ArrayUtils.EMPTY_STRING_ARRAY);
    rule.getName();
    expectLastCall().andReturn("my test name");
    rule.getDescription();
    expectLastCall().andReturn("my test description");
    rule.getCallTag();
    expectLastCall().andReturn(CallTag.CUST).anyTimes();
    rule.getPatterns();
    expectLastCall().andReturn(array("x."));
    rule.getSiteTransforms();
    expectLastCall().andReturn(siteTr);

    replay(rule);

    IDialingRule emergencyRule = createStrictMock(IDialingRule.class);
    emergencyRule.isInternal();
    expectLastCall().andReturn(false);
    emergencyRule.getHostPatterns();
    expectLastCall().andReturn(ArrayUtils.EMPTY_STRING_ARRAY);
    emergencyRule.getName();
    expectLastCall().andReturn("emergency name");
    emergencyRule.getDescription();
    expectLastCall().andReturn("emergency description");
    emergencyRule.getCallTag();
    expectLastCall().andReturn(CallTag.EMERG).anyTimes();
    emergencyRule.getPatterns();
    expectLastCall().andReturn(array("sos", "911", "9911"));
    emergencyRule.getSiteTransforms();
    expectLastCall().andReturn(siteTr);

    replay(emergencyRule);

    m_out.begin();
    m_out.generate(rule);
    m_out.generate(emergencyRule);
    m_out.end();
    m_out.localizeDocument(TestUtil.createDefaultLocation());

    Document document = m_out.getDocument();
    assertElementInNamespace(document.getRootElement(),
            "http://www.sipfoundry.org/sipX/schema/xml/fallback-00-00");

    String domDoc = TestUtil.asString(document);

    InputStream referenceXmlStream = getClass().getResourceAsStream("fallbackrules-sites.test.xml");
    assertEquals(IOUtils.toString(referenceXmlStream), domDoc);

    verify(rule);
}

From source file:org.sipfoundry.sipxconfig.admin.dialplan.config.MappingRulesTest.java

public void testGenerate() throws Exception {
    UrlTransform voicemail = new UrlTransform();
    voicemail.setUrl("<sip:{digits}@localhost;transport=tcp;" + "play=" + VOICEMAIL_SERVER
            + "/sipx-cgi/voicemail/mediaserver.cgi?action=deposit&mailbox={digits}>;q=0.1");

    UrlTransform voicemail2 = new UrlTransform();
    voicemail2.setUrl("<sip:{digits}@testserver;" + "play=" + VOICEMAIL_SERVER
            + "/sipx-cgi/voicemail/mediaserver.cgi?action=deposit&mailbox={digits}>;q=0.001");

    IMocksControl control = EasyMock.createNiceControl();
    IDialingRule rule = control.createMock(IDialingRule.class);
    rule.isInternal();/*from ww w  .jav  a 2 s  .  c o m*/
    control.andReturn(true);
    rule.getHostPatterns();
    control.andReturn(ArrayUtils.EMPTY_STRING_ARRAY);
    rule.getName();
    control.andReturn(null);
    rule.getDescription();
    control.andReturn("my rule description");
    rule.getPatterns();
    control.andReturn(new String[] { "x." }).anyTimes();
    rule.isTargetPermission();
    control.andReturn(true);
    rule.getPermissionNames();
    control.andReturn(Arrays.asList(new String[] { PermissionName.VOICEMAIL.getName() }));
    rule.getTransforms();
    control.andReturn(new Transform[] { voicemail, voicemail2 });
    control.replay();

    m_out.begin();
    m_out.generate(rule);
    m_out.end();

    Document document = m_out.getDocument();

    String domDoc = TestUtil.asString(document);

    assertXpathEvaluatesTo("my rule description", "/mappings/hostMatch/userMatch/description", domDoc);
    assertXpathEvaluatesTo("x.", "/mappings/hostMatch/userMatch/userPattern", domDoc);
    assertXpathEvaluatesTo("Voicemail", "/mappings/hostMatch/userMatch/permissionMatch/permission", domDoc);
    assertXpathEvaluatesTo(voicemail.getUrl(), "/mappings/hostMatch/userMatch/permissionMatch/transform/url",
            domDoc);
    assertXpathEvaluatesTo(voicemail2.getUrl(),
            "/mappings/hostMatch/userMatch/permissionMatch/transform[2]/url", domDoc);

    control.verify();
}

From source file:org.sipfoundry.sipxconfig.admin.dialplan.config.MappingRulesTest.java

public void testGenerateInternalRuleWithSourcePermission() throws Exception {
    IMocksControl control = EasyMock.createNiceControl();
    IDialingRule rule = control.createMock(IDialingRule.class);
    rule.isInternal();//from  w ww . ja  va  2 s.c om
    control.andReturn(true);
    rule.getHostPatterns();
    control.andReturn(ArrayUtils.EMPTY_STRING_ARRAY);
    rule.getName();
    control.andReturn(null);
    rule.getDescription();
    control.andReturn("my rule description");
    rule.getPatterns();
    control.andReturn(new String[] { "xxx" }).anyTimes();
    rule.isTargetPermission();
    control.andReturn(false);
    rule.getTransforms();
    control.andReturn(new Transform[0]);
    control.replay();

    m_out.begin();
    m_out.generate(rule);
    m_out.end();

    Document document = m_out.getDocument();

    String domDoc = TestUtil.asString(document);

    assertXpathEvaluatesTo("my rule description", "/mappings/hostMatch/userMatch/description", domDoc);
    assertXpathEvaluatesTo("xxx", "/mappings/hostMatch/userMatch/userPattern", domDoc);
    assertXpathNotExists("/mappings/hostMatch/userMatch/permissionMatch/permission", domDoc);

    control.verify();
}

From source file:org.sipfoundry.sipxconfig.admin.dialplan.DialingRule.java

public String[] getHostPatterns() {
    return ArrayUtils.EMPTY_STRING_ARRAY;
}

From source file:org.sipfoundry.sipxconfig.admin.dialplan.DialPattern.java

/**
 * Helper function to tokenize list of numbers into array of strings
 *
 * @param patternsList comma separated list of patterns, spaces are treated as separators as
 *        well//from  ww w .  j  av a 2 s  .com
 * @param suffix string appended to each pattern in the resulting list
 */
public static String[] getPatternsFromList(String patternsList, String suffix) {
    if (StringUtils.isBlank(patternsList)) {
        return ArrayUtils.EMPTY_STRING_ARRAY;
    }
    StringTokenizer tokenizer = new StringTokenizer(patternsList, SEPARATORS);
    String[] patterns = new String[tokenizer.countTokens()];
    for (int i = 0; i < patterns.length; i++) {
        patterns[i] = tokenizer.nextToken() + suffix;
    }
    return patterns;
}

From source file:org.sipfoundry.sipxconfig.admin.dialplan.InternalRuleTest.java

public void testOperator() {
    AutoAttendant aa = new AutoAttendant();
    aa.setName(TEST_NAME);/*from  w  ww  .  j a  v a 2  s  .  c  o  m*/
    aa.setDescription(TEST_DESCRIPTION);

    Operator o = new MappingRule.Operator(aa, "100", ArrayUtils.EMPTY_STRING_ARRAY, m_mediaServer);
    assertEquals("100", StringUtils.join(o.getPatterns(), "|"));
    assertEquals(TEST_NAME, o.getName());
    assertEquals(TEST_DESCRIPTION, o.getDescription());
}

From source file:org.sipfoundry.sipxconfig.dialplan.config.FallbackRulesTest.java

public void testGenerateRuleWithGateways() throws Exception {
    FullTransform t1 = new FullTransform();
    t1.setUser("333");
    t1.setHost("10.1.1.14");
    t1.setFieldParams("Q=0.97");
    t1.addHeaderParams("expires=7200");

    IDialingRule rule = createStrictMock(IDialingRule.class);
    rule.isInternal();/*from  w w w  . j  a v a  2 s . com*/
    expectLastCall().andReturn(false);
    rule.getHostPatterns();
    expectLastCall().andReturn(ArrayUtils.EMPTY_STRING_ARRAY);
    rule.getName();
    expectLastCall().andReturn("my test name");
    rule.getDescription();
    expectLastCall().andReturn("my test description");
    rule.getCallTag();
    expectLastCall().andReturn(CallTag.CUST).anyTimes();
    rule.getPatterns();
    expectLastCall().andReturn(array("x."));
    rule.getSiteTransforms();
    Map<String, List<? extends Transform>> siteMap = new HashMap<String, List<? extends Transform>>();
    siteMap.put(StringUtils.EMPTY, Arrays.asList(t1));
    expectLastCall().andReturn(siteMap);

    replay(rule);

    IDialingRule emergencyRule = createStrictMock(IDialingRule.class);
    emergencyRule.isInternal();
    expectLastCall().andReturn(false);
    emergencyRule.getHostPatterns();
    expectLastCall().andReturn(ArrayUtils.EMPTY_STRING_ARRAY);
    emergencyRule.getName();
    expectLastCall().andReturn("emergency name");
    emergencyRule.getDescription();
    expectLastCall().andReturn("emergency description");
    emergencyRule.getCallTag();
    expectLastCall().andReturn(CallTag.EMERG).anyTimes();
    emergencyRule.getPatterns();
    expectLastCall().andReturn(array("sos", "911", "9911"));
    emergencyRule.getSiteTransforms();
    Map<String, List<? extends Transform>> emergencySiteMap = new HashMap<String, List<? extends Transform>>();
    emergencySiteMap.put(StringUtils.EMPTY, Arrays.asList(t1));
    expectLastCall().andReturn(emergencySiteMap);

    replay(emergencyRule);

    m_out.begin();
    m_out.generate(rule);
    m_out.generate(emergencyRule);
    m_out.end();
    m_out.setLocation(TestHelper.createDefaultLocation());

    Document document = m_out.getDocument();

    assertElementInNamespace(document.getRootElement(),
            "http://www.sipfoundry.org/sipX/schema/xml/fallback-00-00");

    String domDoc = TestHelper.asString(document);
    InputStream referenceXmlStream = getClass().getResourceAsStream("fallbackrules.test.xml");
    assertEquals(IOUtils.toString(referenceXmlStream), domDoc);

    verify(rule);
}

From source file:org.sipfoundry.sipxconfig.dialplan.config.FallbackRulesTest.java

public void testGenerateRuleWithGatewaysAndSite() throws Exception {
    Transform t1 = createTransform("444", "montreal.example.org", "q=0.95", "expires=7200");
    Transform t2 = createTransform("9444", "lisbon.example.org", "q=0.95", "expires=7200");

    Map<String, List<Transform>> siteTr = new LinkedHashMap<String, List<Transform>>();
    siteTr.put("Montreal", Arrays.asList(t1));
    siteTr.put("Lisbon", Arrays.asList(t2));

    IDialingRule rule = createStrictMock(IDialingRule.class);
    rule.isInternal();/*  w  ww  .  ja va  2s  .  c o  m*/
    expectLastCall().andReturn(false);
    rule.getHostPatterns();
    expectLastCall().andReturn(ArrayUtils.EMPTY_STRING_ARRAY);
    rule.getName();
    expectLastCall().andReturn("my test name");
    rule.getDescription();
    expectLastCall().andReturn("my test description");
    rule.getCallTag();
    expectLastCall().andReturn(CallTag.CUST).anyTimes();
    rule.getPatterns();
    expectLastCall().andReturn(array("x."));
    rule.getSiteTransforms();
    expectLastCall().andReturn(siteTr);

    replay(rule);

    IDialingRule emergencyRule = createStrictMock(IDialingRule.class);
    emergencyRule.isInternal();
    expectLastCall().andReturn(false);
    emergencyRule.getHostPatterns();
    expectLastCall().andReturn(ArrayUtils.EMPTY_STRING_ARRAY);
    emergencyRule.getName();
    expectLastCall().andReturn("emergency name");
    emergencyRule.getDescription();
    expectLastCall().andReturn("emergency description");
    emergencyRule.getCallTag();
    expectLastCall().andReturn(CallTag.EMERG).anyTimes();
    emergencyRule.getPatterns();
    expectLastCall().andReturn(array("sos", "911", "9911"));
    emergencyRule.getSiteTransforms();
    expectLastCall().andReturn(siteTr);

    replay(emergencyRule);

    m_out.begin();
    m_out.generate(rule);
    m_out.generate(emergencyRule);
    m_out.end();
    m_out.setLocation(TestHelper.createDefaultLocation());

    Document document = m_out.getDocument();
    assertElementInNamespace(document.getRootElement(),
            "http://www.sipfoundry.org/sipX/schema/xml/fallback-00-00");

    String domDoc = TestHelper.asString(document);

    InputStream referenceXmlStream = getClass().getResourceAsStream("fallbackrules-sites.test.xml");
    assertEquals(IOUtils.toString(referenceXmlStream), domDoc);

    verify(rule);
}

From source file:org.sipfoundry.sipxconfig.dialplan.config.MappingRulesTest.java

public void testGenerate() throws Exception {
    UrlTransform voicemail = new UrlTransform();
    voicemail.setUrl("<sip:{digits}@localhost;transport=tcp;" + "play=" + VOICEMAIL_SERVER
            + "/sipx-cgi/voicemail/mediaserver.cgi?action=deposit&mailbox={digits}>;q=0.1");

    UrlTransform voicemail2 = new UrlTransform();
    voicemail2.setUrl("<sip:{digits}@testserver;" + "play=" + VOICEMAIL_SERVER
            + "/sipx-cgi/voicemail/mediaserver.cgi?action=deposit&mailbox={digits}>;q=0.001");

    IMocksControl control = EasyMock.createNiceControl();
    IDialingRule rule = control.createMock(IDialingRule.class);
    rule.isInternal();//from   w w  w .ja v a  2 s  .c om
    control.andReturn(true);
    rule.getHostPatterns();
    control.andReturn(ArrayUtils.EMPTY_STRING_ARRAY);
    rule.getName();
    control.andReturn(null);
    rule.getDescription();
    control.andReturn("my rule description");
    rule.getPatterns();
    control.andReturn(new String[] { "x." }).anyTimes();
    rule.isTargetPermission();
    control.andReturn(true);
    rule.getPermissionNames();
    control.andReturn(Arrays.asList(new String[] { PermissionName.VOICEMAIL.getName() }));
    rule.getTransforms();
    control.andReturn(new Transform[] { voicemail, voicemail2 });
    control.replay();

    m_out.begin();
    m_out.generate(rule);
    m_out.end();

    Document document = m_out.getDocument();

    String domDoc = TestHelper.asString(document);

    assertXpathEvaluatesTo("my rule description", "/mappings/hostMatch/userMatch/description", domDoc);
    assertXpathEvaluatesTo("x.", "/mappings/hostMatch/userMatch/userPattern", domDoc);
    assertXpathEvaluatesTo("Voicemail", "/mappings/hostMatch/userMatch/permissionMatch/permission", domDoc);
    assertXpathEvaluatesTo(voicemail.getUrl(), "/mappings/hostMatch/userMatch/permissionMatch/transform/url",
            domDoc);
    assertXpathEvaluatesTo(voicemail2.getUrl(),
            "/mappings/hostMatch/userMatch/permissionMatch/transform[2]/url", domDoc);

    control.verify();
}