Package de.odysseus.calyxo.control.impl

Source Code of de.odysseus.calyxo.control.impl.DefaultI18nSupportTest

/*
* Copyright 2004, 2005, 2006 Odysseus Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.odysseus.calyxo.control.impl;

import java.util.ArrayList;
import java.util.Locale;

import de.odysseus.calyxo.base.test.TestPageContext;
import de.odysseus.calyxo.base.test.TestRequest;

import junit.framework.TestCase;

/**
*
* @author Christoph Beck
*/
public class DefaultI18nSupportTest extends TestCase {
  private final String BUNDLE_NAME =
    getClass().getPackage().getName() + ".resources";

  /**
   * Constructor for DefaultI18nSupportTest.
   * @param arg0
   */
  public DefaultI18nSupportTest(String arg0) {
    super(arg0);
  }

  public static void main(String[] args) {
    junit.textui.TestRunner.run(DefaultI18nSupportTest.class);
  }

  public void testLocale() {
    TestRequest request = new TestRequest();
    Locale locale = new Locale("cc", "");
    DefaultI18nSupport support = new DefaultI18nSupport();
    support.setLocale(request, locale);
    assertSame(locale, support.getLocale(request));
    assertSame(locale, support.getLocale(new TestPageContext(request)));
  }
 
  public void testResource() {
    Locale locale = new Locale("cc", "");
    DefaultI18nSupport support = new DefaultI18nSupport();
    String s = support.getResource(locale, BUNDLE_NAME, "msg0");
    assertEquals("message0", s);
  }

  public void testMessage() {
    Locale locale = new Locale("cc", "");
    DefaultI18nSupport support = new DefaultI18nSupport();
    ArrayList args = new ArrayList();
    String s = null;

    s = support.getMessage(locale, BUNDLE_NAME, "msg0", args.toArray());
    assertEquals("message0", s);
    args.add("arg1");
    s = support.getMessage(locale, BUNDLE_NAME, "msg1", args.toArray());
    assertEquals("message1: arg1", s);
    args.add("arg2");
    s = support.getMessage(locale, BUNDLE_NAME, "msg2", args.toArray());
    assertEquals("message2: arg1, arg2", s);
  }
}
TOP

Related Classes of de.odysseus.calyxo.control.impl.DefaultI18nSupportTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.