Source Code Cross Referenced for TransparencyTestApp.java in  » Net » Terracotta » com » tctest » 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 » Net » Terracotta » com.tctest 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
0003:         * notice. All rights reserved.
0004:         */
0005:        package com.tctest;
0006:
0007:        import com.tc.object.bytecode.ManagerUtil;
0008:        import com.tc.object.config.ConfigVisitor;
0009:        import com.tc.object.config.DSOClientConfigHelper;
0010:        import com.tc.object.config.TransparencyClassSpec;
0011:        import com.tc.simulator.app.ApplicationConfig;
0012:        import com.tc.simulator.listener.ListenerProvider;
0013:        import com.tc.util.Assert;
0014:        import com.tctest.runner.AbstractTransparentApp;
0015:
0016:        import java.io.File;
0017:        import java.lang.reflect.Field;
0018:        import java.lang.reflect.Modifier;
0019:        import java.math.BigDecimal;
0020:        import java.math.BigInteger;
0021:        import java.util.ArrayList;
0022:        import java.util.Collection;
0023:        import java.util.Collections;
0024:        import java.util.Date;
0025:        import java.util.HashMap;
0026:        import java.util.HashSet;
0027:        import java.util.List;
0028:        import java.util.Map;
0029:        import java.util.Set;
0030:        import java.util.Vector;
0031:
0032:        /**
0033:         * @author steve
0034:         */
0035:        public class TransparencyTestApp extends AbstractTransparentApp {
0036:
0037:            private Map myRoot;
0038:            private Object out;
0039:            private static Object err;
0040:
0041:            public TransparencyTestApp(String appId, ApplicationConfig cfg,
0042:                    ListenerProvider listenerProvider) {
0043:                super (appId, cfg, listenerProvider);
0044:                System.err.println("APPID is " + appId);
0045:            }
0046:
0047:            public static void visitL1DSOConfig(ConfigVisitor visitor,
0048:                    DSOClientConfigHelper config) {
0049:                config
0050:                        .getOrCreateSpec("com.sun.jmx.mbeanserver.RepositorySupport");
0051:
0052:                String testAppName = TransparencyTestApp.class.getName();
0053:                config.addIncludePattern(testAppName);
0054:                config.addIncludePattern(testAppName + "$*");
0055:
0056:                TransparencyClassSpec appSpec = config
0057:                        .getOrCreateSpec("com.tctest.TransparencyTestApp");
0058:                appSpec.addRoot("myRoot", "rootBabyRoot");
0059:                appSpec.addRoot("vector", "vector");
0060:                appSpec.addRoot("out", "out");
0061:
0062:                TransparencyClassSpec spec = config
0063:                        .getOrCreateSpec("com.tctest.TransparencyTestApp$TestObj");
0064:
0065:                spec.addTransient("transientObject");
0066:                spec.addTransient("transientPrimitive");
0067:                config
0068:                        .addWriteAutolock("* com.tctest.TransparencyTestApp.*(..)");
0069:                config
0070:                        .addWriteAutolock("* com.tctest.AbstractTransparencyApp.*(..)");
0071:
0072:                config.getOrCreateSpec(FunnyCstr.class.getName());
0073:                config.getOrCreateSpec(FunnyBase.class.getName());
0074:            }
0075:
0076:            public void run() {
0077:                // Test case for LKC-774 (accessing static fields of the same name as roots)
0078:                out = new Object();
0079:                System.out.println("out is: " + out);
0080:                System.err.println("err is: " + err);
0081:
0082:                testStaticNonRoot();
0083:
0084:                myRoot = new HashMap();
0085:                synchronized (myRoot) {
0086:                    test1();
0087:                    Vector v = new Vector();
0088:                    v.add("Hello Steve");
0089:                    testFunnyInner();
0090:                    testFunnyCstr();
0091:                }
0092:
0093:            }
0094:
0095:            private void testStaticNonRoot() {
0096:                try {
0097:                    Class c = TestObj.class;
0098:                    Field f = c.getDeclaredField("staticFinalNonRoot");
0099:
0100:                    Assert.assertTrue(ManagerUtil.isPhysicallyInstrumented(c));
0101:
0102:                    Assert.assertFalse(ManagerUtil.isRoot(f));
0103:
0104:                    int access = f.getModifiers();
0105:                    Assert.assertTrue(Modifier.isFinal(access));
0106:                    Assert.assertTrue(Modifier.isStatic(access));
0107:                    Assert.assertTrue(Modifier.isPublic(access));
0108:
0109:                } catch (Exception e) {
0110:                    throw new RuntimeException(e);
0111:                }
0112:            }
0113:
0114:            FunnyCstr funnyCstr;
0115:
0116:            private void testFunnyCstr() {
0117:                funnyCstr = new FunnyCstr(new Object[] { this  }, new Object(),
0118:                        true);
0119:            }
0120:
0121:            interface Foo {
0122:                public Object foo();
0123:            }
0124:
0125:            Foo inner;
0126:
0127:            private void testFunnyInner() {
0128:                class Inner implements  Foo {
0129:
0130:                    class Nested implements  Foo {
0131:                        public Object foo() {
0132:                            return this ;
0133:                        }
0134:                    }
0135:
0136:                    public Object foo() {
0137:                        return new Nested();
0138:                    }
0139:                }
0140:
0141:                inner = new Inner();
0142:                inner = (Foo) inner.foo();
0143:            }
0144:
0145:            public void test1() {
0146:                System.out.println("Entering test1");
0147:                if (!myRoot.containsKey("value")) {
0148:                    myRoot.put("value", "1");
0149:                    Map fullMap = new HashMap();
0150:                    fullMap.put("1", new TestObj(new TestObj(null)));
0151:                    fullMap.put(new TestObj(new TestObj(null)), new TestObj(
0152:                            new TestObj(null)));
0153:                    fullMap.put("3", "4");
0154:                    fullMap.put("5", Collections.EMPTY_LIST);
0155:                    myRoot.put("testMapWithstuff", fullMap);
0156:                    System.out.println("Entering test2 put");
0157:                }
0158:
0159:                if (myRoot.get("value").equals("1")) {
0160:                    System.out.println("1");
0161:                    System.out
0162:                            .println("Creating test objects and putting them in the map");
0163:                    TestObj testObjectEmpty = new TestObj(new TestObj(null));
0164:                    TestObj testObjectFull = initialize(new TestObj(
0165:                            new TestObj(null)));
0166:                    myRoot.put("testObjectEmpty", testObjectEmpty);
0167:                    System.out.println("BEGIN ADD TO ROOT:");
0168:                    myRoot.put("testObjectFull", testObjectFull);
0169:                    System.out.println("END ADD TO ROOT:");
0170:                    myRoot.put("InitializeEmpty", null);
0171:                    myRoot.put("value", "2");
0172:                    return;
0173:                }
0174:
0175:                if (myRoot.get("value").equals("2")) {
0176:                    System.out.println("2");
0177:                    System.out
0178:                            .println("Checking to make sure the stuff we put in is there and that nothing extra is there");
0179:                    Assert.eval((TestObj) myRoot.get("testObject") == null);
0180:                    Assert
0181:                            .eval((TestObj) myRoot.get("testObjectEmpty") != null);
0182:                    Assert.eval((TestObj) myRoot.get("testObjectFull") != null);
0183:
0184:                    System.out.println("Checking to make sure full is full");
0185:                    TestObj full = (TestObj) myRoot.get("testObjectFull");
0186:
0187:                    verifyFull(full);
0188:
0189:                    System.out.println("putting stuff in the empty one");
0190:                    TestObj testObjectEmpty = (TestObj) myRoot
0191:                            .get("testObjectEmpty");
0192:                    initialize(testObjectEmpty);
0193:                    myRoot.put("VerifyEmptyFull", null);
0194:                    myRoot.remove("InitializeEmpty");
0195:                    myRoot.put("value", "3");
0196:                    return;
0197:                }
0198:
0199:                if (myRoot.get("value").equals("3")) {
0200:                    System.out.println("3");
0201:                    TestObj testObjectEmpty = (TestObj) myRoot
0202:                            .get("testObjectEmpty");
0203:                    verifyFull(testObjectEmpty);
0204:                    initialize2(testObjectEmpty);
0205:                    myRoot.remove("VerifyEmptyFull");
0206:                    myRoot.put("VerifyInitialize2", null);
0207:                    System.out.println("Verified Empty Now Full");
0208:                    myRoot.put("value", "4");
0209:                    return;
0210:                }
0211:                if (myRoot.get("value").equals("4")) {
0212:                    System.out.println("4");
0213:                    TestObj testObjectEmpty = (TestObj) myRoot
0214:                            .get("testObjectEmpty");
0215:                    verifyFull2(testObjectEmpty);
0216:                    System.out.println("Verified Empty Now Full");
0217:                    myRoot.put("value", "5");
0218:                }
0219:            }
0220:
0221:            private TestObj initialize(TestObj obj) {
0222:
0223:                class NamedSubclass implements  Runnable {
0224:                    public void run() {
0225:                        System.out.println("Hello world");
0226:                    }
0227:                }
0228:
0229:                obj.namedSubclass = new NamedSubclass();
0230:                obj.setSyncMap(Collections.synchronizedMap(new HashMap()));
0231:                obj.setSyncSet(Collections.synchronizedSet(new HashSet()));
0232:                obj.setSyncList(Collections.synchronizedList(new ArrayList()));
0233:                obj.setSyncCollection(Collections
0234:                        .synchronizedCollection(new ArrayList()));
0235:
0236:                System.setProperty("steve", "prop1");
0237:                obj.setClassObject(Object.class);
0238:                obj.setSqlDate(new java.sql.Date(10));
0239:                obj.setTransientObject(new HashMap());
0240:                obj.setTransientPrimitive(101L);
0241:                obj.setObjectArray(new Object[5]);
0242:                obj.setObjectArray(1, new File("hello"));
0243:                obj.setObjectArray(2, new Character('b'));
0244:
0245:                Date[] dates = new Date[2];
0246:                obj.setFile(new File("yellow"));
0247:                obj.setDates(dates);
0248:                obj.setDate(0, new Date());
0249:
0250:                obj.setCharacters(new Character[2]);
0251:                obj.setCharacter(0, new Character('c'));
0252:
0253:                obj.setDate(new Date());
0254:                obj.setLiteralObject(new Long(0));
0255:                obj.setBooleanObject(new Boolean(true));
0256:                obj.setBooleanValue(true);
0257:                obj.setByteObject(new Byte((byte) 1));
0258:                obj.setByteValue((byte) 2);
0259:                obj.setCharValue('a');
0260:                obj.setCharObject(new Character('b'));
0261:                obj.setDoubleObject(new Double(1.1));
0262:                obj.setDoubleValue(1.2);
0263:                obj.floatObject = new Float(2.1);
0264:                obj.setFloatValue((float) 2.2);
0265:                // obj.setIntegerObject(new Integer(3));
0266:                obj.integerObject = new Integer(3);
0267:                obj.setIntegerValue(4);
0268:                obj.longObject = new Long(5);
0269:                obj.setLongValue(6);
0270:                obj.setShortObject(new Short((short) 7));
0271:                obj.setShortValue((short) 8);
0272:                obj.setStringValue("Steve");
0273:                obj.setObjects(new TestObj[1]);
0274:                TestObj to = new TestObj(null);
0275:                to.setStringValue("cool");
0276:                obj.setObject(0, to);
0277:                obj.setLongs(new long[4]);
0278:                obj.setLong(2, 4);
0279:                obj.setInts(new int[6]);
0280:                obj.setInt(3, 6);
0281:                obj.ints2 = new int[6];
0282:                System.arraycopy(obj.ints, 0, obj.ints2, 0, 6);
0283:                obj.setDoubles(new double[8]);
0284:                obj.setDouble(4, 8);
0285:                obj.setShorts(new short[10]);
0286:                obj.setShort(5, (short) 10);
0287:                obj.setBooleans(new boolean[12]);
0288:                obj.setBoolean(6, true);
0289:                obj.setBytes(new byte[14]);
0290:                obj.setByte(7, (byte) 14);
0291:                obj.setFloats(new float[16]);
0292:                obj.setFloat(8, 16);
0293:                obj.setChars(new char[18]);
0294:                obj.setChar(9, 'A');
0295:                obj.setTwoDobjects(new TestObj[6][4]);
0296:                to = new TestObj(null);
0297:                to.setStringValue("baby");
0298:                obj.setTwoDobject(4, 2, to);
0299:                obj.bigIntegerObject = new BigInteger("100");
0300:                obj.bigDecimalObject = new BigDecimal(100.0);
0301:                return obj;
0302:            }
0303:
0304:            private TestObj initialize2(TestObj obj) {
0305:                System.setProperty("steve", "prop2");
0306:
0307:                obj.getSyncMap().put("Hello", "Steve");
0308:                obj.getSyncList().add("Hello");
0309:                obj.getSyncSet().add("Hello");
0310:                obj.getSyncCollection().add("Hello");
0311:
0312:                obj.setClassObject(Integer.class);
0313:                obj.setSqlDate(new java.sql.Date(11));
0314:                obj.setTransientObject(new Date());
0315:                obj.setTransientPrimitive(1011L);
0316:
0317:                obj.setObjectArray(2, new File("hello"));
0318:                obj.setObjectArray(1, new Character('b'));
0319:
0320:                obj.setFile(new File("yellow"));
0321:                obj.setDate(1, new Date());
0322:                obj.setCharacter(1, new Character('d'));
0323:                obj.setDate(new Date());
0324:                obj.setLiteralObject("Steve");
0325:                obj.setBooleanObject(new Boolean(false));
0326:                obj.setBooleanValue(false);
0327:                obj.setByteObject(new Byte((byte) 2));
0328:                obj.setByteValue((byte) 3);
0329:                obj.setCharValue('e');
0330:                obj.setCharObject(new Character('f'));
0331:                // obj.setDoubleObject(new Double((double) 5.1));
0332:                obj.doubleObject = new Double(5.1);
0333:                obj.setDoubleValue(6.2);
0334:                obj.setFloatObject(new Float(7.1));
0335:                obj.setFloatValue((float) 8.2);
0336:                obj.setIntegerObject(new Integer(9));
0337:                obj.setIntegerValue(10);
0338:                obj.setLongObject(new Long(11));
0339:                obj.setLongValue(6);
0340:                obj.setShortObject(new Short((short) 12));
0341:                obj.setShortValue((short) 13);
0342:                obj.setStringValue("Steve2");
0343:                TestObj to = obj.getObject(0);
0344:                to.setStringValue("cool2");
0345:                obj.setObject(0, to);
0346:                obj.setLong(2, 3);
0347:                obj.setInt(3, 5);
0348:                obj.setDouble(4, 7);
0349:                obj.setShort(5, (short) 9);
0350:                obj.setBoolean(6, false);
0351:                obj.setByte(7, (byte) 13);
0352:                obj.setFloat(8, 15);
0353:                obj.setChar(9, 'B');
0354:                to = obj.getTwoDobject(4, 2);
0355:                to.setStringValue("baby2");
0356:                final Object outer = new Object();
0357:                final float oneInt = 100;
0358:                final char oneChar = 'c';
0359:                new Thread(new Runnable() {
0360:                    public void run() {
0361:                        System.out.println(outer + " " + oneInt + " one:"
0362:                                + oneChar);
0363:                    }
0364:                }).start();
0365:                obj.setTwoDobject(5, 1, new TestObj(null));
0366:                obj.setBigIntegerObject(new BigInteger("200"));
0367:                obj.setBigDecimalObject(new BigDecimal(200.0));
0368:                return obj;
0369:            }
0370:
0371:            private void verifyFull2(TestObj obj) {
0372:
0373:                Assert.eval(obj.getSyncMap().containsKey("Hello"));
0374:                Assert.eval(obj.getSyncMap().get("Hello").equals("Steve"));
0375:
0376:                Assert.eval(obj.getSyncSet().contains("Hello"));
0377:                Assert.eval(obj.getSyncList().contains("Hello"));
0378:                Assert.eval(obj.getSyncCollection().contains("Hello"));
0379:
0380:                Assert.eval(obj.getSqlDate().getTime() == 11);
0381:                Assert.eval(Integer.class.equals(obj.getClassObject()));
0382:                Assert.eval(obj.getTransientObject() == null);
0383:                Assert.eval(obj.getTransientPrimitive() == 0);
0384:                Assert.eval(obj.getObjectArray(2).equals(new File("hello")));
0385:                Assert.eval(obj.getObjectArray(1).equals(new Character('b')));
0386:
0387:                Assert.eval(obj.getFile().equals(new File("yellow")));
0388:                Assert.eval(System.getProperty("steve").equals("prop2"));
0389:                Assert.eval(obj.getCharacter(0).equals(new Character('c')));
0390:                Assert.eval(obj.getCharacter(1).equals(new Character('d')));
0391:
0392:                Assert.eval(obj.getDate() != null);
0393:                Assert.eval(obj.getDate(0) != null);
0394:                Assert.eval(obj.getDate(1) != null);
0395:                Assert.eval(obj.getLiteralObject().equals("Steve"));
0396:                Assert.eval(obj.getBooleanObject().equals(new Boolean(false)));
0397:                Assert.eval(obj.getBooleanValue() == false);
0398:                Assert.eval(obj.getByteObject().equals(new Byte((byte) 2)));
0399:                Assert.eval(obj.getByteValue() == (byte) 3);
0400:                Assert.eval(obj.getCharValue() == 'e');
0401:                Assert.eval(obj.getCharObject().equals(new Character('f')));
0402:                Assert.eval(obj.getDoubleObject().equals(new Double(5.1)));
0403:                Assert.eval(obj.getDoubleValue() == 6.2);
0404:                Assert.eval(obj.getFloatObject().equals(new Float(7.1)));
0405:                Assert.eval(obj.getFloatValue() == (float) 8.2);
0406:                Assert.eval(obj.getIntegerObject().equals(new Integer(9)));
0407:                Assert.eval(obj.getIntegerValue() == 10);
0408:                Assert.eval(obj.getLongObject().equals(new Long(11)));
0409:                Assert.eval(obj.getLongValue() == 6);
0410:                Assert.eval(obj.getShortObject().equals(new Short((short) 12)));
0411:                Assert.eval(obj.getShortValue() == (short) 13);
0412:                Assert.eval(obj.getStringValue().equals("Steve2"));
0413:                Assert.eval(obj.getObjects().length == 1);
0414:                Assert
0415:                        .eval((obj.getObject(0)).getStringValue().equals(
0416:                                "cool2"));
0417:                Assert.eval(obj.getBigIntegerObject().equals(
0418:                        new BigInteger("200")));
0419:                Assert.eval(obj.getBigDecimalObject().equals(
0420:                        new BigDecimal(200.0)));
0421:
0422:                Assert.eval(obj.getInts().length == 6);
0423:                System.out.println("Got value:" + obj.getInt(3) + " array:"
0424:                        + obj.getInts());
0425:                Assert.eval(obj.getInt(3) == 5);
0426:
0427:                Assert.eval(obj.getLongs().length == 4);
0428:                Assert.eval(obj.getLong(2) == 3);
0429:
0430:                Assert.eval(obj.getDoubles().length == 8);
0431:                Assert.eval(obj.getDouble(4) == 7);
0432:                Assert.eval(obj.getShorts().length == 10);
0433:                Assert.eval(obj.getShort(5) == (short) 9);
0434:                Assert.eval(obj.getBooleans().length == 12);
0435:                Assert.eval(!obj.getBoolean(6));
0436:                Assert.eval(obj.getBytes().length == 14);
0437:                Assert.eval(obj.getByte(7) == (byte) 13);
0438:                Assert.eval(obj.getFloats().length == 16);
0439:                Assert.eval(obj.getFloat(8) == 15);
0440:                Assert.eval(obj.getChars().length == 18);
0441:                Assert.eval(obj.getChar(9) == 'B');
0442:                Assert.eval(obj.getTwoDobjects().length == 6);
0443:                System.out.println("About to check 2d");
0444:                Assert.eval(obj.getTwoDobjects()[0].length == 4);
0445:                Assert.eval(obj.getTwoDobject(4, 2).getStringValue().equals(
0446:                        "baby2"));
0447:                System.out.println("Checked 2d");
0448:            }
0449:
0450:            private void verifyFull(TestObj obj) {
0451:
0452:                Assert.eval(obj.getSyncMap() != null);
0453:                Assert.eval(obj.getSyncSet() != null);
0454:                Assert.eval(obj.getSyncCollection() != null);
0455:                Assert.eval(obj.getSyncList() != null);
0456:
0457:                Assert.eval(obj.getTransientObject() == null);
0458:                Assert.eval(Object.class.equals(obj.getClassObject()));
0459:                Assert.eval(obj.getSqlDate().getTime() == 10);
0460:                System.out.println("Got:" + obj.getTransientPrimitive());
0461:                Assert.eval(obj.getTransientPrimitive() == 0);
0462:                Assert.eval(obj.getObjectArray(1).equals(new File("hello")));
0463:                Assert.eval(obj.getObjectArray(2).equals(new Character('b')));
0464:                Assert.eval(obj.getFile().equals(new File("yellow")));
0465:                Assert.eval(System.getProperty("steve").equals("prop1"));
0466:                Assert.eval(obj.getCharacter(0).equals(new Character('c')));
0467:                Assert.eval(obj.getCharacter(1) == null);
0468:                Assert.eval(obj.getDate() != null);
0469:                Assert.eval(obj.getDate(0) != null);
0470:                Assert.eval(obj.getDate(1) == null);
0471:                Assert.eval(obj.getLiteralObject().equals(new Long(0)));
0472:                Assert.eval(obj.getBooleanObject().equals(new Boolean(true)));
0473:                Assert.eval(obj.getBooleanValue() == true);
0474:                Assert.eval(obj.getByteObject().equals(new Byte((byte) 1)));
0475:                Assert.eval(obj.getByteValue() == (byte) 2);
0476:                Assert.eval(obj.getCharValue() == 'a');
0477:                Assert.eval(obj.getCharObject().equals(new Character('b')));
0478:                Assert.eval(obj.getDoubleObject().equals(new Double(1.1)));
0479:                Assert.eval(obj.getDoubleValue() == 1.2);
0480:                Assert.eval(obj.floatObject.equals(new Float(2.1)));
0481:                Assert.eval(obj.getFloatValue() == (float) 2.2);
0482:                Assert.eval(obj.getIntegerObject().equals(new Integer(3)));
0483:                Assert.eval(obj.integerValue == 4);
0484:                Assert.eval(obj.getLongObject().equals(new Long(5)));
0485:                Assert.eval(obj.getLongValue() == 6);
0486:                Assert.eval(obj.getShortObject().equals(new Short((short) 7)));
0487:                Assert.eval(obj.getShortValue() == (short) 8);
0488:                Assert.eval(obj.getStringValue().equals("Steve"));
0489:                Assert.eval(obj.getObjects().length == 1);
0490:                Assert.eval((obj.getObject(0)).getStringValue().equals("cool"));
0491:                Assert.eval(obj.bigIntegerObject.equals(new BigInteger("100")));
0492:                Assert.eval(obj.bigDecimalObject.equals(new BigDecimal(100.0)));
0493:
0494:                Assert.eval(obj.getInts().length == 6);
0495:                System.out.println("Got value:" + obj.getInt(3) + " array:"
0496:                        + obj.getInts());
0497:                Assert.eval(obj.getInt(3) == 6);
0498:                Assert.eval(obj.ints2[3] == 6);
0499:                Assert.eval(obj.getLongs().length == 4);
0500:                Assert.eval(obj.getLong(2) == 4);
0501:
0502:                Assert.eval(obj.getDoubles().length == 8);
0503:                Assert.eval(obj.getDouble(4) == 8);
0504:                Assert.eval(obj.getShorts().length == 10);
0505:                Assert.eval(obj.getShort(5) == (short) 10);
0506:                Assert.eval(obj.getBooleans().length == 12);
0507:                Assert.eval(obj.getBoolean(6));
0508:                Assert.eval(obj.getBytes().length == 14);
0509:                Assert.eval(obj.getByte(7) == (byte) 14);
0510:                Assert.eval(obj.getFloats().length == 16);
0511:                Assert.eval(obj.getFloat(8) == 16);
0512:                Assert.eval(obj.getChars().length == 18);
0513:                Assert.eval(obj.getChar(9) == 'A');
0514:                Assert.eval(obj.getTwoDobjects().length == 6);
0515:                System.out.println("About to check 2d");
0516:                Assert.eval(obj.getTwoDobjects()[0].length == 4);
0517:                Assert.eval(obj.getTwoDobject(4, 2).getStringValue().equals(
0518:                        "baby"));
0519:                System.out.println("Checked 2d");
0520:            }
0521:
0522:            private static class FunnyBase {
0523:                FunnyBase(Object object, Object arg2) {
0524:                    //
0525:                }
0526:            }
0527:
0528:            private static class FunnyCstr extends FunnyBase {
0529:                // The only thing interesting about this class is that makes
0530:                // a static method invocation in it's cstr(). Our class adapter
0531:                // tripped up on this construct at one point
0532:                public FunnyCstr(Object[] arg1, Object arg2, boolean b) {
0533:                    super (FunnyCstr.foo(arg1[0], b), arg2);
0534:                }
0535:
0536:                private static Object foo(Object object, boolean b) {
0537:                    return object;
0538:                }
0539:            }
0540:
0541:            public static class TestObj {
0542:
0543:                public static final Object staticFinalNonRoot = new Object();
0544:
0545:                public void __tc_getallfieldvalues(Map values) {
0546:                    values.put("transientObject", transientObject);
0547:                    values.put("transientPrimitive", new Long(
0548:                            transientPrimitive));
0549:                }
0550:
0551:                public void __tc_setfieldvalue(String fieldName, Object value) {
0552:                    if (fieldName.equals("transientObject")) {
0553:                        this .transientObject = value;
0554:                    }
0555:                    if (fieldName.equals("transientPrimitive")) {
0556:                        this .transientPrimitive = ((Long) value).longValue();
0557:                    }
0558:                }
0559:
0560:                private Runnable anonymousSubclass = new Runnable() {
0561:                    private Object o;
0562:
0563:                    public void run() {
0564:                        System.out.println("syncMap" + syncMap);
0565:                        System.out.println("o: " + o);
0566:                    }
0567:                };
0568:
0569:                public Object namedSubclass;
0570:
0571:                public Runnable getAnonymousSubclass() {
0572:                    // This method here to silence warnings
0573:                    return this .anonymousSubclass;
0574:                }
0575:
0576:                public Object getNamedSubclass() {
0577:                    // This method here to silence warnings
0578:                    return this .namedSubclass;
0579:                }
0580:
0581:                private Map syncMap;
0582:                private Collection syncCollection;
0583:                private List syncList;
0584:                private Set syncSet;
0585:
0586:                private Object transientObject;
0587:                private long transientPrimitive;
0588:
0589:                private Class classObject;
0590:                private java.sql.Date sqlDate;
0591:                private final TestObj obj;
0592:                private File file;
0593:                private Date dateObject;
0594:                private String stringValue;
0595:                private Integer integerObject;
0596:                private int integerValue;
0597:                private Boolean booleanObject;
0598:                private boolean booleanValue;
0599:                private Long longObject;
0600:                private long longValue;
0601:                private Short shortObject;
0602:                private short shortValue;
0603:                private Double doubleObject;
0604:                private double doubleValue;
0605:                protected Float floatObject;
0606:                private float floatValue;
0607:                private Character charObject;
0608:                private char charValue;
0609:                private Byte byteObject;
0610:                private byte byteValue;
0611:                private TestObj[] objects;
0612:                private TestObj[][] twoDobjects;
0613:                private long[] longs;
0614:                private int[] ints;
0615:                private int[] ints2;
0616:                private double[] doubles;
0617:                private short[] shorts;
0618:                private boolean[] booleans;
0619:                private byte[] bytes;
0620:                private float[] floats;
0621:                private char[] chars;
0622:                private Date[] dates;
0623:                private Character[] charObjects;
0624:                private Object literalObject;
0625:                private Object[] objectArray;
0626:                private BigInteger bigIntegerObject;
0627:                private BigDecimal bigDecimalObject;
0628:
0629:                public TestObj(TestObj obj) {
0630:                    this .obj = obj;
0631:                }
0632:
0633:                public void setSyncMap(Map map) {
0634:                    this .syncMap = map;
0635:                }
0636:
0637:                public void setSyncSet(Set set) {
0638:                    this .syncSet = set;
0639:                }
0640:
0641:                public void setSyncList(List list) {
0642:                    this .syncList = list;
0643:                }
0644:
0645:                public void setSyncCollection(Collection collection) {
0646:                    this .syncCollection = collection;
0647:                }
0648:
0649:                public Map getSyncMap() {
0650:                    return this .syncMap;
0651:                }
0652:
0653:                public Set getSyncSet() {
0654:                    return this .syncSet;
0655:                }
0656:
0657:                public Collection getSyncCollection() {
0658:                    return this .syncCollection;
0659:                }
0660:
0661:                public List getSyncList() {
0662:                    return this .syncList;
0663:                }
0664:
0665:                public void setLiteralObject(Object o) {
0666:                    literalObject = o;
0667:                }
0668:
0669:                public Object getLiteralObject() {
0670:                    return literalObject;
0671:                }
0672:
0673:                /**
0674:                 * @return
0675:                 */
0676:                public boolean getBooleanValue() {
0677:                    return booleanValue;
0678:                }
0679:
0680:                /**
0681:                 * @return Returns the booleanObject.
0682:                 */
0683:                public Boolean getBooleanObject() {
0684:                    return booleanObject;
0685:                }
0686:
0687:                public java.sql.Date getSqlDate() {
0688:                    return sqlDate;
0689:                }
0690:
0691:                public void setSqlDate(java.sql.Date sqlDate) {
0692:                    this .sqlDate = sqlDate;
0693:                }
0694:
0695:                /**
0696:                 * @param booleanObject The booleanObject to set.
0697:                 */
0698:                public void setBooleanObject(Boolean booleanObject) {
0699:                    this .booleanObject = booleanObject;
0700:                }
0701:
0702:                /**
0703:                 * @return Returns the booleanValue.
0704:                 */
0705:                public boolean isBooleanValue() {
0706:                    return booleanValue;
0707:                }
0708:
0709:                /**
0710:                 * @param booleanValue The booleanValue to set.
0711:                 */
0712:                public void setBooleanValue(boolean booleanValue) {
0713:                    this .booleanValue = booleanValue;
0714:                }
0715:
0716:                /**
0717:                 * @return Returns the byteObject.
0718:                 */
0719:                public Byte getByteObject() {
0720:                    return byteObject;
0721:                }
0722:
0723:                /**
0724:                 * @param byteObject The byteObject to set.
0725:                 */
0726:                public void setByteObject(Byte byteObject) {
0727:                    this .byteObject = byteObject;
0728:                }
0729:
0730:                /**
0731:                 * @return Returns the byteValue.
0732:                 */
0733:                public byte getByteValue() {
0734:                    return byteValue;
0735:                }
0736:
0737:                public void setDate(int index, Date value) {
0738:                    dates[index] = value;
0739:                }
0740:
0741:                /**
0742:                 * @param byteValue The byteValue to set.
0743:                 */
0744:                public void setByteValue(byte byteValue) {
0745:                    this .byteValue = byteValue;
0746:                }
0747:
0748:                /**
0749:                 * @return Returns the charObject.
0750:                 */
0751:                public Character getCharObject() {
0752:                    return charObject;
0753:                }
0754:
0755:                /**
0756:                 * @param charObject The charObject to set.
0757:                 */
0758:                public void setCharObject(Character charObject) {
0759:                    this .charObject = charObject;
0760:                }
0761:
0762:                /**
0763:                 * @return Returns the charValue.
0764:                 */
0765:                public char getCharValue() {
0766:                    return charValue;
0767:                }
0768:
0769:                /**
0770:                 * @param charValue The charValue to set.
0771:                 */
0772:                public void setCharValue(char charValue) {
0773:                    this .charValue = charValue;
0774:                }
0775:
0776:                public void setCharacters(Character[] charObjects) {
0777:                    this .charObjects = charObjects;
0778:                }
0779:
0780:                public void setCharacter(int index, Character value) {
0781:                    this .charObjects[index] = value;
0782:                }
0783:
0784:                public Character getCharacter(int index) {
0785:                    return charObjects[index];
0786:                }
0787:
0788:                /**
0789:                 * @return Returns the doubleObject.
0790:                 */
0791:                public Double getDoubleObject() {
0792:                    return doubleObject;
0793:                }
0794:
0795:                /**
0796:                 * @param doubleObject The doubleObject to set.
0797:                 */
0798:                public void setDoubleObject(Double doubleObject) {
0799:                    this .doubleObject = doubleObject;
0800:                }
0801:
0802:                /**
0803:                 * @return Returns the doubleValue.
0804:                 */
0805:                public double getDoubleValue() {
0806:                    return doubleValue;
0807:                }
0808:
0809:                /**
0810:                 * @param doubleValue The doubleValue to set.
0811:                 */
0812:                public void setDoubleValue(double doubleValue) {
0813:                    this .doubleValue = doubleValue;
0814:                }
0815:
0816:                /**
0817:                 * @return Returns the floatObject.
0818:                 */
0819:                public Float getFloatObject() {
0820:                    return floatObject;
0821:                }
0822:
0823:                /**
0824:                 * @param floatObject The floatObject to set.
0825:                 */
0826:                public void setFloatObject(Float floatObject) {
0827:                    this .floatObject = floatObject;
0828:                }
0829:
0830:                /**
0831:                 * @return Returns the floatValue.
0832:                 */
0833:                public float getFloatValue() {
0834:                    return floatValue;
0835:                }
0836:
0837:                /**
0838:                 * @param floatValue The floatValue to set.
0839:                 */
0840:                public void setFloatValue(float floatValue) {
0841:                    this .floatValue = floatValue;
0842:                }
0843:
0844:                /**
0845:                 * @return Returns the integerObject.
0846:                 */
0847:                public Integer getIntegerObject() {
0848:                    return integerObject;
0849:                }
0850:
0851:                /**
0852:                 * @param integerObject The integerObject to set.
0853:                 */
0854:                public void setIntegerObject(Integer integerObject) {
0855:                    this .integerObject = integerObject;
0856:                }
0857:
0858:                /**
0859:                 * @return Returns the integerValue.
0860:                 */
0861:                public int getIntegerValue() {
0862:                    return integerValue;
0863:                }
0864:
0865:                /**
0866:                 * @param integerValue The integerValue to set.
0867:                 */
0868:                public void setIntegerValue(int integerValue) {
0869:                    this .integerValue = integerValue;
0870:                }
0871:
0872:                /**
0873:                 * @return Returns the longObject.
0874:                 */
0875:                public Long getLongObject() {
0876:                    return longObject;
0877:                }
0878:
0879:                /**
0880:                 * @param longObject The longObject to set.
0881:                 */
0882:                public void setLongObject(Long longObject) {
0883:                    this .longObject = longObject;
0884:                }
0885:
0886:                /**
0887:                 * @return Returns the longValue.
0888:                 */
0889:                public long getLongValue() {
0890:                    return longValue;
0891:                }
0892:
0893:                /**
0894:                 * @param longValue The longValue to set.
0895:                 */
0896:                public void setLongValue(long longValue) {
0897:                    this .longValue = longValue;
0898:                }
0899:
0900:                /**
0901:                 * @return Returns the obj.
0902:                 */
0903:                public TestObj getObj() {
0904:                    return obj;
0905:                }
0906:
0907:                /**
0908:                 * @return Returns the shortObject.
0909:                 */
0910:                public Short getShortObject() {
0911:                    return shortObject;
0912:                }
0913:
0914:                /**
0915:                 * @param shortObject The shortObject to set.
0916:                 */
0917:                public void setShortObject(Short shortObject) {
0918:                    this .shortObject = shortObject;
0919:                }
0920:
0921:                /**
0922:                 * @return Returns the shortValue.
0923:                 */
0924:                public short getShortValue() {
0925:                    return shortValue;
0926:                }
0927:
0928:                /**
0929:                 * @param shortValue The shortValue to set.
0930:                 */
0931:                public void setShortValue(short shortValue) {
0932:                    this .shortValue = shortValue;
0933:                }
0934:
0935:                /**
0936:                 * @return Returns the stringValue.
0937:                 */
0938:                public String getStringValue() {
0939:                    return stringValue;
0940:                }
0941:
0942:                /**
0943:                 * @param stringValue The stringValue to set.
0944:                 */
0945:                public void setStringValue(String stringValue) {
0946:                    this .stringValue = stringValue;
0947:                }
0948:
0949:                public TestObj[] getObjects() {
0950:                    return objects;
0951:                }
0952:
0953:                public void setObjects(TestObj[] objects) {
0954:                    this .objects = objects;
0955:                }
0956:
0957:                public void setObject(int index, TestObj value) {
0958:                    objects[index] = value;
0959:                }
0960:
0961:                public TestObj getObject(int index) {
0962:                    return objects[index];
0963:                }
0964:
0965:                public long getLong(int index) {
0966:                    return longs[index];
0967:                }
0968:
0969:                public void setLong(int index, long value) {
0970:                    longs[index] = value;
0971:                }
0972:
0973:                public int getInt(int index) {
0974:                    return ints[index];
0975:                }
0976:
0977:                public void setInt(int index, int value) {
0978:                    ints[index] = value;
0979:                }
0980:
0981:                public void setDates(Date[] dates) {
0982:                    this .dates = dates;
0983:                }
0984:
0985:                public Date getDate(int index) {
0986:                    return dates[index];
0987:                }
0988:
0989:                public double getDouble(int index) {
0990:                    return doubles[index];
0991:                }
0992:
0993:                public void setDouble(int index, double value) {
0994:                    doubles[index] = value;
0995:                }
0996:
0997:                public short getShort(int index) {
0998:                    return shorts[index];
0999:                }
1000:
1001:                public void setShort(int index, short value) {
1002:                    shorts[index] = value;
1003:                }
1004:
1005:                public boolean getBoolean(int index) {
1006:                    return booleans[index];
1007:                }
1008:
1009:                public void setBoolean(int index, boolean value) {
1010:                    booleans[index] = value;
1011:                }
1012:
1013:                public byte getByte(int index) {
1014:                    return bytes[index];
1015:                }
1016:
1017:                public void setByte(int index, byte value) {
1018:                    bytes[index] = value;
1019:                }
1020:
1021:                public void setDate(Date date) {
1022:                    this .dateObject = date;
1023:                }
1024:
1025:                public Date getDate() {
1026:                    return dateObject;
1027:                }
1028:
1029:                public float getFloat(int index) {
1030:                    return floats[index];
1031:                }
1032:
1033:                public void setFloat(int index, float value) {
1034:                    floats[index] = value;
1035:                }
1036:
1037:                public char getChar(int index) {
1038:                    return chars[index];
1039:                }
1040:
1041:                public void setChar(int index, char value) {
1042:                    chars[index] = value;
1043:                }
1044:
1045:                public boolean[] getBooleans() {
1046:                    return booleans;
1047:                }
1048:
1049:                public void setBooleans(boolean[] booleans) {
1050:                    this .booleans = booleans;
1051:                }
1052:
1053:                public byte[] getBytes() {
1054:                    return bytes;
1055:                }
1056:
1057:                public void setBytes(byte[] bytes) {
1058:                    this .bytes = bytes;
1059:                }
1060:
1061:                public char[] getChars() {
1062:                    return chars;
1063:                }
1064:
1065:                public void setChars(char[] chars) {
1066:                    this .chars = chars;
1067:                }
1068:
1069:                public double[] getDoubles() {
1070:                    return doubles;
1071:                }
1072:
1073:                public void setDoubles(double[] doubles) {
1074:                    this .doubles = doubles;
1075:                }
1076:
1077:                public float[] getFloats() {
1078:                    return floats;
1079:                }
1080:
1081:                public void setFloats(float[] floats) {
1082:                    this .floats = floats;
1083:                }
1084:
1085:                public int[] getInts() {
1086:                    return ints;
1087:                }
1088:
1089:                public void setInts(int[] ints) {
1090:                    this .ints = ints;
1091:                }
1092:
1093:                public long[] getLongs() {
1094:                    return longs;
1095:                }
1096:
1097:                public void setLongs(long[] longs) {
1098:                    this .longs = longs;
1099:                }
1100:
1101:                public short[] getShorts() {
1102:                    return shorts;
1103:                }
1104:
1105:                public void setShorts(short[] shorts) {
1106:                    this .shorts = shorts;
1107:                }
1108:
1109:                public TestObj[][] getTwoDobjects() {
1110:                    return twoDobjects;
1111:                }
1112:
1113:                public void setTwoDobjects(TestObj[][] twoDobjects) {
1114:                    this .twoDobjects = twoDobjects;
1115:                }
1116:
1117:                public void setTwoDobject(int i1, int i2, TestObj value) {
1118:                    this .twoDobjects[i1][i2] = value;
1119:                }
1120:
1121:                public TestObj getTwoDobject(int i1, int i2) {
1122:                    return twoDobjects[i1][i2];
1123:                }
1124:
1125:                public File getFile() {
1126:                    return this .file;
1127:                }
1128:
1129:                public void setFile(File file) {
1130:                    this .file = file;
1131:                }
1132:
1133:                public Object getObjectArray(int index) {
1134:                    return objectArray[index];
1135:                }
1136:
1137:                public Object[] getObjectArray() {
1138:                    return this .objectArray;
1139:                }
1140:
1141:                public void setObjectArray(int index, Object value) {
1142:                    objectArray[index] = value;
1143:                }
1144:
1145:                public void setObjectArray(Object[] objectArray) {
1146:                    this .objectArray = objectArray;
1147:                }
1148:
1149:                public Object getTransientObject() {
1150:                    return this .transientObject;
1151:                }
1152:
1153:                public void setTransientObject(Object transientObject) {
1154:                    this .transientObject = transientObject;
1155:                }
1156:
1157:                public long getTransientPrimitive() {
1158:                    return this .transientPrimitive;
1159:                }
1160:
1161:                public void setTransientPrimitive(long transientPrimitive) {
1162:                    this .transientPrimitive = transientPrimitive;
1163:                }
1164:
1165:                public Class getClassObject() {
1166:                    return classObject;
1167:                }
1168:
1169:                public void setClassObject(Class classObject) {
1170:                    this .classObject = classObject;
1171:                }
1172:
1173:                public BigDecimal getBigDecimalObject() {
1174:                    return bigDecimalObject;
1175:                }
1176:
1177:                public void setBigDecimalObject(BigDecimal bigDecimalObject) {
1178:                    this .bigDecimalObject = bigDecimalObject;
1179:                }
1180:
1181:                public BigInteger getBigIntegerObject() {
1182:                    return bigIntegerObject;
1183:                }
1184:
1185:                public void setBigIntegerObject(BigInteger bigIntegerObject) {
1186:                    this .bigIntegerObject = bigIntegerObject;
1187:                }
1188:
1189:            }
1190:
1191:            public synchronized void testAbstractLock() throws Exception {
1192:                System.out.println("never called");
1193:            }
1194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.