]> source.dussan.org Git - archiva.git/commitdiff
repackaging to o.a.a.r
authorOlivier Lamy <olamy@apache.org>
Mon, 9 Apr 2012 20:19:29 +0000 (20:19 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 9 Apr 2012 20:19:29 +0000 (20:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1311413 13f79535-47bb-0310-9956-ffa450edef68

redback-keys/redback-keys-providers/redback-keys-cached/src/test/java/org/apache/archiva/redback/keys/cached/CachedKeyManagerTest.java
redback-keys/redback-keys-providers/redback-keys-jdo/src/test/java/org/apache/archiva/redback/keys/jdo/JdoKeyManagerTest.java
redback-keys/redback-keys-providers/redback-keys-memory/src/test/java/org/apache/archiva/redback/keys/memory/MemoryKeyManagerTest.java
redback-keys/redback-keys-tests/src/main/java/org/apache/archiva/redback/keys/KeyManagerTestCase.java [new file with mode: 0644]
redback-keys/redback-keys-tests/src/main/java/org/codehaus/plexus/redback/keys/KeyManagerTestCase.java [deleted file]

index 90dca43eaedbb4e09d741f44c1db81c3276d8aff..1974cb9092ad062b1c7f54497617a0b56da0a7d5 100644 (file)
@@ -21,8 +21,7 @@ package org.apache.archiva.redback.keys.cached;
 
 import net.sf.ehcache.CacheManager;
 import org.apache.archiva.redback.keys.KeyManager;
-import org.apache.archiva.redback.keys.cached.CachedKeyManager;
-import org.codehaus.plexus.redback.keys.KeyManagerTestCase;
+import org.apache.archiva.redback.keys.KeyManagerTestCase;
 import org.junit.Before;
 
 import javax.inject.Inject;
index f0710729e7adf94ed64ba4a1a270732f341e4564..31d7dd1887ed985c6dac5683690bd6243ce47429 100644 (file)
@@ -21,7 +21,7 @@ package org.apache.archiva.redback.keys.jdo;
 
 import org.apache.archiva.redback.keys.KeyManager;
 import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
-import org.codehaus.plexus.redback.keys.KeyManagerTestCase;
+import org.apache.archiva.redback.keys.KeyManagerTestCase;
 import org.jpox.SchemaTool;
 import org.junit.Before;
 
index 256cfd24f117df0ee8c8b9aa3a004ad1f2038df4..ad10015bddd48f37c20ba4a6bb72586f33bb7f14 100644 (file)
@@ -20,7 +20,7 @@ package org.apache.archiva.redback.keys.memory;
  */
 
 import org.apache.archiva.redback.keys.KeyManager;
-import org.codehaus.plexus.redback.keys.KeyManagerTestCase;
+import org.apache.archiva.redback.keys.KeyManagerTestCase;
 import org.junit.Before;
 
 import javax.inject.Inject;
diff --git a/redback-keys/redback-keys-tests/src/main/java/org/apache/archiva/redback/keys/KeyManagerTestCase.java b/redback-keys/redback-keys-tests/src/main/java/org/apache/archiva/redback/keys/KeyManagerTestCase.java
new file mode 100644 (file)
index 0000000..56d1676
--- /dev/null
@@ -0,0 +1,234 @@
+package org.apache.archiva.redback.keys;
+
+/*
+ * Copyright 2001-2006 The Apache Software 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
+ *
+ *      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.
+ */
+
+import junit.framework.TestCase;
+import org.apache.archiva.redback.keys.AuthenticationKey;
+import org.apache.archiva.redback.keys.KeyManager;
+import org.apache.archiva.redback.keys.KeyManagerException;
+import org.apache.archiva.redback.keys.KeyNotFoundException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * KeyManagerTestCase
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath*:/spring-context.xml"} )
+public class KeyManagerTestCase
+    extends TestCase
+{
+    private KeyManager manager;
+
+    public KeyManager getKeyManager()
+    {
+        return manager;
+    }
+
+    public void setKeyManager( KeyManager manager )
+    {
+        this.manager = manager;
+    }
+
+    private void assertSameDates( Date expected, Date actual )
+    {
+        if ( ( expected == null ) && ( actual != null ) )
+        {
+            fail( "Expected date is null, actual date [" + actual + "]." );
+        }
+
+        if ( ( expected != null ) && ( actual == null ) )
+        {
+            fail( "Expected date [" + expected + "], actual date is null." );
+        }
+
+        SimpleDateFormat format = new SimpleDateFormat( "EEE, d MMM yyyy HH:mm:ss Z" );
+        assertEquals( format.format( expected ), format.format( actual ) );
+    }
+
+    @Test
+    public void testNormal()
+        throws KeyNotFoundException, KeyManagerException
+    {
+        String principal = "foo";
+        String purpose = "Testing";
+
+        AuthenticationKey created = getKeyManager().createKey( principal, purpose, 15 );
+
+        assertNotNull( created );
+        assertNotNull( created.getKey() );
+        assertNotNull( created.getDateCreated() );
+        assertNotNull( created.getDateExpires() );
+
+        assertEquals( principal, created.getForPrincipal() );
+        assertEquals( purpose, created.getPurpose() );
+
+        Date expectedCreated = created.getDateCreated();
+        Date expectedExpires = created.getDateExpires();
+
+        String expectedKey = created.getKey();
+
+        AuthenticationKey found = getKeyManager().findKey( expectedKey );
+
+        assertEquals( expectedKey, found.getKey() );
+        assertEquals( principal, found.getForPrincipal() );
+        assertEquals( purpose, found.getPurpose() );
+        assertSameDates( expectedCreated, found.getDateCreated() );
+        assertSameDates( expectedExpires, found.getDateExpires() );
+    }
+
+    @Test
+    public void testGetAllKeys()
+        throws KeyManagerException
+    {
+        getKeyManager().eraseDatabase();
+        AuthenticationKey created1 = getKeyManager().createKey( "foo", "Testing", 15 );
+        AuthenticationKey created2 = getKeyManager().createKey( "bar", "Something", 23 );
+
+        assertNotNull( created1 );
+        assertNotNull( created2 );
+
+        assertEquals( "foo", created1.getForPrincipal() );
+        assertEquals( "Testing", created1.getPurpose() );
+
+        assertEquals( "bar", created2.getForPrincipal() );
+        assertEquals( "Something", created2.getPurpose() );
+
+        List<AuthenticationKey> keys = getKeyManager().getAllKeys();
+        Collections.sort( keys, new Comparator<AuthenticationKey>()
+        {
+            public int compare( AuthenticationKey key1, AuthenticationKey key2 )
+            {
+                return key2.getForPrincipal().compareTo( key1.getForPrincipal() );
+            }
+        } );
+
+        AuthenticationKey found = (AuthenticationKey) keys.get( 0 );
+        assertEquals( created1.getKey(), found.getKey() );
+        assertEquals( "foo", found.getForPrincipal() );
+        assertEquals( "Testing", found.getPurpose() );
+        assertSameDates( created1.getDateCreated(), found.getDateCreated() );
+        assertSameDates( created1.getDateExpires(), found.getDateExpires() );
+
+        found = (AuthenticationKey) keys.get( 1 );
+        assertEquals( created2.getKey(), found.getKey() );
+        assertEquals( "bar", found.getForPrincipal() );
+        assertEquals( "Something", found.getPurpose() );
+        assertSameDates( created2.getDateCreated(), found.getDateCreated() );
+        assertSameDates( created2.getDateExpires(), found.getDateExpires() );
+    }
+
+    @Test
+    public void testNotThere()
+        throws KeyManagerException
+    {
+        String principal = "foo";
+        String purpose = "Testing";
+
+        AuthenticationKey created = getKeyManager().createKey( principal, purpose, 15 );
+
+        assertNotNull( created );
+        assertNotNull( created.getKey() );
+        assertNotNull( created.getDateCreated() );
+        assertNotNull( created.getDateExpires() );
+
+        assertEquals( principal, created.getForPrincipal() );
+        assertEquals( purpose, created.getPurpose() );
+
+        try
+        {
+            getKeyManager().findKey( "deadbeefkey" );
+            fail( "Invalid Key should not have been found." );
+        }
+        catch ( KeyNotFoundException e )
+        {
+            // Expected path for this test.
+        }
+    }
+
+    @Test
+    public void testExpired()
+        throws KeyManagerException, InterruptedException
+    {
+        String principal = "foo";
+        String purpose = "Testing";
+
+        AuthenticationKey created = getKeyManager().createKey( principal, purpose, 0 );
+
+        assertNotNull( created );
+        assertNotNull( created.getKey() );
+        assertNotNull( created.getDateCreated() );
+        assertNotNull( created.getDateExpires() );
+
+        assertEquals( principal, created.getForPrincipal() );
+        assertEquals( purpose, created.getPurpose() );
+
+        String expectedKey = created.getKey();
+
+        try
+        {
+            Thread.sleep( 500 ); // Sleep to let it expire
+            getKeyManager().findKey( expectedKey );
+            fail( "Expired Key should not have been found." );
+        }
+        catch ( KeyNotFoundException e )
+        {
+            // Expected path for this test.
+        }
+    }
+
+    @Test
+    public void testPermanent()
+        throws KeyManagerException
+    {
+        String principal = "foo";
+        String purpose = "Testing";
+
+        AuthenticationKey created = getKeyManager().createKey( principal, purpose, -1 );
+
+        assertNotNull( created );
+        assertNotNull( created.getKey() );
+        assertNotNull( created.getDateCreated() );
+        assertNull( created.getDateExpires() );
+
+        assertEquals( principal, created.getForPrincipal() );
+        assertEquals( purpose, created.getPurpose() );
+
+        Date expectedCreated = created.getDateCreated();
+
+        String expectedKey = created.getKey();
+
+        AuthenticationKey found = getKeyManager().findKey( expectedKey );
+
+        assertEquals( expectedKey, found.getKey() );
+        assertEquals( principal, found.getForPrincipal() );
+        assertEquals( purpose, found.getPurpose() );
+        assertSameDates( expectedCreated, found.getDateCreated() );
+        assertNull( found.getDateExpires() );
+    }
+}
diff --git a/redback-keys/redback-keys-tests/src/main/java/org/codehaus/plexus/redback/keys/KeyManagerTestCase.java b/redback-keys/redback-keys-tests/src/main/java/org/codehaus/plexus/redback/keys/KeyManagerTestCase.java
deleted file mode 100644 (file)
index adc3224..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-package org.codehaus.plexus.redback.keys;
-
-/*
- * Copyright 2001-2006 The Apache Software 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
- *
- *      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.
- */
-
-import junit.framework.TestCase;
-import org.apache.archiva.redback.keys.AuthenticationKey;
-import org.apache.archiva.redback.keys.KeyManager;
-import org.apache.archiva.redback.keys.KeyManagerException;
-import org.apache.archiva.redback.keys.KeyNotFoundException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-
-/**
- * KeyManagerTestCase
- *
- * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
- * @version $Id$
- */
-@RunWith( SpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath*:/spring-context.xml"} )
-public class KeyManagerTestCase
-    extends TestCase
-{
-    private KeyManager manager;
-
-    public KeyManager getKeyManager()
-    {
-        return manager;
-    }
-
-    public void setKeyManager( KeyManager manager )
-    {
-        this.manager = manager;
-    }
-
-    private void assertSameDates( Date expected, Date actual )
-    {
-        if ( ( expected == null ) && ( actual != null ) )
-        {
-            fail( "Expected date is null, actual date [" + actual + "]." );
-        }
-
-        if ( ( expected != null ) && ( actual == null ) )
-        {
-            fail( "Expected date [" + expected + "], actual date is null." );
-        }
-
-        SimpleDateFormat format = new SimpleDateFormat( "EEE, d MMM yyyy HH:mm:ss Z" );
-        assertEquals( format.format( expected ), format.format( actual ) );
-    }
-
-    @Test
-    public void testNormal()
-        throws KeyNotFoundException, KeyManagerException
-    {
-        String principal = "foo";
-        String purpose = "Testing";
-
-        AuthenticationKey created = getKeyManager().createKey( principal, purpose, 15 );
-
-        assertNotNull( created );
-        assertNotNull( created.getKey() );
-        assertNotNull( created.getDateCreated() );
-        assertNotNull( created.getDateExpires() );
-
-        assertEquals( principal, created.getForPrincipal() );
-        assertEquals( purpose, created.getPurpose() );
-
-        Date expectedCreated = created.getDateCreated();
-        Date expectedExpires = created.getDateExpires();
-
-        String expectedKey = created.getKey();
-
-        AuthenticationKey found = getKeyManager().findKey( expectedKey );
-
-        assertEquals( expectedKey, found.getKey() );
-        assertEquals( principal, found.getForPrincipal() );
-        assertEquals( purpose, found.getPurpose() );
-        assertSameDates( expectedCreated, found.getDateCreated() );
-        assertSameDates( expectedExpires, found.getDateExpires() );
-    }
-
-    @Test
-    public void testGetAllKeys()
-        throws KeyManagerException
-    {
-        getKeyManager().eraseDatabase();
-        AuthenticationKey created1 = getKeyManager().createKey( "foo", "Testing", 15 );
-        AuthenticationKey created2 = getKeyManager().createKey( "bar", "Something", 23 );
-
-        assertNotNull( created1 );
-        assertNotNull( created2 );
-
-        assertEquals( "foo", created1.getForPrincipal() );
-        assertEquals( "Testing", created1.getPurpose() );
-
-        assertEquals( "bar", created2.getForPrincipal() );
-        assertEquals( "Something", created2.getPurpose() );
-
-        List<AuthenticationKey> keys = getKeyManager().getAllKeys();
-        Collections.sort( keys, new Comparator<AuthenticationKey>()
-        {
-            public int compare( AuthenticationKey key1, AuthenticationKey key2 )
-            {
-                return key2.getForPrincipal().compareTo( key1.getForPrincipal() );
-            }
-        } );
-
-        AuthenticationKey found = (AuthenticationKey) keys.get( 0 );
-        assertEquals( created1.getKey(), found.getKey() );
-        assertEquals( "foo", found.getForPrincipal() );
-        assertEquals( "Testing", found.getPurpose() );
-        assertSameDates( created1.getDateCreated(), found.getDateCreated() );
-        assertSameDates( created1.getDateExpires(), found.getDateExpires() );
-
-        found = (AuthenticationKey) keys.get( 1 );
-        assertEquals( created2.getKey(), found.getKey() );
-        assertEquals( "bar", found.getForPrincipal() );
-        assertEquals( "Something", found.getPurpose() );
-        assertSameDates( created2.getDateCreated(), found.getDateCreated() );
-        assertSameDates( created2.getDateExpires(), found.getDateExpires() );
-    }
-
-    @Test
-    public void testNotThere()
-        throws KeyManagerException
-    {
-        String principal = "foo";
-        String purpose = "Testing";
-
-        AuthenticationKey created = getKeyManager().createKey( principal, purpose, 15 );
-
-        assertNotNull( created );
-        assertNotNull( created.getKey() );
-        assertNotNull( created.getDateCreated() );
-        assertNotNull( created.getDateExpires() );
-
-        assertEquals( principal, created.getForPrincipal() );
-        assertEquals( purpose, created.getPurpose() );
-
-        try
-        {
-            getKeyManager().findKey( "deadbeefkey" );
-            fail( "Invalid Key should not have been found." );
-        }
-        catch ( KeyNotFoundException e )
-        {
-            // Expected path for this test.
-        }
-    }
-
-    @Test
-    public void testExpired()
-        throws KeyManagerException, InterruptedException
-    {
-        String principal = "foo";
-        String purpose = "Testing";
-
-        AuthenticationKey created = getKeyManager().createKey( principal, purpose, 0 );
-
-        assertNotNull( created );
-        assertNotNull( created.getKey() );
-        assertNotNull( created.getDateCreated() );
-        assertNotNull( created.getDateExpires() );
-
-        assertEquals( principal, created.getForPrincipal() );
-        assertEquals( purpose, created.getPurpose() );
-
-        String expectedKey = created.getKey();
-
-        try
-        {
-            Thread.sleep( 500 ); // Sleep to let it expire
-            getKeyManager().findKey( expectedKey );
-            fail( "Expired Key should not have been found." );
-        }
-        catch ( KeyNotFoundException e )
-        {
-            // Expected path for this test.
-        }
-    }
-
-    @Test
-    public void testPermanent()
-        throws KeyManagerException
-    {
-        String principal = "foo";
-        String purpose = "Testing";
-
-        AuthenticationKey created = getKeyManager().createKey( principal, purpose, -1 );
-
-        assertNotNull( created );
-        assertNotNull( created.getKey() );
-        assertNotNull( created.getDateCreated() );
-        assertNull( created.getDateExpires() );
-
-        assertEquals( principal, created.getForPrincipal() );
-        assertEquals( purpose, created.getPurpose() );
-
-        Date expectedCreated = created.getDateCreated();
-
-        String expectedKey = created.getKey();
-
-        AuthenticationKey found = getKeyManager().findKey( expectedKey );
-
-        assertEquals( expectedKey, found.getKey() );
-        assertEquals( principal, found.getForPrincipal() );
-        assertEquals( purpose, found.getPurpose() );
-        assertSameDates( expectedCreated, found.getDateCreated() );
-        assertNull( found.getDateExpires() );
-    }
-}