1 5 package com.tctest.restart.system; 6 7 import com.tc.config.schema.builder.InstrumentedClassConfigBuilder; 8 import com.tc.config.schema.builder.LockConfigBuilder; 9 import com.tc.config.schema.builder.RootConfigBuilder; 10 import com.tc.config.schema.test.InstrumentedClassConfigBuilderImpl; 11 import com.tc.config.schema.test.LockConfigBuilderImpl; 12 import com.tc.config.schema.test.RootConfigBuilderImpl; 13 import com.tc.config.schema.test.TerracottaConfigBuilder; 14 import com.tctest.ServerCrashingTestBase; 15 import com.tctest.restart.system.ClientTerminatingTestApp.Client; 16 import com.tctest.runner.AbstractTransparentApp; 17 18 public class ClientTerminatingTest extends ServerCrashingTestBase { 19 20 private static final int NODE_COUNT = 2; 21 22 private boolean isSynchronousWrite = false; 23 24 public ClientTerminatingTest() { 25 super(NODE_COUNT); 26 } 27 28 protected void setSynchronousWrite() { 29 isSynchronousWrite = true; 30 } 31 32 protected Class getApplicationClass() { 33 return ClientTerminatingTestApp.class; 34 } 35 36 protected void createConfig(TerracottaConfigBuilder cb) { 37 String testClassName = ClientTerminatingTestApp.class.getName(); 38 String testClassSuperName = AbstractTransparentApp.class.getName(); 39 String clientClassName = Client.class.getName(); 40 41 LockConfigBuilder lock1 = new LockConfigBuilderImpl(LockConfigBuilder.TAG_AUTO_LOCK); 42 lock1.setMethodExpression("* " + testClassName + ".run(..)"); 43 setLockLevel(lock1); 44 45 LockConfigBuilder lock2 = new LockConfigBuilderImpl(LockConfigBuilder.TAG_AUTO_LOCK); 46 lock2.setMethodExpression("* " + clientClassName + ".execute(..)"); 47 setLockLevel(lock2); 48 49 cb.getApplication().getDSO().setLocks(new LockConfigBuilder[] { lock1, lock2 }); 50 51 RootConfigBuilder root = new RootConfigBuilderImpl(); 52 root.setFieldName(testClassName + ".queue"); 53 cb.getApplication().getDSO().setRoots(new RootConfigBuilder[] { root }); 55 56 InstrumentedClassConfigBuilder instrumented1 = new InstrumentedClassConfigBuilderImpl(); 57 instrumented1.setClassExpression(testClassName + "*"); 58 59 InstrumentedClassConfigBuilder instrumented2 = new InstrumentedClassConfigBuilderImpl(); 60 instrumented2.setClassExpression(testClassSuperName + "*"); 61 62 cb.getApplication().getDSO().setInstrumentedClasses( 63 new InstrumentedClassConfigBuilder[] { instrumented1, 64 instrumented2 }); 65 } 66 67 private void setLockLevel(LockConfigBuilder lock) { 68 if (isSynchronousWrite) { 69 lock.setLockLevel(LockConfigBuilder.LEVEL_SYNCHRONOUS_WRITE); 70 } else { 71 lock.setLockLevel(LockConfigBuilder.LEVEL_WRITE); 72 } 73 } 74 75 } 76 | Popular Tags |