1 package net.sf.jlayercheck.gui;
2
3 import java.awt.image.BufferedImage;
4 import java.util.Map;
5 import java.util.Set;
6 import java.util.TreeMap;
7 import java.util.TreeSet;
8
9 import junit.framework.TestCase;
10 import net.sf.jlayercheck.util.exceptions.CycleFoundException;
11 import net.sf.jlayercheck.util.graph.GraphModuleDependencies;
12
13
14
15
16
17
18 public class GraphModuleDependenciesTest extends TestCase {
19
20
21
22
23
24
25 public void testCycleException() throws Exception {
26 Map<String, Set<String>> testmap = new TreeMap<String, Set<String>>();
27
28 Set<String> guiset = new TreeSet<String>();
29 guiset.add("domain");
30 guiset.add("persistency");
31 testmap.put("gui3", guiset);
32
33 Set<String> pset = new TreeSet<String>();
34 pset.add("domain");
35 testmap.put("persistency", pset);
36
37 Set<String> dset = new TreeSet<String>();
38 dset.add("gui3");
39 testmap.put("domain", dset);
40
41 try {
42 new GraphModuleDependencies(testmap);
43 assertTrue(false);
44
45
46 } catch(CycleFoundException e) {
47
48 }
49 }
50
51 public void testNormalCase() throws Exception {
52 Map<String, Set<String>> testmap = new TreeMap<String, Set<String>>();
53
54 Set<String> guiset = new TreeSet<String>();
55 guiset.add("domain");
56 guiset.add("persistency");
57 testmap.put("gui", guiset);
58
59 Set<String> pset = new TreeSet<String>();
60 pset.add("domain");
61 testmap.put("persistency", pset);
62
63 Set<String> dset = new TreeSet<String>();
64 testmap.put("domain", dset);
65
66 BufferedImage bi = new GraphModuleDependencies(testmap).getImage();
67
68 assertTrue(bi.getWidth()>100);
69 assertTrue(bi.getHeight()>100);
70 }
71 }