Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 244017 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilTest.java (+61 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.internal.trac.ui;
10
11
import java.util.regex.Matcher;
12
13
import junit.framework.TestCase;
14
15
/**
16
 * 
17
 * @author David Green
18
 */
19
public class TracHyperlinkUtilTest extends TestCase {
20
	public void testWikiPattern2SinglePositiveMatch() {
21
		Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there");
22
		assertTrue(matcher.find());
23
		assertEquals(matcher.group(0), "HyperLink");
24
		assertFalse(matcher.find());
25
	}
26
27
	public void testWikiPattern2MultiplePositiveMatch() {
28
		Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there and ThereIsAnother");
29
		assertTrue(matcher.find());
30
		assertEquals(matcher.group(0), "HyperLink");
31
		assertTrue(matcher.find());
32
		assertEquals(matcher.group(0), "ThereIsAnother");
33
		assertFalse(matcher.find());
34
	}
35
36
	public void testWikiPattern2SingleNegativeMatch() {
37
		Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("no !HyperLink there");
38
		assertFalse(matcher.find());
39
	}
40
41
	public void testWikiPattern2SinglePositiveMatchAtStartOfLine() {
42
		Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("HyperLink there");
43
		assertTrue(matcher.find());
44
		assertEquals(matcher.group(0), "HyperLink");
45
		assertFalse(matcher.find());
46
	}
47
48
	public void testWikiPattern2SingleNegativeMatchAtStartOfLine() {
49
		Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("!HyperLink there");
50
		assertFalse(matcher.find());
51
	}
52
53
	public void testWikiPattern2MixedPositiveNegativeMatch() {
54
		Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there and ThereIsAnother but !NotHere");
55
		assertTrue(matcher.find());
56
		assertEquals(matcher.group(0), "HyperLink");
57
		assertTrue(matcher.find());
58
		assertEquals(matcher.group(0), "ThereIsAnother");
59
		assertFalse(matcher.find());
60
	}
61
}
(-)src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtil.java (-1 / +1 lines)
Lines 56-62 Link Here
56
56
57
	static Pattern wikiPattern1 = Pattern.compile("wiki:(\\w+)");
57
	static Pattern wikiPattern1 = Pattern.compile("wiki:(\\w+)");
58
58
59
	static Pattern wikiPattern2 = Pattern.compile("(?<![!])[A-Z][a-z0-9]+[A-Z]\\w*");
59
	static Pattern wikiPattern2 = Pattern.compile("((?<!\\!)|^)[A-Z][a-z0-9]+[A-Z]\\w*");
60
60
61
	static Pattern milestonePattern = Pattern.compile("milestone:([\\w\\.]+)");
61
	static Pattern milestonePattern = Pattern.compile("milestone:([\\w\\.]+)");
62
62

Return to bug 244017