apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/environment/PortalMetaServerProviderTest.java
@Test
    public void testDynamicEnvironmentFromSystemProperty() {
        String someDevMetaAddress = "someMetaAddress";
        String someFatMetaAddress = "someFatMetaAddress";
        System.setProperty("dev_meta", someDevMetaAddress);
        System.setProperty("fat_meta", someFatMetaAddress);
        // reload above added
        PortalMetaServerProvider.reloadAll();
        assertEquals(someDevMetaAddress, PortalMetaServerProvider.getMetaServerAddress(Env.DEV));
        assertEquals(someFatMetaAddress, PortalMetaServerProvider.getMetaServerAddress(Env.FAT));

        String randomAddress = "randomAddress";
        String randomEnvironment = "randomEnvironment";
        System.setProperty(randomEnvironment + "_meta", randomAddress);
        // reload above added
        PortalMetaServerProvider.reloadAll();
        assertEquals(
                randomAddress,
                PortalMetaServerProvider.getMetaServerAddress(
                        Env.valueOf(randomEnvironment)
                )
        );

        // clear the property
        System.clearProperty(randomEnvironment + "_meta");
    }
/**
     * testing the environment dynamic added from system property
     */
testing the environment dynamic added from system property
testing the environment dynamic added from system property
@Test
    public void testDynamicEnvironmentFromSystemProperty() {
        String someDevMetaAddress = "someMetaAddress";
        String someFatMetaAddress = "someFatMetaAddress";
        System.setProperty("dev_meta", someDevMetaAddress);
        System.setProperty("fat_meta", someFatMetaAddress);
        PortalMetaServerProvider.reloadAll();
        assertEquals(someDevMetaAddress, PortalMetaServerProvider.getMetaServerAddress(Env.DEV));
        assertEquals(someFatMetaAddress, PortalMetaServerProvider.getMetaServerAddress(Env.FAT));
        String randomAddress = "randomAddress";
        String randomEnvironment = "randomEnvironment";
        System.setProperty(randomEnvironment + "_meta", randomAddress);
        PortalMetaServerProvider.reloadAll();
        assertEquals(
                randomAddress,
                PortalMetaServerProvider.getMetaServerAddress(
                        Env.valueOf(randomEnvironment)
                )
        );
        System.clearProperty(randomEnvironment + "_meta");
    }
@ Test public void testDynamicEnvironmentFromSystemProperty ( ) { String someDevMetaAddress = "someMetaAddress" ; String someFatMetaAddress = "someFatMetaAddress" ; System . setProperty ( "dev_meta" , someDevMetaAddress ) ; System . setProperty ( "fat_meta" , someFatMetaAddress ) ; PortalMetaServerProvider . reloadAll ( ) ; assertEquals ( someDevMetaAddress , PortalMetaServerProvider . getMetaServerAddress ( Env . DEV ) ) ; assertEquals ( someFatMetaAddress , PortalMetaServerProvider . getMetaServerAddress ( Env . FAT ) ) ; String randomAddress = "randomAddress" ; String randomEnvironment = "randomEnvironment" ; System . setProperty ( randomEnvironment + "_meta" , randomAddress ) ; PortalMetaServerProvider . reloadAll ( ) ; assertEquals ( randomAddress , PortalMetaServerProvider . getMetaServerAddress ( Env . valueOf ( randomEnvironment ) ) ) ; System . clearProperty ( randomEnvironment + "_meta" ) ; }
testing the environment dynamic added from system property
testing the environment dynamic added from system property
// reload above added // reload above added // clear the property