📄 otaconfigparsertest.java
字号:
/*
* Funambol is a mobile platform developed by Funambol, Inc.
* Copyright (C) 2003 - 2007 Funambol, Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by
* the Free Software Foundation with the addition of the following permission
* added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
* WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program; if not, see http://www.gnu.org/licenses or write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA.
*
* You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
* 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License
* version 3, these Appropriate Legal Notices must retain the display of the
* "Powered by Funambol" logo. If the display of the logo is not reasonably
* feasible for technical reasons, the Appropriate Legal Notices must display
* the words "Powered by Funambol".
*/
package com.funambol.syncml.client;
import com.funambol.syncml.spds.SyncSource;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
import jmunit.framework.cldc10.AssertionFailedException;
import jmunit.framework.cldc10.TestCase;
import com.funambol.util.Log;
/**
* Testcase for OTAConfigParser
*/
public class OTAConfigParserTest extends TestCase {
/** String for testing URL Configuration*/
public static final String URL = "http://www.funambol.net";
/** String for testing User Configuration*/
public static final String USER = "user";
/** String for testing Password Configuration*/
public static final String PASSWORD = "password";
/** String for testing Visible Name Configuration*/
public static final String VISIBLENAME = "visibleName";
/** String for testing Mail Address Configuration*/
public static final String MAILADDRESS = "mailAddress";
/** String for testing Remote Mail Source URI*/
public static final String REMOTEMAILURI = "REMOTEMAILURI";
/** String for testing Remote Contact Source URI*/
public static final String REMOTECONTACTURI = "REMOTECONTACTURI";
/** String for testing Remote Calendar Source URI*/
public static final String REMOTECALENDARURI = "REMOTECALENDARURI";
/** String for testing Remote task Source URI*/
public static final String REMOTETASKURI = "REMOTETASKURI";
/** String for testing Remote Note Source URI*/
public static final String REMOTENOTEURI = "REMOTENOTEURI";
/** String for testing Remote Briefcase Source URI*/
public static final String REMOTEBRIEFCASEURI = "REMOTEBRIEFCASEURI";
/** String for testing value for Format*/
public static final String FORMAT = "FORMAT";
//This constant won't be valorized in V1
//public static final String LOCALURI = "LOCALURI";
/** Expected sections to be parsed*/
private static int EXPECTED_SECTION_NUMBER = 7;
private ByteArrayInputStream bais;
private byte[] msg;
public OTAConfigMessageParser ocmp;
private OTAConfigMessage message;
public OTAConfigParserTest() throws Exception {
super(6, "OTAConfig Parser Test");
}
/**
* Configure TestCase Environment
*/
public void setUp() throws Exception {
Log.setLogLevel(Log.DEBUG);
ocmp = new OTAConfigMessageParser();
initParserTest();
}
/**
* Clear TestCase Environment
*/
public void tearDown() {
}
/**
* Core test engine
*/
public void test(int testNumber) throws Throwable {
switch(testNumber) {
case 0:
//testParseMessage();
testParseMessageMailSection();
break;
case 1:
testParseMessageContactSection();
break;
case 2:
testParseMessageCalendarSection();
break;
case 3:
testParseMessageTaskSection();
break;
case 4:
testParseMessageNoteUriSection();
break;
case 5:
testParseMessageBriefcaseSection();
break;
default:
break;
}
}
/**
* Test Configuration value after Message parsing
*/
private void testParseMessageMailSection() throws Exception {
boolean result = true;
String msg = "testParseMessageMailSection - Error parsing: \n";
if(!message.getSyncUrl().equals(URL)){
result = false;
msg += ("URL, found: " + message.getSyncUrl() + " instead of: " + URL + "\n");
}
if(!message.getUserName().equals(USER)){
result = false;
msg += ("Username, found: " + message.getUserName() + " instead of: " + USER + "\n");
}
if(!message.getPassword().equals(PASSWORD)){
result = false;
msg += ("Password, found: " + message.getPassword() + " instead of: " + PASSWORD +"\n");
}
if(!message.getRemoteUri(message.MAIL).equals(REMOTEMAILURI)){
result = false;
msg += ("RemoteMailUri, found: " + message.getRemoteUri(message.MAIL)
+ " instead of: " + REMOTEMAILURI+"\n");
}
try{
assertTrue(msg, result);
}
catch (AssertionFailedException asex){
}
}
/**
* Test REMOTECONTACTURI value after Message parsing
*/
private void testParseMessageContactSection() throws Exception {
boolean result = true;
String msg = "testParseMessageContactSection - Error parsing: \n";
if(!message.getRemoteUri(message.CONTACT).equals(REMOTECONTACTURI)){
result = false;
msg += ("RemoteContactURI, found: " + message.getRemoteUri(message.CONTACT)
+ " instead of: " + REMOTECONTACTURI);
}
try{
assertTrue(msg, result);
}
catch (AssertionFailedException asex){
}
}
/**
* Test REMOTECALENDARURI value after Message parsing
*/
private void testParseMessageCalendarSection() throws Exception {
boolean result = true;
String msg = "testParseMessageCalendarSection - Error parsing: \n";
if(!message.getRemoteUri(message.CALENDAR).equals(REMOTECALENDARURI)){
result = false;
msg += ("RemoteCalendarURI, found: " + message.getRemoteUri(message.CALENDAR)
+ " instead of: " + REMOTECALENDARURI);
}
try{
assertTrue(msg, result);
}
catch (AssertionFailedException asex){
}
}
/**
* Test REMOTETASKURI value after Message parsing
*/
private void testParseMessageTaskSection() throws Exception {
boolean result = true;
String msg = "testParseMessageTaskSection - Error parsing: \n";
if(!message.getRemoteUri(message.TASK).equals(REMOTETASKURI)){
result = false;
msg += ("TASK, found: " + message.getRemoteUri(message.TASK)
+ " instead of: " + REMOTETASKURI);
}
try{
assertTrue(msg, result);
}
catch (AssertionFailedException asex){
}
}
/**
* Test REMOTENOTEURI value after Message parsing
*/
private void testParseMessageNoteUriSection() throws Exception {
boolean result = true;
String msg = "testParseMessageNoteUriSection - Error parsing: \n";
if(!message.getRemoteUri(message.NOTE).equals(REMOTENOTEURI)){
result = false;
msg += ("REMOTENOTEURI, found: " + message.getRemoteUri(message.NOTE)
+ " instead of: " + REMOTENOTEURI);
}
try{
assertTrue(msg, result);
}
catch (AssertionFailedException asex){
}
}
/**
* Test REMOTEBRIEFCASEURI value after Message parsing
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -