Skip to content

Commit

Permalink
add test case management
Browse files Browse the repository at this point in the history
  • Loading branch information
qdriven committed Sep 20, 2023
1 parent d4b4def commit 780e75b
Show file tree
Hide file tree
Showing 109 changed files with 18,376 additions and 380 deletions.
6 changes: 5 additions & 1 deletion components/fluent-builtin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
<version>2.21.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>

<!-- <dependency>-->
<!-- <groupId>org.eclipse.collections</groupId>-->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.fluent.builtin;

import cn.hutool.core.util.XmlUtil;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Unmarshaller;
import lombok.extern.slf4j.Slf4j;
import org.w3c.dom.Document;

import javax.xml.xpath.XPathConstants;
import java.io.BufferedInputStream;
import java.io.FileInputStream;

@Slf4j
public class XmlUtils extends XmlUtil {

public static Document getDocument(String xmlFilePath) {
return XmlUtil.readXML(xmlFilePath);
}

public static Object getValueByXpath(String xmlFilePath,
String xpathExpr) {
Document doc = getDocument(xmlFilePath);
return XmlUtil.getByXPath(xpathExpr, doc, XPathConstants.STRING);
}

public static Object getValueByXpath(Document doc,
String xpathExpr) {
return XmlUtil.getByXPath(xpathExpr, doc, XPathConstants.STRING);
}

/**
* JAXB Read Xml file
*
* @param xmlFilePath
* @param clazz
* @return
*/
public static <T> T readXmlToObject(String xmlFilePath, Class<T> clazz) {

try {
JAXBContext context = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = context.createUnmarshaller();
return (T) unmarshaller.unmarshal(new BufferedInputStream(new FileInputStream(xmlFilePath)));
} catch (Exception e) {
log.error("parse xml failed,", e);
throw new RuntimeException(e);
}
}

public static <T> T readXmlToObject(Document doc, Class<T> clazz) {

try {
JAXBContext context = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = context.createUnmarshaller();
return (T) unmarshaller.unmarshal(doc);
} catch (Exception e) {
log.error("parse xml failed,", e);
throw new RuntimeException(e);
}
}
}
38 changes: 38 additions & 0 deletions components/fluent-ext/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
Loading

0 comments on commit 780e75b

Please sign in to comment.