Java 类org.joda.time.tz.DefaultNameProvider 实例源码

项目:RIT-Dining-Planner-Android    文件:TestDateTimeZone.java   
public void testNameProvider() {
    try {
        assertNotNull(DateTimeZone.getNameProvider());

        NameProvider provider = DateTimeZone.getNameProvider();
        DateTimeZone.setNameProvider(null);
        assertEquals(provider.getClass(), DateTimeZone.getNameProvider().getClass());

        provider = new MockOKButNullNameProvider();
        DateTimeZone.setNameProvider(provider);
        assertSame(provider, DateTimeZone.getNameProvider());

        assertEquals("+00:00", DateTimeZone.UTC.getShortName(TEST_TIME_SUMMER));
        assertEquals("+00:00", DateTimeZone.UTC.getName(TEST_TIME_SUMMER));
    } finally {
        DateTimeZone.setNameProvider(null);
    }

    try {
        System.setProperty("org.joda.time.DateTimeZone.NameProvider", "org.joda.time.tz.DefaultNameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    } finally {
        System.getProperties().remove("org.joda.time.DateTimeZone.NameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    }
}
项目:RIT-Dining-Planner-Android    文件:TestDateTimeZone.java   
public void testNameProvider_badClassName() {
    try {
        System.setProperty("org.joda.time.DateTimeZone.NameProvider", "xxx");
        DateTimeZone.setProvider(null);

    } catch (RuntimeException ex) {
        // expected
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    } finally {
        System.getProperties().remove("org.joda.time.DateTimeZone.NameProvider");
        DateTimeZone.setProvider(null);
    }
}
项目:astor    文件:TestDateTimeZone.java   
public void testNameProvider() {
    try {
        assertNotNull(DateTimeZone.getNameProvider());

        NameProvider provider = DateTimeZone.getNameProvider();
        DateTimeZone.setNameProvider(null);
        assertEquals(provider.getClass(), DateTimeZone.getNameProvider().getClass());

        provider = new MockOKButNullNameProvider();
        DateTimeZone.setNameProvider(provider);
        assertSame(provider, DateTimeZone.getNameProvider());

        assertEquals("+00:00", DateTimeZone.UTC.getShortName(TEST_TIME_SUMMER));
        assertEquals("+00:00", DateTimeZone.UTC.getName(TEST_TIME_SUMMER));
    } finally {
        DateTimeZone.setNameProvider(null);
    }

    try {
        System.setProperty("org.joda.time.DateTimeZone.NameProvider", "org.joda.time.tz.DefaultNameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    } finally {
        System.getProperties().remove("org.joda.time.DateTimeZone.NameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    }
}
项目:astor    文件:TestDateTimeZone.java   
public void testNameProvider_badClassName() {
    try {
        System.setProperty("org.joda.time.DateTimeZone.NameProvider", "xxx");
        DateTimeZone.setProvider(null);

    } catch (RuntimeException ex) {
        // expected
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    } finally {
        System.getProperties().remove("org.joda.time.DateTimeZone.NameProvider");
        DateTimeZone.setProvider(null);
    }
}
项目:joda-time-android    文件:TestDateTimeZone.java   
public void testNameProvider() {
    try {
        assertNotNull(DateTimeZone.getNameProvider());

        NameProvider provider = DateTimeZone.getNameProvider();
        DateTimeZone.setNameProvider(null);
        assertEquals(provider.getClass(), DateTimeZone.getNameProvider().getClass());

        provider = new MockOKButNullNameProvider();
        DateTimeZone.setNameProvider(provider);
        assertSame(provider, DateTimeZone.getNameProvider());

        assertEquals("+00:00", DateTimeZone.UTC.getShortName(TEST_TIME_SUMMER));
        assertEquals("+00:00", DateTimeZone.UTC.getName(TEST_TIME_SUMMER));
    } finally {
        DateTimeZone.setNameProvider(null);
    }

    try {
        System.setProperty("org.joda.time.DateTimeZone.NameProvider", "org.joda.time.tz.DefaultNameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    } finally {
        System.getProperties().remove("org.joda.time.DateTimeZone.NameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    }
}
项目:joda-time-android    文件:TestDateTimeZone.java   
public void testNameProvider_badClassName() {
    try {
        System.setProperty("org.joda.time.DateTimeZone.NameProvider", "xxx");
        DateTimeZone.setProvider(null);

    } catch (RuntimeException ex) {
        // expected
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    } finally {
        System.getProperties().remove("org.joda.time.DateTimeZone.NameProvider");
        DateTimeZone.setProvider(null);
    }
}
项目:astor    文件:TestDateTimeZone.java   
public void testNameProvider() {
    try {
        assertNotNull(DateTimeZone.getNameProvider());

        NameProvider provider = DateTimeZone.getNameProvider();
        DateTimeZone.setNameProvider(null);
        assertEquals(provider.getClass(), DateTimeZone.getNameProvider().getClass());

        provider = new MockOKButNullNameProvider();
        DateTimeZone.setNameProvider(provider);
        assertSame(provider, DateTimeZone.getNameProvider());

        assertEquals("+00:00", DateTimeZone.UTC.getShortName(TEST_TIME_SUMMER));
        assertEquals("+00:00", DateTimeZone.UTC.getName(TEST_TIME_SUMMER));
    } finally {
        DateTimeZone.setNameProvider(null);
    }

    try {
        System.setProperty("org.joda.time.DateTimeZone.NameProvider", "org.joda.time.tz.DefaultNameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    } finally {
        System.getProperties().remove("org.joda.time.DateTimeZone.NameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    }

    PrintStream syserr = System.err;
    try {
        System.setProperty("org.joda.time.DateTimeZone.NameProvider", "xxx");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        System.setErr(new PrintStream(baos));

        DateTimeZone.setNameProvider(null);

        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
        String str = new String(baos.toByteArray());
        assertTrue(str.indexOf("java.lang.ClassNotFoundException") >= 0);
    } finally {
        System.setErr(syserr);
        System.getProperties().remove("org.joda.time.DateTimeZone.NameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    }
}
项目:versemem-android    文件:TestDateTimeZone.java   
public void testNameProvider() {
    try {
        assertNotNull(DateTimeZone.getNameProvider());

        NameProvider provider = DateTimeZone.getNameProvider();
        DateTimeZone.setNameProvider(null);
        assertEquals(provider.getClass(), DateTimeZone.getNameProvider().getClass());

        provider = new MockOKButNullNameProvider();
        DateTimeZone.setNameProvider(provider);
        assertSame(provider, DateTimeZone.getNameProvider());

        assertEquals("+00:00", DateTimeZone.UTC.getShortName(TEST_TIME_SUMMER));
        assertEquals("+00:00", DateTimeZone.UTC.getName(TEST_TIME_SUMMER));
    } finally {
        DateTimeZone.setNameProvider(null);
    }

    try {
        System.setProperty("org.joda.time.DateTimeZone.NameProvider", "org.joda.time.tz.DefaultNameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    } finally {
        System.getProperties().remove("org.joda.time.DateTimeZone.NameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    }

    PrintStream syserr = System.err;
    try {
        System.setProperty("org.joda.time.DateTimeZone.NameProvider", "xxx");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        System.setErr(new PrintStream(baos));

        DateTimeZone.setNameProvider(null);

        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
        String str = new String(baos.toByteArray());
        assertTrue(str.indexOf("java.lang.ClassNotFoundException") >= 0);
    } finally {
        System.setErr(syserr);
        System.getProperties().remove("org.joda.time.DateTimeZone.NameProvider");
        DateTimeZone.setNameProvider(null);
        assertEquals(DefaultNameProvider.class, DateTimeZone.getNameProvider().getClass());
    }
}