587
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
package com.nokia.helium.signaling.tests;
|
|
19 |
|
628
|
20 |
import java.io.File;
|
|
21 |
|
587
|
22 |
import org.apache.tools.ant.Project;
|
628
|
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;
|
587
|
30 |
|
|
31 |
public class TestEmailSender {
|
|
32 |
|
|
33 |
@Before
|
|
34 |
public void setUp() {
|
|
35 |
}
|
|
36 |
|
|
37 |
@After
|
|
38 |
public void tearDown() {
|
|
39 |
}
|
|
40 |
|
|
41 |
/**
|
|
42 |
* @throws Exception
|
|
43 |
*/
|
|
44 |
@Test
|
628
|
45 |
public void test_simpleEmailNotification() throws Exception {
|
587
|
46 |
EMAILNotifier en = new EMAILNotifier();
|
|
47 |
Project p = new Project();
|
|
48 |
p.setNewProperty("user.name", "test");
|
|
49 |
en.setProject(p);
|
628
|
50 |
en.setNotifyWhen((NotifyWhenEnum)NotifyWhenEnum.getInstance(NotifyWhenEnum.class, "always"));
|
587
|
51 |
en.setTitle("test");
|
|
52 |
en.setSmtp("test");
|
|
53 |
en.setLdap("test");
|
|
54 |
NotifierInput input = new NotifierInput();
|
|
55 |
input.setFile(new File(System.getProperty("testdir") + "/tests/data/test.log_status.html"));
|
|
56 |
en.sendData("test", true, input, "Test Message");
|
|
57 |
}
|
|
58 |
|
628
|
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 |
}
|
587
|
76 |
|
|
77 |
} |