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

Check specific properties when deserializing XML file #29577

Merged
merged 1 commit into from
Dec 31, 2023
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 @@ -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,41 +17,54 @@

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;

/**
* JDBC repository SQL.
* `required` in {@link com.fasterxml.jackson.annotation.JsonProperty} only provides Metadata without detecting Null values, which is actually consistent with the design of the JAXB API.
* See <a href="https://github.com/FasterXML/jackson-dataformat-xml/issues/625">FasterXML/jackson-dataformat-xml#625</a>
*
* @see JsonProperty
*/
@JacksonXmlRootElement(localName = "sql")
@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