ConfigurePDXCommand extends SingleGfshCommand { protected ReflectionBasedAutoSerializer createReflectionBasedAutoSerializer( boolean checkPortability, String[] patterns) { return new ReflectionBasedAutoSerializer(checkPortability, patterns); }  @CliCommand(value = CliStrings.CONFIGURE_PDX, help = CliStrings.CONFIGURE_PDX__HELP) @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION, interceptor = "org.apache.geode.management.internal.cli.commands.ConfigurePDXCommand$Interceptor") @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER, operation = ResourcePermission.Operation.MANAGE) ResultModel configurePDX(
      @CliOption(key = CliStrings.CONFIGURE_PDX__READ__SERIALIZED,
          unspecifiedDefaultValue = "false",
          help = CliStrings.CONFIGURE_PDX__READ__SERIALIZED__HELP) Boolean readSerialized,
      @CliOption(key = CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS,
          unspecifiedDefaultValue = "false",
          help = CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS__HELP) Boolean ignoreUnreadFields,
      @CliOption(key = CliStrings.CONFIGURE_PDX__DISKSTORE, specifiedDefaultValue = "DEFAULT",
          help = CliStrings.CONFIGURE_PDX__DISKSTORE__HELP) String diskStore,
      @CliOption(key = CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES,
          help = CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES__HELP) String[] nonPortableClassesPatterns,
      @CliOption(key = CliStrings.CONFIGURE_PDX__PORTABLE__AUTO__SERIALIZER__CLASSES,
          help = CliStrings.CONFIGURE_PDX__PORTABLE__AUTO__SERIALIZER__CLASSES__HELP) String[] portableClassesPatterns); @Override boolean updateConfigForGroup(String group, CacheConfig config, Object configObject);  }
@Test public void executionShouldCorrectlyConfigurePersistenceWhenDefaultDiskStoreIsUsed() { gfshParserRule.executeAndAssertThat(command, BASE_COMMAND_STRING + "--disk-store") .statusIsSuccess().containsOutput("persistent = true") .containsOutput("disk-store = DEFAULT").containsOutput("read-serialized = false") .containsOutput("ignore-unread-fields = false"); verify(clusterConfigurationService, times(1)).updateCacheConfig(any(), any()); verify(command, times(0)).createReflectionBasedAutoSerializer(anyBoolean(), any()); }
@Test public void executionShouldCorrectlyConfigurePersistenceWhenCustomDiskStoreIsUsed() { gfshParserRule.executeAndAssertThat(command, BASE_COMMAND_STRING + "--disk-store=myDiskStore") .statusIsSuccess().containsOutput("persistent = true") .containsOutput("disk-store = myDiskStore").containsOutput("read-serialized = false") .containsOutput("ignore-unread-fields = false"); verify(clusterConfigurationService, times(1)).updateCacheConfig(any(), any()); verify(command, times(0)).createReflectionBasedAutoSerializer(anyBoolean(), any()); }
@Test public void executionShouldCorrectlyConfigureReadSerializedWhenFlagIsSetAsTrue() { gfshParserRule.executeAndAssertThat(command, BASE_COMMAND_STRING + "--read-serialized=true") .statusIsSuccess().containsOutput("persistent = false") .containsOutput("read-serialized = true").containsOutput("ignore-unread-fields = false"); verify(clusterConfigurationService, times(1)).updateCacheConfig(any(), any()); verify(command, times(0)).createReflectionBasedAutoSerializer(anyBoolean(), any()); }
@Test public void executionShouldCorrectlyConfigureReadSerializedWhenFlagIsSetAsFalse() { gfshParserRule.executeAndAssertThat(command, BASE_COMMAND_STRING + "--read-serialized=false") .statusIsSuccess().containsOutput("persistent = false") .containsOutput("read-serialized = false").containsOutput("ignore-unread-fields = false"); verify(clusterConfigurationService, times(1)).updateCacheConfig(any(), any()); verify(command, times(0)).createReflectionBasedAutoSerializer(anyBoolean(), any()); }
@Test public void executionShouldCorrectlyConfigureIgnoreUnreadFieldsWhenFlagIsSetAsTrue() { gfshParserRule .executeAndAssertThat(command, BASE_COMMAND_STRING + "--ignore-unread-fields=true") .statusIsSuccess().containsOutput("persistent = false") .containsOutput("read-serialized = false").containsOutput("ignore-unread-fields = true"); verify(clusterConfigurationService, times(1)).updateCacheConfig(any(), any()); verify(command, times(0)).createReflectionBasedAutoSerializer(anyBoolean(), any()); }
@Test public void executionShouldCorrectlyConfigureIgnoreUnreadFieldsWhenFlagIsSetAsFalse() { gfshParserRule .executeAndAssertThat(command, BASE_COMMAND_STRING + "--ignore-unread-fields=false") .statusIsSuccess().containsOutput("persistent = false") .containsOutput("read-serialized = false").containsOutput("ignore-unread-fields = false"); verify(clusterConfigurationService, times(1)).updateCacheConfig(any(), any()); verify(command, times(0)).createReflectionBasedAutoSerializer(anyBoolean(), any()); }
@Test public void executionShouldCorrectlyConfigurePortableAutoSerializableClassesWhenUsingCustomPattern() { String[] patterns = new String[] {"com.company.DomainObject.*#identity=id"}; gfshParserRule .executeAndAssertThat(command, BASE_COMMAND_STRING + "--portable-auto-serializable-classes=" + patterns[0]) .statusIsSuccess().containsOutput("persistent = false") .containsOutput("read-serialized = false").containsOutput("ignore-unread-fields = false") .containsOutput("Portable Classes = [com.company.DomainObject.*#identity=id]") .containsOutput("PDX Serializer = org.apache.geode.pdx.ReflectionBasedAutoSerializer"); verify(clusterConfigurationService, times(1)).updateCacheConfig(any(), any()); verify(command, times(1)).createReflectionBasedAutoSerializer(true, patterns); }
@Test public void executionShouldCorrectlyConfigureAutoSerializableClassesWhenUsingCustomPattern() { String[] patterns = new String[] {"com.company.DomainObject.*#identity=id"}; gfshParserRule .executeAndAssertThat(command, BASE_COMMAND_STRING + "--auto-serializable-classes=" + patterns[0]) .statusIsSuccess().containsOutput("persistent = false") .containsOutput("read-serialized = false").containsOutput("ignore-unread-fields = false") .containsOutput("Non Portable Classes = [com.company.DomainObject.*#identity=id]") .containsOutput("PDX Serializer = org.apache.geode.pdx.ReflectionBasedAutoSerializer"); verify(clusterConfigurationService, times(1)).updateCacheConfig(any(), any()); verify(command, times(1)).createReflectionBasedAutoSerializer(false, patterns); }