001: /*
002: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003: * notice. All rights reserved.
004: */
005: package com.tctest;
006:
007: import EDU.oswego.cs.dl.util.concurrent.CyclicBarrier;
008:
009: import com.tc.config.schema.builder.InstrumentedClassConfigBuilder;
010: import com.tc.config.schema.builder.LockConfigBuilder;
011: import com.tc.config.schema.builder.RootConfigBuilder;
012: import com.tc.config.schema.test.InstrumentedClassConfigBuilderImpl;
013: import com.tc.config.schema.test.L1ConfigBuilder;
014: import com.tc.config.schema.test.L2ConfigBuilder;
015: import com.tc.config.schema.test.LockConfigBuilderImpl;
016: import com.tc.config.schema.test.RootConfigBuilderImpl;
017: import com.tc.config.schema.test.TerracottaConfigBuilder;
018: import com.tc.util.TIMUtil;
019: import com.tctest.EhcacheGlobalEvictionTestApp.L1Client;
020:
021: public abstract class EhcacheGlobalEvictionTestBase extends
022: ServerCrashingTestBase {
023: private final static int NODE_COUNT = 1;
024:
025: public EhcacheGlobalEvictionTestBase() {
026: super (NODE_COUNT);
027: // disableAllUntil("2007-08-31");
028: }
029:
030: public void setUp() throws Exception {
031: super .setUp();
032:
033: getTransparentAppConfig().setClientCount(NODE_COUNT)
034: .setIntensity(1);
035: initializeTestRunner();
036: }
037:
038: protected void createConfig(TerracottaConfigBuilder cb) {
039: cb.getServers().getL2s()[0]
040: .setPersistenceMode(L2ConfigBuilder.PERSISTENCE_MODE_TEMPORARY_SWAP_ONLY);
041:
042: String testClassName = EhcacheGlobalEvictionTestApp.class
043: .getName();
044: String clientClassName = L1Client.class.getName();
045: String barrierClassName = CyclicBarrier.class.getName();
046:
047: L1ConfigBuilder l1Config = cb.getClient();
048: l1Config.addModule(TIMUtil.EHCACHE_1_2_4, TIMUtil
049: .getVersion(TIMUtil.EHCACHE_1_2_4));
050:
051: LockConfigBuilder lock1 = new LockConfigBuilderImpl(
052: LockConfigBuilder.TAG_AUTO_LOCK);
053: lock1.setMethodExpression("* " + testClassName + "*.*(..)");
054: setLockLevel(lock1);
055:
056: LockConfigBuilder lock2 = new LockConfigBuilderImpl(
057: LockConfigBuilder.TAG_AUTO_LOCK);
058: lock2.setMethodExpression("* " + clientClassName + "*.*(..)");
059: setLockLevel(lock2);
060:
061: LockConfigBuilder lock3 = new LockConfigBuilderImpl(
062: LockConfigBuilder.TAG_AUTO_LOCK);
063: lock3.setMethodExpression("* " + barrierClassName + "*.*(..)");
064: setLockLevel(lock3);
065:
066: LockConfigBuilder lock4 = new LockConfigBuilderImpl(
067: LockConfigBuilder.TAG_AUTO_LOCK);
068: lock4.setMethodExpression("* "
069: + getApplicationClass().getName() + "*.*(..)");
070: setLockLevel(lock4);
071:
072: cb.getApplication().getDSO().setLocks(
073: new LockConfigBuilder[] { lock1, lock2, lock3, lock4 });
074:
075: RootConfigBuilder root = new RootConfigBuilderImpl();
076: root.setFieldName(clientClassName + ".barrier");
077: root.setRootName("barrier");
078: RootConfigBuilder root2 = new RootConfigBuilderImpl();
079: root2.setFieldName(clientClassName + ".cacheManager");
080: root2.setRootName("cacheManager");
081: cb.getApplication().getDSO().setRoots(
082: new RootConfigBuilder[] { root, root2 });
083:
084: InstrumentedClassConfigBuilder instrumented1 = new InstrumentedClassConfigBuilderImpl();
085: instrumented1.setClassExpression(testClassName + "*");
086:
087: InstrumentedClassConfigBuilder instrumented2 = new InstrumentedClassConfigBuilderImpl();
088: instrumented2.setClassExpression(clientClassName + "*");
089:
090: InstrumentedClassConfigBuilder instrumented3 = new InstrumentedClassConfigBuilderImpl();
091: instrumented3.setClassExpression(barrierClassName + "*");
092:
093: InstrumentedClassConfigBuilder instrumented4 = new InstrumentedClassConfigBuilderImpl();
094: instrumented4.setClassExpression(getApplicationClass()
095: .getName()
096: + "*");
097:
098: cb.getApplication().getDSO().setInstrumentedClasses(
099: new InstrumentedClassConfigBuilder[] { instrumented1,
100: instrumented2, instrumented3, instrumented4 });
101:
102: }
103:
104: protected void setLockLevel(LockConfigBuilder lock) {
105: lock.setLockLevel(LockConfigBuilder.LEVEL_WRITE);
106: }
107:
108: protected void setReadLockLevel(LockConfigBuilder lock) {
109: lock.setLockLevel(LockConfigBuilder.LEVEL_READ);
110: }
111:
112: }
|