org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration#com.icegreen.greenmail.util.ServerSetupTest源码实例Demo

下面列出了org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration#com.icegreen.greenmail.util.ServerSetupTest 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: syndesis   文件: EMailTestServer.java
public EMailTestServer(String hostName, Options... options) {
    this.optionsList = Arrays.asList(options);

    if (optionsList.contains(Options.IMAP)) {
        initServer(hostName, ServerSetupTest.IMAP, () -> greenMail.getImap());
    } else if (optionsList.contains(Options.IMAPS)) {
        initServer(hostName, ServerSetupTest.IMAPS, () -> greenMail.getImaps());
    } else if (optionsList.contains(Options.POP3)) {
        initServer(hostName, ServerSetupTest.POP3, () -> greenMail.getPop3());
    } else if (optionsList.contains(Options.POP3S)) {
        initServer(hostName, ServerSetupTest.POP3S, () -> greenMail.getPop3s());
    } else if (optionsList.contains(Options.SMTP)) {
        initServer(hostName, ServerSetupTest.SMTP, () -> greenMail.getSmtp());
    } else if (optionsList.contains(Options.SMTPS)) {
        initServer(hostName, ServerSetupTest.SMTPS, () -> greenMail.getSmtps());
    } else {
        throw new UnsupportedOperationException("Server must be either IMAP(S), POP3(S) or SMTP(S)");
    }
}
 
源代码2 项目: greenmail   文件: ConcurrentCloseIT.java
private void testThis() throws InterruptedException {
    final GreenMail greenMail = new GreenMail(ServerSetupTest.SMTP);
    greenMail.setUser("[email protected]", "[email protected]");
    greenMail.start();
    final SenderThread sendThread = new SenderThread();
    try {
        sendThread.start();
        greenMail.waitForIncomingEmail(3000, 1);
        final MimeMessage[] emails = greenMail.getReceivedMessages();
        assertEquals(1, emails.length);
        sendThread.join(10000);
    } finally {
        greenMail.stop();
    }

    if (sendThread.exc != null) {
        throw sendThread.exc;
    }
}
 
