// Path: cal10n-api/src/test/java/ch/qos/cal10n/sample/Colors.java
// @BaseName("colors")
// @LocaleData( { @Locale("en_UK"), @Locale("fr") })
// public enum Colors {
//   // sub-class for testing purposes
//   RED {
// 
//   },
//   BLUE, GREEN;
// }


import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.Locale;
import java.util.ResourceBundle;
import org.junit.Test;
import ch.qos.cal10n.sample.Colors;
/*
 * Copyright (c) 2009 QOS.ch All rights reserved.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS  IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package ch.qos.cal10n.util;





public class CAL10NResourceBundleFinderTest {
  ResourceBundle rb;
  String encoding;

  AnnotationExtractorViaEnumClass annotationExtractor = new AnnotationExtractorViaEnumClass(Colors.class);
  CAL10NBundleFinderByClassloader cal10NBundleFinderByClassloader = new CAL10NBundleFinderByClassloader(this.getClass().getClassLoader());

  @Test
  public void smoke() throws IOException {
    encoding = annotationExtractor.extractCharset(Locale.FRENCH);
    rb = cal10NBundleFinderByClassloader.getBundle("colors", Locale.FRENCH, encoding);
    assertEquals("les roses sont rouges", rb.getString("RED"));
  }

  @Test
  public void withCountry() throws IOException {
    encoding = annotationExtractor.extractCharset(Locale.FRENCH);
    rb = cal10NBundleFinderByClassloader.getBundle("colors", Locale.FRENCH, encoding);
    assertEquals("les roses sont rouges", rb.getString("RED"));

    rb = cal10NBundleFinderByClassloader.getBundle("colors", Locale.FRANCE, encoding);
    assertEquals("les roses sont rouges, et alors?", rb.getString("RED"));
  }

  @Test
  public void inDirectory() throws IOException {
// Path: cal10n-api/src/test/java/ch/qos/cal10n/sample/Colors.java
// @BaseName("colors")
// @LocaleData( { @Locale("en_UK"), @Locale("fr") })
// public enum Colors {
//   // sub-class for testing purposes
//   RED {
// 
//   },
//   BLUE, GREEN;
// }


// Path: cal10n-api/src/test/java/ch/qos/cal10n/util/CAL10NResourceBundleFinderTest.java
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.Locale;
import java.util.ResourceBundle;
import org.junit.Test;
import ch.qos.cal10n.sample.Colors;

/*
 * Copyright (c) 2009 QOS.ch All rights reserved.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS  IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package ch.qos.cal10n.util;





public class CAL10NResourceBundleFinderTest {
  ResourceBundle rb;
  String encoding;

  AnnotationExtractorViaEnumClass annotationExtractor = new AnnotationExtractorViaEnumClass(Colors.class);
  CAL10NBundleFinderByClassloader cal10NBundleFinderByClassloader = new CAL10NBundleFinderByClassloader(this.getClass().getClassLoader());

  @Test
  public void smoke() throws IOException {
    encoding = annotationExtractor.extractCharset(Locale.FRENCH);
    rb = cal10NBundleFinderByClassloader.getBundle("colors", Locale.FRENCH, encoding);
    assertEquals("les roses sont rouges", rb.getString("RED"));
  }

  @Test
  public void withCountry() throws IOException {
    encoding = annotationExtractor.extractCharset(Locale.FRENCH);
    rb = cal10NBundleFinderByClassloader.getBundle("colors", Locale.FRENCH, encoding);
    assertEquals("les roses sont rouges", rb.getString("RED"));

    rb = cal10NBundleFinderByClassloader.getBundle("colors", Locale.FRANCE, encoding);
    assertEquals("les roses sont rouges, et alors?", rb.getString("RED"));
  }

  @Test
  public void inDirectory() throws IOException {
    encoding = annotationExtractor.extractCharset(Locale.ENGLISH);