KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > slf4j > BasicMarkerTest


1 /*
2  * Copyright (c) 2004-2005 SLF4J.ORG
3  * Copyright (c) 2004-2005 QOS.ch
4  *
5  * All rights reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, and/or sell copies of the Software, and to permit persons
12  * to whom the Software is furnished to do so, provided that the above
13  * copyright notice(s) and this permission notice appear in all copies of
14  * the Software and that both the above copyright notice(s) and this
15  * permission notice appear in supporting documentation.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
20  * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
22  * SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
23  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
24  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
25  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26  *
27  * Except as contained in this notice, the name of a copyright holder
28  * shall not be used in advertising or otherwise to promote the sale, use
29  * or other dealings in this Software without prior written authorization
30  * of the copyright holder.
31  *
32  */

33 package org.slf4j;
34
35 import junit.framework.TestCase;
36
37 import org.slf4j.helpers.BasicMarkerFactory;
38
39
40 /**
41  * @author ceki
42  */

43 public class BasicMarkerTest extends TestCase {
44   static final String JavaDoc BLUE_STR = "BLUE";
45   static final String JavaDoc RED_STR = "RED";
46   static final String JavaDoc GREEN_STR = "GREEN";
47   static final String JavaDoc COMP_STR = "COMP";
48   static final String JavaDoc 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