源代码3 项目: ogham   文件: EmailSMTPAuthenticationTest.java
@Before
public void setUp() throws IOException {
	greenMail.setUser("[email protected]", "test.sender", "password");							// <1>
	oghamService = MessagingBuilder.standard()
			.environment()
				.properties("/application.properties")
				.properties()
					.set("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress())
					.set("mail.smtp.port", ServerSetupTest.SMTP.getPort())
					.set("mail.smtp.auth", "true")												// <2>
					.set("ogham.email.javamail.authenticator.username", "test.sender")			// <3>
					.set("ogham.email.javamail.authenticator.password", "password")				// <4>
					.and()
				.and()
			.build();
}
 
源代码4 项目: ogham   文件: EmailDifferentPrefixesTest.java
@Before
public void setUp() throws IOException {
	// copy files
	File folder = temp.newFolder("template", "mixed", "source");
	File thymeleafFolder = folder.toPath().resolve("thymeleaf").toFile();
	thymeleafFolder.mkdirs();
	File freemarkerFolder = folder.toPath().resolve("freemarker").toFile();
	freemarkerFolder.mkdirs();
	IOUtils.copy(resource("template/thymeleaf/source/simple.html"), thymeleafFolder.toPath().resolve("simple.html").toFile());
	IOUtils.copy(resource("template/freemarker/source/simple.txt.ftl"), freemarkerFolder.toPath().resolve("simple.txt.ftl").toFile());
	// prepare ogham
	oghamService = MessagingBuilder.standard()
			.environment()
				.properties("/application.properties")
				.properties()
					.set("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress())
					.set("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()))
					.set("ogham.email.thymeleaf.classpath.path-prefix", "/template/thymeleaf/source/")
					.set("ogham.email.thymeleaf.file.path-prefix", thymeleafFolder.getAbsolutePath()+"/")
					.set("ogham.email.freemarker.classpath.path-prefix", "/template/freemarker/source/")
					.set("ogham.email.freemarker.file.path-prefix", freemarkerFolder.getAbsolutePath()+"/")
					.and()
				.and()
			.build();
}
 
源代码5 项目: ogham   文件: EmailSMTPDefaultsTest.java
@Before
public void setUp() throws IOException {
	Properties additionalProps = new Properties();
	additionalProps.setProperty("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress());
	additionalProps.setProperty("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()));
	oghamService = MessagingBuilder.standard()
			.email()
			.images()
				.inline()
					.attach()
						.cid()
							.generator(new SequentialIdGenerator(true))
							.and().and().and().and().and()
			.environment()
				.properties("/application.properties")
				.properties(additionalProps)
				.and()
			.build();
}
 
源代码6 项目: ogham   文件: EmailPropertiesTest.java
@Before
public void setUp() throws IOException {
	Properties additional = new Properties();
	additional.setProperty("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress());
	additional.setProperty("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()));
	additional.setProperty("ogham.email.from.default-value", "[email protected]");
	additional.setProperty("ogham.email.to.default-value", "[email protected],  [email protected] , [email protected]");   // <1>
	additional.setProperty("ogham.email.cc.default-value", "[email protected],[email protected]");                            // <2>
	additional.setProperty("ogham.email.bcc.default-value", "[email protected]");                                                // <3>
	oghamService = MessagingBuilder.standard()
			.environment()
				.properties("/application.properties")
				.properties(additional)
				.and()
			.build();
}
 
源代码7 项目: ogham   文件: FluentEmailTest.java
@Before
public void setUp() throws IOException {
	Properties additionalProps = new Properties();
	additionalProps.setProperty("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress());
	additionalProps.setProperty("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()));
	oghamService = MessagingBuilder.standard()
			.email()
			.images()
				.inline()
					.attach()
						.cid()
							.generator(new SequentialIdGenerator(true))
							.and().and().and().and().and()
			.environment()
				.properties("/application.properties")
				.properties(additionalProps)
				.and()
			.build();
}
 
源代码8 项目: ogham   文件: ThymeleafRelativeResourcesTest.java
public void setup(Property... specificProps) throws IOException {
	// disable freemarker to be sure to use thymeleaf
	disableFreemarker();
	Properties additionalProps = new Properties();
	additionalProps.setProperty("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress());
	additionalProps.setProperty("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()));
	if(specificProps != null) {
		for(Property prop : specificProps) {
			additionalProps.setProperty(prop.getKey(), prop.getValue());
		}
	}
	oghamService = MessagingBuilder.standard()
			.email()
			.images()
				.inline()
					.attach()
						.cid()
							.generator(new SequentialIdGenerator(true))
							.and().and().and().and().and()
			.environment()
				.properties("/application.properties")
				.properties(additionalProps)
				.and()
			.build();
}
 
源代码9 项目: ogham   文件: FreemarkerRelativeResourcesTests.java
public void setup(Property... specificProps) throws IOException {
	// disable thymeleaf to be sure to use freemarker
	disableThymeleaf();
	Properties additionalProps = new Properties();
	additionalProps.setProperty("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress());
	additionalProps.setProperty("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()));
	if(specificProps != null) {
		for(Property prop : specificProps) {
			additionalProps.setProperty(prop.getKey(), prop.getValue());
		}
	}
	oghamService = MessagingBuilder.standard()
			.email()
				.images()
					.inline()
						.attach()
							.cid()
								.generator(new SequentialIdGenerator(true))
								.and().and().and().and().and()
			.environment()
				.properties("/application.properties")
				.properties(additionalProps)
				.and()
			.build();
}
 
源代码10 项目: ogham   文件: AutoRetryTest.java
@Test
public void doNotResendEmailIfInvalidTemplate() throws MessagingException {
	// @formatter:off
	builder
		.environment()
			.properties()
				.set("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress())
				.set("mail.smtp.port", ServerSetupTest.SMTP.getPort());
	// @formatter:on
	MessagingService messagingService = builder.build();
	// @formatter:off
	MessageNotSentException e = assertThrows("should throw", MessageNotSentException.class, () -> {
		messagingService.send(new Email()
				.from("[email protected]")
				.to("[email protected]")
				.body().template("/template/thymeleaf/source/invalid.html", new SimpleBean("foo", 42)));
	});
	// @formatter:on
	assertThat("should indicate that this is due to unrecoverable error", e, hasAnyCause(UnrecoverableException.class));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasSize(1)));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasItem(hasAnyCause(instanceOf(TemplateParsingFailedException.class)))));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasItem(hasAnyCause(instanceOf(ParseException.class)))));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasItem(hasAnyCause(instanceOf(TemplateProcessingException.class)))));
}
 
源代码11 项目: ogham   文件: AutoRetryTest.java
@Test
public void doNotResendEmailIfTemplateNotFound() throws MessagingException {
	// @formatter:off
	builder
		.environment()
			.properties()
				.set("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress())
				.set("mail.smtp.port", ServerSetupTest.SMTP.getPort());
	// @formatter:on
	MessagingService messagingService = builder.build();
	// @formatter:off
	MessageNotSentException e = assertThrows("should throw", MessageNotSentException.class, () -> {
		messagingService.send(new Email()
				.from("[email protected]")
				.to("[email protected]")
				.body().template("/not-found.html.ftl", null));
	});
	// @formatter:on
	assertThat("should indicate that this is due to unrecoverable error", e, hasAnyCause(UnrecoverableException.class));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasSize(1)));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasItem(hasAnyCause(instanceOf(NoContentException.class)))));
	assertThat("should indicate original exceptions", e, missingContentFailures(UnrecoverableException.class, hasItems(instanceOf(TemplateNotFoundException.class), instanceOf(TemplateNotFoundException.class))));
}
 
源代码12 项目: ogham   文件: AutoRetryTest.java
@Test
public void doNotResendEmailIfResourceUnresolved() throws MessagingException {
	// @formatter:off
	builder
		.environment()
			.properties()
				.set("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress())
				.set("mail.smtp.port", ServerSetupTest.SMTP.getPort());
	// @formatter:on
	MessagingService messagingService = builder.build();
	// @formatter:off
	MessageNotSentException e = assertThrows("should throw", MessageNotSentException.class, () -> {
		messagingService.send(new Email()
				.from("[email protected]")
				.to("[email protected]")
				.body().template("/template/freemarker/source/invalid-resources.html.ftl", new SimpleBean("foo", 42)));
	});
	// @formatter:on
	assertThat("should indicate that this is due to unrecoverable error", e, hasAnyCause(UnrecoverableException.class));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasSize(1)));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasItem(hasAnyCause(instanceOf(ImageInliningException.class)))));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasItem(hasAnyCause(instanceOf(ResourceResolutionException.class)))));
}
 
