use of com.zimbra.cs.account.Server in project zm-mailbox by Zimbra.
the class FilterUtilTest method init.
@BeforeClass
public static void init() throws Exception {
MailboxTestUtil.initServer();
Provisioning prov = Provisioning.getInstance();
Account acct1 = prov.createAccount("test@zimbra.com", "secret", new HashMap<String, Object>());
Server server = Provisioning.getInstance().getServer(acct1);
}
use of com.zimbra.cs.account.Server in project zm-mailbox by Zimbra.
the class RedirectCopyTest method init.
@BeforeClass
public static void init() throws Exception {
MailboxTestUtil.initServer();
Provisioning prov = Provisioning.getInstance();
Map<String, Object> attrs = Maps.newHashMap();
prov.createDomain("zimbra.com", attrs);
attrs = Maps.newHashMap();
attrs.put(Provisioning.A_zimbraId, UUID.randomUUID().toString());
prov.createAccount("test1@zimbra.com", "secret", attrs);
attrs = Maps.newHashMap();
attrs.put(Provisioning.A_zimbraId, UUID.randomUUID().toString());
Account acct = prov.createAccount("test2@zimbra.com", "secret", attrs);
attrs = Maps.newHashMap();
attrs.put(Provisioning.A_zimbraId, UUID.randomUUID().toString());
prov.createAccount("test3@zimbra.com", "secret", attrs);
Server server = Provisioning.getInstance().getServer(acct);
// this MailboxManager does everything except actually send mail
MailboxManager.setInstance(new DirectInsertionMailboxManager());
}
use of com.zimbra.cs.account.Server in project zm-mailbox by Zimbra.
the class SetVariableTest method init.
@BeforeClass
public static void init() throws Exception {
MailboxTestUtil.initServer();
Provisioning prov = Provisioning.getInstance();
Account acct = prov.createAccount("test1@zimbra.com", "secret", new HashMap<String, Object>());
Server server = Provisioning.getInstance().getServer(acct);
}
use of com.zimbra.cs.account.Server in project zm-mailbox by Zimbra.
the class MailSenderTest method sendExternalMessage.
//@Test
public void sendExternalMessage() throws Exception {
Provisioning prov = Provisioning.getInstance();
Server server = prov.getLocalServer();
server.setSmtpHostname(new String[] { "bogusname.test" });
server.setSmtpPort(25);
server.setSmtpTimeout(60);
server.setSmtpSendPartial(true);
server.setShareNotificationMtaHostname("mta02.zimbra.com");
server.setShareNotificationMtaPort(25);
server.setShareNotificationMtaAuthRequired(true);
server.setShareNotificationMtaConnectionType(ShareNotificationMtaConnectionType.STARTTLS);
server.setShareNotificationMtaAuthAccount("test-jylee");
server.setShareNotificationMtaAuthPassword("test123");
MimeMessage mm = new MimeMessage(JMSession.getSmtpSession());
InternetAddress address = new JavaMailInternetAddress("test-jylee@zimbra.com");
mm.setFrom(address);
address = new JavaMailInternetAddress("test-jylee@zimbra.com");
mm.setRecipient(javax.mail.Message.RecipientType.TO, address);
mm.setSubject("test mail");
mm.setText("hello world");
mm.saveChanges();
ZimbraLog.smtp.setLevel(Level.trace);
MailSender.relayMessage(mm);
}
use of com.zimbra.cs.account.Server in project zm-mailbox by Zimbra.
the class CheckPortConflict method checkConfig.
private void checkConfig(Config config, Map<String, Object> configAttrsToModify) throws ServiceException {
BiMap<String, String> newDefaults = HashBiMap.create();
/*
* First, make sure there is no conflict in the Config entry, even
* if the value on the config entry might not be effective on a server.
*/
for (String attrName : sPortAttrs) {
if (!configAttrsToModify.containsKey(attrName))
newDefaults.put(config.getAttr(attrName), attrName);
}
// check conflict for attrs being changed
for (Map.Entry<String, Object> attrToModify : configAttrsToModify.entrySet()) {
String attrName = attrToModify.getKey();
if (!sPortAttrs.contains(attrName))
continue;
SingleValueMod mod = singleValueMod(configAttrsToModify, attrName);
String newValue = null;
if (mod.setting())
newValue = mod.value();
if (conflict(null, newDefaults, newValue, attrName)) {
throw ServiceException.INVALID_REQUEST("port " + newValue + " conflict between " + attrName + " and " + newDefaults.get(newValue) + " on global config", null);
} else
newDefaults.put(newValue, attrName);
}
/*
* Then, iterate through all servers see if this port change on the Config
* entry has impact on a server.
*/
List<Server> servers = Provisioning.getInstance().getAllServers();
for (Server server : servers) {
checkServerWithNewDefaults(server, newDefaults, configAttrsToModify);
}
}
Aggregations