1 package jp.sourceforge.stigmata.birthmarks.cvfv;
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;
14 import org.junit.Assert;
15 import org.junit.Before;
16 import org.junit.Test;
20 * @author Haruaki TAMADA
23 public class CVFVBirthmarkExtractorTest{
24 private Stigmata stigmata;
25 private BirthmarkContext context;
29 stigmata = Stigmata.getInstance();
30 context = stigmata.createContext();
31 context.addBirthmarkType("cvfv");
35 public void checkCVFVBirthmark() throws Exception{
36 ExtractionResultSet ers = stigmata.createEngine().extract(
37 new String[] { "target/classes/jp/sourceforge/stigmata/Stigmata.class", },
40 BirthmarkSet[] array = ers.getBirthmarkSets();
42 Assert.assertEquals(1, array.length);
43 Assert.assertNotNull(array[0].getBirthmark("cvfv"));
45 Birthmark birthmark = array[0].getBirthmark("cvfv");
46 Assert.assertEquals("cvfv", birthmark.getType());
47 Assert.assertEquals(4, birthmark.getElementCount());
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());
59 Assert.assertEquals("Ljp/sourceforge/stigmata/Stigmata;",
60 ((TypeAndValueBirthmarkElement)elements[0]).getSignature());
61 Assert.assertNull(((TypeAndValueBirthmarkElement)elements[0]).getValue());
63 Assert.assertEquals("Ljp/sourceforge/stigmata/printer/PrinterManager;",
64 ((TypeAndValueBirthmarkElement)elements[1]).getSignature());
65 Assert.assertNull(((TypeAndValueBirthmarkElement)elements[1]).getValue());
67 Assert.assertEquals("Ljp/sourceforge/stigmata/BirthmarkEnvironment;",
68 ((TypeAndValueBirthmarkElement)elements[2]).getSignature());
69 Assert.assertNull(((TypeAndValueBirthmarkElement)elements[2]).getValue());
71 Assert.assertEquals("Ljava/util/List;",
72 ((TypeAndValueBirthmarkElement)elements[3]).getSignature());
73 Assert.assertNull(((TypeAndValueBirthmarkElement)elements[3]).getValue());
77 public void checkCVFVBirthmark2() throws Exception{
78 ExtractionResultSet ers = stigmata.createEngine().extract(
79 new String[] { "target/classes/jp/sourceforge/stigmata/result/RoundRobinComparisonResultSet.class", },
83 BirthmarkSet[] array = ers.getBirthmarkSets();
85 Assert.assertEquals(array.length, 1);
86 Assert.assertNotNull(array[0].getBirthmark("cvfv"));
88 Birthmark birthmark = array[0].getBirthmark("cvfv");
89 Assert.assertEquals(birthmark.getType(), "cvfv");
90 Assert.assertEquals(3, birthmark.getElementCount());
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());
100 Assert.assertEquals("I", ((TypeAndValueBirthmarkElement)elements[0]).getSignature());
101 Assert.assertEquals(-1, ((TypeAndValueBirthmarkElement)elements[0]).getValue());
103 Assert.assertEquals("Z", ((TypeAndValueBirthmarkElement)elements[1]).getSignature());
104 Assert.assertEquals(null, ((TypeAndValueBirthmarkElement)elements[1]).getValue());
106 Assert.assertEquals("Z", ((TypeAndValueBirthmarkElement)elements[2]).getSignature());
107 Assert.assertEquals(0, ((TypeAndValueBirthmarkElement)elements[2]).getValue());