/**
 * 
 */
package com.hiatus.rez;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

import java.util.ListResourceBundle;
import java.util.Locale;
import java.util.ResourceBundle;

import org.testng.annotations.Test;

import com.google.common.base.Function;

/**
 * TODO
 *
 * @author andrewregan
 *
 */
public class BasicTest {

	private final static Locale	SWITZ_DE = new Locale("de", "CH");

	@Test
	public void doTest() {
		ResourceBundleStore x = new ResourceBundleStore("test", Locale.UK);
		x.registerFinder( new Function<Locale,ResourceBundle>() {
			public final ResourceBundle apply( Locale input) {
				if ( input.equals( Locale.UK )) {
					return new ListResourceBundle() {

						@Override
						protected Object[][] getContents() {
							return new Object[][] { {"name", "Prince Andrew"} };
						}};
				}
				else if ( input.equals( Locale.US )) {
					return new ListResourceBundle() {

						@Override
						protected Object[][] getContents() {
							return new Object[][] { {"name", "Andrew"} };
						}};
				}
				else if ( input.equals(SWITZ_DE)) {
					return new ListResourceBundle() {

						@Override
						protected Object[][] getContents() {
							return new Object[][] { {"name", "Anders"} };
						}};
				}
				return null;
			}
		} );

		assertThat( x.getString( "name", Locale.US), is("Andrew"));
		assertThat( x.getString( "name", Locale.UK), is("Prince Andrew"));
		assertThat( x.getString( "name", Locale.GERMANY), is("Prince Andrew"));
		assertThat( x.getString( "name", SWITZ_DE), is("Anders"));
		assertThat( x.getStringArray("poo", Locale.UK), is( new String[]{"Anders"} ));
	}
}

@@ -1,15 +1,14 @@
 /**%0A *
- 
 %0A */%0Apac
@@ -431,16 +431,91 @@
 , %22CH%22);
+%0A%09private final static Locale%09SWITZ_DE_2 = new Locale(%22de%22, %22CH%22, %22Berne%22);
 %0A%0A%09@Test
@@ -541,16 +541,22 @@
 t() %7B%0A%09%09
+final 
 Resource
@@ -567,17 +567,19 @@
 leStore 
-x
+rbs
  = new R
@@ -619,17 +619,19 @@
 .UK);%0A%09%09
-x
+rbs
 .registe
@@ -716,16 +716,22 @@
 e apply(
+ final
  Locale 
@@ -924,32 +924,50 @@
 %22Prince Andrew%22%7D
+, %7B%22year%22, %221976%22%7D
  %7D;%0A%09%09%09%09%09%09%7D%7D;%0A%09%09
@@ -1369,16 +1369,34 @@
 Anders%22%7D
+, %7B%22year%22, %221981%22%7D
  %7D;%0A%09%09%09%09
@@ -1443,33 +1443,35 @@
 %0A%0A%09%09assertThat( 
-x
+rbs
 .getString( %22nam
@@ -1507,33 +1507,35 @@
 ;%0A%09%09assertThat( 
-x
+rbs
 .getString( %22nam
@@ -1578,33 +1578,35 @@
 ;%0A%09%09assertThat( 
-x
+rbs
 .getString( %22nam
@@ -1654,33 +1654,35 @@
 ;%0A%09%09assertThat( 
-x
+rbs
 .getString( %22nam
@@ -1707,24 +1707,25 @@
 %22Anders%22));%0A
+%0A
 %09%09assertThat
@@ -1730,9 +1730,11 @@
 at( 
-x
+rbs
 .get
@@ -1743,65 +1743,297 @@
 ring
-Array(%22poo%22, Locale.UK), is( new String%5B%5D%7B%22Anders%22%7D 
+( %22year%22, Locale.US), is(%221976%22));%0A%09%09assertThat( rbs.getString( %22year%22, Locale.UK), is(%221976%22));%0A%09%09assertThat( rbs.getString( %22year%22, Locale.GERMANY), is(%221976%22));%0A%09%09assertThat( rbs.getString( %22year%22, SWITZ_DE), is(%221981%22));%0A%09%09assertThat( rbs.getString( %22year%22, SWITZ_DE_2), is(%221981%22
 ));%0A%09%7D%0A%7D
 %0A
@@ -2031,9 +2031,8 @@
 ));%0A%09%7D%0A%7D
-%0A

Test tweaks