Last change
on this file since 12562 was 11171, checked in by simon04, 8 years ago |
Fix MOTD image link replacement
Avoids downloading images which are contained in the JOSM distribution.
|
File size:
1.3 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertFalse;
|
---|
5 |
|
---|
6 | import java.io.IOException;
|
---|
7 |
|
---|
8 | import org.junit.BeforeClass;
|
---|
9 | import org.junit.Test;
|
---|
10 | import org.openstreetmap.josm.JOSMFixture;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Tests the {@link GettingStarted} class.
|
---|
14 | */
|
---|
15 | public class GettingStartedTest {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Setup test.
|
---|
19 | */
|
---|
20 | @BeforeClass
|
---|
21 | public static void init() {
|
---|
22 | JOSMFixture.createFunctionalTestFixture().init();
|
---|
23 | }
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Tests that image links are replaced.
|
---|
27 | *
|
---|
28 | * @throws IOException if any I/O error occurs
|
---|
29 | */
|
---|
30 | @Test
|
---|
31 | public void testImageReplacement() throws IOException {
|
---|
32 | final String motd = new GettingStarted.MotdContent().updateIfRequiredString();
|
---|
33 | // assuming that the MOTD contains one image included, fixImageLinks changes the HTML string
|
---|
34 | assertFalse(GettingStarted.fixImageLinks(motd).equals(motd));
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Tests that image links are replaced.
|
---|
39 | */
|
---|
40 | @Test
|
---|
41 | public void testImageReplacementStatic() {
|
---|
42 | final String html = "the download button <img src=\"/browser/trunk/images/download.png?format=raw\" " +
|
---|
43 | "alt=\"source:trunk/images/download.png\" title=\"source:trunk/images/download.png\" />.";
|
---|
44 | assertFalse(GettingStarted.fixImageLinks(html).equals(html));
|
---|
45 |
|
---|
46 | }
|
---|
47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.