MailMergeTest.java
/***************************************************************************
Copyright 2012 Emily Estes
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
***************************************************************************/
package net.metanotion.email;
import java.util.HashMap;
import javax.sql.DataSource;
import net.metanotion.io.JavaFileSystem;
import net.metanotion.sql.MockDataSource;
public final class MailMergeTest {
public static void main(String[] args) throws Exception {
// MailMergeUtil test.
final HashMap<String,Object> mmuMap = new HashMap<>();
MailMergeUtil.LOGGING.send("sender@example.com", "receive@example.com", "test", "message");
MailMergeUtil.LOGGING.sendEmail("sender@example.com", "receive@example.com", mmuMap, "/template.txt");
MailMergeUtil.LOGGING.sendEmail("sender@example.com", "receive@example.com", "subject", mmuMap, "/template.txt");
MailMergeUtil.NULL.send("sender@example.com", "receive@example.com", "test", "message");
MailMergeUtil.NULL.sendEmail("sender@example.com", "receive@example.com", mmuMap, "/template.txt");
MailMergeUtil.NULL.sendEmail("sender@example.com", "receive@example.com", "subject", mmuMap, "/template.txt");
new MailMergeUtil();
final DataSource dataSource = new MockDataSource();
final JavaFileSystem emailTemplates = new JavaFileSystem(args[0]);
final MailMerge mailMerge = new MailMergeDbQueue(dataSource, emailTemplates);
final HashMap<String,Object> vars = new HashMap<>();
vars.put("Foo", "Bar");
mailMerge.sendEmail("testing@metanotion.mailgun.org", "matt.estes@metanotion.net", "Test", vars, "/test.txt");
mailMerge.sendEmail("testing@metanotion.mailgun.org", "matt.estes@metanotion.net", vars, "/test2.txt");
mailMerge.sendEmail("testing@metanotion.mailgun.org", "matt.estes@metanotion.net", vars, "/test3.txt");
}
}