Skip to content

Commit

Permalink
Merge pull request #273 from isa-group/feature/#272
Browse files Browse the repository at this point in the history
ReadProperties Modification
  • Loading branch information
josgarmar31 authored Jun 10, 2024
2 parents efc5258 + bf00634 commit be6aab3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ private void generateStatefulObjectNode(ObjectNode dictNode, Schema<?> schema, J
|| (requiredProperties != null && requiredProperties.contains(resolvedProperty)) // Req. property
|| ((requiredProperties == null || !requiredProperties.contains(resolvedProperty)) && random.nextBoolean())) { // Optional property (50% prob.)
JsonNode childNode = null;
if (schema.getType() == null) {
logger.warn("The schema of {}{} has no type defined. RESTest will use a default value.", operationMethod, operationPath);
}
if (schema.getType().equals("object")) {
childNode = "".equals(prefix) && firstLevel ? rootNode : objectMapper.createObjectNode();

Expand Down
22 changes: 19 additions & 3 deletions src/main/java/es/us/isa/restest/util/PropertyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
Expand All @@ -17,6 +19,10 @@ public class PropertyManager {
static Properties globalProperties = null;
static Properties userProperties = null;

private static Map<String, Properties> userPropertiesMap= new HashMap<>();



private static Logger logger = LogManager.getLogger(PropertyManager.class.getName());

/**
Expand Down Expand Up @@ -48,10 +54,13 @@ static public String readProperty(String name) {
*/
public static String readProperty(String evalPropertiesFilePath, String name) {

Properties userProperties = userPropertiesMap.get(evalPropertiesFilePath);

if (userProperties ==null) {
userProperties = new Properties();
try(FileInputStream experimentProperties = new FileInputStream(evalPropertiesFilePath)) {
PropertyManager.userProperties.load(experimentProperties);
userProperties.load(experimentProperties);
userPropertiesMap.put(evalPropertiesFilePath, userProperties);
} catch (IOException e) {
logger.error("Error reading property file: {}", e.getMessage());
logger.error("Exception: ", e);
Expand All @@ -63,8 +72,15 @@ public static String readProperty(String evalPropertiesFilePath, String name) {

// Setters

public static void setUserPropertiesFilePath(Properties userPropertiesFilePath) {
userProperties = userPropertiesFilePath;
public static void setUserPropertiesFilePath(String evalPropertiesFilePath) {
Properties userProperties = new Properties();
try (FileInputStream experimentProperties = new FileInputStream(evalPropertiesFilePath)) {
userProperties.load(experimentProperties);
userPropertiesMap.put(evalPropertiesFilePath, userProperties);
} catch (IOException e) {
logger.error("Error reading property file: {}", e.getMessage());
logger.error("Exception: ", e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void testExecutor() throws RESTestException {


@Test
@Ignore
public void testExecuteWithNonExistingTestClass() {

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ coverage.output=true
stats.csv=true

# Maximum number of test cases to be generated
numtotaltestcases=126
numtotaltestcases=12

# Optional delay between each iteration (in seconds)
delay=-1
Expand Down

0 comments on commit be6aab3

Please sign in to comment.