Add extra files that should have been included in the previous commit.
[cfb.git] / test / net / jaekl / cfb / xml / messages / MessageCollectionTest.java
1 package net.jaekl.cfb.xml.messages;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5
6 import java.io.ByteArrayInputStream;
7 import java.io.FileNotFoundException;
8 import java.io.IOException;
9 import java.io.UnsupportedEncodingException;
10
11 import net.jaekl.cfb.analyze.MessageMap;
12 import net.jaekl.cfb.xml.MessagesXmlData;
13
14 import org.junit.Test;
15 import org.xml.sax.InputSource;
16 import org.xml.sax.SAXException;
17
18 public class MessageCollectionTest {
19         private final String UNDEFINED_TYPE = "ThisTypeDoesNotExist";
20
21         @Test
22         public void testGetPatternForUnknownType() throws FileNotFoundException, UnsupportedEncodingException, IOException, SAXException {
23                 MessageMap msgMap = new MessageMap();
24                 msgMap.parse(new InputSource(new ByteArrayInputStream(MessagesXmlData.XML.getBytes("UTF-8"))));
25                 
26                 MessageCollection msgColl = msgMap.getColl();
27                 assertNotNull(msgColl);
28                 
29                 BugPattern pat = msgColl.getPattern(UNDEFINED_TYPE);
30                 assertNotNull(pat);
31                 assertEquals(BugPattern.UNKNOWN.getId(), pat.getId());
32         }
33 }