Java Code Examples for org.subethamail.smtp.client.SmartClient#from()
The following examples show how to use
org.subethamail.smtp.client.SmartClient#from() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 6 votes |
@Test public void testSiteIdAccept() throws Exception { User sender = mock(User.class); when(userDirectoryService.findUsersByEmail("[email protected]")).thenReturn(Collections.singleton(sender)); MailArchiveChannel channel = mock(MailArchiveChannel.class); when(channel.getEnabled()).thenReturn(true); when(channel.getOpen()).thenReturn(false); when(channel.allowAddMessage(sender)).thenReturn(true); when(channel.getId()).thenReturn("channelId"); when(channel.getContext()).thenReturn("siteId"); when(mailArchiveService.channelReference("siteId", SiteService.MAIN_CONTAINER)).thenReturn("/site/siteId"); when(mailArchiveService.getMailArchiveChannel("/site/siteId")).thenReturn(channel); SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); writeData(client, "/simple-email.txt"); verify(channel, times(1)).addMailArchiveMessage(anyString(), eq("[email protected]"), any(), any(), any(), any()); }
Example 2
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 6 votes |
@Test // Check that the BATV parsing is working correctly public void testSiteIdAcceptBatv() throws Exception { User sender = mock(User.class); when(userDirectoryService.findUsersByEmail("[email protected]")).thenReturn(Collections.singleton(sender)); MailArchiveChannel channel = mock(MailArchiveChannel.class); when(channel.getEnabled()).thenReturn(true); when(channel.getOpen()).thenReturn(false); when(channel.allowAddMessage(sender)).thenReturn(true); when(channel.getId()).thenReturn("channelId"); when(channel.getContext()).thenReturn("siteId"); when(mailArchiveService.channelReference("siteId", SiteService.MAIN_CONTAINER)).thenReturn("/site/siteId"); when(mailArchiveService.getMailArchiveChannel("/site/siteId")).thenReturn(channel); SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); // BATV is only in the envelope so the mail message should be the same. writeData(client, "/simple-email.txt"); verify(channel, times(1)).addMailArchiveMessage(anyString(), eq("[email protected]"), any(), any(), any(), any()); }
Example 3
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 6 votes |
@Test // Check that the BATV parsing is working correctly public void testSiteIdAcceptBatv() throws Exception { User sender = mock(User.class); when(userDirectoryService.findUsersByEmail("[email protected]")).thenReturn(Collections.singleton(sender)); MailArchiveChannel channel = mock(MailArchiveChannel.class); when(channel.getEnabled()).thenReturn(true); when(channel.getOpen()).thenReturn(false); when(channel.allowAddMessage(sender)).thenReturn(true); when(channel.getId()).thenReturn("channelId"); when(channel.getContext()).thenReturn("siteId"); when(mailArchiveService.channelReference("siteId", SiteService.MAIN_CONTAINER)).thenReturn("/site/siteId"); when(mailArchiveService.getMailArchiveChannel("/site/siteId")).thenReturn(channel); SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); // BATV is only in the envelope so the mail message should be the same. writeData(client, "/simple-email.txt"); verify(channel, times(1)).addMailArchiveMessage(anyString(), eq("[email protected]"), any(), any(), any(), any()); }
Example 4
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 6 votes |
@Test public void testBadDomainCase() throws Exception { // Checks that we ignore the case on the domain when(serverConfigurationService.getServerName()).thenReturn("saKai.exAmple.cOm"); User sender = mock(User.class); when(userDirectoryService.findUsersByEmail("[email protected]")).thenReturn(Collections.singleton(sender)); MailArchiveChannel channel = mock(MailArchiveChannel.class); when(channel.getEnabled()).thenReturn(true); when(channel.getOpen()).thenReturn(false); when(channel.allowAddMessage(sender)).thenReturn(true); when(channel.getId()).thenReturn("channelId"); when(channel.getContext()).thenReturn("siteId"); when(mailArchiveService.channelReference("siteId", SiteService.MAIN_CONTAINER)).thenReturn("/site/siteId"); when(mailArchiveService.getMailArchiveChannel("/site/siteId")).thenReturn(channel); SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); writeData(client, "/simple-email.txt"); verify(channel, times(1)).addMailArchiveMessage(anyString(), eq("[email protected]"), any(), any(), any(), any()); }
Example 5
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 5 votes |
@Test public void testIgnoreNoReply() throws Exception { SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); writeData(client, "/no-reply.txt"); }
Example 6
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 5 votes |
@Test(expected = SMTPException.class) public void testRejectedAddress() throws Exception { when(aliasService.getTarget("user")).thenThrow(IdUnusedException.class); when(rb.getString("err_addr_unknown")).thenReturn("err_addr_unknown"); SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); }
Example 7
Source File: RelayFunctionalTest.java From mireka with Apache License 2.0 | 5 votes |
@Test public void testQuit() throws Exception { SmartClient smartClient = new SmartClient("localhost", 25, "localhost"); smartClient.from(""); smartClient.to("[email protected]"); smartClient.dataStart(); byte[] bytes = ExampleMailData.simple().bytes; smartClient.dataWrite(bytes, bytes.length); smartClient.dataEnd(); smartClient.quit(); assertTrue(quitReceived); assertEquals(1, wiser.getMessages().size()); }
Example 8
Source File: ClientServerRelayTest.java From mireka with Apache License 2.0 | 5 votes |
@Test public void testReceivingAndSending() throws IOException, SMTPException, IOException { SmartClient client = new SmartClient("localhost", 8025, "SmartClient"); client.from("[email protected]"); client.to("[email protected]"); client.dataStart(); byte[] exampleMail = ExampleMailData.simple().bytes; client.dataWrite(exampleMail, exampleMail.length); client.dataEnd(); client.quit(); WiserMessage message = wiser.getMessages().get(0); assertThat(message.getData(), new ArrayEndsWith(exampleMail)); }
Example 9
Source File: MxPopTest.java From mireka with Apache License 2.0 | 5 votes |
private void sendMail() throws UnknownHostException, IOException, SMTPException { SmartClient client = new SmartClient("localhost", PORT_SMTP, "SmartClient"); client.from("[email protected]"); client.to("[email protected]"); client.dataStart(); byte[] exampleMail = ExampleMailData.simple().bytes; client.dataWrite(exampleMail, exampleMail.length); client.dataEnd(); client.quit(); }
Example 10
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 5 votes |
@Test public void testPostmaster() throws Exception { // Here there is no postmaster which may happen and should be dealt with String reference = "/mailarchive/no-permission/main"; when(mailArchiveService.channelReference("no-permission", SiteService.MAIN_CONTAINER)).thenReturn(reference); when(mailArchiveService.getMailArchiveChannel(reference)).thenThrow(PermissionException.class); when(userDirectoryService.getUser("postmaster")).thenThrow(UserNotDefinedException.class); SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); writeData(client, "/no-permission.txt"); }
Example 11
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 5 votes |
@Test(expected = SMTPException.class) public void testEmptyReturnPath() throws Exception { // Here there isn't a good email in the from address to make a return path String reference = "/mailarchive/empty-return-path/main"; SmartClient client = createClient(); client.from(""); }
Example 12
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 5 votes |
@Test(expected = SMTPException.class) public void testNoReturnPath() throws Exception { // Here there isn't a good email in the from address to make a return path String reference = "/mailarchive/no-good-mail/main"; SmartClient client = createClient(); client.from(""); }
Example 13
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 5 votes |
@Test(expected = SMTPException.class) public void testNoPermission() throws Exception { // Here there is no permission, this should never happen in real life String reference = "/mailarchive/no-permission/main"; when(mailArchiveService.channelReference("no-permission", SiteService.MAIN_CONTAINER)).thenReturn(reference); when(mailArchiveService.getMailArchiveChannel(reference)).thenThrow(PermissionException.class); SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); writeData(client, "/no-permission.txt"); }
Example 14
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 5 votes |
@Test public void testMultipleSiteIdAccept() throws Exception { User sender = mock(User.class); when(userDirectoryService.findUsersByEmail("[email protected]")).thenReturn(Collections.singleton(sender)); MailArchiveChannel channel1 = mock(MailArchiveChannel.class); when(channel1.getEnabled()).thenReturn(true); when(channel1.getOpen()).thenReturn(false); when(channel1.allowAddMessage(sender)).thenReturn(true); when(channel1.getId()).thenReturn("channelId"); when(channel1.getContext()).thenReturn("siteId1"); MailArchiveChannel channel2 = mock(MailArchiveChannel.class); when(channel2.getEnabled()).thenReturn(true); when(channel2.getOpen()).thenReturn(false); when(channel2.allowAddMessage(sender)).thenReturn(true); when(channel2.getId()).thenReturn("channelId"); when(channel2.getContext()).thenReturn("siteId2"); when(mailArchiveService.channelReference("siteId1", SiteService.MAIN_CONTAINER)).thenReturn("/site/siteId1"); when(mailArchiveService.getMailArchiveChannel("/site/siteId1")).thenReturn(channel1); when(mailArchiveService.channelReference("siteId2", SiteService.MAIN_CONTAINER)).thenReturn("/site/siteId2"); when(mailArchiveService.getMailArchiveChannel("/site/siteId2")).thenReturn(channel2); SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); client.to("[email protected]"); writeData(client, "/simple-email.txt"); verify(channel1, times(1)).addMailArchiveMessage(anyString(), eq("[email protected]"), any(), any(), any(), any()); verify(channel2, times(1)).addMailArchiveMessage(anyString(), eq("[email protected]"), any(), any(), any(), any()); }
Example 15
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 5 votes |
@Test() public void testIgnorePostmaster() throws Exception { when(aliasService.getTarget("postmaster")).thenThrow(IdUnusedException.class); SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); writeData(client, "/simple-email.txt"); }
Example 16
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 5 votes |
@Test(expected = SMTPException.class) public void testRejectedAddress() throws Exception { when(aliasService.getTarget("user")).thenThrow(IdUnusedException.class); when(rb.getString("err_addr_unknown")).thenReturn("err_addr_unknown"); SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); }
Example 17
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 5 votes |
@Test public void testIgnoreNoReply() throws Exception { SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); writeData(client, "/no-reply.txt"); }
Example 18
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 5 votes |
@Test(expected = SMTPException.class) public void testEmptyReturnPath() throws Exception { // Here there isn't a good email in the from address to make a return path String reference = "/mailarchive/empty-return-path/main"; SmartClient client = createClient(); client.from(""); }
Example 19
Source File: MessageHandlerTest.java From subethasmtp with Apache License 2.0 | 4 votes |
@Test public void testTwoMailsInOneSession() throws Exception { new Expectations() { { messageHandlerFactory.create((MessageContext) any); result = messageHandler; onInstance(messageHandler).from(anyString); onInstance(messageHandler).recipient(anyString); onInstance(messageHandler).data((InputStream) any); onInstance(messageHandler).done(); messageHandlerFactory.create((MessageContext) any); result = messageHandler2; onInstance(messageHandler2).from(anyString); onInstance(messageHandler2).recipient(anyString); onInstance(messageHandler2).data((InputStream) any); onInstance(messageHandler2).done(); } }; SmartClient client = new SmartClient("localhost", smtpServer.getPort(), "localhost"); client.from("[email protected]"); client.to("[email protected]"); client.dataStart(); client.dataWrite(TextUtils.getAsciiBytes("body1"), 5); client.dataEnd(); client.from("[email protected]"); client.to("[email protected]"); client.dataStart(); client.dataWrite(TextUtils.getAsciiBytes("body2"), 5); client.dataEnd(); client.quit(); smtpServer.stop(); // wait for the server to catch up }
Example 20
Source File: SakaiMessageHandlerTest.java From sakai with Educational Community License v2.0 | 4 votes |
@Test(expected = SMTPException.class) public void testRejectedDomain() throws IOException { SmartClient client = createClient(); client.from("[email protected]"); client.to("[email protected]"); }