buildframework/helium/sf/java/signaling/tests/src/com/nokia/helium/signaling/tests/TestEmailSender.java
changeset 628 7c4a911dc066
parent 587 85df38eb4012
child 645 b8d81fa19e7d
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 package com.nokia.helium.signaling.tests;
    18 package com.nokia.helium.signaling.tests;
    19 
    19 
    20 import org.junit.*;
    20 import java.io.File;
    21 import static org.junit.Assert.*;
    21 
    22 import java.io.*;
       
    23 import java.util.*;
       
    24 import com.nokia.helium.signal.ant.types.*;
       
    25 import org.apache.tools.ant.Project;
    22 import org.apache.tools.ant.Project;
       
    23 import org.junit.After;
       
    24 import org.junit.Before;
       
    25 import org.junit.Test;
       
    26 
       
    27 import com.nokia.helium.signal.ant.types.EMAILNotifier;
       
    28 import com.nokia.helium.signal.ant.types.NotifierInput;
       
    29 import com.nokia.helium.signal.ant.types.NotifyWhenEnum;
    26 
    30 
    27 public class TestEmailSender {
    31 public class TestEmailSender {
    28     
    32     
    29     @Before
    33     @Before
    30     public void setUp() {
    34     public void setUp() {
    36     
    40     
    37     /**
    41     /**
    38      * @throws Exception
    42      * @throws Exception
    39      */
    43      */
    40     @Test
    44     @Test
    41     public void test_simpleMergeNode() throws Exception {
    45     public void test_simpleEmailNotification() throws Exception {
    42         EMAILNotifier en = new EMAILNotifier();
    46         EMAILNotifier en = new EMAILNotifier();
    43         Project p = new Project();
    47         Project p = new Project();
    44         p.setNewProperty("user.name", "test");
    48         p.setNewProperty("user.name", "test");
    45         en.setProject(p);
    49         en.setProject(p);
    46         en.setNotifyWhen("always");
    50         en.setNotifyWhen((NotifyWhenEnum)NotifyWhenEnum.getInstance(NotifyWhenEnum.class, "always"));
    47         en.setTitle("test");
    51         en.setTitle("test");
    48         en.setSmtp("test");
    52         en.setSmtp("test");
    49         en.setLdap("test");
    53         en.setLdap("test");
    50         NotifierInput input = new NotifierInput();
    54         NotifierInput input = new NotifierInput();
    51         input.setFile(new File(System.getProperty("testdir") + "/tests/data/test.log_status.html"));
    55         input.setFile(new File(System.getProperty("testdir") + "/tests/data/test.log_status.html"));
    52         en.sendData("test", true, input, "Test Message");
    56         en.sendData("test", true, input, "Test Message");
    53     }
    57     }
    54 
    58 
    55    
    59     /**
       
    60      * This test should not fail the build, when no log are found, or default template 
       
    61      * is missing just skip the notification and log an error.
       
    62      * @throws Exception
       
    63      */
       
    64     public void test_emailNotificationWithoutNotifyFileAndTemplate() throws Exception {
       
    65         EMAILNotifier en = new EMAILNotifier();
       
    66         Project p = new Project();
       
    67         p.setNewProperty("user.name", "test");
       
    68         en.setProject(p);
       
    69         en.setNotifyWhen((NotifyWhenEnum)NotifyWhenEnum.getInstance(NotifyWhenEnum.class, "always"));
       
    70         en.setTitle("test");
       
    71         en.setSmtp("test");
       
    72         en.setLdap("test");
       
    73         NotifierInput input = new NotifierInput();
       
    74         en.sendData("test", true, input, "Test Message");
       
    75     }   
    56 
    76 
    57 }
    77 }