Skip to content

Commit

Permalink
Release 2.2 (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
3dgiordano authored Oct 2, 2023
1 parent 08d088d commit fc53222
Show file tree
Hide file tree
Showing 46 changed files with 2,558 additions and 1,176 deletions.
13 changes: 12 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.blazemeter</groupId>
<artifactId>jmeter-bzm-correlation-recorder</artifactId>
<packaging>jar</packaging>
<version>2.1</version>
<version>2.2</version>
<name>Correlation Recorder as JMeter plugin</name>
<description>Correlation Recorder Plugin for JMeter</description>
<url>https://github.com/Blazemeter/CorrelationRecorder</url>
Expand Down Expand Up @@ -160,6 +160,17 @@
<version>1.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.8.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
import com.blazemeter.jmeter.correlation.core.templates.ConfigurationException;
import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplateDependency;
import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplateVersions;
import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplatesRegistry;
import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplatesRegistryHandler;
import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplatesRepositoriesConfiguration;
import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplatesRepositoriesRegistryHandler;
import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplatesRepository;
import com.blazemeter.jmeter.correlation.core.templates.LocalConfiguration;
import com.blazemeter.jmeter.correlation.core.templates.LocalCorrelationTemplatesRegistry;
import com.blazemeter.jmeter.correlation.core.templates.Template;
import com.blazemeter.jmeter.correlation.core.templates.Template.Builder;
import com.blazemeter.jmeter.correlation.core.templates.repository.RepositoryManager;
Expand Down Expand Up @@ -115,7 +113,6 @@ public class CorrelationProxyControl extends ProxyControl implements
private transient CorrelationTemplatesRepositoriesConfiguration templateRepositoryConfig;
private transient LocalConfiguration localConfiguration;
private transient CorrelationEngine correlationEngine;
private transient CorrelationTemplatesRegistry correlationTemplatesRegistry;
private JMeterTreeNode target = null;
private List<SampleResult> samples = new ArrayList<>();
private Method putSamplesIntoModel;
Expand All @@ -136,7 +133,6 @@ public CorrelationProxyControl() {
correlationEngine = new CorrelationEngine();
componentsRegistry = CorrelationComponentsRegistry.getInstance();
localConfiguration = new LocalConfiguration(JMeterUtils.getJMeterBinDir());
correlationTemplatesRegistry = new LocalCorrelationTemplatesRegistry(localConfiguration);
templateRepositoryConfig =
new CorrelationTemplatesRepositoriesConfiguration(localConfiguration);
setName(RECORDER_NAME);
Expand All @@ -147,14 +143,12 @@ public CorrelationProxyControl(
CorrelationComponentsRegistry componentsRegistry,
CorrelationTemplatesRepositoriesConfiguration templateRepositoryConfig,
LocalConfiguration localConfiguration,
CorrelationEngine correlationEngine,
CorrelationTemplatesRegistry correlationTemplatesRegistry) {
CorrelationEngine correlationEngine) {
this.componentsRegistry = componentsRegistry;
this.templateRepositoryConfig =
templateRepositoryConfig;
this.localConfiguration = localConfiguration;
this.correlationEngine = correlationEngine;
this.correlationTemplatesRegistry = correlationTemplatesRegistry;
}

public CorrelationTemplatesRepositoriesConfiguration getTemplateRepositoryConfig() {
Expand Down Expand Up @@ -519,9 +513,7 @@ public void onSaveTemplate(Builder builder) throws IOException, ConfigurationExc
.withResponseFilters(getResponseFilter())
.build();

correlationTemplatesRegistry.save(template);
updateLocalRepository(template);
installTemplate(template.getRepositoryId(), template.getId(), template.getVersion());
localConfiguration.saveTemplate(template);
}

public List<RulesGroup> getGroups() {
Expand Down Expand Up @@ -578,16 +570,12 @@ public void setResponseFilter(String responseFilter) {
setProperty(RESPONSE_FILTER, responseFilter);
}

private void updateLocalRepository(Template template) {
templateRepositoryConfig
.updateLocalRepository(template.getId(), template.getVersion());
}

@Override
public void onLoadTemplate(String repositoryOwner, String id, String templateVersion)
throws IOException {
Optional<Template> correlationTemplate = correlationTemplatesRegistry
.findByID(repositoryOwner, id, templateVersion);

Optional<Template> correlationTemplate = localConfiguration
.findById(repositoryOwner, id, templateVersion);
if (correlationTemplate.isPresent()) {
Template template = correlationTemplate.get();

Expand Down Expand Up @@ -658,24 +646,12 @@ private String cleanRepeated(String actual, String loaded) {
return cleaned.stream().map(String::trim).collect(Collectors.joining(","));
}

private List<CorrelationRule> appendCorrelationRules(List<CorrelationRule> actualRules,
List<CorrelationRule> loadedRules) {
if (loadedRules.isEmpty()) {
return actualRules;
}

LinkedHashSet<CorrelationRule> actualRulesSet = new LinkedHashSet<>(actualRules);
actualRulesSet.addAll(loadedRules);

return new ArrayList<>(actualRulesSet);
}

public String getContentTypeInclude() {
return getPropertyAsString(RESPONSE_FILTER);
}

public List<Template> getInstalledCorrelationTemplates() {
return correlationTemplatesRegistry.getInstalledTemplates();
return localConfiguration.getInstalledTemplates();
}

public void update(String correlationComponents, List<RulesGroup> groups, String responseFilter,
Expand All @@ -688,7 +664,7 @@ public void update(String correlationComponents, List<RulesGroup> groups, String

@Override
public void saveRepository(String id, String url) throws IOException {
templateRepositoryConfig.save(id, url);
templateRepositoryConfig.saveRepository(id, url);
}

@Override
Expand Down Expand Up @@ -723,13 +699,13 @@ public Map<String, CorrelationTemplateVersions> getCorrelationTemplateVersionsBy
@Override
public void installTemplate(String repositoryName, String id, String version)
throws ConfigurationException {
templateRepositoryConfig.installTemplate(repositoryName, id, version);
localConfiguration.installTemplate(repositoryName, id, version);
}

@Override
public void uninstallTemplate(String repositoryName, String id, String version)
throws ConfigurationException {
templateRepositoryConfig.uninstallTemplate(repositoryName, id, version);
localConfiguration.uninstallTemplate(repositoryName, id, version);
}

@Override
Expand All @@ -739,12 +715,12 @@ public String getRepositoryURL(String otherName) {

@Override
public RepositoryManager getRepositoryManager(String name) {
return templateRepositoryConfig.getRepositoryManager(name);
return localConfiguration.getRepositoryManager(name);
}

@Override
public RepositoryManager getRepositoryManager(String name, String url) {
return templateRepositoryConfig.getRepositoryManager(name, url);
return localConfiguration.getRepositoryManager(name, url);
}

@Override
Expand Down Expand Up @@ -784,8 +760,8 @@ public List<String> checkURL(String id, String url) {
public boolean refreshRepositories(String localConfigurationRoute,
Consumer<Integer> setProgressConsumer,
Consumer<String> setStatusConsumer) {
return templateRepositoryConfig
.refreshRepositories(localConfigurationRoute, setProgressConsumer, setStatusConsumer);
return localConfiguration.refreshRepositories(localConfigurationRoute, setProgressConsumer,
setStatusConsumer);
}

@Override
Expand Down Expand Up @@ -852,7 +828,6 @@ private void readObject(ObjectInputStream inputStream)
correlationEngine = new CorrelationEngine();
componentsRegistry = CorrelationComponentsRegistry.getInstance();
localConfiguration = new LocalConfiguration(getTemplateDirectoryPath());
correlationTemplatesRegistry = new LocalCorrelationTemplatesRegistry(localConfiguration);
templateRepositoryConfig =
new CorrelationTemplatesRepositoriesConfiguration(localConfiguration);
setName(RECORDER_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class CorrelationProxyControlGui extends ProxyControlGui
private CorrelationWizard wizard;

static {
LocalConfiguration.installDefaultFiles();
LocalConfiguration.installDefaultFiles(JMeterUtils.getJMeterBinDir());
}

public CorrelationProxyControlGui() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@
import java.util.List;
import java.util.Objects;

/**
* This class represents a list of versions for a specific template.
* For example, if we have a template for "WordPress" with versions 1.0 and 1.1,
* this class will have name="WordPress" and versions=[1.0, 1.1]
*/
public class CorrelationTemplateVersions {

private final List<String> versions = new ArrayList<>();
private transient String name;
private String repositoryDisplayName;

//Constructor added to avoid issues with the serialization
public CorrelationTemplateVersions() {
this.repositoryDisplayName = "";
}

public CorrelationTemplateVersions(String name, List<String> versions) {
this.name = name;
this.versions.addAll(versions);
}

public CorrelationTemplateVersions(String version) {
Expand All @@ -34,9 +45,17 @@ public void addVersion(String version) {
versions.add(version);
}

public String getRepositoryDisplayName() {
return repositoryDisplayName;
}

public void setRepositoryDisplayName(String repositoryDisplayName) {
this.repositoryDisplayName = repositoryDisplayName;
}

@Override
public String toString() {
return "CorrelationTemplateReference{" +
return "CorrelationTemplateVersions {" +
"versions=" + versions +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
package com.blazemeter.jmeter.correlation.core.templates;

import java.io.IOException;
import java.util.List;
import java.util.Optional;

public interface CorrelationTemplatesRegistry {

void save(Template template) throws IOException;

Optional<Template> findByID(String repositoryOwner, String id,
String templateVersion) throws IOException;

List<Template> getInstalledTemplates();
}
Loading

0 comments on commit fc53222

Please sign in to comment.