1 23 24 package org.objectweb.jorm.mapper.fos.lib; 25 26 import junit.framework.TestCase; 27 import org.objectweb.jorm.api.PException; 28 29 35 public class TestFosPMappingStructuresManager extends TestCase { 36 private final static String JCN1 = "org.objectweb.test.C1"; 37 private final static String JCN2 = "org.objectweb.test.C2"; 38 39 private final static String D1 = "org/d1"; 40 private final static String D2 = "org/d2long"; 41 private final static String D11 = "org/d1/d1"; 42 43 public TestFosPMappingStructuresManager(String testname) { 44 super(testname); 45 } 46 47 protected void setUp() { 48 49 } 50 51 protected void tearDown() { 52 53 } 54 55 public void testClusterWith1Class1Dir() { 56 try { 57 FosPMappingStructuresManager man = new FosPMappingStructuresManager(); 58 man.addDirName(JCN1, D1); 59 FosPMapCluster cl = (FosPMapCluster) man.getPMapCluster(JCN1); 60 assertTrue("Cluster has not been created for " + JCN1, cl != null); 61 assertTrue("Directory " + D1 + " does not exist in cluster", cl.containDirectory(D1)); 62 } catch (PException e) { 63 e.printStackTrace(); 64 fail(e.getMessage()); 65 } 66 } 67 68 public void testClusterWith1Class1DirDup() { 69 try { 70 FosPMappingStructuresManager man = new FosPMappingStructuresManager(); 71 man.addDirName(JCN1, D1); 72 man.addDirName(JCN1, D1); 73 FosPMapCluster cl = (FosPMapCluster) man.getPMapCluster(JCN1); 74 assertTrue("Cluster has not been created for " + JCN1, cl != null); 75 assertTrue("Directory " + D1 + " does not exist in cluster", cl.containDirectory(D1)); 76 } catch (PException e) { 77 e.printStackTrace(); 78 fail(e.getMessage()); 79 } 80 } 81 82 public void testClusterWith1Class2DirSubBefore() { 83 try { 84 FosPMappingStructuresManager man = new FosPMappingStructuresManager(); 85 man.addDirName(JCN1, D1); 86 man.addDirName(JCN1, D11); 87 FosPMapCluster cl = (FosPMapCluster) man.getPMapCluster(JCN1); 88 assertTrue("Cluster has not been created for " + JCN1, cl != null); 89 assertTrue("Directory " + D11 + " does not exist in cluster", cl.containDirectory(D11)); 90 assertTrue("Directory " + D1 + " does not exist in cluster", cl.containDirectory(D1)); 91 } catch (PException e) { 92 e.printStackTrace(); 93 fail(e.getMessage()); 94 } 95 } 96 97 public void testClusterWith1Class2DirSubAfter() { 98 try { 99 FosPMappingStructuresManager man = new FosPMappingStructuresManager(); 100 man.addDirName(JCN1, D1); 101 man.addDirName(JCN1, D11); 102 FosPMapCluster cl = (FosPMapCluster) man.getPMapCluster(JCN1); 103 assertTrue("Cluster has not been created for " + JCN1, cl != null); 104 assertTrue("Directory " + D1 + " does not exist in cluster", cl.containDirectory(D1)); 105 assertTrue("Directory " + D11 + " does not exist in cluster", cl.containDirectory(D11)); 106 } catch (PException e) { 107 e.printStackTrace(); 108 fail(e.getMessage()); 109 } 110 } 111 112 public void testClusterWith2Class2DirNoMerge() { 113 try { 114 FosPMappingStructuresManager man = new FosPMappingStructuresManager(); 115 man.addDirName(JCN1, D1); 116 man.addDirName(JCN2, D2); 117 FosPMapCluster cl = (FosPMapCluster) man.getPMapCluster(JCN1); 118 FosPMapCluster cl2 = (FosPMapCluster) man.getPMapCluster(JCN2); 119 assertTrue("Cluster has not been created for " + JCN1, cl != null); 120 assertTrue("Cluster has not been created for " + JCN2, cl2 != null); 121 assertTrue("The two classes are into the same cluster", cl != cl2); 122 assertTrue("Directory " + D1 + " does not exist in cluster", cl.containDirectory(D1)); 123 assertTrue("Directory " + D2 + " does not exist in cluster", cl2.containDirectory(D2)); 124 } catch (PException e) { 125 e.printStackTrace(); 126 fail(e.getMessage()); 127 } 128 } 129 130 public void testClusterWith2Class3DirMerge() { 131 try { 132 FosPMappingStructuresManager man = new FosPMappingStructuresManager(); 133 man.addDirName(JCN1, D1); 134 man.addDirName(JCN1, D2); 135 man.addDirName(JCN2, D11); 136 FosPMapCluster cl = (FosPMapCluster) man.getPMapCluster(JCN1); 137 FosPMapCluster cl2 = (FosPMapCluster) man.getPMapCluster(JCN2); 138 assertTrue("Cluster has not been created for " + JCN1, cl != null); 139 assertTrue("Cluster has not been created for " + JCN2, cl2 != null); 140 assertTrue("The two classes are not into the same cluster", cl == cl2); 141 assertTrue("Directory " + D1 + " does not exist in cluster", cl.containDirectory(D1)); 142 assertTrue("Directory " + D2 + " does not exist in cluster", cl.containDirectory(D2)); 143 assertTrue("Directory " + D11 + " does not exist in cluster", cl.containDirectory(D11)); 144 } catch (PException e) { 145 e.printStackTrace(); 146 fail(e.getMessage()); 147 } 148 } 149 } 150 | Popular Tags |