源代码13 项目: ogham   文件: AutoRetryTest.java
@Test
public void doNotResendEmailIfMimetypeDetectionFailed() throws MessagingException {
	// @formatter:off
	builder
		.environment()
			.properties()
				.set("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress())
				.set("mail.smtp.port", ServerSetupTest.SMTP.getPort());
	// @formatter:on
	MessagingService messagingService = builder.build();
	// @formatter:off
	MessageNotSentException e = assertThrows("should throw", MessageNotSentException.class, () -> {
		messagingService.send(new Email()
				.from("[email protected]")
				.to("[email protected]")
				.body().template("/template/freemarker/source/invalid-image-mimetype.html.ftl", new SimpleBean("foo", 42)));
	});
	// @formatter:on
	assertThat("should indicate that this is due to unrecoverable error", e, hasAnyCause(UnrecoverableException.class));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasSize(1)));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasItem(hasAnyCause(instanceOf(ImageInliningException.class)))));
	assertThat("should indicate original exceptions", e, executionFailures(UnrecoverableException.class, hasItem(hasAnyCause(instanceOf(MimeTypeDetectionException.class)))));
}
 
源代码14 项目: greenmail   文件: ServerStartStopTest.java
@Test
public void testStartStop() {
    GreenMail service = new GreenMail(ServerSetupTest.ALL);
    try {
        // Try to stop before start: Nothing happens
        service.stop();
        service.start();
        service.stop();
        // Now the server is stopped, should be started by reset command
        service.reset();
        // Start again
        service.reset();
    } finally {
        // And finally stop
        service.stop();
    }
}
 
