Source Code Cross Referenced for TabularTypeTest.java in  » JMX » mx4j » test » javax » management » openmbean » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » JMX » mx4j » test.javax.management.openmbean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (C) The MX4J Contributors.
003:         * All rights reserved.
004:         *
005:         * This software is distributed under the terms of the MX4J License version 1.0.
006:         * See the terms of the MX4J License in the documentation provided with this software.
007:         */package test.javax.management.openmbean;
008:
009:        import java.util.Arrays;
010:        import java.util.HashSet;
011:        import java.util.List;
012:        import javax.management.openmbean.CompositeType;
013:        import javax.management.openmbean.OpenDataException;
014:        import javax.management.openmbean.OpenType;
015:        import javax.management.openmbean.SimpleType;
016:        import javax.management.openmbean.TabularType;
017:
018:        import test.MX4JTestCase;
019:
020:        /**
021:         * @version $Revision: 1.8 $
022:         */
023:        public class TabularTypeTest extends MX4JTestCase {
024:            private String[] itemNames = null;
025:            private String[] itemDescriptions = null;
026:            private OpenType[] itemTypes;
027:            private String[] indexNames;
028:            private CompositeType tShirtType;
029:            private CompositeType wine;
030:            private TabularType allTShirtTypes;
031:
032:            public TabularTypeTest(String s) {
033:                super (s);
034:            }
035:
036:            protected void setUp() throws Exception {
037:                itemNames = new String[] { "model", "color", "size", "price" };
038:                itemDescriptions = new String[] { "TShirt's model name",
039:                        "TShirt's color", "TShirt's size", "TShirt's price" };
040:                itemTypes = new OpenType[] { SimpleType.STRING,
041:                        SimpleType.STRING, SimpleType.STRING, SimpleType.FLOAT };
042:                indexNames = new String[] { "model", "color", "size" };
043:                tShirtType = new CompositeType("tShirt", "a TShirt", itemNames,
044:                        itemDescriptions, itemTypes);
045:
046:                allTShirtTypes = new TabularType("tShirts",
047:                        "List of available TShirts", tShirtType, indexNames);
048:
049:                wine = new CompositeType("Wine", "Nectar of the gods",
050:                        new String[] { "Type", "Winery", "Vintage" },
051:                        new String[] { "Red, White, Rose, etc.",
052:                                "The wine's producer",
053:                                "The year the wine was made" }, new OpenType[] {
054:                                SimpleType.STRING, SimpleType.STRING,
055:                                SimpleType.INTEGER });
056:            }
057:
058:            public void testEquals() throws Exception {
059:                String[] itemNames2 = { "model", "color", "size", "price" };
060:                String[] itemDescriptions2 = { "Manufacturer's model name",
061:                        "The shirt's color", "How big is it",
062:                        "How much does it cost" };
063:                OpenType[] itemTypes2 = { SimpleType.STRING, SimpleType.STRING,
064:                        SimpleType.STRING, SimpleType.FLOAT };
065:                String[] indexNames2 = { "model", "color", "size" };
066:                CompositeType tShirtType2 = new CompositeType("tShirt",
067:                        "a TShirt", itemNames2, itemDescriptions2, itemTypes2);
068:                TabularType allTShirtTypes2 = new TabularType("tShirts",
069:                        "List of available TShirts", tShirtType2, indexNames2);
070:                assertTrue(allTShirtTypes.equals(allTShirtTypes2));
071:                // assert reverse
072:                assertTrue(allTShirtTypes2.equals(allTShirtTypes));
073:            }
074:
075:            public void testNotEqual() throws Exception {
076:                String[] itemNames3 = { "model3", "color3", "size3", "price3" };
077:                String[] itemDescriptions3 = { "TShirt's model name",
078:                        "TShirt's color", "TShirt's size", "TShirt's price" };
079:                OpenType[] itemTypes3 = { SimpleType.STRING,
080:                        SimpleType.BOOLEAN, SimpleType.STRING, SimpleType.FLOAT };
081:                String[] indexNames3 = { "model3", "color3", "size3" };
082:                CompositeType tShirtType3 = new CompositeType("tShirt3",
083:                        "a TShirt", itemNames3, itemDescriptions3, itemTypes3);
084:                TabularType allTShirtTypes3 = new TabularType("tShirts3",
085:                        "List of available TShirts", tShirtType3, indexNames3);
086:                assertFalse(allTShirtTypes.equals(allTShirtTypes3));
087:            }
088:
089:            public void testGetRowType() {
090:                CompositeType test = allTShirtTypes.getRowType();
091:                assertEquals(test, tShirtType);
092:            }
093:
094:            public void testGetIndexNames() {
095:                List temp = allTShirtTypes.getIndexNames();
096:                String[] tempList = (String[]) temp.toArray(new String[temp
097:                        .size()]);
098:
099:                assertEquals(tempList.length, indexNames.length);
100:                // assert all elements are the same
101:                for (int i = 0; i < tempList.length; i++) {
102:                    assertTrue(tempList[i] == indexNames[i]);
103:                }
104:            }
105:
106:            public void testHashCode() throws Exception {
107:                String[] itemNames2 = { "model", "color", "size", "price" };
108:                String[] itemDescriptions2 = { "Manufacturer's model name",
109:                        "The shirt's color", "How big is it",
110:                        "How much does it cost" };
111:                OpenType[] itemTypes2 = { SimpleType.STRING, SimpleType.STRING,
112:                        SimpleType.STRING, SimpleType.FLOAT };
113:                String[] indexNames2 = { "model", "color", "size" };
114:                CompositeType tShirtType2 = new CompositeType("tShirt",
115:                        "a TShirt", itemNames2, itemDescriptions2, itemTypes2);
116:                TabularType allTShirtTypes2 = new TabularType("tShirts",
117:                        "List of available TShirts", tShirtType2, indexNames2);
118:
119:                String[] itemNames3 = { "model3", "color3", "size3", "price3" };
120:                String[] itemDescriptions3 = { "TShirt's model name",
121:                        "TShirt's color", "TShirt's size", "TShirt's price" };
122:                OpenType[] itemTypes3 = { SimpleType.STRING,
123:                        SimpleType.BOOLEAN, SimpleType.STRING, SimpleType.FLOAT };
124:                String[] indexNames3 = { "model3", "color3", "size3" };
125:                CompositeType tShirtType3 = new CompositeType("tShirt3",
126:                        "a TShirt", itemNames3, itemDescriptions3, itemTypes3);
127:                TabularType allTShirtTypes3 = new TabularType("tShirts3",
128:                        "List of available TShirts", tShirtType3, indexNames3);
129:
130:                int code1 = allTShirtTypes.hashCode();
131:                int code2 = allTShirtTypes2.hashCode();
132:                assertEquals(code2, "tShirts".hashCode()
133:                        + tShirtType2.hashCode()
134:                        + (new HashSet(Arrays.asList(indexNames))).hashCode());
135:                int code3 = allTShirtTypes3.hashCode();
136:
137:                assertEquals(code1, code2);
138:                assertTrue(code1 != code3);
139:            }
140:
141:            public void testCtor() throws Exception {
142:                TabularType winecatalog = new TabularType("Wine Catalog",
143:                        "Catalog of available wines", wine, new String[] {
144:                                "Winery", "Vintage" });
145:                assertTrue("Unexpected name", winecatalog.getTypeName()
146:                        .compareTo("Wine Catalog") == 0);
147:                assertTrue("Unexpected CompositeType", winecatalog.getRowType()
148:                        .equals(wine));
149:                List index = winecatalog.getIndexNames();
150:                assertTrue("Incorrect index size", index.size() == 2);
151:                assertTrue("Unexpected index entries", ((String) index.get(0))
152:                        .compareTo("Winery") == 0
153:                        && ((String) index.get(1)).compareTo("Vintage") == 0);
154:            }
155:
156:            public void testCtorNullName() throws Exception {
157:                try {
158:                    new TabularType(null, "Catalog of available wines", wine,
159:                            new String[] { "Winery", "Vintage" });
160:                    fail("Expecting IllegalArgumentException");
161:                } catch (IllegalArgumentException x) {
162:                }
163:            }
164:
165:            public void testCtorEmptyName() throws Exception {
166:                try {
167:                    new TabularType("", "Catalog of available wines", wine,
168:                            new String[] { "Winery", "Vintage" });
169:                    fail("Expecting IllegalArgumentException");
170:                } catch (IllegalArgumentException x) {
171:                }
172:            }
173:
174:            public void testCtorNullDescriptor() throws Exception {
175:                try {
176:                    new TabularType("Wine Catalog", null, wine, new String[] {
177:                            "Winery", "Vintage" });
178:                    fail("Expecting IllegalArgumentException");
179:                } catch (IllegalArgumentException x) {
180:                }
181:            }
182:
183:            public void testCtorEmptyDescriptor() throws Exception {
184:                try {
185:                    new TabularType("Wine Catalog", "", wine, new String[] {
186:                            "Winery", "Vintage" });
187:                    fail("Expecting IllegalArgumentException");
188:                } catch (IllegalArgumentException x) {
189:                }
190:            }
191:
192:            public void testCtorNullRowType() throws Exception {
193:                try {
194:                    new TabularType("Wine Catalog",
195:                            "Catalog of available wines", null, new String[] {
196:                                    "Winery", "Vintage" });
197:                    fail("Expecting IllegalArgumentException");
198:                } catch (IllegalArgumentException x) {
199:                }
200:            }
201:
202:            public void testCtorNullIndex() throws Exception {
203:                try {
204:                    new TabularType("Wine Catalog",
205:                            "Catalog of available wines", wine, null);
206:                    fail("Expecting IllegalArgumentException");
207:                } catch (IllegalArgumentException x) {
208:                }
209:            }
210:
211:            public void testCtorEmptyIndex() throws Exception {
212:                try {
213:                    new TabularType("Wine Catalog",
214:                            "Catalog of available wines", wine, new String[0]);
215:                    fail("Expecting IllegalArgumentException");
216:                } catch (IllegalArgumentException x) {
217:                }
218:            }
219:
220:            public void testCtorBogusIndex() throws Exception {
221:                try {
222:                    new TabularType("Wine Catalog",
223:                            "Catalog of available wines", wine, new String[] {
224:                                    "Region", "Vintage" });
225:                    fail("Expecting OpenDataException");
226:                } catch (OpenDataException x) {
227:                }
228:            }
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.