Author: [email protected]
Date: Fri Feb 10 17:11:43 2012
New Revision: 2083

Log:
[AMDATUCASSANDRA-148] Fixed failing integration test caused by un-exporting the 
implementation package of the Nonce store

Modified:
   
trunk/amdatu-cassandra/test-integration/tests/src/test/java/org/amdatu/cassandra/test/integration/tests/NonceStoreTest.java

Modified: 
trunk/amdatu-cassandra/test-integration/tests/src/test/java/org/amdatu/cassandra/test/integration/tests/NonceStoreTest.java
==============================================================================
--- 
trunk/amdatu-cassandra/test-integration/tests/src/test/java/org/amdatu/cassandra/test/integration/tests/NonceStoreTest.java
 (original)
+++ 
trunk/amdatu-cassandra/test-integration/tests/src/test/java/org/amdatu/cassandra/test/integration/tests/NonceStoreTest.java
 Fri Feb 10 17:11:43 2012
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2010, 2011 The Amdatu Foundation
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -15,32 +15,29 @@
  */
 package org.amdatu.cassandra.test.integration.tests;
 
-import junit.framework.Assert;
-
-import 
org.amdatu.cassandra.store.nonce.service.CassandraNonceStorageProviderImpl;
 import org.amdatu.cassandra.test.integration.tests.framework.CassandraTestBase;
 
+import java.lang.reflect.Method;
+
 public class NonceStoreTest extends CassandraTestBase {
 
-    public void execute() throws Exception {        
-        // Now with the Cassandra implementation, we should wait for 5 minutes 
to verify that the 
-        // nonces have been removed. But we can't just block the integration 
test for that long, so 
+    public void execute() throws Exception {
+        // Now with the Cassandra implementation, we should wait for 5 minutes 
to verify that the
+        // nonces have been removed. But we can't just block the integration 
test for that long, so
         // we change the TTL to 1 second
         int ttl = 1;
+
+        // Since the nonce store is an unexposed implementation class, we need 
to use reflection here
+        Method setTTLMethod = 
m_OAuthNonceStore.getClass().getDeclaredMethod("setTTL", new 
Class<?>[]{int.class});
+        setTTLMethod.invoke(m_OAuthNonceStore, new Object[]{ttl});
         
-        if (m_OAuthNonceStore instanceof CassandraNonceStorageProviderImpl) {
-            ((CassandraNonceStorageProviderImpl) 
m_OAuthNonceStore).setTTL(ttl);
-        } else {
-            Assert.fail("Expected to retrieve the Cassandra nonce store, but 
received a different implementation.");
-        }
-       
         String nonce = "A";
         long timestamp1 = 10000; // second 10
         long timestamp2 = 10001;
         long timestamp3 = 10002;
         long timestamp4 = 20000;
         long timestamp5 = 2435436;
-        
+
         // Validate that the same nonce can be added only once
         assertTrue(m_OAuthNonceStore.addNonce(timestamp1, nonce, null));
         assertFalse(m_OAuthNonceStore.addNonce(timestamp1, nonce, null));
@@ -54,7 +51,7 @@
         assertFalse(m_OAuthNonceStore.addNonce(timestamp5, nonce, new 
String[]{"arg1", "arg2"}));
 
         try {
-            // The TTL in Cassandra can be set in seconds, not milliseconds. 
So that means that columns 
+            // The TTL in Cassandra can be set in seconds, not milliseconds. 
So that means that columns
             // are removed for certain after TTL + 1 seconds (due to rounding 
errors)
             Thread.sleep((ttl + 1)*1000);
         }
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to