Package KFM.test

Source Code of KFM.test.SmtpTest

/*
*  This software and supporting documentation were developed by
*
*    Siemens Corporate Technology
*    Competence Center Knowledge Management and Business Transformation
*    D-81730 Munich, Germany
*
*    Authors (representing a really great team ;-) )
*            Stefan B. Augustin, Thorbj�rn Hansen, Manfred Langen
*
*  This software is Open Source under GNU General Public License (GPL).
*  Read the text of this license in LICENSE.TXT
*  or look at www.opensource.org/licenses/
*
*  Once more we emphasize, that:
*  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  WITHOUT ANY WARRANTY
*  REGARDING  THE  SOFTWARE,  ITS  PERFORMANCE OR
*  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR
*  ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
*  PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
*
*/


// SmtpTest

// Package
package KFM.test;

// Imports

// This application/module packages
import appl.Portal.Test.*;

// Other application/module packages
import junit.framework.*;

// KFM packages
import KFM.Smtp;

// Library classes (JHDK, JSDK, RegExp, ...)

// Java packages
import java.util.*;

/** One sentence about SmtpTest.
*
* <P>SmtpTest documentation.</P>
*
* <H2>Usage</H2>
*
* <P>Usage.</P>
*
* <H2>Related classes</H2>
*
* <P>Cut&paste-source was `P_Test�.</P>
*
* <PRE>
* - ServletTestCase -- Father class.
* </PRE>
*
* @version 0.1 (2001 04 25)
* @see ServletTestCase
*/
public class SmtpTest extends ServletTestCase
{

    // ************************************************************
    // Inner classes
    // ************************************************************

    // ************************************************************
    // Constants
    // ************************************************************

    // ************************************************************
    // Variables
    // ************************************************************

    private static String mServer = null;
    private static String mTo = null;
    private static String mToSeveral = null;
    private static String mFrom = null;

    // ************************************************************
    // Methods
    // ************************************************************

    /** SmtpTest
     *
     * Constructor for this class.
     */
    public SmtpTest(String aName) {
        super(aName);
    }

    public void testSmtpSend()
    {
        String tBody = "JUNIT:KFM.test.SmtpTest";
        String tData = "Subject: JUNIT:KFM.test.SmtpTest\n\n"; // this is terrible

        assertTrue("mServer should not be null", mServer != null);
        assertTrue("mTo should not be null", mTo != null);
        assertTrue("mFrom should not be null", mFrom != null);

        Smtp tMail = new Smtp(
            mServer,
            mTo,
            mFrom,
            tData + tBody);

        assertTrue("Expected no problems sending mails, but some problem occured",
            tMail.result() /* isOK */);

        /* now we should make sure we received the mail via POP3, etc. */
    }

    public void testSmtpSendToSeveral()
    {
        String tBody = "JUNIT:KFM.test.SmtpTest";
        String tData = "Subject: JUNIT:KFM.test.SmtpTest\n\n"; // this is terrible

        assertTrue("mServer should not be null", mServer != null);
        assertTrue("mTo should not be null", mToSeveral != null);
        assertTrue("mFrom should not be null", mFrom != null);

        Smtp tMail = new Smtp(
            mServer,
            mToSeveral,
            mFrom,
            tData + tBody,
            true /* to several receipients */);

        assertTrue("Expected no problems sending mails, but some problem occured",
            tMail.result() /* isOK */);

        /* now we should make sure we received the mail via POP3, etc. */
    }

    public void initialize() {
        String tStr;
        super.initialize();

        tStr = getProperties().getProperty("smtp.server");
        if(tStr != null) {
            mServer = tStr;
        }
        tStr = getProperties().getProperty("smtp.to");
        if(tStr != null) {
            mTo = tStr;
        }
        tStr = getProperties().getProperty("smtp.toSeveral");
        if(tStr != null) {
            mToSeveral = tStr;
        }
        tStr = getProperties().getProperty("smtp.from");
        if(tStr != null) {
            mFrom = tStr;
        }
    }

    public static Test suite() {
        // * Create a dummy object of this class
        SmtpTest tObj = new SmtpTest(null);
        tObj.initialize();

        boolean allTests = true;
        TestSuite suite = null;
        if(allTests) {
            // Create a new TestSuite with name of this class
            //   which contains all basic tests in this class (void test*())
            suite = new TestSuite(SmtpTest.class);
        } else {
            // Create a new TestSuite with the name "SmtpTest"
            suite = new TestSuite("SmtpTest");
            // Add one of our Tests to this TestSuite
            suite.addTest(new SmtpTest("testName"));
        }
        return suite;
    }

    // ************************************************************
    // Debugging
    // ************************************************************

TOP

Related Classes of KFM.test.SmtpTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.