Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ef212d1344ba554b60c3cc3667e7f099bed257aa (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
/*******************************************************************************
 * Copyright (c) 2008, 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.other;

import static org.junit.Assert.fail;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

import org.junit.Test;

public class ResourceTest {
	@Test
	public void testHelpUIResources() throws IllegalArgumentException, IllegalAccessException {
		checkFields(org.eclipse.help.ui.internal.Messages.class);
	}

	@Test
	public void testHelpBaseResources() throws IllegalArgumentException, IllegalAccessException {
		checkFields(org.eclipse.help.internal.base.HelpBaseResources.class);
	}

	@Test
	public void testCheatsheetResources() throws IllegalArgumentException, IllegalAccessException {
		checkFields(org.eclipse.ui.internal.cheatsheets.Messages.class);
	}

	@Test
	public void testIntroResources() throws IllegalArgumentException, IllegalAccessException {
		checkFields(org.eclipse.ui.internal.intro.impl.Messages.class);
	}

	@Test
	public void testUniversalIntroResources() throws IllegalArgumentException, IllegalAccessException {
		checkFields(org.eclipse.ui.internal.intro.universal.Messages.class);
	}

	private void checkFields(Class<?> messages) throws IllegalAccessException {
		Field[] fields = messages.getFields();
		for (Field field : fields) {
			int modifiers = field.getModifiers();
			if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers)) {
				Object value = field.get(null);
				if (value instanceof String) {
					String stringValue = (String)value;
					if (stringValue.startsWith("NLS missing message")) {
						fail("Missing resource for " + field.getName());
					}
				}
			}
		}
	}

}

Back to the top