@Test
public void testValidLocales() {

    assertEquals(new Locale("nl"), LocaleUtil.parse("nl"));
    assertEquals(new Locale("nl", "NL"), LocaleUtil.parse("nl_nl"));
    assertEquals(new Locale("", "NL"), LocaleUtil.parse("_NL"));
    assertEquals(new Locale("nl", "NL"), LocaleUtil.parse("nl_NL"));
    assertEquals(new Locale("nl", "", "MAC"), LocaleUtil.parse("nl__MAC"));
    assertEquals(new Locale("nl", "NL", "MAC"), LocaleUtil.parse("nl_NL_MAC"));
    assertEquals(new Locale("", "NL", "MAC"), LocaleUtil.parse("_NL_MAC"));
    assertEquals(new Locale("es", "ES", "Traditional_WIN"), LocaleUtil.parse("es_ES_Traditional_WIN"));
    // Maybe not a very useful case, but since variant can contain '_' the following is allowed.
    assertEquals(new Locale("nl", "", "_"), LocaleUtil.parse("nl___"));
}