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(3, 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());
57 Assert.assertEquals("Ljp/sourceforge/stigmata/Stigmata;",
58 ((TypeAndValueBirthmarkElement)elements[0]).getSignature());
59 Assert.assertNull(((TypeAndValueBirthmarkElement)elements[0]).getValue());
61 Assert.assertEquals("Ljp/sourceforge/stigmata/BirthmarkEnvironment;",
62 ((TypeAndValueBirthmarkElement)elements[1]).getSignature());
63 Assert.assertNull(((TypeAndValueBirthmarkElement)elements[1]).getValue());
65 Assert.assertEquals("Ljava/util/List;",
66 ((TypeAndValueBirthmarkElement)elements[2]).getSignature());
67 Assert.assertNull(((TypeAndValueBirthmarkElement)elements[2]).getValue());
71 public void checkCVFVBirthmark2() throws Exception{
72 ExtractionResultSet ers = stigmata.createEngine().extract(
73 new String[] { "target/classes/jp/sourceforge/stigmata/result/RoundRobinComparisonResultSet.class", },
77 BirthmarkSet[] array = ers.getBirthmarkSets();
79 Assert.assertEquals(array.length, 1);
80 Assert.assertNotNull(array[0].getBirthmark("cvfv"));
82 Birthmark birthmark = array[0].getBirthmark("cvfv");
83 Assert.assertEquals(birthmark.getType(), "cvfv");
84 Assert.assertEquals(3, birthmark.getElementCount());
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());
94 Assert.assertEquals("I", ((TypeAndValueBirthmarkElement)elements[0]).getSignature());
95 Assert.assertEquals(-1, ((TypeAndValueBirthmarkElement)elements[0]).getValue());
97 Assert.assertEquals("Z", ((TypeAndValueBirthmarkElement)elements[1]).getSignature());
98 Assert.assertEquals(null, ((TypeAndValueBirthmarkElement)elements[1]).getValue());
100 Assert.assertEquals("Z", ((TypeAndValueBirthmarkElement)elements[2]).getSignature());
101 Assert.assertEquals(0, ((TypeAndValueBirthmarkElement)elements[2]).getValue());