Skip to content

Commit

Permalink
Check specific properties when deserializing XML file
Browse files Browse the repository at this point in the history
  • Loading branch information
linghengqian committed Dec 28, 2023
1 parent a752ed0 commit 15c6d73
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.sqlfederation.optimizer.it;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import lombok.Getter;
Expand All @@ -32,5 +33,6 @@
public final class TestCases {

@JacksonXmlProperty(localName = "test-case")
@JacksonXmlElementWrapper(useWrapping = false)
private final Collection<TestCase> testCases = new LinkedList<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public final class TestCasesLoader {

private static final TestCasesLoader INSTANCE = new TestCasesLoader();

private static final ObjectMapper XML_MAPPER = XmlMapper.builder().defaultUseWrapper(false).build();
private static final ObjectMapper XML_MAPPER = XmlMapper.builder().build();

/**
* Get singleton instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.mode.repository.standalone.jdbc.sql;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import lombok.Getter;
Expand All @@ -28,30 +29,38 @@
@Getter
public final class JDBCRepositorySQL {

@JsonProperty(required = true)
@JacksonXmlProperty(isAttribute = true)
private String type;

@JsonProperty(required = true)
@JacksonXmlProperty(localName = "driver-class-name", isAttribute = true)
private String driverClassName;

@JacksonXmlProperty(localName = "default", isAttribute = true)
private boolean isDefault;

@JsonProperty(required = true)
@JacksonXmlProperty(localName = "create-table")
private String createTableSQL;

@JsonProperty(required = true)
@JacksonXmlProperty(localName = "select-by-key")
private String selectByKeySQL;

@JsonProperty(required = true)
@JacksonXmlProperty(localName = "select-by-parent")
private String selectByParentKeySQL;

@JsonProperty(required = true)
@JacksonXmlProperty(localName = "insert")
private String insertSQL;

@JsonProperty(required = true)
@JacksonXmlProperty(localName = "update")
private String updateSQL;

@JsonProperty(required = true)
@JacksonXmlProperty(localName = "delete")
private String deleteSQL;
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public final class JDBCRepositorySQLLoader {

private static final Collection<String> JAR_URL_PROTOCOLS = new HashSet<>(Arrays.asList("jar", "war", "zip", "wsjar", "vfszip"));

private static final ObjectMapper XML_MAPPER = XmlMapper.builder().defaultUseWrapper(false).build();
private static final ObjectMapper XML_MAPPER = XmlMapper.builder().build();

/**
* Load JDBC repository SQL.
Expand Down

0 comments on commit 15c6d73

Please sign in to comment.