/** Test method for {@link at.spardat.enterprise.fmt.ABooleanFmt#mayBeAppliedTo(byte)}. */ public void testMayBeAppliedTo() { IFmt fmt = ABooleanFmt.getInstance(ABooleanFmt.SHORT, Locale.GERMAN); assertTrue(fmt.mayBeAppliedTo(Types.T_BOOLEAN)); assertFalse(fmt.mayBeAppliedTo(Types.T_BCD)); assertFalse(fmt.mayBeAppliedTo(Types.T_DATE)); assertFalse(fmt.mayBeAppliedTo(Types.T_DOM)); assertFalse(fmt.mayBeAppliedTo(Types.T_STRING)); assertFalse(fmt.mayBeAppliedTo(Types.T_TIMESTAMP)); }
/** * Test method for {@link * at.spardat.enterprise.fmt.ABooleanFmt#isLegalInternal(java.lang.String)}. */ public void testIsLegalInternal() { IFmt fmt = ABooleanFmt.getInstance(ABooleanFmt.SHORT, Locale.GERMAN); assertTrue(fmt.isLegalInternal("")); assertTrue(fmt.isLegalInternal("J")); assertTrue(fmt.isLegalInternal("N")); assertFalse(fmt.isLegalInternal(" ")); assertFalse(fmt.isLegalInternal("0")); assertFalse(fmt.isLegalInternal("1")); // internal for all locals the same fmt = ABooleanFmt.getInstance(ABooleanFmt.SHORT, new Locale("CS")); assertTrue(fmt.isLegalInternal("")); assertTrue(fmt.isLegalInternal("J")); assertTrue(fmt.isLegalInternal("N")); assertFalse(fmt.isLegalInternal(" ")); assertFalse(fmt.isLegalInternal("0")); assertFalse(fmt.isLegalInternal("1")); }
/** Test method for {@link at.spardat.enterprise.fmt.ABooleanFmt#format(java.lang.String)}. */ public void testFormat() { IFmt fmt = ABooleanFmt.getInstance(ABooleanFmt.SHORT, Locale.GERMAN); assertEquals("J", fmt.format("J")); assertEquals("N", fmt.format("N")); fmt = ABooleanFmt.getInstance(ABooleanFmt.LONG, Locale.GERMAN); assertEquals("ja", fmt.format("J")); assertEquals("nein", fmt.format("N")); fmt = ABooleanFmt.getInstance(ABooleanFmt.SHORT, Locale.ENGLISH); assertEquals("Y", fmt.format("J")); assertEquals("N", fmt.format("N")); fmt = ABooleanFmt.getInstance(ABooleanFmt.LONG, Locale.ENGLISH); assertEquals("yes", fmt.format("J")); assertEquals("no", fmt.format("N")); fmt = ABooleanFmt.getInstance(ABooleanFmt.SHORT, new Locale("ru")); assertEquals("Д", fmt.format("J")); assertEquals("Н", fmt.format("N")); fmt = ABooleanFmt.getInstance(ABooleanFmt.LONG, new Locale("ru")); assertEquals("да", fmt.format("J")); assertEquals("нет", fmt.format("N")); fmt = ABooleanFmt.getInstance(ABooleanFmt.SHORT, new Locale("sk")); assertEquals("Á", fmt.format("J")); assertEquals("N", fmt.format("N")); fmt = ABooleanFmt.getInstance(ABooleanFmt.LONG, new Locale("sk")); assertEquals("áno", fmt.format("J")); assertEquals("nie", fmt.format("N")); }
/** Test method for {@link at.spardat.enterprise.fmt.ABooleanFmt#parse(java.lang.String)}. */ public void testParse() { IFmt fmt = ABooleanFmt.getInstance(ABooleanFmt.LONG, Locale.GERMAN); assertEquals("J", fmt.parse("ja")); assertEquals("J", fmt.parse("j")); assertEquals("J", fmt.parse("JA")); assertEquals("J", fmt.parse("J")); assertEquals("N", fmt.parse("nein")); assertEquals("N", fmt.parse("ne")); assertEquals("N", fmt.parse("NEI")); assertEquals("N", fmt.parse("n")); assertEquals("N", fmt.parse("N")); assertEquals("", fmt.parse("")); try { fmt.parse("yes"); assertFalse(true); } catch (AParseException exc) { assertEquals("Bitte geben Sie ja oder nein ein.", exc.getUIMessage(Locale.GERMAN)); } fmt.setMandatory(true); try { fmt.parse(""); assertFalse(true); } catch (AParseException exc) { assertEquals("Eingabe erforderlich.", exc.getUIMessage(Locale.GERMAN)); } fmt = ABooleanFmt.getInstance(ABooleanFmt.SHORT, Locale.GERMAN); assertEquals("J", fmt.parse("ja")); assertEquals("J", fmt.parse("j")); assertEquals("J", fmt.parse("JA")); assertEquals("J", fmt.parse("J")); assertEquals("N", fmt.parse("nein")); assertEquals("N", fmt.parse("ne")); assertEquals("N", fmt.parse("NEI")); assertEquals("N", fmt.parse("n")); assertEquals("N", fmt.parse("N")); assertEquals("", fmt.parse("")); try { fmt.parse("yes"); assertFalse(true); } catch (AParseException exc) { assertEquals("Bitte geben Sie J oder N ein.", exc.getUIMessage(Locale.GERMAN)); } fmt = ABooleanFmt.getInstance(ABooleanFmt.LONG, new Locale("ru")); assertEquals("J", fmt.parse("да")); assertEquals("J", fmt.parse("д")); assertEquals("J", fmt.parse("Д")); assertEquals("N", fmt.parse("нет")); assertEquals("N", fmt.parse("Нет")); assertEquals("N", fmt.parse("н")); assertEquals("N", fmt.parse("Н")); assertEquals("", fmt.parse("")); try { fmt.parse("yes"); assertFalse(true); } catch (AParseException exc) { assertEquals("Пожалуйста, введите либо да или нет.", exc.getUIMessage(new Locale("ru"))); } }
/** Test method for {@link at.spardat.enterprise.fmt.ABooleanFmt#isOneWay()}. */ public void testIsOneWay() { IFmt fmt = ABooleanFmt.getInstance(ABooleanFmt.SHORT, Locale.GERMAN); assertFalse(fmt.isOneWay()); }
/** Test method for {@link at.spardat.enterprise.fmt.ABooleanFmt#maxLenOfExternal()}. */ public void testMaxLenOfExternal() { IFmt fmt = ABooleanFmt.getInstance(ABooleanFmt.SHORT, Locale.GERMAN); assertEquals(4, fmt.maxLenOfExternal()); fmt = ABooleanFmt.getInstance(ABooleanFmt.LONG, Locale.GERMAN); assertEquals(4, fmt.maxLenOfExternal()); }