1 33 package org.slf4j; 34 35 import junit.framework.TestCase; 36 37 import org.slf4j.helpers.BasicMarkerFactory; 38 39 40 43 public class BasicMarkerTest extends TestCase { 44 static final String BLUE_STR = "BLUE"; 45 static final String RED_STR = "RED"; 46 static final String GREEN_STR = "GREEN"; 47 static final String COMP_STR = "COMP"; 48 static final String MULTI_COMP_STR = "MULTI_COMP"; 49 50 final IMarkerFactory factory; 51 final Marker blue; 52 final Marker red; 53 final Marker green; 54 final Marker comp; 55 final Marker multiComp; 56 57 public BasicMarkerTest() { 58 factory = new BasicMarkerFactory(); 59 60 blue = factory.getMarker(BLUE_STR); 61 red = factory.getMarker(RED_STR); 62 green = factory.getMarker(GREEN_STR); 63 comp = factory.getMarker(COMP_STR); 64 comp.add(blue); 65 66 multiComp = factory.getMarker(MULTI_COMP_STR); 67 multiComp.add(green); 68 multiComp.add(comp); 69 70 } 71 public void testPrimitive() { 72 assertEquals(BLUE_STR, blue.getName()); 73 assertTrue(blue.contains(blue)); 74 75 Marker blue2 = factory.getMarker(BLUE_STR); 76 assertEquals(BLUE_STR, blue2.getName()); 77 assertEquals(blue, blue2); 78 assertTrue(blue.contains(blue2)); 79 assertTrue(blue2.contains(blue)); 80 } 81 82 public void testPrimitiveByName() { 83 assertTrue(blue.contains(BLUE_STR)); 84 } 85 86 public void testComposite() { 87 assertTrue(comp.contains(comp)); 88 assertTrue(comp.contains(blue)); 89 } 90 91 public void testCompositeByName() { 92 assertTrue(comp.contains(COMP_STR)); 93 assertTrue(comp.contains(BLUE_STR)); 94 } 95 96 97 public void testMultiComposite() { 98 assertTrue(multiComp.contains(comp)); 99 assertTrue(multiComp.contains(blue)); 100 assertTrue(multiComp.contains(green)); 101 assertFalse(multiComp.contains(red)); 102 } 103 104 public void testMultiCompositeByName() { 105 assertTrue(multiComp.contains(COMP_STR)); 106 assertTrue(multiComp.contains(BLUE_STR)); 107 assertTrue(multiComp.contains(GREEN_STR)); 108 assertFalse(multiComp.contains(RED_STR)); 109 } 110 111 112 113 114 } 115 | Popular Tags |