コード例 #1
0
  /** Test of doubleSeparators method, of class NotificationServerUtil. */
  @Test
  public void testDoubleSeparators() {
    String simpleValue = "Le petit chat est mort";
    String expResult = "Le petit chat est mort";
    String result = NotificationServerUtil.doubleSeparators(simpleValue);
    assertEquals(expResult, result);
    String stringWithEqual = "0+0 = la tête à toto";
    expResult = "0+0 == la tête à toto";
    result = NotificationServerUtil.doubleSeparators(stringWithEqual);
    assertEquals(expResult, result);

    String stringWithComa = "Oh, Oh, oh; comment vas tu ?";
    expResult = "Oh, Oh, oh;; comment vas tu ?";
    result = NotificationServerUtil.doubleSeparators(stringWithComa);
    assertEquals(expResult, result);
  }
コード例 #2
0
 /**
  * Test of convertXMLToNotificationData method, of class NotificationServerUtil.
  *
  * @throws Exception
  */
 @Test
 public void testConvertXMLToNotificationData() throws Exception {
   Date dateParam = RandomGenerator.getRandomCalendar().getTime();
   String p_XML =
       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<NOTIFY>	<LOGIN>		<USER>"
           + "<![CDATA[user]]></USER>		<PASSWORD><![CDATA[password]]></PASSWORD>	</LOGIN>	"
           + "<MESSAGE><![CDATA[message]]></MESSAGE>	<SENDER>		<ID><![CDATA[bart.simpson@silverpeas"
           + ".com]]></ID>		<NAME><![CDATA[Bart Simpson]]></NAME>		<ANSWERALLOWED>true"
           + "</ANSWERALLOWED>	</SENDER>	<COMMENT><![CDATA[comment]]></COMMENT>	<TARGET CHANNEL=\"SMTP\">"
           + "		<NAME><![CDATA[Home Simpson]]></NAME>		<RECEIPT><![CDATA[receipt]]></RECEIPT>		"
           + "<PARAM><![CDATA[date=#DATE#"
           + dateParam.getTime()
           + ";string=bonjour le monde;; 0 + 0 == la tête à "
           + "toto]]></PARAM>	</TARGET>	<PRIORITY SPEED=\"fast\"/>	<REPORT>	</REPORT></NOTIFY>";
   NotificationData expResult = new NotificationData();
   Map<String, Object> params = new HashMap<String, Object>(2);
   params.put("string", "bonjour le monde; 0 + 0 = la tête à toto");
   params.put("date", dateParam);
   expResult.setAnswerAllowed(true);
   expResult.setComment("comment");
   expResult.setLoginPassword("password");
   expResult.setLoginUser("user");
   expResult.setMessage("message");
   expResult.setNotificationId(0L);
   expResult.setPrioritySpeed("fast");
   expResult.setSenderId("*****@*****.**");
   expResult.setSenderName("Bart Simpson");
   expResult.setTargetChannel("SMTP");
   expResult.setTargetName("Home Simpson");
   expResult.setTargetParam(params);
   expResult.setTargetReceipt("receipt");
   NotificationData result = NotificationServerUtil.convertXMLToNotificationData(p_XML);
   assertEquals(expResult, result);
 }
コード例 #3
0
 /** Test of packKeyValues method, of class NotificationServerUtil. */
 @Test
 public void testPackKeyValues() {
   Map<String, Object> params = new LinkedHashMap<String, Object>(2);
   params.put("date", new Date(1358963160000l));
   params.put("string", "bonjour le monde; 0 + 0 = la tête à toto");
   params.put("title", "Titre d'œuvre");
   String expResult =
       "date=#DATE#1358963160000;string=bonjour le monde;; 0 + 0 == la tête à toto;title=Titre d'œuvre";
   String result = NotificationServerUtil.packKeyValues(params);
   assertEquals(expResult, result);
 }
コード例 #4
0
 /** Test of unpackKeyValues method, of class NotificationServerUtil. */
 @Test
 public void testUnpackKeyValues() {
   String keyvaluestring =
       "date=#DATE#1358963160000;string=bonjour le monde;; 0 + 0 == la tête à toto;title=Titre d'œuvre";
   Map<String, Object> expResult = new HashMap<String, Object>(3);
   expResult.put("date", new Date(1358963160000l));
   expResult.put("string", "bonjour le monde; 0 + 0 = la tête à toto");
   expResult.put("title", "Titre d'œuvre");
   Map<String, Object> result = NotificationServerUtil.unpackKeyValues(keyvaluestring);
   assertEquals(expResult, result);
 }