OSDN Git Service

21e1d3e57d4061a320088fa23c5441df49350b37
[stigmata/stigmata.git] / src / test / java / jp / sourceforge / stigmata / birthmarks / cvfv / CVFVBirthmarkExtractorTest.java
1 package jp.sourceforge.stigmata.birthmarks.cvfv;
2
3 import jp.sourceforge.stigmata.Birthmark;
4 import jp.sourceforge.stigmata.BirthmarkContext;
5 import jp.sourceforge.stigmata.BirthmarkElement;
6 import jp.sourceforge.stigmata.BirthmarkSet;
7 import jp.sourceforge.stigmata.ExtractionResultSet;
8 import jp.sourceforge.stigmata.Stigmata;
9
10 import org.junit.Assert;
11 import org.junit.Before;
12 import org.junit.Test;
13
14 /**
15  *
16  * @author Haruaki TAMADA
17  */
18 public class CVFVBirthmarkExtractorTest{
19     private Stigmata stigmata;
20     private BirthmarkContext context;
21
22     @Before
23     public void setup(){
24         stigmata = Stigmata.getInstance();
25         context = stigmata.createContext();
26         context.addBirthmarkType("cvfv");
27     }
28
29     @Test
30     public void checkCVFVBirthmark() throws Exception{
31         ExtractionResultSet ers = stigmata.createEngine().extract(
32             new String[] { "target/classes/jp/sourceforge/stigmata/Stigmata.class", },
33             context
34         );
35         BirthmarkSet[] array = ers.getBirthmarkSets();
36
37         Assert.assertEquals(1, array.length);
38         Assert.assertNotNull(array[0].getBirthmark("cvfv"));
39
40         Birthmark birthmark = array[0].getBirthmark("cvfv");
41         Assert.assertEquals("cvfv", birthmark.getType());
42         Assert.assertEquals(4, birthmark.getElementCount());
43
44         BirthmarkElement[] elements = birthmark.getElements();
45         Assert.assertEquals("jp.sourceforge.stigmata.birthmarks.cvfv.TypeAndValueBirthmarkElement",
46                             elements[0].getClass().getName());
47         Assert.assertEquals("jp.sourceforge.stigmata.birthmarks.cvfv.TypeAndValueBirthmarkElement",
48                             elements[1].getClass().getName());
49         Assert.assertEquals("jp.sourceforge.stigmata.birthmarks.cvfv.TypeAndValueBirthmarkElement",
50                             elements[2].getClass().getName());
51         Assert.assertEquals("jp.sourceforge.stigmata.birthmarks.cvfv.TypeAndValueBirthmarkElement",
52                             elements[3].getClass().getName());
53
54         Assert.assertEquals("Ljp/sourceforge/stigmata/Stigmata;",
55             ((TypeAndValueBirthmarkElement)elements[0]).getSignature());
56         Assert.assertNull(((TypeAndValueBirthmarkElement)elements[0]).getValue());
57
58         Assert.assertEquals("Ljp/sourceforge/stigmata/printer/PrinterManager;",
59             ((TypeAndValueBirthmarkElement)elements[1]).getSignature());
60         Assert.assertNull(((TypeAndValueBirthmarkElement)elements[1]).getValue());
61
62         Assert.assertEquals("Ljp/sourceforge/stigmata/BirthmarkEnvironment;",
63                             ((TypeAndValueBirthmarkElement)elements[2]).getSignature());
64         Assert.assertNull(((TypeAndValueBirthmarkElement)elements[2]).getValue());
65
66         Assert.assertEquals("Ljava/util/List;",
67                             ((TypeAndValueBirthmarkElement)elements[3]).getSignature());
68         Assert.assertNull(((TypeAndValueBirthmarkElement)elements[3]).getValue());
69     }
70
71     @Test
72     public void checkCVFVBirthmark2() throws Exception{
73         ExtractionResultSet ers = stigmata.createEngine().extract(
74             new String[] { "target/classes/jp/sourceforge/stigmata/result/RoundRobinComparisonResultSet.class", },
75             context
76         );
77
78         BirthmarkSet[] array = ers.getBirthmarkSets();
79
80         Assert.assertEquals(array.length, 1);
81         Assert.assertNotNull(array[0].getBirthmark("cvfv"));
82
83         Birthmark birthmark = array[0].getBirthmark("cvfv");
84         Assert.assertEquals(birthmark.getType(), "cvfv");
85         Assert.assertEquals(3, birthmark.getElementCount());
86
87         BirthmarkElement[] elements = birthmark.getElements();
88         Assert.assertEquals("jp.sourceforge.stigmata.birthmarks.cvfv.TypeAndValueBirthmarkElement",
89                             elements[0].getClass().getName());
90         Assert.assertEquals("jp.sourceforge.stigmata.birthmarks.cvfv.TypeAndValueBirthmarkElement",
91                             elements[1].getClass().getName());
92         Assert.assertEquals("jp.sourceforge.stigmata.birthmarks.cvfv.TypeAndValueBirthmarkElement",
93                             elements[2].getClass().getName());
94
95         Assert.assertEquals("I",   ((TypeAndValueBirthmarkElement)elements[0]).getSignature());
96         Assert.assertEquals(-1,    ((TypeAndValueBirthmarkElement)elements[0]).getValue());
97
98         Assert.assertEquals("Z",   ((TypeAndValueBirthmarkElement)elements[1]).getSignature());
99         Assert.assertEquals(null,  ((TypeAndValueBirthmarkElement)elements[1]).getValue());
100
101         Assert.assertEquals("Z",   ((TypeAndValueBirthmarkElement)elements[2]).getSignature());
102         Assert.assertEquals(0,     ((TypeAndValueBirthmarkElement)elements[2]).getValue());
103     }
104 }