OSDN Git Service

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