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 |
package com.nokia.helium.internaldata.tests;
|
|
18 |
|
|
19 |
import static org.junit.Assert.assertFalse;
|
|
20 |
|
|
21 |
import java.io.BufferedReader;
|
|
22 |
import java.io.File;
|
|
23 |
import java.io.FileReader;
|
|
24 |
|
|
25 |
import org.apache.log4j.Level;
|
|
26 |
import org.apache.log4j.LogManager;
|
628
|
27 |
import org.apache.log4j.Logger;
|
587
|
28 |
import org.junit.Test;
|
|
29 |
|
|
30 |
import com.nokia.helium.internaldata.ant.listener.EmailDataSender;
|
|
31 |
|
|
32 |
public class TestEmailDataSender {
|
|
33 |
|
|
34 |
@Test
|
|
35 |
public void testSendData(){
|
|
36 |
EmailDataSender emailDataSender = new EmailDataSender();
|
|
37 |
Logger log = Logger.getLogger(EmailDataSender.class);
|
|
38 |
log.setLevel(Level.DEBUG);
|
|
39 |
emailDataSender.sendData("Helium antlib internaldata junit test");
|
|
40 |
LogManager.shutdown(); // to flush the log output to file
|
|
41 |
String fileContent = "";
|
|
42 |
String fileName = "hlm_debug.log";
|
|
43 |
|
|
44 |
try {
|
|
45 |
BufferedReader br = new BufferedReader(new FileReader(fileName));
|
|
46 |
String s;
|
|
47 |
while((s = br.readLine()) != null) {
|
|
48 |
fileContent = fileContent + s;
|
|
49 |
}
|
|
50 |
br.close();
|
|
51 |
}
|
|
52 |
catch (Exception e){
|
|
53 |
System.out.println("File hlm_debug.log can not be read" + e.getMessage() + e);
|
|
54 |
}
|
|
55 |
// delete the debug log which we created
|
|
56 |
File f = new File(fileName);
|
|
57 |
boolean success = f.delete();
|
|
58 |
if (!success){
|
|
59 |
throw new IllegalArgumentException("Delete: deletion failed");
|
|
60 |
}
|
|
61 |
assertFalse(fileContent.contains("Internal data failure:"));
|
|
62 |
}
|
|
63 |
}
|
|
64 |
|
|
65 |
|