77
88import static org .junit .Assert .*;
99
10+ import java .io .InputStream ;
1011import java .util .*;
1112
12- public class RetryTest {
13+ public class RetryIT {
1314
1415 private static final String SERVER_URL = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor" ;
1516 private MerchantConfig mc ;
@@ -18,41 +19,31 @@ public class RetryTest{
1819 @ Rule
1920 public ExpectedException expectedException = ExpectedException .none ();
2021
21- class GoodRequest extends HashMap <String , String >
22- {
23- GoodRequest ()
24- {
25- put ("ccAuthService_run" , "true" );
26- put ("merchantReferenceCode" , "1" );
27- put ("billTo_firstName" , "Ponce" );
28- put ("billTo_lastName" , "de León" );
29- }
30- }
3122
3223 @ Before
3324 public void setUp () throws Exception
3425 {
3526 props = new Properties ();
36- props .setProperty ("serverURL" , SERVER_URL );
37- props .setProperty ("merchantID" , "cybs_test_ashish" );
38- props .setProperty ("targetAPIVersion" , "1.50" );
39- props .setProperty ("keysDirectory" , "/Users/mayadav/p12/" );
40- mc = new MerchantConfig (props , "cybs_test_ashish" );
27+ InputStream in = Thread .currentThread ().getContextClassLoader ().getResourceAsStream ("test_cybs.properties" );
28+ if (in == null ) {
29+ throw new RuntimeException ("Unable to load test_cybs.properties file" );
30+ }
31+ props .load (in );
32+ mc = new MerchantConfig (props , null );
4133
4234 }
4335
4436 @ Test
4537 public void checkRetry () throws Exception
4638 {
4739 String errMsg ="Invalid value of numberOfRetries and/or retryInterval" ;
48- Map <String ,String > request = new HashMap ();
4940 // request fails as number of retry value is incorrect
5041 props .setProperty ("allowRetry" , "true" );
5142 props .setProperty ("numberOfRetries" , "10" );
5243 props .setProperty ("retryInterval" , "10" );
5344 // request 1 Should fail as the number of retry attempt is exceeding 3
5445 try {
55- Client .runTransaction (request , props );
46+ Client .runTransaction (new HashMap () , props );
5647 }
5748 catch (ClientException e ){
5849 assertEquals (errMsg , e .getMessage ());
@@ -64,14 +55,13 @@ public void checkRetry() throws Exception
6455 public void checkNegative () throws Exception
6556 {
6657 String errMsg ="Invalid value of numberOfRetries and/or retryInterval" ;
67- Map <String ,String > request = new HashMap ();
6858 // request fails as number of retry and retry interval values are in negative
6959 props .setProperty ("allowRetry" , "true" );
7060 props .setProperty ("numberOfRetries" , "-10" );
7161 props .setProperty ("retryInterval" , "-10" );
7262 try
7363 {
74- Client .runTransaction (request , props );
64+ Client .runTransaction (new HashMap () , props );
7565 }
7666 catch (ClientException e )
7767 {
@@ -80,12 +70,11 @@ public void checkNegative() throws Exception
8070 }
8171 @ Test
8272 public void retryDisabled () throws Exception {
83- Map <String ,String > request = new HashMap ();
8473 // request should work as the Allow Retry is set to false other values will be ignored
8574 props .setProperty ("allowRetry" , "false" );
8675 props .setProperty ("numberOfRetries" , "-10" );
8776 props .setProperty ("retryInterval" , "-10" );
88- Map reply = Client .runTransaction (request , props );
77+ Map reply = Client .runTransaction (new HashMap () , props );
8978 assertNotNull (reply .get ("requestID" ));
9079
9180 }
0 commit comments