@Override protected void onTearDown() throws IOException { IDatabaseConnection connection = null; try { connection = getConnection(); DatabaseOperation.DELETE_ALL.execute(connection, getDataSet()); cleanJndi(); } catch (Exception ex) { ex.printStackTrace(); } finally { if (connection != null) { try { connection.getConnection().close(); } catch (SQLException e) { e.printStackTrace(); } } } MockObjectFactory.clearAll(); cleanJndi(); }
@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"); }