diff --git a/edi/ect/maven-ect-plugin/pom.xml b/edi/ect/maven-ect-plugin/pom.xml index defb0cb..1544e49 100644 --- a/edi/ect/maven-ect-plugin/pom.xml +++ b/edi/ect/maven-ect-plugin/pom.xml @@ -50,6 +50,14 @@ 1.4.0 runtime + + + com.sun + tools + ${jdk.version} + system + ${java.home}/../lib/tools.jar + diff --git a/edi/ect/pom.xml b/edi/ect/pom.xml index da56b62..816a083 100644 --- a/edi/ect/pom.xml +++ b/edi/ect/pom.xml @@ -46,7 +46,7 @@ org.eclipse.emf.ecore.xmi 2.5.0.v20100521-1846 jar - test + compile diff --git a/edi/edi-test/pom.xml b/edi/edi-test/pom.xml index 48f2953..2d0e93b 100644 --- a/edi/edi-test/pom.xml +++ b/edi/edi-test/pom.xml @@ -59,6 +59,14 @@ + + com.sun + tools + ${jdk.version} + system + ${java.home}/../lib/tools.jar + + org.milyn milyn-smooks-ejc diff --git a/edi/edisax/src/main/java/org/milyn/edisax/BufferedSegmentReader.java b/edi/edisax/src/main/java/org/milyn/edisax/BufferedSegmentReader.java index 1eecab4..5333c3b 100644 --- a/edi/edisax/src/main/java/org/milyn/edisax/BufferedSegmentReader.java +++ b/edi/edisax/src/main/java/org/milyn/edisax/BufferedSegmentReader.java @@ -16,13 +16,6 @@ package org.milyn.edisax; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.milyn.edisax.model.internal.Delimiters; -import org.milyn.edisax.util.EDIUtils; -import org.xml.sax.InputSource; - -import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -30,15 +23,21 @@ import java.io.Reader; import java.nio.charset.Charset; import java.util.Stack; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.milyn.edisax.model.internal.Delimiters; +import org.milyn.edisax.util.EDIUtils; +import org.xml.sax.InputSource; + /** * Buffered EDI Stream Segment reader. * @author tfennelly */ public class BufferedSegmentReader { - private static final int MAX_MARK_READ = 512; + private static final int MAX_MARK_READ = 512; - private static Log logger = LogFactory.getLog(BufferedSegmentReader.class); + private static Log logger = LogFactory.getLog(BufferedSegmentReader.class); public static String IGNORE_CR_LF = "!$"; @@ -48,12 +47,12 @@ public class BufferedSegmentReader { private Reader reader; private StringBuffer segmentBuffer = new StringBuffer(512); private String[] currentSegmentFields = null; - private int currentSegmentNumber = 0; - private Stack delimitersStack = new Stack(); + private int currentSegmentNumber = 0; + private Stack delimitersStack = new Stack(); private Delimiters currentDelimiters; private BufferedSegmentListener segmentListener; - private boolean ignoreNewLines; - private int charReadCount = 0; + private boolean ignoreNewLines; + private int charReadCount = 0; /** @@ -65,10 +64,10 @@ public class BufferedSegmentReader { underlyingByteStream = ediInputSource.getByteStream(); reader = ediInputSource.getCharacterStream(); if(reader == null) { - readEncoding = Charset.defaultCharset(); + readEncoding = Charset.defaultCharset(); reader = new InputStreamReader(underlyingByteStream, readEncoding); } else if(reader instanceof InputStreamReader) { - readEncoding = Charset.forName(((InputStreamReader) reader).getEncoding()); + readEncoding = Charset.forName(((InputStreamReader) reader).getEncoding()); } this.currentDelimiters = rootDelimiters; } @@ -77,20 +76,20 @@ public class BufferedSegmentReader { * Try mark the stream so we can support changing of the reader encoding. * @see #changeEncoding(Charset) */ - public void mark() { + public void mark() { if(underlyingByteStream != null) { - if(underlyingByteStream.markSupported()) { - // We don't support reader changing after we've read MAX_MARK_READ bytes... - underlyingByteStream.mark(MAX_MARK_READ); - marked = true; - } else { - logger.debug("Unable to mark EDI Reader for rest (to change reader encoding). Underlying InputStream type '" + underlyingByteStream.getClass().getName() + "' does not support mark."); - } + if(underlyingByteStream.markSupported()) { + // We don't support reader changing after we've read MAX_MARK_READ bytes... + underlyingByteStream.mark(MAX_MARK_READ); + marked = true; + } else { + logger.debug("Unable to mark EDI Reader for rest (to change reader encoding). Underlying InputStream type '" + underlyingByteStream.getClass().getName() + "' does not support mark."); + } } else { - logger.debug("Unable to mark EDI Reader for rest (to change reader encoding). BufferedSegmentReader instance does not have access to the underlying InputStream."); + logger.debug("Unable to mark EDI Reader for rest (to change reader encoding). BufferedSegmentReader instance does not have access to the underlying InputStream."); } - } - + } + /** * Change the encoding used to read the underlying EDI data stream. *

@@ -100,103 +99,103 @@ public class BufferedSegmentReader { * @throws IOException Failed to skip already read characters. */ public Charset changeEncoding(Charset encoding) throws IOException { - if(underlyingByteStream == null) { - throw new IllegalStateException("Unable to change stream read encoding to '" + encoding + "'. BufferedSegmentReader does not have access to the underlying stream."); - } - if(readEncoding != null && encoding.equals(readEncoding)) { - return readEncoding; - } + if(underlyingByteStream == null) { + throw new IllegalStateException("Unable to change stream read encoding to '" + encoding + "'. BufferedSegmentReader does not have access to the underlying stream."); + } + if(readEncoding != null && encoding.equals(readEncoding)) { + return readEncoding; + } if(!underlyingByteStream.markSupported()) { - logger.debug("Unable to to change stream read encoding on a stream that does not support 'mark'."); - return readEncoding; + logger.debug("Unable to to change stream read encoding on a stream that does not support 'mark'."); + return readEncoding; } if(!marked) { - logger.debug("Unable to to change stream read encoding on a stream. 'mark' was not called, or was called and failed."); - return readEncoding; + logger.debug("Unable to to change stream read encoding on a stream. 'mark' was not called, or was called and failed."); + return readEncoding; } - + // reset the stream... try { - underlyingByteStream.reset(); - marked = false; - } catch (IOException e) { - logger.debug("Unable to to change stream read encoding on stream because reset failed. Probably because the mark has been invalidated after reading more than " + MAX_MARK_READ + " bytes from the stream.", e); - return readEncoding; - } - - // Create a new reader and skip passed the already read characters... - reader = new InputStreamReader(underlyingByteStream, encoding); - underlyingByteStream.skip(charReadCount); - try { - return readEncoding; - } finally { - readEncoding = encoding; - } + underlyingByteStream.reset(); + marked = false; + } catch (IOException e) { + logger.debug("Unable to to change stream read encoding on stream because reset failed. Probably because the mark has been invalidated after reading more than " + MAX_MARK_READ + " bytes from the stream.", e); + return readEncoding; + } + + // Create a new reader and skip passed the already read characters... + reader = new InputStreamReader(underlyingByteStream, encoding); + underlyingByteStream.skip(charReadCount); + try { + return readEncoding; + } finally { + readEncoding = encoding; + } } - + /** * Get the current delimiter set. - * @return the currentDelimiters The current delimiter set. - */ - public Delimiters getDelimiters() { - return currentDelimiters; - } - - /** - * Push in a new {@link Delimiters} set into the reader. - * @param delimiters New delimiters. - */ - public void pushDelimiters(Delimiters delimiters) { - delimitersStack.push(currentDelimiters); - currentDelimiters = delimiters; - } - - /** - * Restore the parent delimiters set. - *

- * Be sure to {@link #getDelimitersStack() get the delimiters stack} and check - * that it is not empty before popping. - */ - public void popDelimiters() { - currentDelimiters = delimitersStack.pop(); - } - - /** - * Get the - * @return the delimitersStack - */ - public Stack getDelimitersStack() { - return delimitersStack; - } - - /** - * Set ignore new lines in the EDI Stream. - *

- * Some EDI messages are formatted with new lines for readability and so the - * new line characters should be ignored. - * - * @param ignoreNewLines True if new line characters should be ignored, otherwise false. - */ - public void setIgnoreNewLines(boolean ignoreNewLines) { - this.ignoreNewLines = ignoreNewLines; - } - - /** - * Read a fixed number of characters from the input source. - * @param numChars The number of characters to read. - * @return The characters in a String. If the end of the input source - * was reached, the length of the string will be less than the requested number - * of characters. - * @throws IOException Error reading from input source. - */ - public String read(int numChars) throws IOException { - segmentBuffer.setLength(0); + * @return the currentDelimiters The current delimiter set. + */ + public Delimiters getDelimiters() { + return currentDelimiters; + } + + /** + * Push in a new {@link Delimiters} set into the reader. + * @param delimiters New delimiters. + */ + public void pushDelimiters(Delimiters delimiters) { + delimitersStack.push(currentDelimiters); + currentDelimiters = delimiters; + } + + /** + * Restore the parent delimiters set. + *

+ * Be sure to {@link #getDelimitersStack() get the delimiters stack} and check + * that it is not empty before popping. + */ + public void popDelimiters() { + currentDelimiters = delimitersStack.pop(); + } + + /** + * Get the + * @return the delimitersStack + */ + public Stack getDelimitersStack() { + return delimitersStack; + } + + /** + * Set ignore new lines in the EDI Stream. + *

+ * Some EDI messages are formatted with new lines for readability and so the + * new line characters should be ignored. + * + * @param ignoreNewLines True if new line characters should be ignored, otherwise false. + */ + public void setIgnoreNewLines(boolean ignoreNewLines) { + this.ignoreNewLines = ignoreNewLines; + } + + /** + * Read a fixed number of characters from the input source. + * @param numChars The number of characters to read. + * @return The characters in a String. If the end of the input source + * was reached, the length of the string will be less than the requested number + * of characters. + * @throws IOException Error reading from input source. + */ + public String read(int numChars) throws IOException { + segmentBuffer.setLength(0); try { - return peek(numChars); + return peek(numChars); } finally { - segmentBuffer.setLength(0); + segmentBuffer.setLength(0); } - } + } /** * Peek a fixed number of characters from the input source. @@ -214,28 +213,28 @@ public class BufferedSegmentReader { return peek(numChars, false); } - /** - * Peek a fixed number of characters from the input source. - *

- * Peek differs from {@link #read(int)} in that it leaves the - * characters in the segment buffer. - * - * @param numChars The number of characters to peeked. + /** + * Peek a fixed number of characters from the input source. + *

+ * Peek differs from {@link #read(int)} in that it leaves the + * characters in the segment buffer. + * + * @param numChars The number of characters to peeked. * @param ignoreLeadingWhitespace Ignore leading whitespace. - * @return The characters in a String. If the end of the input source - * was reached, the length of the string will be less than the requested number - * of characters. - * @throws IOException Error reading from input source. - */ - public String peek(int numChars, boolean ignoreLeadingWhitespace) throws IOException { + * @return The characters in a String. If the end of the input source + * was reached, the length of the string will be less than the requested number + * of characters. + * @throws IOException Error reading from input source. + */ + public String peek(int numChars, boolean ignoreLeadingWhitespace) throws IOException { boolean ignoreCRLF; // Ignoring of new lines can be set as part of the segment delimiter, or // as a feature on the parser (the later is the preferred method)... ignoreCRLF = (currentDelimiters.ignoreCRLF() || ignoreNewLines); - if(segmentBuffer.length() < numChars) { - int c; + if(segmentBuffer.length() < numChars) { + int c; if(ignoreLeadingWhitespace) { c = forwardPastWhitespace(); @@ -244,34 +243,34 @@ public class BufferedSegmentReader { } while(c != -1) { - if (ignoreCRLF && (c == '\n' || c == '\r')) { - c = readChar(); - continue; - } + if (ignoreCRLF && (c == '\n' || c == '\r')) { + c = readChar(); + continue; + } - segmentBuffer.append((char)c); - if(segmentBuffer.length() == numChars) { - break; - } + segmentBuffer.append((char)c); + if(segmentBuffer.length() == numChars) { + break; + } - c = readChar(); + c = readChar(); } - } - - int endIndex = Math.min(numChars, segmentBuffer.length()); - - return segmentBuffer.substring(0, endIndex); - } + } + + int endIndex = Math.min(numChars, segmentBuffer.length()); + + return segmentBuffer.substring(0, endIndex); + } + + /** + * Set the segment listener. + * @param segmentListener The segment listener. + */ + public void setSegmentListener(BufferedSegmentListener segmentListener) { + this.segmentListener = segmentListener; + } /** - * Set the segment listener. - * @param segmentListener The segment listener. - */ - public void setSegmentListener(BufferedSegmentListener segmentListener) { - this.segmentListener = segmentListener; - } - - /** * Move to the next EDI segment. *

* Simply reads and buffers the next EDI segment. Clears the current contents of @@ -280,10 +279,10 @@ public class BufferedSegmentReader { * @throws IOException Error reading from EDI stream. */ public boolean moveToNextSegment() throws IOException { - return moveToNextSegment(true); + return moveToNextSegment(true); } - /** + /** * Move to the next EDI segment. *

* Simply reads and buffers the next EDI segment. @@ -297,15 +296,15 @@ public class BufferedSegmentReader { String escape = currentDelimiters.getEscape(); int escapeLen = escape != null ? escape.length() : 0; boolean ignoreCRLF; - + int c = readChar(); // Ignoring of new lines can be set as part of the segment delimiter, or // as a feature on the parser (the later is the preferred method)... ignoreCRLF = (currentDelimiters.ignoreCRLF() || ignoreNewLines); - + if(clearBuffer) { - segmentBuffer.setLength(0); + segmentBuffer.setLength(0); } currentSegmentFields = null; @@ -318,9 +317,11 @@ public class BufferedSegmentReader { // Ignore leading whitespace on a segment... c = forwardPastWhitespace(c); + boolean escapingMode = false; + // Read the next segment... while(c != -1) { - char theChar = (char) c; + char theChar = (char) c; if (ignoreCRLF && (theChar == '\n' || theChar == '\r')) { c = readChar(); @@ -328,41 +329,40 @@ public class BufferedSegmentReader { } segmentBuffer.append((char)c); - + int segLen = segmentBuffer.length(); if(segLen >= delimiterLen) { - boolean reachedSegEnd = true; - - for(int i = 0; i < delimiterLen; i++) { - char segChar = segmentBuffer.charAt(segLen - 1 - i); - char delimChar = segmentDelimiter[delimiterLen - 1 - i]; - - if(segChar != delimChar) { - // Not the end of a segment - reachedSegEnd = false; - break; - } - - // Do not separate segment if escape character occurs. - int escapeIndex = segLen - 1 - i - escapeLen; - if (escapeIndex > -1 && escape != null) { - String escapeString = segmentBuffer.substring(escapeIndex, escapeIndex + escapeLen); - String precedingEscapeString = escapeIndex - escapeLen > -1 ? segmentBuffer.substring(escapeIndex - escapeLen, escapeIndex) : ""; - if (escape.equals(escapeString) && !escape.equals(precedingEscapeString)) { - segmentBuffer = segmentBuffer.delete(escapeIndex, escapeIndex + escapeLen); - reachedSegEnd = false; - break; + boolean reachedSegEnd = true; + + for(int i = 0; i < delimiterLen; i++) { + char segChar = segmentBuffer.charAt(segLen - 1 - i); + char delimChar = segmentDelimiter[delimiterLen - 1 - i]; + + if (escapingMode) { + if (segChar == delimChar) { + segmentBuffer = segmentBuffer.delete(segLen - 2, segLen - 1); } + escapingMode = false; + reachedSegEnd = false; + break; + } else if (escape != null && escape.equals(Character.toString(segChar))) { + escapingMode = true; + } + + if (segChar != delimChar) { + // Not the end of a segment + reachedSegEnd = false; + break; } } - - // We've reached the end of a segment... - if(reachedSegEnd) { - // Trim off the delimiter and break out... - segmentBuffer.setLength(segLen - delimiterLen); + + // We've reached the end of a segment... + if(reachedSegEnd) { + // Trim off the delimiter and break out... + segmentBuffer.setLength(segLen - delimiterLen); break; - } + } } c = readChar(); @@ -371,13 +371,13 @@ public class BufferedSegmentReader { if(logger.isDebugEnabled()) { logger.debug(segmentBuffer.toString()); } - + currentSegmentNumber++; if(segmentListener != null) { - return segmentListener.onSegment(this); + return segmentListener.onSegment(this); } else { - return true; + return true; } } @@ -387,9 +387,9 @@ public class BufferedSegmentReader { */ public boolean hasCurrentSegment() { if(segmentListener != null) { - return segmentListener.onSegment(this); + return segmentListener.onSegment(this); } else { - return segmentBuffer.length() != 0; + return segmentBuffer.length() != 0; } } @@ -407,19 +407,19 @@ public class BufferedSegmentReader { * @throws IllegalStateException No current Segment. */ public String[] getCurrentSegmentFields() throws IllegalStateException { - assertCurrentSegmentExists(); + assertCurrentSegmentExists(); if(currentSegmentFields == null) { - currentSegmentFields = EDIUtils.split(segmentBuffer.toString(), currentDelimiters.getField(), currentDelimiters.getEscape()); - - // If the segment delimiter is a LF, strip off any preceding CR characters... - if(currentDelimiters.getSegment().equals("\n")) { - int endIndex = currentSegmentFields.length - 1; - if(currentSegmentFields[endIndex].endsWith("\r")) { - int stringLen = currentSegmentFields[endIndex].length(); - currentSegmentFields[endIndex] = currentSegmentFields[endIndex].substring(0, stringLen - 1); - } - } + currentSegmentFields = EDIUtils.split(segmentBuffer.toString(), currentDelimiters.getField(), currentDelimiters.getEscape()); + + // If the segment delimiter is a LF, strip off any preceding CR characters... + if(currentDelimiters.getSegment().equals("\n")) { + int endIndex = currentSegmentFields.length - 1; + if(currentSegmentFields[endIndex].endsWith("\r")) { + int stringLen = currentSegmentFields[endIndex].length(); + currentSegmentFields[endIndex] = currentSegmentFields[endIndex].substring(0, stringLen - 1); + } + } } return currentSegmentFields; @@ -431,9 +431,9 @@ public class BufferedSegmentReader { * The first segment is "segment number 1". * @return The "number" of the current segment. */ - public int getCurrentSegmentNumber() { - return currentSegmentNumber; - } + public int getCurrentSegmentNumber() { + return currentSegmentNumber; + } private int forwardPastWhitespace() throws IOException { return forwardPastWhitespace(readChar()); @@ -460,14 +460,14 @@ public class BufferedSegmentReader { } } - /** - * Assert that there is a current segment. - */ - private void assertCurrentSegmentExists() { - if(segmentBuffer.length() == 0) { - throw new IllegalStateException("No current segment available. Possible conditions: \n" - + "\t\t1. A call to moveToNextSegment() was not made, or \n" - + "\t\t2. The last call to moveToNextSegment() returned false."); - } - } + /** + * Assert that there is a current segment. + */ + private void assertCurrentSegmentExists() { + if(segmentBuffer.length() == 0) { + throw new IllegalStateException("No current segment available. Possible conditions: \n" + + "\t\t1. A call to moveToNextSegment() was not made, or \n" + + "\t\t2. The last call to moveToNextSegment() returned false."); + } + } } diff --git a/edi/edisax/src/test/java/org/milyn/edisax/BufferedSegmentReaderTest.java b/edi/edisax/src/test/java/org/milyn/edisax/BufferedSegmentReaderTest.java index d4ed1cd..e9cd57c 100644 --- a/edi/edisax/src/test/java/org/milyn/edisax/BufferedSegmentReaderTest.java +++ b/edi/edisax/src/test/java/org/milyn/edisax/BufferedSegmentReaderTest.java @@ -20,11 +20,18 @@ import junit.framework.TestCase; import org.apache.commons.lang.StringUtils; import org.milyn.edisax.model.internal.Delimiters; import org.xml.sax.InputSource; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.Arrays; +import org.apache.commons.lang.StringUtils; +import org.junit.Test; +import org.milyn.edisax.model.internal.Delimiters; +import org.xml.sax.InputSource; + /** * @author tfennelly */ @@ -124,6 +131,7 @@ public class BufferedSegmentReaderTest extends TestCase { private BufferedSegmentReader createSegmentReader(String input, String segmentDelim, String fieldDelim) { InputSource inputSource = new InputSource(new ByteArrayInputStream(input.getBytes())); Delimiters delimiters = new Delimiters().setSegment(segmentDelim).setField(fieldDelim); + delimiters.setEscape("?"); BufferedSegmentReader reader = new BufferedSegmentReader(inputSource, delimiters); return reader; } diff --git a/edi/edisax/src/test/java/org/milyn/edisax/EDIParserTest.java b/edi/edisax/src/test/java/org/milyn/edisax/EDIParserTest.java index bf328be..0f60edd 100644 --- a/edi/edisax/src/test/java/org/milyn/edisax/EDIParserTest.java +++ b/edi/edisax/src/test/java/org/milyn/edisax/EDIParserTest.java @@ -16,22 +16,27 @@ package org.milyn.edisax; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; import org.milyn.edisax.model.EDIConfigDigester; import org.milyn.edisax.model.EdifactModel; import org.milyn.edisax.model.internal.Segment; import org.milyn.edisax.model.internal.SegmentGroup; import org.xml.sax.SAXException; -import java.io.IOException; -import java.util.List; - /** * @author tfennelly */ public class EDIParserTest extends AbstractEDIParserTestCase { - public void test_validation() throws IOException, SAXException { - // Valid doc... + @Test + public void test_validation() throws IOException, SAXException { + // Valid doc... try { EDIConfigDigester.digestConfig(getClass().getResourceAsStream("edi-mapping_01.xml")); } catch (EDIConfigurationException e) { @@ -39,115 +44,135 @@ public class EDIParserTest extends AbstractEDIParserTestCase { } // Invalid doc... - try { - EDIConfigDigester.digestConfig(getClass().getResourceAsStream("edi-mapping_02.xml")); - fail("Expected SAXException"); - } catch (SAXException e) { - // OK - } catch (EDIConfigurationException e) { + try { + EDIConfigDigester.digestConfig(getClass().getResourceAsStream("edi-mapping_02.xml")); + fail("Expected SAXException"); + } catch (SAXException e) { + // OK + } catch (EDIConfigurationException e) { fail("Expected SAXException"); } } - public void test_parseMappingModel() throws IOException, SAXException, EDIConfigurationException { - EdifactModel map = EDIParser.parseMappingModel(getClass().getResourceAsStream("edi-mapping_01.xml")); - - // Some basic checks on the model produced by xmlbeans... - - // Make sure xml character refs are rewritten on the delimiters - assertEquals("\n", map.getDelimiters().getSegment()); - assertEquals("*", map.getDelimiters().getField()); - assertEquals("^", map.getDelimiters().getComponent()); - assertEquals("~", map.getDelimiters().getSubComponent()); - - assertEquals("message-x", map.getEdimap().getSegments().getXmltag()); - List segments = map.getEdimap().getSegments().getSegments(); - assertEquals(2, segments.size()); + @Test + public void test_parseMappingModel() throws IOException, SAXException, EDIConfigurationException { + EdifactModel map = EDIParser.parseMappingModel(getClass().getResourceAsStream("edi-mapping_01.xml")); + + // Some basic checks on the model produced by xmlbeans... + + // Make sure xml character refs are rewritten on the delimiters + assertEquals("\n", map.getDelimiters().getSegment()); + assertEquals("*", map.getDelimiters().getField()); + assertEquals("^", map.getDelimiters().getComponent()); + assertEquals("~", map.getDelimiters().getSubComponent()); + + assertEquals("message-x", map.getEdimap().getSegments().getXmltag()); + List segments = map.getEdimap().getSegments().getSegments(); + assertEquals(2, segments.size()); Segment segment = (Segment) segments.get(0); assertEquals(1, segment.getSegments().size()); - assertEquals(1, segment.getFields().size()); + assertEquals(1, segment.getFields().size()); segment = (Segment) segments.get(1); assertEquals(0, segment.getSegments().size()); - assertEquals(1, segment.getFields().size()); - } - - public void test_escape_character() throws IOException { - test("test_escape_character"); - } - - public void test_mapping_01() throws IOException { - test("test01"); - } - - public void test_mapping_02() throws IOException { - test("test02"); - } - - public void test_mapping_03() throws IOException { - test("test03"); - } - - public void test_mapping_04() throws IOException { - test("test04"); - } - - public void test_mapping_05() throws IOException { - test("test05"); - } - - public void test_mapping_06() throws IOException { - test("test06"); - } - - public void test_mapping_07() throws IOException { - test("test07"); - } - - public void test_mapping_08() throws IOException { - test("test08"); - } - - public void test_mapping_09() throws IOException { - test("test09"); - } - - public void test_mapping_10() throws IOException { - test("test10"); - } - - public void test_mapping_11() throws IOException { - test("test11"); - } - - public void test_mapping_12() throws IOException { - test("test12"); - } - - public void test_mapping_13() throws IOException { - test("test13"); - } - - public void test_mapping_14() throws IOException { - test("test14"); - } - - public void test_mapping_15() throws IOException { - test("test15"); - } - - public void test_mapping_16() throws IOException { - test("test16"); - } - - public void test_mapping_17() throws IOException { - test("test17"); - } - - public void test_mapping_18() throws IOException { - test("test18"); - } + assertEquals(1, segment.getFields().size()); + } + + @Test + public void test_escape_character() throws IOException { + test("test_escape_character"); + } + + @Test + public void test_mapping_01() throws IOException { + test("test01"); + } + + @Test + public void test_mapping_02() throws IOException { + test("test02"); + } + + @Test + public void test_mapping_03() throws IOException { + test("test03"); + } + + @Test + public void test_mapping_04() throws IOException { + test("test04"); + } + + @Test + public void test_mapping_05() throws IOException { + test("test05"); + } + + @Test + public void test_mapping_06() throws IOException { + test("test06"); + } + + @Test + public void test_mapping_07() throws IOException { + test("test07"); + } + + @Test + public void test_mapping_08() throws IOException { + test("test08"); + } + + @Test + public void test_mapping_09() throws IOException { + test("test09"); + } + + @Test + public void test_mapping_10() throws IOException { + test("test10"); + } + + @Test + public void test_mapping_11() throws IOException { + test("test11"); + } + + @Test + public void test_mapping_12() throws IOException { + test("test12"); + } + + @Test + public void test_mapping_13() throws IOException { + test("test13"); + } + + @Test + public void test_mapping_14() throws IOException { + test("test14"); + } + + @Test + public void test_mapping_15() throws IOException { + test("test15"); + } + + @Test + public void test_mapping_16() throws IOException { + test("test16"); + } + + @Test + public void test_mapping_17() throws IOException { + test("test17"); + } + + @Test + public void test_mapping_18() throws IOException { + test("test18"); + } public void test_MILYN_108() throws IOException { test("test-MILYN-108-01"); // Tests Segment Truncation @@ -181,10 +206,10 @@ public class EDIParserTest extends AbstractEDIParserTestCase { * Test error in segment node. */ try { - testEDIParseException("error-segment", "message-seg", 2); - fail("Expected EDIParseException."); - } catch(EDIParseException e) { - assertEquals("EDI message processing failed [Test Message][1.0]. Reached end of mapping model but there are more EDI segments in the incoming message. Read 2 segment(s). Current EDI segment is [SEG*6*7**9*10]", e.getMessage()); + testEDIParseException("error-segment", "message-seg", 2); + fail("Expected EDIParseException."); + } catch (EDIParseException e) { + assertEquals("EDI message processing failed [Test Message][1.0]. Reached end of mapping model but there are more EDI segments in the incoming message. Read 2 segment(s). Current EDI segment is [SEG*6*7**9*10]", e.getMessage()); } /** diff --git a/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/edi-input.txt b/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/edi-input.txt index 60e67c3..2563986 100644 --- a/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/edi-input.txt +++ b/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/edi-input.txt @@ -1,3 +1,6 @@ SEG1+1+2++4+5??' SEG2+1+2++4+5?'1' -SEG3+2+4+3+5+6' \ No newline at end of file +SEG3+2+4+3+5+6' +SEG4+2+4???'+3+5+6' +SEG5+2+4+3+5+6???'' +SEG6+2+4+3+5+6???'???+?'' \ No newline at end of file diff --git a/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/edi-to-xml-mapping.xml b/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/edi-to-xml-mapping.xml index cb8789a..45140f9 100644 --- a/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/edi-to-xml-mapping.xml +++ b/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/edi-to-xml-mapping.xml @@ -27,6 +27,27 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/expected.xml b/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/expected.xml index 8ed700b..a51b56c 100644 --- a/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/expected.xml +++ b/edi/edisax/src/test/java/org/milyn/edisax/test_escape_character/expected.xml @@ -18,4 +18,25 @@ 5 6 + + 2 + 4?' + 3 + 5 + 6 + + + 2 + 4 + 3 + 5 + 6?' + + + 2 + 4 + 3 + 5 + 6?'?+' + diff --git a/edi/ejc/maven-ejc-plugin/pom.xml b/edi/ejc/maven-ejc-plugin/pom.xml index cc86144..94f8da3 100644 --- a/edi/ejc/maven-ejc-plugin/pom.xml +++ b/edi/ejc/maven-ejc-plugin/pom.xml @@ -59,6 +59,13 @@ 1.4.0 runtime + + com.sun + tools + ${jdk.version} + system + ${java.home}/../lib/tools.jar +