コード例 #1
0
ファイル: ResourceListsTest.java プロジェクト: ossapp/sipxecs
 @Override
 protected void setUp() throws Exception {
   m_db = new MongoTemplate(new SimpleMongoDbFactory(new Mongo(), "test"));
   m_coreContext = createMock(CoreContext.class);
   m_coreContext.getDomainName();
   expectLastCall().andReturn(DOMAIN).anyTimes();
   replay(m_coreContext);
   m_db.getDb().dropDatabase();
   m_rl = new ResourceLists();
   ValidUsersSpring vu = new ValidUsersSpring();
   vu.setImdbTemplate(m_db);
   m_rl.setValidUsers(vu);
   m_rl.setCoreContext(m_coreContext);
 }
コード例 #2
0
ファイル: ResourceListsTest.java プロジェクト: ossapp/sipxecs
  /**
   * No matter if the user does not have blf permission, we should keep generating what speeddials
   * we have The BLF permission turning off only restricts the user to change his blf permission
   * from user-portal
   *
   * @throws Exception
   */
  public void testGenerateNoBlfPerm() throws Exception {
    String json3 =
        "{ \"_id\" : \"User3\", \"uid\" : \"user_name_0\", \"imenbld\" : \"false\", \"ent\": \"user\"}";

    String json2 =
        "{ \"_id\" : \"User2\", \"uid\" : \"user_c\", \"imenbld\" : \"false\", \"ent\": \"user\", "
            + "\""
            + MongoConstants.SPEEDDIAL
            + "\" : { \""
            + MongoConstants.USER
            + "\" : \"~~rl~F~user_c\", \""
            + MongoConstants.USER_CONS
            + "\" : \"~~rl~C~user_c\", \""
            + MongoConstants.BUTTONS
            + "\" : [ "
            + "{\""
            + MongoConstants.URI
            + "\" : \"sip:[email protected]\",\""
            + MongoConstants.NAME
            + "\" : \"delta\"}"
            + "]}, \"prm\" : [\"Mobile\""
            + "]}";

    insertJson(getEntityCollection(), json3, json2);
    Thread.sleep(1000);

    Document doc = m_rl.getDocument();
    String fileContent = TestHelper.asString(doc);
    InputStream referenceXml = getClass().getResourceAsStream("resource-lists-noblfperm.test.xml");
    assertXMLEqual(new InputStreamReader(referenceXml), new StringReader(fileContent));
  }
コード例 #3
0
ファイル: ResourceListsTest.java プロジェクト: ossapp/sipxecs
  public void testGenerate() throws Exception {
    String json1 =
        "{ \"_id\" : \"User1\", \"uid\" : \"user_a\", \"imenbld\" : \"false\", \"ent\": \"user\", "
            + "\""
            + MongoConstants.SPEEDDIAL
            + "\": { \""
            + MongoConstants.USER
            + "\" : \"~~rl~F~user_a\", \""
            + MongoConstants.USER_CONS
            + "\" : \"~~rl~C~user_a\", \""
            + MongoConstants.BUTTONS
            + "\" : [ "
            + "{\""
            + MongoConstants.URI
            + "\" : \"sip:[email protected]\",\""
            + MongoConstants.NAME
            + "\" : \"beta\"},"
            + "{\""
            + MongoConstants.URI
            + "\" : \"sip:[email protected]\",\""
            + MongoConstants.NAME
            + "\" : \"gamma\"}"
            + "]}, \"prm\" : [\"subscribe-to-presence\""
            + "]}";

    String json2 =
        "{ \"_id\" : \"User2\", \"uid\" : \"user_c\", \"imenbld\" : \"false\", \"ent\": \"user\","
            + "\""
            + MongoConstants.SPEEDDIAL
            + "\" : { \""
            + MongoConstants.USER
            + "\" : \"~~rl~F~user_c\", \""
            + MongoConstants.USER_CONS
            + "\" : \"~~rl~C~user_c\", \""
            + MongoConstants.BUTTONS
            + "\" : [ "
            + "{\""
            + MongoConstants.URI
            + "\" : \"sip:[email protected]\",\""
            + MongoConstants.NAME
            + "\" : \"delta\"}"
            + "]}, \"prm\" : [\"subscribe-to-presence\""
            + "]}";

    String json3 =
        "{ \"_id\" : \"User3\", \"uid\" : \"user_name_0\", \"imenbld\" : \"true\", \"ent\": \"user\"}";

    String json4 =
        "{ \"_id\" : \"User4\", \"uid\" : \"user_name_1\", \"imenbld\" : \"true\", ent: \"user\"}";
    insertJson(getEntityCollection(), json1, json2, json3, json4);
    Thread.sleep(1000); // sleep 1 second. I get inconsistent results when running the tests,
    // as if mongo does not pick up quickly

    Document doc = m_rl.getDocument();
    String generatedXml = TestHelper.asString(doc);
    InputStream referenceXml = getClass().getResourceAsStream("resource-lists.test.xml");
    assertXMLEqual(new InputStreamReader(referenceXml), new StringReader(generatedXml));
  }