源代码15 项目: attic-apex-malhar   文件: SmtpOutputOperatorTest.java
@Before
public void setup() throws Exception
{
  node = new SmtpOutputOperator();
  greenMail = new GreenMail(ServerSetupTest.ALL);
  greenMail.start();
  node.setFrom(from);
  node.setContent(content);
  node.setSmtpHost("127.0.0.1");
  node.setSmtpPort(ServerSetupTest.getPortOffset() + ServerSetup.SMTP.getPort());
  node.setSmtpUserName(from);
  node.setSmtpPassword("<password>");
  //node.setUseSsl(true);
  node.setSubject(subject);
  data = new HashMap<String, String>();
  data.put("alertkey", "alertvalue");

}
 
源代码16 项目: greenmail   文件: ExampleReceiveNoRuleTest.java
@Test
public void testReceive() throws MessagingException, IOException {
    //Start all email servers using non-default ports.
    GreenMail greenMail = new GreenMail(ServerSetupTest.SMTP_IMAP);
    try {
        greenMail.start();

        //Use random content to avoid potential residual lingering problems
        final String subject = GreenMailUtil.random();
        final String body = GreenMailUtil.random();
        MimeMessage message = createMimeMessage(subject, body, greenMail); // Construct message
        GreenMailUser user = greenMail.setUser("[email protected]", "waelc", "soooosecret");
        user.deliver(message);
        assertEquals(1, greenMail.getReceivedMessages().length);

        // --- Place your retrieve code here

    } finally {
        greenMail.stop();
    }
}
 
源代码17 项目: greenmail   文件: UserManagerTest.java
@Test
public void testDeleteUserShouldDeleteMail() throws Exception {
    ImapHostManager imapHostManager = new ImapHostManagerImpl(new InMemoryStore());
    UserManager userManager = new UserManager(imapHostManager);

    GreenMailUser user = userManager.createUser("[email protected]", "foo", "pwd");
    assertEquals(1, userManager.listUser().size());

    imapHostManager.createPrivateMailAccount(user);
    MailFolder otherfolder = imapHostManager.createMailbox(user, "otherfolder");
    MailFolder inbox = imapHostManager.getFolder(user, ImapConstants.INBOX_NAME);

    ServerSetup ss = ServerSetupTest.IMAP;
    MimeMessage m1 = GreenMailUtil.createTextEmail("[email protected]", "[email protected]", "sub1", "msg1", ss);
    MimeMessage m2 = GreenMailUtil.createTextEmail("[email protected]", "[email protected]", "sub1", "msg1", ss);

    inbox.store(m1);
    otherfolder.store(m2);
 
    userManager.deleteUser(user);
    assertTrue(imapHostManager.getAllMessages().isEmpty());
}
 
源代码18 项目: greenmail   文件: ConcurrentCloseIT.java
public void run() {
    try {
        GreenMailUtil.sendTextEmail("[email protected]", "[email protected]", "abc", "def", ServerSetupTest.SMTP);
    } catch (final Throwable e) {
        exc = new IllegalStateException(e);
    }
}
 
