OSDN Git Service

update command line interface, and introduce command pattern in Main class
[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(4, 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         Assert.assertEquals("jp.sourceforge.stigmata.birthmarks.cvfv.TypeAndValueBirthmarkElement",
57                             elements[3].getClass().getName());
58
59         Assert.assertEquals("Ljp/sourceforge/stigmata/Stigmata;",
60             ((TypeAndValueBirthmarkElement)elements[0]).getSignature());
61         Assert.assertNull(((TypeAndValueBirthmarkElement)elements[0]).getValue());
62
63         Assert.assertEquals("Ljp/sourceforge/stigmata/printer/PrinterManager;",
64             ((TypeAndValueBirthmarkElement)elements[1]).getSignature());
65         Assert.assertNull(((TypeAndValueBirthmarkElement)elements[1]).getValue());
66
67         Assert.assertEquals("Ljp/sourceforge/stigmata/BirthmarkEnvironment;",
68                             ((TypeAndValueBirthmarkElement)elements[2]).getSignature());
69         Assert.assertNull(((TypeAndValueBirthmarkElement)elements[2]).getValue());
70
71         Assert.assertEquals("Ljava/util/List;",
72                             ((TypeAndValueBirthmarkElement)elements[3]).getSignature());
73         Assert.assertNull(((TypeAndValueBirthmarkElement)elements[3]).getValue());
74     }
75
76     @Test
77     public void checkCVFVBirthmark2() throws Exception{
78         ExtractionResultSet ers = stigmata.createEngine().extract(
79             new String[] { "target/classes/jp/sourceforge/stigmata/result/RoundRobinComparisonResultSet.class", },
80             context
81         );
82
83         BirthmarkSet[] array = ers.getBirthmarkSets();
84
85         Assert.assertEquals(array.length, 1);
86         Assert.assertNotNull(array[0].getBirthmark("cvfv"));
87
88         Birthmark birthmark = array[0].getBirthmark("cvfv");
89         Assert.assertEquals(birthmark.getType(), "cvfv");
90         Assert.assertEquals(3, birthmark.getElementCount());
91
92         BirthmarkElement[] elements = birthmark.getElements();
93         Assert.assertEquals("jp.sourceforge.stigmata.birthmarks.cvfv.TypeAndValueBirthmarkElement",
94                             elements[0].getClass().getName());
95         Assert.assertEquals("jp.sourceforge.stigmata.birthmarks.cvfv.TypeAndValueBirthmarkElement",
96                             elements[1].getClass().getName());
97         Assert.assertEquals("jp.sourceforge.stigmata.birthmarks.cvfv.TypeAndValueBirthmarkElement",
98                             elements[2].getClass().getName());
99
100         Assert.assertEquals("I",   ((TypeAndValueBirthmarkElement)elements[0]).getSignature());
101         Assert.assertEquals(-1,    ((TypeAndValueBirthmarkElement)elements[0]).getValue());
102
103         Assert.assertEquals("Z",   ((TypeAndValueBirthmarkElement)elements[1]).getSignature());
104         Assert.assertEquals(null,  ((TypeAndValueBirthmarkElement)elements[1]).getValue());
105
106         Assert.assertEquals("Z",   ((TypeAndValueBirthmarkElement)elements[2]).getSignature());
107         Assert.assertEquals(0,     ((TypeAndValueBirthmarkElement)elements[2]).getValue());
108     }
109 }