1 package org.jacorb.test.notification.engine; 2 3 22 23 import junit.framework.Test; 24 import junit.framework.TestSuite; 25 26 import org.jacorb.notification.engine.RetryException; 27 import org.jacorb.notification.engine.AbstractRetryStrategy; 28 import org.jacorb.notification.engine.WaitRetryStrategy; 29 import org.omg.CORBA.TRANSIENT ; 30 31 34 35 public class WaitRetryStrategyTest extends AbstractRetryStrategyTest 36 { 37 public WaitRetryStrategyTest(String name) 38 { 39 super(name); 40 } 41 42 public void testRetryTerminatesAndThrowsException() throws Exception 43 { 44 mockConsumer_.isRetryAllowed(); 45 controlConsumer_.setReturnValue(true); 46 47 mockConsumer_.isRetryAllowed(); 48 controlConsumer_.setReturnValue(true); 49 50 mockConsumer_.isRetryAllowed(); 51 controlConsumer_.setDefaultReturnValue(false); 52 53 mockConsumer_.incErrorCounter(); 54 controlConsumer_.setReturnValue(0); 55 56 mockConsumer_.destroy(); 57 58 controlConsumer_.replay(); 59 60 mockPushOperation_.invokePush(); 61 controlPushOperation_.setThrowable(new TRANSIENT ()); 62 63 mockPushOperation_.dispose(); 64 65 controlPushOperation_.replay(); 66 67 try 68 { 69 objectUnderTest_.retry(); 70 71 fail(); 72 } catch (RetryException e) 73 { 74 } 76 77 controlPushOperation_.verify(); 78 controlConsumer_.verify(); 79 } 80 81 public void testRetrySucceeds() throws Exception 82 { 83 mockConsumer_.isRetryAllowed(); 84 controlConsumer_.setDefaultReturnValue(true); 85 86 mockPushOperation_.invokePush(); 87 mockPushOperation_.dispose(); 88 controlPushOperation_.replay(); 89 90 controlConsumer_.replay(); 91 92 objectUnderTest_.retry(); 93 94 controlConsumer_.verify(); 95 controlPushOperation_.verify(); 96 } 97 98 public void testSuccessfulRetryDisposesPushOperation() throws Exception 99 { 100 mockPushOperation_.invokePush(); 101 mockPushOperation_.dispose(); 102 103 controlPushOperation_.replay(); 104 105 mockConsumer_.isRetryAllowed(); 106 controlConsumer_.setDefaultReturnValue(true); 107 108 controlConsumer_.replay(); 109 110 objectUnderTest_.retry(); 111 112 controlPushOperation_.verify(); 113 } 114 115 public void testNotSuccessfulRetryDisposes() throws Exception 116 { 117 mockPushOperation_.dispose(); 118 119 mockConsumer_.isRetryAllowed(); 120 controlConsumer_.setDefaultReturnValue(false); 121 122 controlPushOperation_.replay(); 123 124 controlConsumer_.replay(); 125 126 objectUnderTest_.retry(); 127 128 controlPushOperation_.verify(); 129 } 130 131 132 public void testRetryAllowedDisposesPushOperation() throws Exception 133 { 134 mockPushOperation_.dispose(); 135 136 controlPushOperation_.replay(); 137 138 mockConsumer_.isRetryAllowed(); 139 controlConsumer_.setDefaultReturnValue(true); 140 141 controlConsumer_.replay(); 142 143 objectUnderTest_.retry(); 144 145 controlPushOperation_.verify(); 146 } 147 148 public static Test suite() 149 { 150 TestSuite suite = new TestSuite(WaitRetryStrategyTest.class); 151 152 return suite; 153 } 154 155 156 protected void setUpTest() 157 { 158 } 160 161 162 protected AbstractRetryStrategy newRetryStrategy() 163 { 164 return new WaitRetryStrategy(mockConsumer_, mockPushOperation_); 165 } 166 } | Popular Tags |