[Schmitzm-commits] r2102 - in trunk/schmitzm-core/src: main/java/de/schmitzm/io main/java/de/schmitzm/swing main/resources/de/schmitzm/swing/resource/locales test/java/de/schmitzm/testing

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Sat Oct 6 20:10:52 CEST 2012


Author: mojays
Date: 2012-10-06 20:10:52 +0200 (Sat, 06 Oct 2012)
New Revision: 2102

Added:
   trunk/schmitzm-core/src/main/java/de/schmitzm/io/SMTPSettings.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SMTPSettingsPanel.java
Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/io/ConnectionSettings.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ConnectionSettingsPanel.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
   trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties
   trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties
   trunk/schmitzm-core/src/test/java/de/schmitzm/testing/SwingUtilTest.java
Log:
SwingUtil: method to create SMTP settings InputOptions
ConnectionSettings/ConnectionSettingsPanel: JavaDoc update, unused field removed
new SMTPSettings, SMTPSettingsPanel

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/io/ConnectionSettings.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/io/ConnectionSettings.java	2012-10-05 13:02:12 UTC (rev 2101)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/io/ConnectionSettings.java	2012-10-06 18:10:52 UTC (rev 2102)
@@ -37,7 +37,7 @@
 import org.apache.log4j.Logger;
 
 /**
- * Holds several intenet connection settings.
+ * Holds several internet connection settings.
  * <ul>
  *   <li>proxy setting</li>
  *   <li>connection timeout</li>

Added: trunk/schmitzm-core/src/main/java/de/schmitzm/io/SMTPSettings.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/io/SMTPSettings.java	                        (rev 0)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/io/SMTPSettings.java	2012-10-06 18:10:52 UTC (rev 2102)
@@ -0,0 +1,156 @@
+/**
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ * 
+ * This file is part of the SCHMITZM library - a collection of utility 
+ * classes based on Java 1.6, focusing (not only) on Java Swing 
+ * and the Geotools library.
+ * 
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ * 
+ * Contributors:
+ *     Martin O. J. Schmitz - initial API and implementation
+ *     Stefan A. Tzeggai - additional utility classes
+ */
+package de.schmitzm.io;
+
+import java.io.IOException;
+import java.net.Proxy;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Holds several SMTP connection settings.
+ * <ul>
+ *   <li>SMTP Server</li>
+ *   <li>Authentication user and password</li>
+ *   <li>Sender mail address</li>
+ * </ul>
+ * @author Martin O.J. Schmitz
+ */
+public class SMTPSettings {
+  private static Logger LOGGER = Logger.getLogger(SMTPSettings.class.getName());
+
+  /** Holds whether SMTP should be used. */
+  protected boolean smtpUsed = true;
+  /** Holds the SMTP server name. */
+  protected String smtpServer = null;
+  /** Holds whether authentication is required. */
+  protected boolean authUsed = false;
+  /** Holds the user name for authentication. */
+  protected String authUser = "";
+  /** Holds the password for authentication */
+  protected char[] authPW = new char[0];
+  /** Holds the sender mail address. */
+  protected String senderAddr = "";
+  
+  
+  /**
+   * Returns whether SMTP should be used.
+   */
+  public boolean isSMTPUsed() {
+    return smtpUsed;
+  }
+
+  /**
+   * Sets whether SMTP server should be used.
+   */
+  public void setSMTPUsed(boolean smtpUsed) {
+    this.smtpUsed = smtpUsed;
+  }
+
+  /**
+   * Returns the SMTP server name.
+   */
+  public String getServer() {
+    return smtpServer;
+  }
+
+  /**
+   * Sets the SMTP server name.
+   */
+  public void setServer(String server) {
+    this.smtpServer = server;
+  }
+  
+  /**
+   * Returns whether authentication is used.
+   */
+  public boolean isAuthUsed() {
+    return authUsed;
+  }
+  
+  /**
+   * Sets whether authentication is used.
+   */
+  public void setAuthUsed(boolean authUsed) {
+    this.authUsed = authUsed;
+  }
+  
+  /**
+   * Returns the user name for authentication.
+   */
+  public String getAuthUser() {
+    return authUser;
+  }
+  
+  /**
+   * Sets the user name for authentication.
+   */
+  public void setAuthUser(String authUser) {
+    this.authUser = authUser;
+  }
+  
+  /**
+   * Returns the password for authentication.
+   */
+  public char[] getAuthPassword() {
+    return authPW;
+  }
+
+  /**
+   * Sets the password for authentication.
+   */
+  public void setAuthPassword(char[] password) {
+    this.authPW = password;
+  }
+  
+  /**
+   * Sets the password for authentication.
+   */
+  public void setAuthPassword(String password) {
+    setAuthPassword(password == null ? null : password.toCharArray() );
+  }
+
+  /**
+   * Returns the sender mail address.
+   */
+  public String getSenderAddress() {
+    return senderAddr;
+  }
+  
+  /**
+   * Sets the sender mail address.
+   */
+  public void setSenderAddress(String senderAddr) {
+    this.senderAddr = senderAddr;
+  }
+}
+

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ConnectionSettingsPanel.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ConnectionSettingsPanel.java	2012-10-05 13:02:12 UTC (rev 2101)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ConnectionSettingsPanel.java	2012-10-06 18:10:52 UTC (rev 2102)
@@ -59,7 +59,6 @@
 public class ConnectionSettingsPanel extends JPanel {
   private Logger LOGGER = LangUtil.createLogger(this);  
   
-  protected JLabel proxyUsedCaption;
   protected SelectionInputOption.Radio<Boolean> proxyUsed;
   protected JLabel proxyTypeCaption;
   protected SelectionInputOption.Combo<Proxy.Type> proxyType;

Added: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SMTPSettingsPanel.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SMTPSettingsPanel.java	                        (rev 0)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SMTPSettingsPanel.java	2012-10-06 18:10:52 UTC (rev 2102)
@@ -0,0 +1,163 @@
+/**
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ * 
+ * This file is part of the SCHMITZM library - a collection of utility 
+ * classes based on Java 1.6, focusing (not only) on Java Swing 
+ * and the Geotools library.
+ * 
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ * 
+ * Contributors:
+ *     Martin O. J. Schmitz - initial API and implementation
+ *     Stefan A. Tzeggai - additional utility classes
+ */
+package de.schmitzm.swing;
+
+import java.net.Proxy;
+import java.net.Proxy.Type;
+import java.util.List;
+import java.util.concurrent.Semaphore;
+
+import javax.swing.JLabel;
+
+import net.miginfocom.swing.MigLayout;
+
+import org.apache.log4j.Logger;
+
+import de.schmitzm.io.ConnectionSettings;
+import de.schmitzm.io.IOUtil;
+import de.schmitzm.io.SMTPSettings;
+import de.schmitzm.lang.LangUtil;
+import de.schmitzm.swing.input.BooleanInputOption;
+import de.schmitzm.swing.input.InputOption;
+import de.schmitzm.swing.input.InputOptionAdapter;
+import de.schmitzm.swing.input.ManualInputOption;
+import de.schmitzm.swing.input.ManualInputOption.Text;
+import de.schmitzm.swing.input.SelectionInputOption;
+
+/**
+ * Panel to specify SMTP server settings:
+ * <ul>
+ *   <li>SMTP Server</li>
+ *   <li>User</li>
+ *   <li>Password</li>
+ *   <li>Sender address (optional)</li>
+ * </ul>
+ * @author Martin O.J. Schmitz
+ */
+public class SMTPSettingsPanel extends JPanel {
+  private Logger LOGGER = LangUtil.createLogger(this);  
+  
+  protected JLabel smtpUsedCaption;
+  protected BooleanInputOption smtpUsed;
+  protected JLabel smptServerCaption;
+  protected ManualInputOption.Text smtpServer;
+  protected JLabel authUsedCaption;
+  protected BooleanInputOption authUsed;
+  protected JLabel authUserCaption;
+  protected ManualInputOption.Text authUser;
+  protected JLabel authPWCaption;
+  protected ManualInputOption.Password authPW;
+  protected JLabel senderAddressCaption;
+  protected ManualInputOption.Text senderAddress;
+  
+  public SMTPSettingsPanel(boolean inclUsed, boolean inclSender)  {
+    super( new MigLayout("wrap 4","[]10[]10[][grow]","[top]") );
+    
+    List<InputOption<?>> io = SwingUtil.createSMTPSettingsDialogOptions(false,inclUsed, inclSender);
+    int i=0;
+    smtpUsed             = inclUsed ? (BooleanInputOption)io.get(i++) : null;
+    smtpUsedCaption      = new JLabel( SwingUtil.R("SMTPSettings.smtp.used") );
+    smtpServer           = (ManualInputOption.Text) io.get(i++);
+    smptServerCaption    = new JLabel( SwingUtil.R("SMTPSettings.smtp.server") );
+    authUsed             = (BooleanInputOption) io.get(i++);
+    authUsedCaption      = new JLabel( SwingUtil.R("SMTPSettings.auth") );
+    authUser             = (ManualInputOption.Text) io.get(i++);
+    authUserCaption      = new JLabel( SwingUtil.R("SMTPSettings.auth.user") );
+    authPW               = (ManualInputOption.Password) io.get(i++);
+    authPWCaption        = new JLabel( SwingUtil.R("SMTPSettings.auth.pw") );
+    senderAddress        = inclSender ? (ManualInputOption.Text)io.get(i++) : null;
+    senderAddressCaption = new JLabel( SwingUtil.R("SMTPSettings.sender.addr") );
+
+    if ( inclUsed ) {
+      add(smtpUsed,"span 4, split 2");
+      add(smtpUsedCaption,"gapleft 10");
+    }
+    add(smptServerCaption,"");
+    add(smtpServer,"span 3, growx");
+    
+    add(authUsed,"span 4, split 2");
+    add(authUsedCaption,"gapleft 10");
+
+    add(authUserCaption,"gapleft 30");
+    add(authUser,"span 3, growx");
+    add(authPWCaption,"gapleft 30");
+    add(authPW,"span 3, w 150, growx");
+    if ( inclSender ) {
+      add(senderAddressCaption,"span 2");
+      add(senderAddress,"span 2, growx");
+    }
+    
+  }
+  
+ 
+  
+  /**
+   * Returns a {@link SMTPSettings} object which holds all of the 
+   * current GUI settings.
+   * @return always a new {@link SMTPSettings} instance, so changes
+   *         on this object does not effect GUI unless {@link #setSMTPSettings(SMTPSettings)}
+   *         is called!
+   */
+  public SMTPSettings getSMTPSettings() {
+    SMTPSettings settings = new SMTPSettings();
+    settings.setSMTPUsed(smtpUsed != null ? smtpUsed.getValue() : true);
+    settings.setServer(smtpServer.getValue());
+    settings.setAuthUsed(authUsed.getValue());
+    settings.setAuthUser(authUser.getValue());
+    settings.setAuthPassword(authPW.getValue());
+    settings.setSenderAddress(senderAddress != null ? senderAddress.getValue() : null);
+    return settings;
+  }
+  
+  /**
+   * Sets the GUI settings by a {@link SMTPSettings} object.
+   */
+  public void setSMTPSettings(SMTPSettings settings) {
+    if ( settings == null ){
+      smtpServer.setValue("");
+      authUsed.setValue(false);
+      authUser.setValue("");
+      authPW.setValue("");
+      if ( senderAddress != null )
+        senderAddress.setValue("");
+      if ( smtpUsed != null )
+        smtpUsed.setValue(false);
+      return;
+    }
+    smtpServer.setValue(settings.getServer());
+    authUsed.setValue(settings.isAuthUsed());
+    authUser.setValue(settings.getAuthUser());
+    authPW.setValue(settings.getAuthPassword() != null ? String.valueOf(settings.getAuthPassword()) : null);
+    if ( senderAddress != null )
+      senderAddress.setValue(settings.getSenderAddress());
+    if ( smtpUsed != null )
+      smtpUsed.setValue(settings.isSMTPUsed());
+  }
+}

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java	2012-10-05 13:02:12 UTC (rev 2101)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java	2012-10-06 18:10:52 UTC (rev 2102)
@@ -138,6 +138,7 @@
 import de.schmitzm.io.IOUtil;
 import de.schmitzm.lang.LangUtil;
 import de.schmitzm.lang.ResourceProvider;
+import de.schmitzm.swing.input.BooleanInputOption;
 import de.schmitzm.swing.input.InputOption;
 import de.schmitzm.swing.input.ManualInputOption;
 import de.schmitzm.swing.input.MultipleOptionPane;
@@ -1047,6 +1048,100 @@
       return (Integer)pane.getValue();
     }
     
