directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1044277 - /directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java
Date Fri, 10 Dec 2010 10:46:08 GMT
Author: pamarcelot
Date: Fri Dec 10 10:46:07 2010
New Revision: 1044277

URL: http://svn.apache.org/viewvc?rev=1044277&view=rev
Log:
Added 200 ms more before checking the values.

Modified:
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java?rev=1044277&r1=1044276&r2=1044277&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java
Fri Dec 10 10:46:07 2010
@@ -1,110 +1,110 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you 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
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
-package org.apache.directory.server.kerberos.shared.replay;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import javax.security.auth.kerberos.KerberosPrincipal;
-
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-
-import org.apache.directory.junit.tools.Concurrent;
-import org.apache.directory.junit.tools.ConcurrentJunitRunner;
-import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
-import org.apache.directory.shared.kerberos.KerberosTime;
-import org.apache.directory.shared.kerberos.codec.types.PrincipalNameType;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-
-/**
- * Test the InMemory replay cache
- * 
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-@RunWith(ConcurrentJunitRunner.class)
-@Concurrent()
-public class ReplayCacheImplTest
-{
-    @Rule
-    public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.THREADSAFE
);
-
-
-    /**
-     * Test that the cache is working well. We will create a new entry
-     * every 500 ms, with 4 different serverPrincipals.
-     * 
-     * After this period of time, we should only have 2 entries in the cache
-     */
-    @Test
-    public void testCacheSetting() throws Exception
-    {
-        long clockSkew = 1000; // 1 sec
-
-        CacheManager cacheManager = new CacheManager( ReplayCacheImplTest.class.getClassLoader().getResource(
-            "directory-cacheservice.xml" ) );
-
-        Cache ehCache = cacheManager.getCache( "kdcReplayCache" );
-        ehCache.getCacheConfiguration().setMaxElementsInMemory( 2 );
-        ehCache.getCacheConfiguration().setTimeToLiveSeconds( 1 );
-        ehCache.getCacheConfiguration().setTimeToIdleSeconds( 1 );
-        ehCache.getCacheConfiguration().setDiskExpiryThreadIntervalSeconds( 1 );
-
-        ReplayCacheImpl cache = new ReplayCacheImpl( ehCache, clockSkew );
-
-        int i = 0;
-
-        // Inject 4 entries 
-        while ( i < 4 )
-        {
-            KerberosPrincipal serverPrincipal = new KerberosPrincipal( "server" + i + "@APACHE.ORG",
-                PrincipalNameType.KRB_NT_PRINCIPAL.getValue() );
-            KerberosPrincipal clientPrincipal = new KerberosPrincipal( "client" + i + "@APACHE.ORG",
-                PrincipalNameType.KRB_NT_PRINCIPAL.getValue() );
-
-            cache.save( serverPrincipal, clientPrincipal, new KerberosTime( System.currentTimeMillis()
), 0 );
-
-            i++;
-        }
-
-        List keys = ehCache.getKeys();
-
-        // We should have 4 entries
-        assertTrue( keys.size() != 0 );
-
-        // Wait till the timetolive time exceeds 
-        Thread.sleep( 1000 );
-
-        // then access the cache so that the objects present in the cache will be expired
-        for ( Object k : keys )
-        {
-            assertNull( ehCache.get( k ) );
-        }
-
-        assertEquals( 0, ehCache.getKeys().size() );
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.kerberos.shared.replay;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import javax.security.auth.kerberos.KerberosPrincipal;
+
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
+import org.apache.directory.shared.kerberos.KerberosTime;
+import org.apache.directory.shared.kerberos.codec.types.PrincipalNameType;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Test the InMemory replay cache
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class ReplayCacheImplTest
+{
+    @Rule
+    public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.THREADSAFE
);
+
+
+    /**
+     * Test that the cache is working well. We will create a new entry
+     * every 500 ms, with 4 different serverPrincipals.
+     * 
+     * After this period of time, we should only have 2 entries in the cache
+     */
+    @Test
+    public void testCacheSetting() throws Exception
+    {
+        long clockSkew = 1000; // 1 sec
+
+        CacheManager cacheManager = new CacheManager( ReplayCacheImplTest.class.getClassLoader().getResource(
+            "directory-cacheservice.xml" ) );
+
+        Cache ehCache = cacheManager.getCache( "kdcReplayCache" );
+        ehCache.getCacheConfiguration().setMaxElementsInMemory( 2 );
+        ehCache.getCacheConfiguration().setTimeToLiveSeconds( 1 );
+        ehCache.getCacheConfiguration().setTimeToIdleSeconds( 1 );
+        ehCache.getCacheConfiguration().setDiskExpiryThreadIntervalSeconds( 1 );
+
+        ReplayCacheImpl cache = new ReplayCacheImpl( ehCache, clockSkew );
+
+        int i = 0;
+
+        // Inject 4 entries 
+        while ( i < 4 )
+        {
+            KerberosPrincipal serverPrincipal = new KerberosPrincipal( "server" + i + "@APACHE.ORG",
+                PrincipalNameType.KRB_NT_PRINCIPAL.getValue() );
+            KerberosPrincipal clientPrincipal = new KerberosPrincipal( "client" + i + "@APACHE.ORG",
+                PrincipalNameType.KRB_NT_PRINCIPAL.getValue() );
+
+            cache.save( serverPrincipal, clientPrincipal, new KerberosTime( System.currentTimeMillis()
), 0 );
+
+            i++;
+        }
+
+        List keys = ehCache.getKeys();
+
+        // We should have 4 entries
+        assertTrue( keys.size() != 0 );
+
+        // Wait till the timetolive time exceeds 
+        Thread.sleep( 1200 );
+
+        // then access the cache so that the objects present in the cache will be expired
+        for ( Object k : keys )
+        {
+            assertNull( ehCache.get( k ) );
+        }
+
+        assertEquals( 0, ehCache.getKeys().size() );
+    }
+}



Mime
View raw message