源代码19 项目: localization_nifi   文件: TestConsumeEmail.java
@Test
public void testConsumeIMAP4() throws Exception {

    final TestRunner runner = TestRunners.newTestRunner(new ConsumeIMAP());
    runner.setProperty(ConsumeIMAP.HOST, ServerSetupTest.IMAP.getBindAddress());
    runner.setProperty(ConsumeIMAP.PORT, String.valueOf(ServerSetupTest.IMAP.getPort()));
    runner.setProperty(ConsumeIMAP.USER, "nifiUserImap");
    runner.setProperty(ConsumeIMAP.PASSWORD, "nifiPassword");
    runner.setProperty(ConsumeIMAP.FOLDER, "INBOX");
    runner.setProperty(ConsumeIMAP.USE_SSL, "false");

    addMessage("testConsumeImap1", imapUser);
    addMessage("testConsumeImap2", imapUser);

    runner.run();

    runner.assertTransferCount(ConsumeIMAP.REL_SUCCESS, 2);
    final List<MockFlowFile> messages = runner.getFlowFilesForRelationship(ConsumeIMAP.REL_SUCCESS);
    String result = new String(runner.getContentAsByteArray(messages.get(0)));

    // Verify body
    Assert.assertTrue(result.contains("test test test chocolate"));

    // Verify sender
    Assert.assertTrue(result.contains("[email protected]"));

    // Verify subject
    Assert.assertTrue(result.contains("testConsumeImap1"));

}
 
源代码20 项目: localization_nifi   文件: TestConsumeEmail.java
@Test
public void testConsumePOP3() throws Exception {

    final TestRunner runner = TestRunners.newTestRunner(new ConsumePOP3());
    runner.setProperty(ConsumeIMAP.HOST, ServerSetupTest.POP3.getBindAddress());
    runner.setProperty(ConsumeIMAP.PORT, String.valueOf(ServerSetupTest.POP3.getPort()));
    runner.setProperty(ConsumeIMAP.USER, "nifiUserPop");
    runner.setProperty(ConsumeIMAP.PASSWORD, "nifiPassword");
    runner.setProperty(ConsumeIMAP.FOLDER, "INBOX");
    runner.setProperty(ConsumeIMAP.USE_SSL, "false");

    addMessage("testConsumePop1", popUser);
    addMessage("testConsumePop2", popUser);

    runner.run();

    runner.assertTransferCount(ConsumePOP3.REL_SUCCESS, 2);
    final List<MockFlowFile> messages = runner.getFlowFilesForRelationship(ConsumePOP3.REL_SUCCESS);
    String result = new String(runner.getContentAsByteArray(messages.get(0)));

    // Verify body
    Assert.assertTrue(result.contains("test test test chocolate"));

    // Verify sender
    Assert.assertTrue(result.contains("[email protected]"));

    // Verify subject
    Assert.assertTrue(result.contains("Pop1"));

}
 
源代码21 项目: QuizZz   文件: LifeCycleTest.java
@Before
public void setup() {
	mvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build();

	smtpServer = new GreenMail(ServerSetupTest.SMTP);
	smtpServer.start();
}
 
源代码22 项目: nifi   文件: ITestConsumeEmail.java
@Test
public void testConsumeIMAP4() throws Exception {

    final TestRunner runner = TestRunners.newTestRunner(new ConsumeIMAP());
    runner.setProperty(ConsumeIMAP.HOST, ServerSetupTest.IMAP.getBindAddress());
    runner.setProperty(ConsumeIMAP.PORT, String.valueOf(ServerSetupTest.IMAP.getPort()));
    runner.setProperty(ConsumeIMAP.USER, "nifiUserImap");
    runner.setProperty(ConsumeIMAP.PASSWORD, "nifiPassword");
    runner.setProperty(ConsumeIMAP.FOLDER, "INBOX");
    runner.setProperty(ConsumeIMAP.USE_SSL, "false");

    addMessage("testConsumeImap1", imapUser);
    addMessage("testConsumeImap2", imapUser);

    runner.run();

    runner.assertTransferCount(ConsumeIMAP.REL_SUCCESS, 2);
    final List<MockFlowFile> messages = runner.getFlowFilesForRelationship(ConsumeIMAP.REL_SUCCESS);
    String result = new String(runner.getContentAsByteArray(messages.get(0)));

    // Verify body
    Assert.assertTrue(result.contains("test test test chocolate"));

    // Verify sender
    Assert.assertTrue(result.contains("[email protected]"));

    // Verify subject
    Assert.assertTrue(result.contains("testConsumeImap1"));

}
 
