Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadProperties Modification #273

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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