1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/*******************************************************************************
* Copyright (c) 2004 - 2006 University Of British Columbia and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* University Of British Columbia - initial API and implementation
*******************************************************************************/
package org.eclipse.mylar.bugzilla.tests;
import java.io.IOException;
import java.text.ParseException;
import javax.security.auth.login.LoginException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylar.internal.bugzilla.core.BugzillaTask;
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
/**
* @author Mik Kersten
*/
public class EncodingTest extends AbstractBugzillaTest {
public void testEncodingSetting() throws LoginException, IOException, ParseException {
String charset = BugzillaClient.getCharsetFromString("text/html; charset=UTF-8");
assertEquals("UTF-8", charset);
charset = BugzillaClient.getCharsetFromString("text/html");
assertEquals(null, charset);
charset = BugzillaClient
.getCharsetFromString("<<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-2\">>");
assertEquals("iso-8859-2", charset);
charset = BugzillaClient
.getCharsetFromString("<<meta http-equiv=\"Content-Type\" content=\"text/html\">>");
assertEquals(null, charset);
}
/**
* This test just shows that when the encoding is changed on the repository
* synchronization does in fact return in a different encoding (though it
* may not be legible)
*/
public void testDifferentReportEncoding() throws CoreException {
init222();
repository.setCharacterEncoding("UTF-8");
BugzillaTask task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "57", null);
assertNotNull(task);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
assertTrue(task.getDescription().equals("\u05D0"));
taskList.deleteTask(task);
connector.getClientManager().repositoryRemoved(repository);
repository.setCharacterEncoding("ISO-8859-1");
task = (BugzillaTask) connector.createTaskFromExistingKey(repository, "57", null);
assertNotNull(task);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
// iso-8859-1 'incorrect' interpretation
assertFalse(task.getDescription().equals("\u05D0"));
}
}
|