Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ca97940fbf19b8eae900de2ec2a72846a1da328d (plain) (blame)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*******************************************************************************
 * Copyright (c) 2009, 2016 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.ua.tests.help.remote;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import java.io.IOException;

import org.eclipse.help.internal.base.BaseHelpSystem;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class ContentServletTest {

	private static final String UA_TESTS = "org.eclipse.ua.tests";
	private int mode;

	@Before
	public void setUp() throws Exception {
		BaseHelpSystem.ensureWebappRunning();
		mode = BaseHelpSystem.getMode();
		BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
	}

	@After
	public void tearDown() throws Exception {
		BaseHelpSystem.setMode(mode);
	}

	@Test
	public void testSimpleContent() throws Exception {
		final String path = "/data/help/index/topic1.html";
		String remoteContent = RemoteTestUtils.getRemoteContent(UA_TESTS, path, "en");
		String localContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
	    assertEquals(remoteContent, localContent);
	}

	@Test
	public void testFilteredContent() throws Exception {
		final String path = "/data/help/manual/filter.xhtml";
		String remoteContent = RemoteTestUtils.getRemoteContent(UA_TESTS, path, "en");
		String localContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
	    assertEquals(remoteContent, localContent);
	}

	@Test
	public void testContentInEnLocale() throws Exception {
		final String path = "/data/help/search/testnl1.xhtml";
		String remoteContent = RemoteTestUtils.getRemoteContent(UA_TESTS, path, "en");
		String localContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
	    assertEquals(remoteContent, localContent);
	}

	@Test
	public void testContentInDeLocale() throws Exception {
		final String path = "/data/help/search/testnl1.xhtml";
		String remoteContent = RemoteTestUtils.getRemoteContent(UA_TESTS, path, "de");
		String enLocalContent = RemoteTestUtils.getLocalContent(UA_TESTS, path);
		String deLocalContent = RemoteTestUtils.getLocalContent(UA_TESTS, "/nl/de" + path);
	    assertEquals(remoteContent, deLocalContent);
	    assertFalse(remoteContent.equals(enLocalContent));
	}

	@Test(expected = IOException.class)
	public void testRemoteContentNotFound() throws Exception {
		RemoteTestUtils.getRemoteContent(UA_TESTS, "/no/such/path.html", "en");
	}



}

Back to the top