@Test
 public void testOnMessageNotModeratedNotify() throws Exception {
   MailingListComponent componentNotModerated = new MailingListComponent("101");
   MailingList list = ServicesFactory.getMailingListService().findMailingList("101");
   assertNotNull(list);
   assertNotNull(list.getModerators());
   assertEquals(3, list.getModerators().size());
   assertNotNull(list.getReaders());
   assertEquals(2, list.getReaders().size());
   assertFalse(list.isModerated());
   assertTrue(list.isNotify());
   Message message = ServicesFactory.getMessageService().getMessage("701");
   assertEquals(textEmailContent, message.getBody());
   message.setContentType("text/plain; charset=\"UTF-8\"");
   MessageEvent event = new MessageEvent();
   event.addMessage(message);
   componentNotModerated.onMessage(event);
   List<TextMessage> jmsMessages = MockObjectFactory.getMessages(JNDINames.JMS_QUEUE);
   assertNotNull(jmsMessages);
   assertEquals(5, jmsMessages.size());
   for (TextMessage alert : jmsMessages) {
     assertNotNull(alert.getText());
     NotificationData data = NotificationServerUtil.convertXMLToNotificationData(alert.getText());
     assertNotNull(data);
     String channel = data.getTargetChannel();
     assertEquals("SMTP", channel);
     String recipient = data.getTargetReceipt();
     assertNotNull(recipient);
     assertTrue(
         "Erreur destinataire " + recipient,
         "*****@*****.**".equals(recipient)
             || "*****@*****.**".equals(recipient)
             || "*****@*****.**".equals(recipient)
             || "*****@*****.**".equals(recipient)
             || "*****@*****.**".equals(recipient));
     assertEquals(message.getSummary(), data.getMessage());
     String url = (String) data.getTargetParam().get("URL");
     assertNotNull(url);
     assertEquals(
         "http://*****:*****@silverpeas.com", source);
   }
   checkSimpleEmail(
       "*****@*****.**",
       "[Liste de diffusion de test non modérée] : Simple Message");
   checkSimpleEmail(
       "*****@*****.**",
       "[Liste de diffusion de test non modérée] : Simple Message");
   checkSimpleEmail(
       "*****@*****.**", "[Liste de diffusion de test non modérée] : Simple Message");
   checkSimpleEmail(
       "*****@*****.**",
       "[Liste de diffusion de test non modérée] : Simple Message");
   checkSimpleEmail(
       "*****@*****.**", "[Liste de diffusion de test non modérée] : Simple Message");
   checkSimpleEmail(
       "*****@*****.**", "[Liste de diffusion de test non modérée] : Simple Message");
   checkSimpleEmail(
       "*****@*****.**",
       "[Liste de diffusion de test non modérée] : Simple Message");
   checkSimpleEmail(
       "*****@*****.**", "[Liste de diffusion de test non modérée] : Simple Message");
   checkSimpleEmail(
       "*****@*****.**",
       "[Liste de diffusion de test non modérée] : Simple Message");
   checkSimpleEmail(
       "*****@*****.**",
       "[Liste de diffusion de test non modérée] : Simple Message");
   checkSimpleEmail(
       "*****@*****.**",
       "[Liste de diffusion de test non modérée] : Simple Message");
   checkSimpleEmail(
       "*****@*****.**",
       "[Liste de diffusion de test non modérée] : Simple Message");
 }
コード例 #2
0
  @Test
  public void testOnMessage() throws Exception {
    Message message =
        MailingListServicesProvider.getFactory().getMessageService().getMessage("700");
    message.setContentType("text/plain; charset=\"UTF-8\"");
    MessageEvent event = new MessageEvent();
    event.addMessage(message);
    component.onMessage(event);
    /*List<TextMessage> jmsMessages = MockObjectFactory.getMessages(JNDINames.JMS_QUEUE);
    assertNotNull(jmsMessages);
    assertEquals(3, jmsMessages.size());
    for (TextMessage alert : jmsMessages) {
      assertNotNull(alert.getText());
      NotificationData data = NotificationServerUtil.convertXMLToNotificationData(alert.getText());
      assertNotNull(data);
      String channel = data.getTargetChannel();
      assertEquals("SMTP", channel);
      String recipient = data.getTargetReceipt();
      assertNotNull(recipient);
      assertTrue("Erreur destinataire " + recipient,
          "*****@*****.**".equals(recipient) || "*****@*****.**"
          .equals(recipient) || "*****@*****.**".equals(recipient));
      assertEquals(message.getSummary() + TECHNICAL_CONTENT, data.getMessage());
      String url = (String) data.getTargetParam().get("URL");
      assertNotNull(url);
      assertEquals("http://*****:*****@silverpeas.com", source);
    }*/
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");

    message =
        MailingListServicesProvider.getFactory().getMessageService().getMessage(message.getId());
    message.setModerated(true);
    event = new MessageEvent();
    event.addMessage(message);
    component.onMessage(event);
    /*jmsMessages = MockObjectFactory.getMessages(JNDINames.JMS_QUEUE);
    assertNotNull(jmsMessages);
    assertEquals(6, jmsMessages.size());
    for (TextMessage alert : jmsMessages) {
      assertNotNull(alert.getText());
      NotificationData data = NotificationServerUtil.convertXMLToNotificationData(alert.getText());
      assertNotNull(data);
      String channel = data.getTargetChannel();
      assertEquals("SMTP", channel);
      String recipient = data.getTargetReceipt();
      assertNotNull(recipient);
      assertTrue("Erreur destinataire " + recipient,
          "*****@*****.**".equals(recipient) || "*****@*****.**"
          .equals(recipient) || "*****@*****.**".equals(recipient));
      assertEquals(message.getSummary() + TECHNICAL_CONTENT, data.getMessage());
      String url = (String) data.getTargetParam().get("URL");
      assertNotNull(url);
      assertEquals(
          "http://*****:*****@silverpeas.com", source);
    }*/
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
    checkNoMessage("*****@*****.**");
  }