buildframework/helium/sf/java/signaling/tests/src/com/nokia/helium/signaling/tests/TestEmailSender.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 587 85df38eb4012
child 645 b8d81fa19e7d
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
* All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
* This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
* which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
* Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
* Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
* Description:  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
*/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
package com.nokia.helium.signaling.tests;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    20
import java.io.File;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    21
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
import org.apache.tools.ant.Project;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    23
import org.junit.After;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    24
import org.junit.Before;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    25
import org.junit.Test;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    26
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    27
import com.nokia.helium.signal.ant.types.EMAILNotifier;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    28
import com.nokia.helium.signal.ant.types.NotifierInput;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    29
import com.nokia.helium.signal.ant.types.NotifyWhenEnum;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
public class TestEmailSender {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
    @Before
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
    public void setUp() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
    @After
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
    public void tearDown() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
     * @throws Exception
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
    @Test
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    45
    public void test_simpleEmailNotification() throws Exception {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
        EMAILNotifier en = new EMAILNotifier();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
        Project p = new Project();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
        p.setNewProperty("user.name", "test");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
        en.setProject(p);
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    50
        en.setNotifyWhen((NotifyWhenEnum)NotifyWhenEnum.getInstance(NotifyWhenEnum.class, "always"));
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
        en.setTitle("test");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
        en.setSmtp("test");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
        en.setLdap("test");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
        NotifierInput input = new NotifierInput();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
        input.setFile(new File(System.getProperty("testdir") + "/tests/data/test.log_status.html"));
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
        en.sendData("test", true, input, "Test Message");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    59
    /**
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    60
     * This test should not fail the build, when no log are found, or default template 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    61
     * is missing just skip the notification and log an error.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    62
     * @throws Exception
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    63
     */
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    64
    public void test_emailNotificationWithoutNotifyFileAndTemplate() throws Exception {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    65
        EMAILNotifier en = new EMAILNotifier();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    66
        Project p = new Project();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    67
        p.setNewProperty("user.name", "test");
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    68
        en.setProject(p);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    69
        en.setNotifyWhen((NotifyWhenEnum)NotifyWhenEnum.getInstance(NotifyWhenEnum.class, "always"));
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    70
        en.setTitle("test");
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    71
        en.setSmtp("test");
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    72
        en.setLdap("test");
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    73
        NotifierInput input = new NotifierInput();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    74
        en.sendData("test", true, input, "Test Message");
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    75
    }   
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
}