geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationDUnitTest.java
@Test // FlakyTest: GEODE-1334
  public void testCreateExtensions() throws Exception {
    Object[] result = setup();
    final int locatorPort = (Integer) result[0];

    createRegion(REPLICATE_REGION, RegionShortcut.REPLICATE, null);
    createMockRegionExtension(REPLICATE_REGION, "value1");
    alterMockRegionExtension(REPLICATE_REGION, "value2");
    createMockCacheExtension("value1");
    alterMockCacheExtension("value2");

    // Start a new member which receives the shared configuration
    // Verify the config creation on this member

    final String newMemberWorkDir =
        this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + newMember;

    VM newMember = getHost(0).getVM(2);
    newMember.invoke(() -> {
      Properties localProps = new Properties();

      File workingDir = new File(newMemberWorkDir);
      workingDir.mkdirs();

      localProps.setProperty(MCAST_PORT, "0");
      localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
      localProps.setProperty(NAME, ClusterConfigurationDUnitTest.newMember);
      localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
      localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath());

      getSystem(localProps);
      InternalCache cache = getCache();

      assertNotNull(cache);

      Region<?, ?> region1 = cache.getRegion(REPLICATE_REGION);
      assertNotNull(region1);

      // MockRegionExtension verification
      @SuppressWarnings("unchecked")
      // should only be one region extension
      final MockRegionExtension mockRegionExtension =
          (MockRegionExtension) ((Extensible<Region<?, ?>>) region1).getExtensionPoint()
              .getExtensions().iterator().next();
      assertNotNull(mockRegionExtension);
      assertEquals(1, mockRegionExtension.beforeCreateCounter.get());
      assertEquals(1, mockRegionExtension.onCreateCounter.get());
      assertEquals("value2", mockRegionExtension.getValue());

      // MockCacheExtension verification
      @SuppressWarnings("unchecked")
      // should only be one cache extension
      final MockCacheExtension mockCacheExtension =
          (MockCacheExtension) cache.getExtensionPoint().getExtensions().iterator().next();
      assertNotNull(mockCacheExtension);
      assertEquals(1, mockCacheExtension.beforeCreateCounter.get());
      assertEquals(1, mockCacheExtension.onCreateCounter.get());
      assertEquals("value2", mockCacheExtension.getValue());

      return getAllNormalMembers(cache);
    });
  }
/**
   * Tests for {@link Extension}, {@link Extensible}, {@link XmlParser}, {@link XmlGenerator},
   * {@link XmlEntity} as it applies to Extensions. Asserts that Mock Extension is created and
   * altered on region and cache.
   * 
   * @since GemFire 8.1
   */
Tests for  Extension,  Extensible,  XmlParser,  XmlGenerator,
XmlEntity as it applies to Extensions. Asserts that Mock Extension is created and
altered on region and cache.


Tests for Extension Extensible XmlParser XmlGenerator XmlEntity as it applies to Extensions . Asserts that Mock Extension is created and altered on region and cache .
@Test 
  public void testCreateExtensions() throws Exception {
    Object[] result = setup();
    final int locatorPort = (Integer) result[0];
    createRegion(REPLICATE_REGION, RegionShortcut.REPLICATE, null);
    createMockRegionExtension(REPLICATE_REGION, "value1");
    alterMockRegionExtension(REPLICATE_REGION, "value2");
    createMockCacheExtension("value1");
    alterMockCacheExtension("value2");
    final String newMemberWorkDir =
        this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + newMember;
    VM newMember = getHost(0).getVM(2);
    newMember.invoke(() -> {
      Properties localProps = new Properties();
      File workingDir = new File(newMemberWorkDir);
      workingDir.mkdirs();
      localProps.setProperty(MCAST_PORT, "0");
      localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
      localProps.setProperty(NAME, ClusterConfigurationDUnitTest.newMember);
      localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
      localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath());
      getSystem(localProps);
      InternalCache cache = getCache();
      assertNotNull(cache);
      Region<?, ?> region1 = cache.getRegion(REPLICATE_REGION);
      assertNotNull(region1);
      @SuppressWarnings("unchecked")
      final MockRegionExtension mockRegionExtension =
          (MockRegionExtension) ((Extensible<Region<?, ?>>) region1).getExtensionPoint()
              .getExtensions().iterator().next();
      assertNotNull(mockRegionExtension);
      assertEquals(1, mockRegionExtension.beforeCreateCounter.get());
      assertEquals(1, mockRegionExtension.onCreateCounter.get());
      assertEquals("value2", mockRegionExtension.getValue());
      @SuppressWarnings("unchecked")
      final MockCacheExtension mockCacheExtension =
          (MockCacheExtension) cache.getExtensionPoint().getExtensions().iterator().next();
      assertNotNull(mockCacheExtension);
      assertEquals(1, mockCacheExtension.beforeCreateCounter.get());
      assertEquals(1, mockCacheExtension.onCreateCounter.get());
      assertEquals("value2", mockCacheExtension.getValue());
      return getAllNormalMembers(cache);
    });
  }
