1 package jp.sourceforge.stigmata.birthmarks.cvfv;
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;
10 import org.junit.Assert;
11 import org.junit.Before;
12 import org.junit.Test;
16 * @author Haruaki TAMADA
18 public class CVFVBirthmarkExtractorTest{
19 private Stigmata stigmata;
20 private BirthmarkContext context;
24 stigmata = Stigmata.getInstance();
25 context = stigmata.createContext();
26 context.addBirthmarkType("cvfv");
30 public void checkCVFVBirthmark() throws Exception{
31 ExtractionResultSet ers = stigmata.createEngine().extract(
32 new String[] { "target/classes/jp/sourceforge/stigmata/Stigmata.class", },
35 BirthmarkSet[] array = ers.getBirthmarkSets();
37 Assert.assertEquals(1, array.length);
38 Assert.assertNotNull(array[0].getBirthmark("cvfv"));
40 Birthmark birthmark = array[0].getBirthmark("cvfv");
41 Assert.assertEquals("cvfv", birthmark.getType());
42 Assert.assertEquals(4, birthmark.getElementCount());
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());
54 Assert.assertEquals("Ljp/sourceforge/stigmata/Stigmata;",
55 ((TypeAndValueBirthmarkElement)elements[0]).getSignature());
56 Assert.assertNull(((TypeAndValueBirthmarkElement)elements[0]).getValue());
58 Assert.assertEquals("Ljp/sourceforge/stigmata/printer/PrinterManager;",
59 ((TypeAndValueBirthmarkElement)elements[1]).getSignature());
60 Assert.assertNull(((TypeAndValueBirthmarkElement)elements[1]).getValue());
62 Assert.assertEquals("Ljp/sourceforge/stigmata/BirthmarkEnvironment;",
63 ((TypeAndValueBirthmarkElement)elements[2]).getSignature());
64 Assert.assertNull(((TypeAndValueBirthmarkElement)elements[2]).getValue());
66 Assert.assertEquals("Ljava/util/List;",
67 ((TypeAndValueBirthmarkElement)elements[3]).getSignature());
68 Assert.assertNull(((TypeAndValueBirthmarkElement)elements[3]).getValue());
72 public void checkCVFVBirthmark2() throws Exception{
73 ExtractionResultSet ers = stigmata.createEngine().extract(
74 new String[] { "target/classes/jp/sourceforge/stigmata/result/RoundRobinComparisonResultSet.class", },
78 BirthmarkSet[] array = ers.getBirthmarkSets();
80 Assert.assertEquals(array.length, 1);
81 Assert.assertNotNull(array[0].getBirthmark("cvfv"));
83 Birthmark birthmark = array[0].getBirthmark("cvfv");
84 Assert.assertEquals(birthmark.getType(), "cvfv");
85 Assert.assertEquals(3, birthmark.getElementCount());
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());
95 Assert.assertEquals("I", ((TypeAndValueBirthmarkElement)elements[0]).getSignature());
96 Assert.assertEquals(-1, ((TypeAndValueBirthmarkElement)elements[0]).getValue());
98 Assert.assertEquals("Z", ((TypeAndValueBirthmarkElement)elements[1]).getSignature());
99 Assert.assertEquals(null, ((TypeAndValueBirthmarkElement)elements[1]).getValue());
101 Assert.assertEquals("Z", ((TypeAndValueBirthmarkElement)elements[2]).getSignature());
102 Assert.assertEquals(0, ((TypeAndValueBirthmarkElement)elements[2]).getValue());