001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package com.db4o.db4ounit.jre11.concurrency.staging;
022:
023: import com.db4o.ext.*;
024:
025: import db4ounit.*;
026: import db4ounit.extensions.*;
027:
028: public class CustomActivationDepthTestCase extends
029: Db4oClientServerTestCase {
030:
031: public static void main(String[] args) {
032: new CustomActivationDepthTestCase().runConcurrency();
033: }
034:
035: int myInt;
036:
037: String myString;
038:
039: int[] ints;
040:
041: String[] strings;
042:
043: CA1 ca1;
044:
045: CA2 ca2;
046:
047: CA3 ca3;
048:
049: CA1[] ca1s;
050:
051: CA2[] ca2s;
052:
053: CA3[] ca3s;
054:
055: protected void store() {
056: myInt = 7;
057: myString = "seven";
058: ints = new int[] { 77 };
059: strings = new String[] { "sevenseven" };
060: ca1 = new CA1("1");
061: ca2 = new CA2("2");
062: ca3 = new CA3("3");
063:
064: ca1s = new CA1[] { new CA1("1arr1"), new CA1("1arr2") };
065: ca2s = new CA2[] { new CA2("2arr1"), new CA2("2arr2") };
066: ca3s = new CA3[] { new CA3("3arr1"), new CA3("3arr2") };
067: store(this );
068: }
069:
070: public void conc(ExtObjectContainer oc, int seq) {
071: oc.configure().objectClass(CustomActivationDepthTestCase.class)
072: .maximumActivationDepth(seq);
073: oc.configure().objectClass(CA1.class).maximumActivationDepth(1);
074: CustomActivationDepthTestCase cad = (CustomActivationDepthTestCase) retrieveOnlyInstance(
075: oc, CustomActivationDepthTestCase.class);
076: oc.activate(cad, seq);
077: oc.activate(cad.ca1, 10);
078: Assert.isNull(cad.ca1.ca2.name);
079: Assert.areEqual("1", cad.ca1.name);
080: if (seq <= 1) {
081: // FIXME: the assertion fails sometimes (randomly). "Expected
082: // reference to be null, but was 2".
083: Assert.isNull(cad.ca2.name);
084: Assert.isNull(cad.ca3.name);
085: Assert.isNull(cad.ca1s[0].name);
086: Assert.isNull(cad.ca1s[1].name);
087: Assert.isNull(cad.ca2s[0].name);
088: Assert.isNull(cad.ca2s[1].name);
089: Assert.isNull(cad.ca3s[0].name);
090: Assert.isNull(cad.ca3s[1].name);
091: } else {
092: Assert.areEqual("2", cad.ca2.name);
093: Assert.areEqual("3", cad.ca3.name);
094: Assert.areEqual("1arr1", cad.ca1s[0].name);
095: Assert.areEqual("1arr2", cad.ca1s[1].name);
096: Assert.areEqual("2arr1", cad.ca2s[0].name);
097: Assert.areEqual("2arr2", cad.ca2s[1].name);
098: Assert.areEqual("3arr1", cad.ca3s[0].name);
099: Assert.areEqual("3arr2", cad.ca3s[1].name);
100: }
101: }
102:
103: public static class CA1 {
104:
105: public String name;
106:
107: public CA2 ca2;
108:
109: public CA1() {
110:
111: }
112:
113: public CA1(String name) {
114: this .name = name;
115: ca2 = new CA2(name + ".2");
116: }
117:
118: }
119:
120: public static class CA2 {
121:
122: public String name;
123:
124: public CA3 ca3;
125:
126: public CA2() {
127:
128: }
129:
130: public CA2(String name) {
131: this .name = name;
132: ca3 = new CA3(name + ".3");
133: }
134:
135: }
136:
137: public static class CA3 {
138:
139: public String name;
140:
141: public CA3() {
142:
143: }
144:
145: public CA3(String name) {
146: this.name = name;
147: }
148:
149: }
150:
151: }
|