@ Test public void testCreateExtensions ( ) throws Exception { Object [ ] result = setup ( ) ; final int locatorPort = ( Integer ) result [ 0 ] ; createRegion ( REPLICATE_REGION , RegionShortcut . REPLICATE , null ) ; createMockRegionExtension ( REPLICATE_REGION , "value1" ) ; alterMockRegionExtension ( REPLICATE_REGION , "value2" ) ; createMockCacheExtension ( "value1" ) ; alterMockCacheExtension ( "value2" ) ; final String newMemberWorkDir = this . temporaryFolder . getRoot ( ) . getCanonicalPath ( ) + File . separator + newMember ; VM newMember = getHost ( 0 ) . getVM ( 2 ) ; newMember . invoke ( ( ) -> { Properties localProps = new Properties ( ) ; File workingDir = new File ( newMemberWorkDir ) ; workingDir . mkdirs ( ) ; localProps . setProperty ( MCAST_PORT , "0" ) ; localProps . setProperty ( LOCATORS , "localhost[" + locatorPort + "]" ) ; localProps . setProperty ( NAME , ClusterConfigurationDUnitTest . newMember ) ; localProps . setProperty ( USE_CLUSTER_CONFIGURATION , "true" ) ; localProps . setProperty ( DEPLOY_WORKING_DIR , workingDir . getCanonicalPath ( ) ) ; getSystem ( localProps ) ; InternalCache cache = getCache ( ) ; assertNotNull ( cache ) ; Region < ? , ? > region1 = cache . getRegion ( REPLICATE_REGION ) ; assertNotNull ( region1 ) ; @ SuppressWarnings ( "unchecked" ) final MockRegionExtension mockRegionExtension = ( MockRegionExtension ) ( ( Extensible < Region < ? , ? > > ) region1 ) . getExtensionPoint ( ) . getExtensions ( ) . iterator ( ) . next ( ) ; assertNotNull ( mockRegionExtension ) ; assertEquals ( 1 , mockRegionExtension . beforeCreateCounter . get ( ) ) ; assertEquals ( 1 , mockRegionExtension . onCreateCounter . get ( ) ) ; assertEquals ( "value2" , mockRegionExtension . getValue ( ) ) ; @ SuppressWarnings ( "unchecked" ) final MockCacheExtension mockCacheExtension = ( MockCacheExtension ) cache . getExtensionPoint ( ) . getExtensions ( ) . iterator ( ) . next ( ) ; assertNotNull ( mockCacheExtension ) ; assertEquals ( 1 , mockCacheExtension . beforeCreateCounter . get ( ) ) ; assertEquals ( 1 , mockCacheExtension . onCreateCounter . get ( ) ) ; assertEquals ( "value2" , mockCacheExtension . getValue ( ) ) ; return getAllNormalMembers ( cache ) ; } ) ; }
Tests for {@link Extension}, {@link Extensible}, {@link XmlParser}, {@link XmlGenerator},
 {@link XmlEntity} as it applies to Extensions.
Tests for { @link Extension } { @link Extensible } { @link XmlParser } { @link XmlGenerator } { @link XmlEntity } as it applies to Extensions .
// FlakyTest: GEODE-1334 // Start a new member which receives the shared configuration // Verify the config creation on this member // MockRegionExtension verification // should only be one region extension // MockCacheExtension verification // should only be one cache extension