Commit 59389e59 authored by Malo Toudic's avatar Malo Toudic
Browse files

Merge branch 'develop' into 'master'

Develop

See merge request !14
parents 8e00bf10 e2ed82fd
......@@ -8,11 +8,19 @@ import net.ihe.gazelle.contentanalyzer.business.exceptions.UnexpectedAnalysisExc
import net.ihe.gazelle.contentanalyzer.business.model.AnalyzedObjectPart;
import net.ihe.gazelle.contentanalyzer.business.model.EncodedType;
import net.ihe.gazelle.contentanalyzer.business.model.config.McaConfigDAO;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.BOMInputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public class MessageContentAnalyzer {
private static final Logger LOGGER = LoggerFactory.getLogger(MessageContentAnalyzer.class);
public static final String BASE64 = "BASE64";
private static final String PART_LOG_TYPE = "Message Content Analyzer";
......@@ -76,6 +84,13 @@ public class MessageContentAnalyzer {
public void analyzeMessageContent(byte[] messageBytesContent, final AnalyzedObjectPart parent, McaConfigDAO mcaConfigDAO)
throws UnexpectedAnalysisException {
try {
byte[] messageByteContentWithoutBOM = IOUtils.toByteArray(new BOMInputStream(new ByteArrayInputStream(messageBytesContent)));
messageBytesContent = messageByteContentWithoutBOM;
} catch (IOException e) {
LOGGER.error("Could not remove BOM");
}
setMessageByteContent(messageBytesContent);
parent.addLog(PART_LOG_TYPE,"Start analysis");
......
......@@ -2195,6 +2195,32 @@ public class MessageContentAnalyzerTest {
assertEquals(4110, analyzedObjectPart.getChildList().get(0).getChildList().get(0).getEndOffset());
}
@Test
public void XmlFileWithUTF8Bom(){
final File f = loadFile("/contentanalyzer/validXmlFileUtf8BomEncoded.xml");
final AnalyzedObjectPart analyzedObjectPart = new AnalyzedObjectPart(new AnalyzedObjectPart(null));
analyzedObjectPart.setDocType("DOCUMENT");
analyzedObjectPart.setEncodedType(EncodedType.NOT_ENCODED);
analyzedObjectPart.setStartOffset(0);
try {
analyzedObjectPart.setEndOffset(FileUtils.readFileToString(f).length());
}catch(IOException e){
System.out.println(e.getMessage());
}
try {
m.analyzeMessageContent(FileUtils.readFileToByteArray(f), analyzedObjectPart, mcaConfigDao);
}catch (IOException e){
fail("Unable to read file");
}catch (UnexpectedAnalysisException e){
fail("No exception is supposed to be raised : " + e.getMessage());
}
assertEquals("XML", analyzedObjectPart.getChildList().get(0).getDocType());
assertEquals(EncodedType.NOT_ENCODED, analyzedObjectPart.getChildList().get(0).getEncodedType());
assertNull(analyzedObjectPart.getChildList().get(0).getDecodedPart());
}
@Test
public void wsTrustWithAssertion(){
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
......@@ -70,7 +72,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire.plugin}</version>
<configuration>
<argLine>${argLine} -Xmx2048m</argLine>
<argLine>${argLine} -Xmx2048m -XX:MaxPermSize=512m</argLine>
<systemPropertyVariables>
<jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
......
<settings>
<servers>
<server>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment