01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.core.tests.internal.databinding.conversion;
11:
12: import junit.framework.TestCase;
13:
14: import org.eclipse.core.internal.databinding.BindingMessages;
15: import org.eclipse.core.internal.databinding.conversion.DateConversionSupport;
16:
17: import com.ibm.icu.text.DateFormat;
18: import com.ibm.icu.text.SimpleDateFormat;
19:
20: /**
21: * @since 1.1
22: */
23: public class DateConversionSupportTest extends TestCase {
24: public void testDatePatternIsExternalized() throws Exception {
25: StubConverter stub = new StubConverter();
26: String key = "DateFormat_DateTime";
27: String format = BindingMessages.getString(key);
28:
29: assertFalse("format is defined", key.equals(format));
30: SimpleDateFormat dateFormat = (SimpleDateFormat) stub
31: .getDateFormat(0);
32: assertEquals(format, dateFormat.toPattern());
33: }
34:
35: public void testTimePatternIsExternalized() throws Exception {
36: StubConverter stub = new StubConverter();
37: String key = "DateFormat_Time";
38: String format = BindingMessages.getString(key);
39:
40: assertFalse("format is defined", key.equals(format));
41: SimpleDateFormat dateFormat = (SimpleDateFormat) stub
42: .getDateFormat(1);
43: assertEquals(format, dateFormat.toPattern());
44: }
45:
46: static class StubConverter extends DateConversionSupport {
47: protected DateFormat getDateFormat(int index) {
48: return super.getDateFormat(index);
49: }
50: }
51: }
|