+    /**
+     * Erzeugt (bis zu) 6 {@link InputOption} fuer ein {@link MultipleOptionPane} zur
+     * Abfrage von SMTP-Einstellungen.
+     * <ol>
+     *   <li>{@linkplain BooleanInputOption Eingabe-Feld} ob SMTP-Einstellungen verwendet werden sollen (optional)</li>
+     *   <li>{@linkplain ManualInputOption.Text Eingabe-Feld} fuer Servernamen</li>
+     *   <li>{@linkplain BooleanInputOption Eingabe-Feld} ob Authentifizierung erforderlich ist</li>
+     *   <li>{@linkplain ManualInputOption.Text Eingabe-Feld} fuer Benutzername</li>
+     *   <li>{@linkplain ManualInputOption.Password Eingabe-Feld} fuer Passwort</li>
+     *   <li>{@linkplain ManualInputOption.Text Eingabe-Feld} fuer Absender-Mail-Adresse (optional)</li>
+     * </ol>
+     * @param createLabels wenn {@code false} werden die {@link InputOption} ohne
+     *                     Labels erzeugt
+     * @param used Standard-Wert ob SMTP-Settings verwendet werden sollen; wenn {@code null}
+     *             wird diese {@link InputOption} NICHT erzeugt!
+     * @param server Standard-Wert fuer Servernamen
+     * @param auth Standard-Wert ob Authentifizierung erforderlich ist
+     * @param user Standard-Wert fuer User
+     * @param pw Standard-Wert fuer Passwort
+     * @param sender Standard-Wert fuer Mail-Absender-Adresse; wenn {@code null}
+     *               wird diese {@link InputOption} NICHT erzeugt!
+     */
+    public static List<InputOption<?>> createSMTPSettingsDialogOptions(boolean createLabels, Boolean used, String server, boolean auth, String user, String pw, String sender) {
+      List<InputOption<?>> inputOptions = new ArrayList<InputOption<?>>();
+      
+      BooleanInputOption smtpUsed = new BooleanInputOption(createLabels ? R("SMTPSettings.smtp.used") : null,false);
+      InputOption smtpServer      = new ManualInputOption.Text(createLabels ? R("SMTPSettings.smtp.serve") : null,false);
+      BooleanInputOption authUsed = new BooleanInputOption(createLabels ? R("SMTPSettings.auth") : null);
+      InputOption authUser        = new ManualInputOption.Text(createLabels ? R("SMTPSettings.auth.user") : null,false);
+      InputOption authPW          = new ManualInputOption.PasswordViewable(createLabels ? R("SMTPSettings.auth.pw") : null,false);
+      InputOption senderAddr      = new ManualInputOption.Text(createLabels ? R("SMTPSettings.sender.addr") : null,false);
+      
+      if ( used != null)
+        inputOptions.add(smtpUsed);
+      inputOptions.add(smtpServer);
+      inputOptions.add(authUsed);
+      inputOptions.add(authUser);
+      inputOptions.add(authPW);
+      if ( sender != null)
+        inputOptions.add(senderAddr);
+
+      // Connect all options with "Use SMTP-Mail", so that
+      // all of these are disabled when "SMTP-Mail verwenden" is unselected
+      if ( smtpUsed != null )
+        for (int i=1; i<inputOptions.size();i++)
+          smtpUsed.connectInputOptions(true,inputOptions.get(i));  
+      // Connect "User" and "Passwort" with "Authentication required", so that
+      // these are disabled when "Authentication required" is unselected
+      authUsed.connectInputOptions(true,authUser,authPW);
+
+      // Set inital values
+      smtpServer.setValue(server);
+      authUsed.setValue(auth);
+      authUser.setValue(user);
+      authPW.setValue(pw);
+      if ( sender != null )
+        senderAddr.setValue(sender);
+      // Important to set the "Use SMTP" at last, because its selection
+      // state has higher priority for the enabled/disabled-state of
+      // the connected options (than "Authentication required")!
+      if ( used != null )
+        smtpUsed.setValue(used);
+      
+      return inputOptions;
+    }
+
+    /**
+     * Erzeugt (bis zu) 6 {@link InputOption} fuer ein {@link MultipleOptionPane} zur
+     * Abfrage von SMTP-Einstellungen.
+     * <ol>
+     *   <li>{@linkplain BooleanInputOption Eingabe-Feld} ob SMTP-Einstellungen verwendet werden sollen (optional)</li>
+     *   <li>{@linkplain ManualInputOption.Text Eingabe-Feld} fuer Servernamen</li>
+     *   <li>{@linkplain BooleanInputOption Eingabe-Feld} ob Authentifizierung erforderlich ist</li>
+     *   <li>{@linkplain ManualInputOption.Text Eingabe-Feld} fuer Benutzername</li>
+     *   <li>{@linkplain ManualInputOption.Password Eingabe-Feld} fuer Passwort</li>
+     *   <li>{@linkplain ManualInputOption.Text Eingabe-Feld} fuer Absender-Mail-Adresse (optional)</li>
+     * </ol>
+     * @param createLabels wenn {@code false} werden die {@link InputOption} ohne
+     *                     Labels erzeugt
+     * @param inclUsed gibt an, ob eine {@link InputOption} fuer "SMTP-Settings verwenden"
+     *                 erzeugt werden sollt
+     * @param inclSender gibt an, ob eine {@link InputOption} fuer die Mail-Absender-Adresse
+     *                   erzeugt werden sollt
+     */
+    public static List<InputOption<?>> createSMTPSettingsDialogOptions(boolean createLabels, boolean inclUsed, boolean inclSender) {
+      return createSMTPSettingsDialogOptions(createLabels,
+                                             inclUsed ? Boolean.TRUE : null,
+                                             "",
+                                             false,
+                                             "",
+                                             "",
+                                             inclSender ? "" : null);
+    }
+    
 	/**
 	 * Erzeugt 5 {@link InputOption} fuer ein {@link MultipleOptionPane} zur
 	 * Datenbank-Anmeldung.

Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2012-10-05 13:02:12 UTC (rev 2101)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2012-10-06 18:10:52 UTC (rev 2102)
@@ -305,3 +305,10 @@
 ConnectionSettingsPanel.conn.timeout=Connection timeout (ms)
 ConnectionSettingsPanel.conn.readtimeout=Connection read timeout (ms)
 ConnectionSettingsPanel.conn.retries=Number of connection/download retries
+
+SMTPSettings.smtp.used=Use SMTP-Mail
+SMTPSettings.smtp.server=SMTP server name
+SMTPSettings.auth=Authentication required
+SMTPSettings.auth.user=User name
+SMTPSettings.auth.pw=Password
+SMTPSettings.sender.addr=Sender mail address

Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties	2012-10-05 13:02:12 UTC (rev 2101)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/swing/resource/locales/SwingResourceBundle_de.properties	2012-10-06 18:10:52 UTC (rev 2102)
@@ -278,3 +278,10 @@
 ConnectionSettingsPanel.conn.timeout=Verbindungs-Timeout (ms)
 ConnectionSettingsPanel.conn.readtimeout=Read-Timeout (ms)
 ConnectionSettingsPanel.conn.retries=Anzahl an Wiederhol-Versuchen f\u00FCr Verbindungsaufbau/Download
+
+SMTPSettings.smtp.used=SMTP-Mail verwenden
+SMTPSettings.smtp.server=SMTP-Server
+SMTPSettings.auth=Authentifizierung erforderlich
+SMTPSettings.auth.user=Benutzer
+SMTPSettings.auth.pw=Passwort
+SMTPSettings.sender.addr=Absender-Mailadresse

Modified: trunk/schmitzm-core/src/test/java/de/schmitzm/testing/SwingUtilTest.java
===================================================================
--- trunk/schmitzm-core/src/test/java/de/schmitzm/testing/SwingUtilTest.java	2012-10-05 13:02:12 UTC (rev 2101)
+++ trunk/schmitzm-core/src/test/java/de/schmitzm/testing/SwingUtilTest.java	2012-10-06 18:10:52 UTC (rev 2102)
@@ -15,9 +15,11 @@
 import org.junit.Ignore;
 import org.junit.Test;
 
+import de.schmitzm.io.SMTPSettings;
 import de.schmitzm.swing.EditableComboBox;
 import de.schmitzm.swing.ExceptionDialog;
 import de.schmitzm.swing.JPanel;
+import de.schmitzm.swing.SMTPSettingsPanel;
 import de.schmitzm.swing.SwingUtil;
 import de.schmitzm.swing.input.FileInputOption;
 import de.schmitzm.swing.input.ManualInputOption;
@@ -146,4 +148,36 @@
       
       TestingUtil.testGui(panel,-1);
 	}
+	
+	@Test
+//	@Ignore
+	public void testSMTPSettingsPanel() throws Throwable {
+	  boolean smtpUsed = true;
+	  String server = "testserver";
+	  boolean authUsed = true;
+	  String authUser = "test";
+	  String password = "test123";
+	  String senderAddr = "noreply at testserver.com";
+	  
+	  SMTPSettings settings = new SMTPSettings();
+	  settings.setSMTPUsed(smtpUsed);
+      settings.setServer(server);
+      settings.setAuthUsed(authUsed);
+      settings.setAuthUser(authUser);
+      settings.setAuthPassword(password);
+      settings.setSenderAddress(senderAddr);
+	  
+	  SMTPSettingsPanel panel = new SMTPSettingsPanel(true, true);
+	  panel.setSMTPSettings(settings);
+	  
+	  settings = panel.getSMTPSettings();
+	  assertEquals(smtpUsed, settings.isSMTPUsed());
+	  assertEquals(server,settings.getServer());
+	  assertEquals(authUsed,settings.isAuthUsed());
+	  assertEquals(authUser,settings.getAuthUser());
+	  assertEquals(password,settings.getAuthPassword() != null ? String.valueOf(settings.getAuthPassword()) : null);
+	  assertEquals(senderAddr,settings.getSenderAddress());
+	  
+//	  TestingUtil.testGui(panel,-1);
+	}
 }
\ No newline at end of file



More information about the Schmitzm-commits mailing list