源代码23 项目: nifi   文件: ITestConsumeEmail.java
@Test
public void testConsumePOP3() throws Exception {

    final TestRunner runner = TestRunners.newTestRunner(new ConsumePOP3());
    runner.setProperty(ConsumeIMAP.HOST, ServerSetupTest.POP3.getBindAddress());
    runner.setProperty(ConsumeIMAP.PORT, String.valueOf(ServerSetupTest.POP3.getPort()));
    runner.setProperty(ConsumeIMAP.USER, "nifiUserPop");
    runner.setProperty(ConsumeIMAP.PASSWORD, "nifiPassword");
    runner.setProperty(ConsumeIMAP.FOLDER, "INBOX");
    runner.setProperty(ConsumeIMAP.USE_SSL, "false");

    addMessage("testConsumePop1", popUser);
    addMessage("testConsumePop2", popUser);

    runner.run();

    runner.assertTransferCount(ConsumePOP3.REL_SUCCESS, 2);
    final List<MockFlowFile> messages = runner.getFlowFilesForRelationship(ConsumePOP3.REL_SUCCESS);
    String result = new String(runner.getContentAsByteArray(messages.get(0)));

    // Verify body
    Assert.assertTrue(result.contains("test test test chocolate"));

    // Verify sender
    Assert.assertTrue(result.contains("[email protected]"));

    // Verify subject
    Assert.assertTrue(result.contains("Pop1"));

}
 
源代码24 项目: greenmail   文件: Pop3ServerTest.java
@Test
public void testRetrieveMultipart() throws Exception {
    assertNotNull(greenMail.getPop3());

    String subject = GreenMailUtil.random();
    String body = GreenMailUtil.random();
    String to = "[email protected]";
    GreenMailUtil.sendAttachmentEmail(to, "[email protected]", subject, body, new byte[]{0, 1, 2}, "image/gif", "testimage_filename", "testimage_description", ServerSetupTest.SMTP);
    greenMail.waitForIncomingEmail(5000, 1);

    try (Retriever retriever = new Retriever(greenMail.getPop3())) {
        Message[] messages = retriever.getMessages(to);

        Object o = messages[0].getContent();
        assertTrue(o instanceof MimeMultipart);
        MimeMultipart mp = (MimeMultipart) o;
        assertEquals(2, mp.getCount());
        BodyPart bp;
        bp = mp.getBodyPart(0);
        assertEquals(body, GreenMailUtil.getBody(bp).trim());

        bp = mp.getBodyPart(1);
        assertEquals("AAEC", GreenMailUtil.getBody(bp).trim());

        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        GreenMailUtil.copyStream(bp.getInputStream(), bout);
        byte[] gif = bout.toByteArray();
        for (int i = 0; i < gif.length; i++) {
            assertEquals(i, gif[i]);
        }
    }
}
 
