1 package be
.nikiroo
.utils
.test
;
5 import be
.nikiroo
.utils
.IOUtils
;
6 import be
.nikiroo
.utils
.resources
.Bundle
;
7 import be
.nikiroo
.utils
.resources
.Bundles
;
8 import be
.nikiroo
.utils
.resources
.Meta
;
10 public class BundleTest
extends TestLauncher
{
12 private B b
= new B();
14 protected boolean isMain() {
18 public BundleTest(String
[] args
) {
19 this("Bundle test", args
);
22 protected BundleTest(String name
, String
[] args
) {
28 addSeries(new BundleTest("After saving/reloading the resources",
31 protected void start() throws Exception
{
32 tmp
= File
.createTempFile("nikiroo-utils", ".test");
35 b
.updateFile(tmp
.getAbsolutePath());
36 Bundles
.setDirectory(tmp
.getAbsolutePath());
41 protected void stop() {
46 protected boolean isMain() {
53 private void addTests() {
56 addTest(new TestCase(pre
+ "getString simple") {
58 public void test() throws Exception
{
59 assertEquals("un", b
.getString(E
.ONE
));
63 addTest(new TestCase(pre
+ "getStringX with null suffix") {
65 public void test() throws Exception
{
66 assertEquals("un", b
.getStringX(E
.ONE
, null));
70 addTest(new TestCase(pre
+ "getStringX with empty suffix") {
72 public void test() throws Exception
{
73 assertEquals(null, b
.getStringX(E
.ONE
, ""));
77 addTest(new TestCase(pre
+ "getStringX with existing suffix") {
79 public void test() throws Exception
{
80 assertEquals("un + suffix", b
.getStringX(E
.ONE
, "suffix"));
84 addTest(new TestCase(pre
+ "getStringX with not existing suffix") {
86 public void test() throws Exception
{
87 assertEquals(null, b
.getStringX(E
.ONE
, "fake"));
91 addTest(new TestCase(pre
+ "getString with UTF-8 content") {
93 public void test() throws Exception
{
94 assertEquals("日本語 Nihongo", b
.getString(E
.JAPANESE
));
104 private class B
extends Bundle
<E
> {
106 super(E
.class, N
.bundle_test
);
112 * Key enum for the {@link Bundle}.
117 @Meta(what
= "", where
= "", format
= "", info
= "")
119 @Meta(what
= "", where
= "", format
= "", info
= "")
121 @Meta(what
= "", where
= "", format
= "", info
= "")
123 @Meta(what
= "", where
= "", format
= "", info
= "")
128 * Name enum for the {@link Bundle}.