Adjusts tests

This commit is contained in:
Lukasz Lenart
2017-03-13 09:10:26 +01:00
parent ca0f62925a
commit f784a16cb7
3 changed files with 16 additions and 35 deletions
@@ -76,40 +76,15 @@ public class CompositeTextProviderTest extends XWorkTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
textProvider = new CompositeTextProvider(new TextProvider[] {
new TextProviderSupport(ResourceBundle.getBundle("com.opensymphony.xwork2.validator.CompositeTextProviderTestResourceBundle1"),
new LocaleProvider() {
public Locale getLocale() {
return Locale.ENGLISH;
}
@Override
public boolean isValidLocaleString(String localeStr) {
return true;
}
TextProviderFactory tpf = container.getInstance(TextProviderFactory.class);
tpf.setTextProvider(null);
@Override
public boolean isValidLocale(Locale locale) {
return true;
}
}),
new TextProviderSupport(ResourceBundle.getBundle("com.opensymphony.xwork2.validator.CompositeTextProviderTestResourceBundle2"),
new LocaleProvider() {
public Locale getLocale() {
return Locale.ENGLISH;
}
@Override
public boolean isValidLocaleString(String localeStr) {
return true;
}
@Override
public boolean isValidLocale(Locale locale) {
return true;
}
})
ActionContext.getContext().setLocale(Locale.ENGLISH);
textProvider = new CompositeTextProvider(new TextProvider[]{
tpf.createInstance(ResourceBundle.getBundle("com.opensymphony.xwork2.validator.CompositeTextProviderTestResourceBundle1")),
tpf.createInstance(ResourceBundle.getBundle("com.opensymphony.xwork2.validator.CompositeTextProviderTestResourceBundle2"))
});
}
@@ -16,7 +16,6 @@
package com.opensymphony.xwork2;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import junit.framework.TestCase;
import java.util.*;
@@ -25,7 +24,7 @@ import java.util.*;
*
* @author Claus Ibsen
*/
public class DefaultTextProviderTest extends TestCase {
public class DefaultTextProviderTest extends XWorkTestCase {
private DefaultTextProvider tp;
@@ -127,6 +126,8 @@ public class DefaultTextProviderTest extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
ActionContext ctx = new ActionContext(new HashMap<String, Object>());
ActionContext.setContext(ctx);
ctx.setLocale(Locale.CANADA);
@@ -134,7 +135,7 @@ public class DefaultTextProviderTest extends TestCase {
LocalizedTextUtil.clearDefaultResourceBundles();
LocalizedTextUtil.addDefaultResourceBundle(DefaultTextProviderTest.class.getName());
tp = new DefaultTextProvider();
tp = container.inject(DefaultTextProvider.class);
}
@Override
@@ -16,6 +16,8 @@
package com.opensymphony.xwork2;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -108,6 +110,9 @@ public class TextProviderSupportTest extends XWorkTestCase {
protected void setUp() throws Exception {
super.setUp();
rb = ResourceBundle.getBundle(TextProviderSupportTest.class.getName(), Locale.ENGLISH);
LocalizedTextUtil ltu = container.getInstance(LocalizedTextUtil.class);
tp = new TextProviderSupport(rb, new LocaleProvider() {
public Locale getLocale() {
return Locale.ENGLISH;
@@ -122,7 +127,7 @@ public class TextProviderSupportTest extends XWorkTestCase {
public boolean isValidLocale(Locale locale) {
return true;
}
});
}, ltu);
}
@Override