源代码25 项目: greenmail   文件: ImapServerTest.java
@Test
public void testExpunge() throws MessagingException {
    greenMail.setUser("[email protected]", "pwd");

    for (int i = 0; i < 6; i++) {
        GreenMailUtil.sendTextEmail("[email protected]", "[email protected]", "Test subject #" + i,
                "Test message", ServerSetupTest.SMTP);
    }
    final IMAPStore store = greenMail.getImap().createStore();
    store.connect("[email protected]", "pwd");
    try {
        Folder inboxFolder = store.getFolder("INBOX");
        inboxFolder.open(Folder.READ_WRITE);

        Message[] messages = inboxFolder.getMessages();
        assertEquals(6, messages.length);
        inboxFolder.setFlags(new int[]{2, 3}, new Flags(DELETED), true); // 1 and 2, offset is not zero-based

        assertFalse(inboxFolder.getMessage(1).isSet(DELETED));
        assertTrue(inboxFolder.getMessage(2).isSet(DELETED));
        assertTrue(inboxFolder.getMessage(3).isSet(DELETED));
        assertFalse(inboxFolder.getMessage(4).isSet(DELETED));
        assertFalse(inboxFolder.getMessage(5).isSet(DELETED));
        assertFalse(inboxFolder.getMessage(6).isSet(DELETED));
        assertEquals(2, inboxFolder.getDeletedMessageCount());
        Message[] expunged = inboxFolder.expunge();
        assertEquals(2, expunged.length);

        messages = inboxFolder.getMessages();
        assertEquals(4, messages.length);
        assertEquals("Test subject #0", messages[0].getSubject());
        assertEquals("Test subject #3", messages[1].getSubject());
        assertEquals("Test subject #4", messages[2].getSubject());
        assertEquals("Test subject #5", messages[3].getSubject());
    } finally {
        store.close();
    }
}
 
源代码26 项目: greenmail   文件: GreenMailUtilTest.java
@Test
public void testSetAndGetQuota() throws MessagingException {
    GreenMail greenMail = new GreenMail(ServerSetupTest.SMTP_IMAP);
    try {
        greenMail.start();

        final GreenMailUser user = greenMail.setUser("[email protected]", "pwd");

        Store store = greenMail.getImap().createStore();
        store.connect("[email protected]", "pwd");

        Quota testQuota = new Quota("INBOX");
        testQuota.setResourceLimit("STORAGE", 1024L * 42L);
        testQuota.setResourceLimit("MESSAGES", 5L);

        assertEquals(0, GreenMailUtil.getQuota(user, testQuota.quotaRoot).length);
        GreenMailUtil.setQuota(user, testQuota);

        final Quota[] quota = GreenMailUtil.getQuota(user, testQuota.quotaRoot);
        assertEquals(1, quota.length);
        assertEquals(2, quota[0].resources.length);

        store.close();
    } finally {
        greenMail.stop();
    }
}
 
源代码27 项目: ogham   文件: EmailExtractSubjectTest.java
@Before
public void setUp() throws IOException {
	builder = MessagingBuilder.standard();
	builder.environment()
			.properties()
				.set("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress())
				.set("mail.smtp.port", ServerSetupTest.SMTP.getPort());
}
 
源代码28 项目: ogham   文件: EmailTemplateStringTest.java
@Before
public void setUp() throws IOException {
	Properties additionalProperties = new Properties();
	additionalProperties.setProperty("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress());
	additionalProperties.setProperty("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()));
	oghamService = MessagingBuilder.standard()
			.environment()
				.properties("/application.properties")
				.properties(additionalProperties)
				.and()
			.build();
}
 
源代码29 项目: ogham   文件: EmailResourceInliningTest.java
@Before
public void setUp() throws IOException {
	Properties additionalProperties = new Properties();
	additionalProperties.setProperty("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress());
	additionalProperties.setProperty("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()));
	additionalProperties.setProperty("ogham.email.template.path-prefix", "/template/thymeleaf/source/");
	additionalProperties.setProperty("ogham.email.template.path-suffix", ".html");
	oghamService = MessagingBuilder.standard()
			.environment()
				.properties("/application.properties")
				.properties(additionalProperties)
				.and()
			.build();
}
 
源代码30 项目: ogham   文件: EmailMultiTemplateTest.java
@Before
public void setUp() throws IOException {
	Properties additionalProps = new Properties();
	additionalProps.setProperty("mail.smtp.host", ServerSetupTest.SMTP.getBindAddress());
	additionalProps.setProperty("mail.smtp.port", String.valueOf(ServerSetupTest.SMTP.getPort()));
	additionalProps.setProperty("ogham.email.template.path-prefix", "/template/");
	oghamService = MessagingBuilder.standard()
			.environment()
				.properties("/application.properties")
				.properties(additionalProps)
				.and()
			.build();
}