diff --git a/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementBeanInfo.java b/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementBeanInfo.java index 6fe8a526..cc4795fa 100644 --- a/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementBeanInfo.java +++ b/src/main/java/com/sngular/kloadgen/config/schemaregistry/SchemaRegistryConfigElementBeanInfo.java @@ -23,8 +23,8 @@ public SchemaRegistryConfigElementBeanInfo() { super(SchemaRegistryConfigElement.class); - createPropertyGroup("schema_registry_config", new String[] {SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_NAME, - SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_URL, SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_PROPERTIES}); + createPropertyGroup("schema_registry_config", new String[] {SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_NAME, SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_URL, + SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_PROPERTIES}); final PropertyDescriptor schemaRegistryName = property(SchemaRegistryConfigElementValue.SCHEMA_REGISTRY_NAME); schemaRegistryName.setPropertyEditorClass(SchemaRegistryNamePropertyEditor.class); diff --git a/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AvroExtractor.java b/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AvroExtractor.java index e73bf921..e2d93c58 100644 --- a/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AvroExtractor.java +++ b/src/main/java/com/sngular/kloadgen/extractor/extractors/avro/AvroExtractor.java @@ -12,11 +12,11 @@ public class AvroExtractor implements ExtractorRegistry { - private static final Map schemaRegistryMap = Map.of(SchemaRegistryEnum.CONFLUENT, new AvroConfluentExtractor(), SchemaRegistryEnum.APICURIO, - new AvroApicurioExtractor()); + private static final Map SCHEMA_REGISTRY_MAP = Map.of(SchemaRegistryEnum.CONFLUENT, new AvroConfluentExtractor(), SchemaRegistryEnum.APICURIO, + new AvroApicurioExtractor()); public final List processSchema(final T schema, final SchemaRegistryEnum registryEnum) { - return schemaRegistryMap.get(registryEnum).processSchema(schema); + return SCHEMA_REGISTRY_MAP.get(registryEnum).processSchema(schema); } public final ParsedSchema processSchema(final String fileContent) { @@ -24,7 +24,7 @@ public final ParsedSchema processSchema(final String fileContent) { } public final List getSchemaNameList(final String schema, final SchemaRegistryEnum registryEnum) { - return schemaRegistryMap.get(registryEnum).getSchemaNameList(schema); + return SCHEMA_REGISTRY_MAP.get(registryEnum).getSchemaNameList(schema); } } \ No newline at end of file diff --git a/src/main/java/com/sngular/kloadgen/sampler/SamplerUtil.java b/src/main/java/com/sngular/kloadgen/sampler/SamplerUtil.java index cd0e7180..80dc89be 100644 --- a/src/main/java/com/sngular/kloadgen/sampler/SamplerUtil.java +++ b/src/main/java/com/sngular/kloadgen/sampler/SamplerUtil.java @@ -33,7 +33,6 @@ import com.sngular.kloadgen.util.PropsKeysHelper; import com.sngular.kloadgen.util.SchemaRegistryKeyHelper; import io.apicurio.registry.resolver.SchemaResolverConfig; -import io.apicurio.registry.serde.SerdeConfig; import io.confluent.kafka.schemaregistry.client.SchemaRegistryClientConfig; import org.apache.avro.SchemaParseException; import org.apache.commons.lang3.ObjectUtils; @@ -99,63 +98,6 @@ public static Arguments getCommonProducerDefaultParameters() { return defaultParameters; } - public static Properties setupCommonProperties(final JavaSamplerContext context) { - final Properties props = new Properties(); - - props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, context.getParameter(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)); - if ("true".equals(JavaSamplerContext.getJMeterVariables().get(PropsKeysHelper.SCHEMA_KEYED_MESSAGE_KEY))) { - props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, JavaSamplerContext.getJMeterVariables().get(PropsKeysHelper.KEY_SERIALIZER_CLASS_PROPERTY)); - } else if ("true".equals(JavaSamplerContext.getJMeterVariables().get(PropsKeysHelper.SIMPLE_KEYED_MESSAGE_KEY))) { - props.put(PropsKeysHelper.MESSAGE_KEY_KEY_TYPE, JavaSamplerContext.getJMeterVariables().get(PropsKeysHelper.KEY_TYPE)); - props.put(PropsKeysHelper.MESSAGE_KEY_KEY_VALUE, JavaSamplerContext.getJMeterVariables().get(PropsKeysHelper.KEY_VALUE)); - if (Objects.nonNull(JavaSamplerContext.getJMeterVariables().get(PropsKeysHelper.KEY_SCHEMA_TYPE))) { - props.put(PropsKeysHelper.KEY_SCHEMA_TYPE, JavaSamplerContext.getJMeterVariables().get(PropsKeysHelper.KEY_SCHEMA_TYPE)); - } - props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, JavaSamplerContext.getJMeterVariables().get(PropsKeysHelper.KEY_SERIALIZER_CLASS_PROPERTY)); - } else { - props.put(PropsKeysHelper.SCHEMA_KEYED_MESSAGE_KEY, Boolean.FALSE); - } - - if (Objects.nonNull(context.getParameter(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG))) { - props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, context.getParameter(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG)); - } - - props.put(ProducerConfig.ACKS_CONFIG, context.getParameter(ProducerConfig.ACKS_CONFIG)); - props.put(ProducerConfig.SEND_BUFFER_CONFIG, context.getParameter(ProducerConfig.SEND_BUFFER_CONFIG)); - props.put(ProducerConfig.RECEIVE_BUFFER_CONFIG, context.getParameter(ProducerConfig.RECEIVE_BUFFER_CONFIG)); - props.put(ProducerConfig.BATCH_SIZE_CONFIG, context.getParameter(ProducerConfig.BATCH_SIZE_CONFIG)); - props.put(ProducerConfig.LINGER_MS_CONFIG, context.getParameter(ProducerConfig.LINGER_MS_CONFIG)); - props.put(ProducerConfig.BUFFER_MEMORY_CONFIG, context.getParameter(ProducerConfig.BUFFER_MEMORY_CONFIG)); - props.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, context.getParameter(ProducerConfig.COMPRESSION_TYPE_CONFIG)); - props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, context.getParameter(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG)); - props.put(ProducerKeysHelper.SASL_MECHANISM, context.getParameter(ProducerKeysHelper.SASL_MECHANISM)); - - final String schemaRegistryNameValue = JavaSamplerContext.getJMeterVariables().get(SchemaRegistryKeyHelper.SCHEMA_REGISTRY_NAME); - final String enableSchemaRegistrationValue = context.getParameter(SchemaRegistryKeyHelper.ENABLE_AUTO_SCHEMA_REGISTRATION_CONFIG); - if (SchemaRegistryKeyHelper.SCHEMA_REGISTRY_APICURIO.equalsIgnoreCase(schemaRegistryNameValue)) { - props.put(SerdeConfig.AUTO_REGISTER_ARTIFACT, enableSchemaRegistrationValue); - props.put(SchemaResolverConfig.REGISTRY_URL, JavaSamplerContext.getJMeterVariables().get(SchemaResolverConfig.REGISTRY_URL)); - props.put(SchemaRegistryKeyHelper.SCHEMA_REGISTRY_URL, JavaSamplerContext.getJMeterVariables().get(SchemaResolverConfig.REGISTRY_URL)); - } else { - props.put(SchemaRegistryKeyHelper.ENABLE_AUTO_SCHEMA_REGISTRATION_CONFIG, enableSchemaRegistrationValue); - final String schemaRegistryURL = JavaSamplerContext.getJMeterVariables().get(SchemaRegistryKeyHelper.SCHEMA_REGISTRY_URL); - if (StringUtils.isNotBlank(schemaRegistryURL)) { - props.put(SchemaRegistryKeyHelper.SCHEMA_REGISTRY_URL, schemaRegistryURL); - } - } - - final Iterator parameters = context.getParameterNamesIterator(); - parameters.forEachRemaining(parameter -> { - if (parameter.startsWith("_")) { - props.put(parameter.substring(1), context.getParameter(parameter)); - } - }); - - verifySecurity(context, props); - - return props; - } - private static String propertyOrDefault(final String property, final String defaultToken, final String valueToSent) { return defaultToken.equals(property) ? valueToSent : property; } diff --git a/src/main/java/com/sngular/kloadgen/sampler/gui/ApiServerRenderer.java b/src/main/java/com/sngular/kloadgen/sampler/gui/ApiServerRenderer.java index 52e4c98e..11e72a8d 100644 --- a/src/main/java/com/sngular/kloadgen/sampler/gui/ApiServerRenderer.java +++ b/src/main/java/com/sngular/kloadgen/sampler/gui/ApiServerRenderer.java @@ -1,11 +1,14 @@ package com.sngular.kloadgen.sampler.gui; -import com.sngular.kloadgen.extractor.model.AsyncApiServer; - -import javax.swing.*; -import java.awt.*; +import java.awt.Color; +import java.awt.Component; import java.util.Objects; +import javax.swing.JLabel; +import javax.swing.JList; + +import com.sngular.kloadgen.extractor.model.AsyncApiServer; + public class ApiServerRenderer extends JLabel implements javax.swing.ListCellRenderer { protected ApiServerRenderer() { diff --git a/src/main/java/com/sngular/kloadgen/sampler/gui/AsyncApiSamplerGui.java b/src/main/java/com/sngular/kloadgen/sampler/gui/AsyncApiSamplerGui.java index 4d9b001b..f0acda17 100644 --- a/src/main/java/com/sngular/kloadgen/sampler/gui/AsyncApiSamplerGui.java +++ b/src/main/java/com/sngular/kloadgen/sampler/gui/AsyncApiSamplerGui.java @@ -129,14 +129,14 @@ public void modifyTestElement(final TestElement element) { asyncApiSampler.setSchemaFieldConfiguration(mapVector(schemaFieldModel.getDataVector())); } } - // asyncApiSampler.setAsyncApiRegistry((AsyncApiSR) registryComboBox.getSelectedItem()); + // asyncApiSampler.setAsyncApiRegistry((AsyncApiSR) registryComboBox.getSelectedItem()); } configureTestElement(element); } private List mapVectorConf(final Vector dataVector) { final var mapResult = new ArrayList(); - for (Vector v : dataVector) { + for (final Vector v : dataVector) { mapResult.add(PropertyMapping .builder() .propertyName(v.get(0).toString()) @@ -385,7 +385,7 @@ private JPanel createSchemaTab() { } private void topicComboActionListener(final ActionEvent event) { - final JComboBox cb = (JComboBox)event.getSource(); + final JComboBox cb = (JComboBox) event.getSource(); final var selectedSchema = (AsyncApiSchema) cb.getSelectedItem(); if (Objects.nonNull(selectedSchema)) { fillTable(schemaFieldModel, selectedSchema.getProperties()); @@ -396,7 +396,7 @@ private void registryComboActionListener(final ActionEvent actionEvent) { } private void serverChooseActionListener(final ActionEvent actionEvent) { - final JComboBox serverChoose = (JComboBox)actionEvent.getSource(); + final JComboBox serverChoose = (JComboBox) actionEvent.getSource(); if (Objects.nonNull(serverChoose)) { fillTable(brokerFieldModel, prepareServer((AsyncApiServer) serverChoose.getSelectedItem())); }