Fix NLSTest and RootLocalTest for JUnit 4

These test classes needed new @Test annotations to be found by the
JUnit 4 test runner.

Change-Id: I61b6a8ebd468fa2d13fad5bf9cbd8f81a6f67e41
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2011-01-02 14:30:55 -08:00
parent 117d081f44
commit e026cfab38
2 changed files with 43 additions and 20 deletions

View File

@ -51,8 +51,11 @@
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
public class TestNLS {
import org.junit.Test;
public class NLSTest {
@Test
public void testNLSLocale() {
NLS.setLocale(NLS.ROOT_LOCALE);
GermanTranslatedBundle bundle = GermanTranslatedBundle.get();
@ -63,6 +66,7 @@ public void testNLSLocale() {
assertEquals(Locale.GERMAN, bundle.effectiveLocale());
}
@Test
public void testJVMDefaultLocale() {
Locale.setDefault(NLS.ROOT_LOCALE);
NLS.useJVMDefaultLocale();
@ -75,6 +79,7 @@ public void testJVMDefaultLocale() {
assertEquals(Locale.GERMAN, bundle.effectiveLocale());
}
@Test
public void testThreadTranslationBundleInheritance() throws InterruptedException {
class T extends Thread {
@ -100,6 +105,7 @@ public void run() {
assertSame(mainThreadsBundle, t.bundle);
}
@Test
public void testParallelThreadsWithDifferentLocales() throws InterruptedException {
final CyclicBarrier barrier = new CyclicBarrier(2);

View File

@ -41,33 +41,50 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.stringext;
package org.eclipse.jgit.nls;
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.awtui.UIText;
import org.eclipse.jgit.console.ConsoleText;
import org.eclipse.jgit.http.server.HttpServerText;
import org.eclipse.jgit.iplog.IpLogText;
import org.eclipse.jgit.nls.NLS;
import org.eclipse.jgit.pgm.CLIText;
import org.junit.Before;
import org.junit.Test;
public class TestStringExternalization {
private static Class[] translationBundleClasses = new Class[] {
ConsoleText.class, HttpServerText.class, IpLogText.class, CLIText.class,
UIText.class, JGitText.class,
};
/**
* Verifies that all translation keys are defined in the root resource bundle.
* <p>
* This makes sure that all translation bundles will get all strings populated
* since the string will be found at last in the root resource bundle.
*/
public void testAllTranslationKeysDefinedInRoot() {
public class RootLocaleTest {
@Before
public void setUp() {
NLS.setLocale(NLS.ROOT_LOCALE);
for (Class c : translationBundleClasses) {
NLS.getBundleFor(c);
}
}
@Test
public void testJGitText() {
NLS.getBundleFor(JGitText.class);
}
@Test
public void testHttpServerText() {
NLS.getBundleFor(HttpServerText.class);
}
@Test
public void testConsoleText() {
NLS.getBundleFor(ConsoleText.class);
}
@Test
public void testCLIText() {
NLS.getBundleFor(CLIText.class);
}
@Test
public void testUIText() {
NLS.getBundleFor(UIText.class);
}
@Test
public void testIpLogText() {
NLS.getBundleFor(IpLogText.class);
}
}