You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/10/01 23:42:05 UTC
svn commit: r451816 [2/2] - in
/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java:
common/javax/security/auth/ common/javax/security/auth/x500/
common/javax/security/sasl/ common/org/apache/harmony/auth/internal/
common/org/apache/ha...
Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/internal/SecurityTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/internal/SecurityTest.java?view=diff&rev=451816&r1=451815&r2=451816
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/internal/SecurityTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/internal/SecurityTest.java Sun Oct 1 14:42:03 2006
@@ -15,11 +15,6 @@
* limitations under the License.
*/
-/**
-* @author Stepan M. Mishura
-* @version $Revision$
-*/
-
package org.apache.harmony.auth.internal;
import java.security.AccessControlContext;
@@ -27,6 +22,7 @@
import java.security.AllPermission;
import java.security.Permission;
import java.security.Permissions;
+import java.security.Principal;
import java.security.ProtectionDomain;
import java.util.Enumeration;
import java.util.HashSet;
@@ -51,7 +47,6 @@
* please notify the author before using it
*
*/
-
public class SecurityTest extends TestCase {
public static boolean testing = false;
@@ -72,12 +67,14 @@
denyMode(); //set default mode
}
+ @Override
protected void runTest() throws Throwable {
if (System.getSecurityManager() != null) {
fail("There MUST be no security manager installed!");
}
SecurityManager sm = new SecurityManager() {
+ @Override
public void checkPermission(Permission permission) {
//System.out.println("P: " + permission);
if (mode) { //deny mode
@@ -120,7 +117,7 @@
* @param permission - permission class for comparing
*/
public final void assertEquals(AccessControlException exception,
- Class permission) {
+ Class<AuthPermission> permission) {
if (!permission.isInstance(exception.getPermission())) {
fail("No expected " + permission.getName());
}
@@ -190,7 +187,7 @@
/**
* Tested <code>set</code>. Must be initialized in derived class
*/
- public Set set;
+ public Set<?> set;
/**
* Set's <code>element</code>. Must be initialized in derived class
@@ -205,6 +202,7 @@
super(name);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
@@ -228,9 +226,10 @@
*
* Expected: must return true
*/
+ @SuppressWarnings("unchecked")
public void testHasNext() {
- set.add(element);
+ ((Set<Object>)set).add(element);
assertTrue("Set is not empty", set.iterator().hasNext());
}
@@ -254,11 +253,12 @@
*
* Expected: no exception, returned element is equals to added
*/
+ @SuppressWarnings("unchecked")
public void testNext() {
- set.add(element);
+ ((Set<Object>)set).add(element);
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
assertEquals("Element", it.next(), element);
assertFalse("Next element", it.hasNext());
@@ -269,11 +269,12 @@
*
* Expected: NoSuchElementException
*/
+ @SuppressWarnings("unchecked")
public void testNext_NoSuchElementException() {
- set.add(element);
+ ((Set<Object>)set).add(element);
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
it.next();
try {
@@ -288,11 +289,12 @@
*
* Expected: no exception, size must be 0
*/
+ @SuppressWarnings("unchecked")
public void testRemove() {
- set.add(element);
+ ((Set<Object>)set).add(element);
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
it.next();
it.remove();
@@ -322,9 +324,10 @@
*
* Expected: IllegalStateException
*/
+ @SuppressWarnings("unchecked")
public void testRemove_IllegalStateException_NoNext() {
- set.add(element);
+ ((Set<Object>)set).add(element);
try {
set.iterator().remove();
@@ -338,11 +341,12 @@
*
* Expected: IllegalStateException
*/
+ @SuppressWarnings("unchecked")
public void testRemove_IllegalStateException_2Remove() {
- set.add(element);
+ ((Set<Object>)set).add(element);
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
it.next();
it.remove();
@@ -358,6 +362,7 @@
* Tests iterator interface for read only set
*
*/
+ @SuppressWarnings("unchecked")
public static class ReadOnlyIteratorTest extends IteratorTest {
public void setReadOnly() {
@@ -368,6 +373,7 @@
/**
* @see org.apache.harmony.auth.internal.SecurityTest.IteratorTest#testHasNext_EmptySet()
*/
+ @Override
public void testHasNext_EmptySet() {
setReadOnly();
super.testHasNext_EmptySet();
@@ -376,9 +382,11 @@
/**
* @see org.apache.harmony.auth.internal.SecurityTest.IteratorTest#testHasNext()
*/
+ @SuppressWarnings("unchecked")
+ @Override
public void testHasNext() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
assertTrue("Set is not empty", set.iterator().hasNext());
@@ -387,6 +395,7 @@
/**
* @see org.apache.harmony.auth.internal.SecurityTest.IteratorTest#testNext_EmptySet_NoSuchElementException()
*/
+ @Override
public void testNext_EmptySet_NoSuchElementException() {
setReadOnly();
super.testNext_EmptySet_NoSuchElementException();
@@ -395,12 +404,13 @@
/**
* @see org.apache.harmony.auth.internal.SecurityTest.IteratorTest#testNext()
*/
+ @Override
public void testNext() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
assertEquals("Element", it.next(), element);
assertFalse("Next element", it.hasNext());
@@ -409,12 +419,13 @@
/**
* @see org.apache.harmony.auth.internal.SecurityTest.IteratorTest#testNext_NoSuchElementException()
*/
+ @Override
public void testNext_NoSuchElementException() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
it.next();
try {
@@ -429,12 +440,13 @@
*
* Expected: IllegalStateException
*/
+ @Override
public void testRemove() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
it.next();
try {
@@ -447,6 +459,7 @@
/**
* @see org.apache.harmony.auth.internal.SecurityTest.IteratorTest#testRemove_EmptySet_IllegalStateException()
*/
+ @Override
public void testRemove_EmptySet_IllegalStateException() {
setReadOnly();
super.testRemove_EmptySet_IllegalStateException();
@@ -458,9 +471,10 @@
*
* Expected: IllegalStateException
*/
+ @Override
public void testRemove_IllegalStateException_NoNext() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
try {
@@ -475,11 +489,12 @@
*
* Expected: IllegalStateException
*/
+ @Override
public void testRemove_IllegalStateException_2Remove() {
- set.add(element);
+ ((Set<Object>)set).add(element);
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
it.next();
setReadOnly();
@@ -495,6 +510,7 @@
* Tests iterator interface for secure set
*
*/
+ @SuppressWarnings("unchecked")
public static class SecureIteratorTest extends IteratorTest {
public void setSecure() {
@@ -505,6 +521,7 @@
/**
* @see org.apache.harmony.auth.internal.SecurityTest.IteratorTest#testHasNext_EmptySet()
*/
+ @Override
public void testHasNext_EmptySet() {
setSecure();
super.testHasNext_EmptySet();
@@ -513,8 +530,9 @@
/**
* @see org.apache.harmony.auth.internal.SecurityTest.IteratorTest#testHasNext()
*/
+ @Override
public void testHasNext() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
assertTrue("Set is not empty", set.iterator().hasNext());
@@ -523,6 +541,7 @@
/**
* @see org.apache.harmony.auth.internal.SecurityTest.IteratorTest#testNext_EmptySet_NoSuchElementException()
*/
+ @Override
public void testNext_EmptySet_NoSuchElementException() {
setSecure();
super.testNext_EmptySet_NoSuchElementException();
@@ -531,11 +550,12 @@
/**
* @see org.apache.harmony.auth.internal.SecurityTest.IteratorTest#testNext_NoSuchElementException()
*/
+ @Override
public void testNext_NoSuchElementException() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
it.next();
try {
@@ -548,11 +568,12 @@
/**
* @see org.apache.harmony.auth.internal.SecurityTest.IteratorTest#testNext()
*/
+ @Override
public void testNext() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
assertEquals("Element", it.next(), element);
assertFalse("Next element", it.hasNext());
@@ -563,11 +584,12 @@
*
* Expected: AccessControlException
*/
+ @Override
public void testRemove() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
it.next();
try {
@@ -584,6 +606,7 @@
*
* Expected: AccessControlException instead IllegalStateException for empty set
*/
+ @Override
public void testRemove_EmptySet_IllegalStateException() {
setSecure();
@@ -600,9 +623,10 @@
*
* Expected: AccessControlException instead IllegalStateException
*/
+ @Override
public void testRemove_IllegalStateException_NoNext() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
try {
@@ -618,10 +642,11 @@
*
* Expected: AccessControlException
*/
+ @Override
public void testRemove_IllegalStateException_2Remove() {
- set.add(element);
+ ((Set<Object>)set).add(element);
- Iterator it = set.iterator();
+ Iterator<?> it = set.iterator();
it.next();
setSecure();
@@ -634,12 +659,13 @@
}
}
+ @SuppressWarnings("unchecked")
public static class SetTest extends SecurityTest {
/**
* Tested <code>set</code>. Must be initialized in derived class
*/
- public Set set;
+ public Set<?> set;
/**
* Set's <code>element</code>. Must be initialized in derived class
@@ -649,8 +675,9 @@
/**
* Is used as collection parameter
*/
- public HashSet hash = new HashSet();
+ public HashSet<Object> hash = new HashSet<Object>();
+ @Override
protected void setUp() throws Exception {
super.setUp();
@@ -666,13 +693,13 @@
// Testing: boolean Set.add(Object o)
//
public void testAdd_NewElement() {
- assertTrue("Adding new element", set.add(element));
+ assertTrue("Adding new element", ((Set<Object>)set).add(element));
assertEquals("Size", 1, set.size());
}
public void testAdd_ExistingElement() {
- set.add(element);
- assertFalse("Adding existing element", set.add(element));
+ ((Set<Object>)set).add(element);
+ assertFalse("Adding existing element", ((Set<Object>)set).add(element));
assertEquals("Size", 1, set.size());
}
@@ -682,25 +709,25 @@
public void testAddAll_NullParameter() {
try {
- set.addAll(null);
+ ((Set<Object>)set).addAll(null);
fail("No expected NullPointerException");
} catch (NullPointerException npe) {
}
}
public void testAddAll_EmptySet() {
- assertFalse("Adding empty set", set.addAll(new HashSet()));
+ assertFalse("Adding empty set", ((Set<Object>)set).addAll(new HashSet<Object>()));
assertEquals("Size", 0, set.size());
}
public void testAddAll_NewElement() {
- assertTrue("Adding new element", set.addAll(hash));
+ assertTrue("Adding new element", ((Set<Object>)set).addAll(hash));
assertEquals("Size", 1, set.size());
}
public void testAddAll_ExistingElement() {
- set.add(element);
- assertFalse("Adding existing element", set.addAll(hash));
+ ((Set<Object>)set).add(element);
+ assertFalse("Adding existing element", ((Set<Object>)set).addAll(hash));
assertEquals("Size", 1, set.size());
}
@@ -713,7 +740,7 @@
}
public void testClear_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
set.clear();
assertEquals("Set MUST be empty", 0, set.size());
}
@@ -726,7 +753,7 @@
}
public void testContains_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
assertTrue("Set contains element", set.contains(element));
}
@@ -742,7 +769,7 @@
}
public void testContainsAll_EmptySet() {
- assertTrue("Empty set", set.containsAll(new HashSet()));
+ assertTrue("Empty set", set.containsAll(new HashSet<Object>()));
}
public void testContainsAll_NotExistingElement() {
@@ -750,7 +777,7 @@
}
public void testContainsAll_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
assertTrue("Set contains element", set.containsAll(hash));
}
@@ -763,7 +790,7 @@
}
public void testIsEmpty_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
assertFalse("Set is not empty", set.isEmpty());
}
@@ -777,8 +804,9 @@
assertNotNull("Iterator", set.iterator());
}
+ @SuppressWarnings("unchecked")
public void testIterator_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
assertNotNull("Iterator", set.iterator());
}
@@ -792,7 +820,7 @@
}
public void testRemove_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
assertTrue("Removing element", set.remove(element));
assertEquals("Size", 0, set.size());
}
@@ -811,7 +839,7 @@
public void testRemoveAll_NullParameter_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
try {
set.removeAll(null);
fail("No expected NullPointerException");
@@ -820,13 +848,13 @@
}
public void testRemoveAll_EmptySet() {
- assertFalse("Removing empty set", set.removeAll(new HashSet()));
+ assertFalse("Removing empty set", set.removeAll(new HashSet<Object>()));
assertEquals("Size", 0, set.size());
}
public void testRemoveAll_NotEmptySet() {
- set.add(element);
- assertFalse("Removing empty set", set.removeAll(new HashSet()));
+ ((Set<Object>)set).add(element);
+ assertFalse("Removing empty set", set.removeAll(new HashSet<Object>()));
assertEquals("Size", 1, set.size());
}
@@ -836,7 +864,7 @@
}
public void testRemoveAll_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
assertTrue("Removing elements", set.removeAll(hash));
assertEquals("Size", 0, set.size());
}
@@ -859,7 +887,7 @@
public void testRetainAll_NullParameter_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
try {
set.retainAll(null);
fail("No expected NullPointerException");
@@ -868,13 +896,13 @@
}
public void testRetainAll_EmptySet() {
- assertFalse("Removing all elements", set.retainAll(new HashSet()));
+ assertFalse("Removing all elements", set.retainAll(new HashSet<Object>()));
assertEquals("Size", 0, set.size());
}
public void testRetainAll_NotEmptySet() {
- set.add(element);
- assertTrue("Removing all elements", set.retainAll(new HashSet()));
+ ((Set<Object>)set).add(element);
+ assertTrue("Removing all elements", set.retainAll(new HashSet<Object>()));
assertEquals("Size", 0, set.size());
}
@@ -884,7 +912,7 @@
}
public void testRetainAll_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
assertFalse("Removing elements", set.retainAll(hash));
assertEquals("Size", 1, set.size());
}
@@ -897,26 +925,27 @@
}
public void testToArray_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
assertEquals("Set is not empty", set.toArray().length, 1);
assertTrue("Set element", set.toArray()[0] == element);
}
public void testToArray_Immutability() {
- set.add(element);
+ ((Set<Object>)set).add(element);
set.toArray()[0] = null;
assertTrue("Element", set.toArray()[0] == element);
}
//TODO test Object[] Set.toArray(Object[] a)
}
-
+
+ @SuppressWarnings("unchecked")
public static class UnsupportedNullTest extends SecurityTest {
/**
* Tested <code>set</code>. Must be initialized in derived class
*/
- public Set set;
+ public Set<?> set;
/**
* Set's <code>element</code>. Must be initialized in derived class
@@ -926,8 +955,9 @@
/**
* Is used as collection parameter
*/
- public HashSet hash = new HashSet();
+ public HashSet<?> hash = new HashSet<Object>();
+ @Override
protected void setUp() throws Exception {
super.setUp();
@@ -965,7 +995,7 @@
if (testing) {
try {
- set.addAll(hash);
+ ((Set<Object>)set).addAll(hash);
// priv/pub credentials set: no NullPointerException
} catch (NullPointerException e) {
assertEquals("Size", 0, set.size());
@@ -974,7 +1004,7 @@
}
} else {
try {
- set.addAll(hash);
+ ((Set<Object>)set).addAll(hash);
fail("No expected NullPointerException");
} catch (NullPointerException e) {
}
@@ -1006,7 +1036,7 @@
}
public void testRetainAll_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
try {
assertTrue("Retaining NULL element", set.retainAll(hash));
} catch (NullPointerException npe) {
@@ -1014,13 +1044,14 @@
assertEquals("Set is empty", 0, set.size());
}
}
-
+
+ @SuppressWarnings("unchecked")
public static class IneligibleElementTest extends SecurityTest {
/**
* Tested <code>set</code>. Must be initialized in derived class
*/
- public Set set;
+ public Set<?> set;
/**
* Set's <code>element</code>. Must be initialized in derived class
@@ -1030,7 +1061,7 @@
/**
* Is used as collection parameter
*/
- public HashSet hash = new HashSet();
+ public HashSet<?> hash = new HashSet<Object>();
/**
* Set's <code>ineligible element</code>. Must be initialized in derived class
@@ -1040,8 +1071,9 @@
/**
* Is used as collection parameter
*/
- public HashSet iHash = new HashSet();
+ public HashSet<Object> iHash = new HashSet<Object>();
+ @Override
protected void setUp() throws Exception {
super.setUp();
@@ -1059,7 +1091,7 @@
public void testAdd() {
try {
- set.add(iElement);
+ ((Set<Object>)set).add(iElement);
fail("No expected ClassCastException or IllegalArgumentException");
} catch (ClassCastException e) {
@@ -1081,7 +1113,7 @@
}
try {
- set.add(new Object());
+ ((Set<Object>)set).add(new Object());
if (!testing) {
// all Class sets - no exception
@@ -1095,7 +1127,7 @@
public void testAddAll() {
try {
- set.addAll(iHash);
+ ((Set<Object>)set).addAll(iHash);
fail("No expected ClassCastException or IllegalArgumentException");
} catch (ClassCastException e) {
@@ -1156,7 +1188,7 @@
public void testRetainAll_NotEmptySet_IneligibleElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
try {
assertTrue("Retaining ineligible element", set.retainAll(iHash));
} catch (ClassCastException e) {
@@ -1165,7 +1197,7 @@
assertEquals("Now set is empty", 0, set.size());
}
}
-
+ @SuppressWarnings("unchecked")
public static class ReadOnlySetTest extends SetTest {
public void setReadOnly() {
@@ -1173,66 +1205,74 @@
"setReadOnly MUST be implemented in derived class");
}
+ @Override
public void testAdd_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
try {
- set.add(element);
+ ((Set<Object>)set).add(element);
fail("No expected IllegalStateException");
} catch (IllegalStateException e) {
}
}
+ @Override
public void testAdd_NewElement() {
setReadOnly();
try {
- set.add(element);
+ ((Set<Object>)set).add(element);
fail("No expected IllegalStateException");
} catch (IllegalStateException e) {
}
}
+ @Override
public void testAddAll_EmptySet() {
setReadOnly();
super.testAddAll_EmptySet();
}
+ @Override
public void testAddAll_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
try {
- set.addAll(hash);
+ ((Set<Object>)set).addAll(hash);
fail("No expected IllegalStateException");
} catch (IllegalStateException e) {
}
}
+ @Override
public void testAddAll_NewElement() {
setReadOnly();
try {
- set.addAll(hash);
+ ((Set<Object>)set).addAll(hash);
fail("No expected IllegalStateException");
} catch (IllegalStateException e) {
}
}
+ @Override
public void testAddAll_NullParameter() {
setReadOnly();
super.testAddAll_NullParameter();
}
+ @Override
public void testClear_EmptySet() {
setReadOnly();
super.testClear_EmptySet();
}
+ @Override
public void testClear_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
try {
@@ -1242,63 +1282,74 @@
}
}
+ @Override
public void testContains_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
assertTrue("Set contains element", set.contains(element));
}
+ @Override
public void testContains_NotExistingElement() {
setReadOnly();
super.testContains_NotExistingElement();
}
+ @Override
public void testContainsAll_EmptySet() {
setReadOnly();
super.testContainsAll_EmptySet();
}
+ @Override
public void testContainsAll_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
assertTrue("Set contains element", set.containsAll(hash));
}
+ @Override
public void testContainsAll_NotExistingElement() {
setReadOnly();
super.testContainsAll_NotExistingElement();
}
+ @Override
public void testContainsAll_NullParameter() {
setReadOnly();
super.testContainsAll_NullParameter();
}
+ @Override
public void testIsEmpty_EmptySet() {
setReadOnly();
super.testIsEmpty_EmptySet();
}
+ @Override
public void testIsEmpty_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
assertFalse("Set is not empty", set.isEmpty());
}
+ @Override
public void testIterator_EmptySet() {
setReadOnly();
super.testIterator_EmptySet();
}
+ @Override
public void testIterator_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
assertNotNull("Iterator", set.iterator());
}
+ @Override
public void testRemove_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
try {
@@ -1308,19 +1359,22 @@
}
}
+ @Override
public void testRemove_NotExistingElement() {
setReadOnly();
super.testRemove_NotExistingElement();
}
+ @Override
public void testRemoveAll_EmptySet() {
setReadOnly();
super.testRemoveAll_EmptySet();
}
+ @Override
public void testRemoveAll_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
try {
@@ -1330,26 +1384,30 @@
}
}
+ @Override
public void testRemoveAll_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
- set.removeAll(new HashSet());
+ set.removeAll(new HashSet<Object>());
}
+ @Override
public void testRemoveAll_NotExistingElement() {
setReadOnly();
super.testRemoveAll_NotExistingElement();
}
+ @Override
public void testRemoveAll_NullParameter_EmptySet() {
setReadOnly();
super.testRemoveAll_NullParameter_EmptySet();
}
+ @Override
public void testRemoveAll_NullParameter_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
try {
@@ -1359,41 +1417,47 @@
}
}
+ @Override
public void testRetainAll_EmptySet() {
setReadOnly();
super.testRetainAll_EmptySet();
}
+ @Override
public void testRetainAll_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
set.retainAll(hash);
}
+ @Override
public void testRetainAll_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
try {
- set.retainAll(new HashSet());
+ set.retainAll(new HashSet<Object>());
fail("No expected IllegalStateException");
} catch (IllegalStateException e) {
}
}
+ @Override
public void testRetainAll_NotExistingElement() {
setReadOnly();
super.testRetainAll_NotExistingElement();
}
+ @Override
public void testRetainAll_NullParameter_EmptySet() {
setReadOnly();
super.testRetainAll_NullParameter_EmptySet();
}
+ @Override
public void testRetainAll_NullParameter_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
try {
@@ -1403,28 +1467,31 @@
}
}
+ @Override
public void testToArray_EmptySet() {
setReadOnly();
super.testToArray_EmptySet();
}
+ @Override
public void testToArray_Immutability() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
set.toArray()[0] = null;
assertTrue("Element", set.toArray()[0] == element);
}
+ @Override
public void testToArray_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setReadOnly();
assertEquals("Set is not empty", set.toArray().length, 1);
assertTrue("Set element", set.toArray()[0] == element);
}
}
-
+ @SuppressWarnings("unchecked")
public static class SecureSetTest extends SetTest {
public void setSecure() {
@@ -1441,72 +1508,80 @@
// }
// }
+ @Override
public void testAdd_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
try {
- set.add(element);
+ ((Set<Object>)set).add(element);
fail("No expected AccessControlException");
} catch (AccessControlException e) {
assertEquals(e, AuthPermission.class);
}
}
+ @Override
public void testAdd_NewElement() {
setSecure();
try {
- set.add(element);
+ ((Set<Object>)set).add(element);
fail("No expected AccessControlException");
} catch (AccessControlException e) {
assertEquals(e, AuthPermission.class);
}
}
+ @Override
public void testAddAll_EmptySet() {
setSecure();
super.testAddAll_EmptySet();
}
+ @Override
public void testAddAll_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
try {
- set.addAll(hash);
+ ((Set<Object>)set).addAll(hash);
fail("No expected AccessControlException");
} catch (AccessControlException e) {
assertEquals(e, AuthPermission.class);
}
}
+ @Override
public void testAddAll_NewElement() {
setSecure();
try {
- set.addAll(hash);
+ ((Set<Object>)set).addAll(hash);
fail("No expected AccessControlException");
} catch (AccessControlException e) {
assertEquals(e, AuthPermission.class);
}
}
+ @Override
public void testAddAll_NullParameter() {
setSecure();
super.testAddAll_NullParameter();
}
+ @Override
public void testClear_EmptySet() {
setSecure();
super.testClear_EmptySet();
}
+ @Override
public void testClear_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
try {
@@ -1517,63 +1592,74 @@
}
}
+ @Override
public void testContains_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
assertTrue("Set contains element", set.contains(element));
}
+ @Override
public void testContains_NotExistingElement() {
setSecure();
super.testContains_NotExistingElement();
}
+ @Override
public void testContainsAll_EmptySet() {
setSecure();
super.testContainsAll_EmptySet();
}
+ @Override
public void testContainsAll_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
assertTrue("Set contains element", set.containsAll(hash));
}
+ @Override
public void testContainsAll_NotExistingElement() {
setSecure();
super.testContainsAll_NotExistingElement();
}
+ @Override
public void testContainsAll_NullParameter() {
setSecure();
super.testContainsAll_NullParameter();
}
+ @Override
public void testIsEmpty_EmptySet() {
setSecure();
super.testIsEmpty_EmptySet();
}
+ @Override
public void testIsEmpty_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
assertFalse("Set is not empty", set.isEmpty());
}
+ @Override
public void testIterator_EmptySet() {
setSecure();
super.testIterator_EmptySet();
}
+ @Override
public void testIterator_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
assertNotNull("Iterator", set.iterator());
}
+ @Override
public void testRemove_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
try {
@@ -1584,19 +1670,22 @@
}
}
+ @Override
public void testRemove_NotExistingElement() {
setSecure();
super.testRemove_NotExistingElement();
}
+ @Override
public void testRemoveAll_EmptySet() {
setSecure();
super.testRemoveAll_EmptySet();
}
+ @Override
public void testRemoveAll_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
try {
@@ -1607,27 +1696,31 @@
}
}
+ @Override
public void testRemoveAll_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
- assertFalse("Removing empty set", set.removeAll(new HashSet()));
+ assertFalse("Removing empty set", set.removeAll(new HashSet<Object>()));
assertEquals("Size", 1, set.size());
}
+ @Override
public void testRemoveAll_NotExistingElement() {
setSecure();
super.testRemoveAll_NotExistingElement();
}
+ @Override
public void testRemoveAll_NullParameter_EmptySet() {
setSecure();
super.testRemoveAll_NullParameter_EmptySet();
}
+ @Override
public void testRemoveAll_NullParameter_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
try {
@@ -1637,43 +1730,49 @@
}
}
+ @Override
public void testRetainAll_EmptySet() {
setSecure();
super.testRetainAll_EmptySet();
}
+ @Override
public void testRetainAll_ExistingElement() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
assertFalse("Removing elements", set.retainAll(hash));
assertEquals("Size", 1, set.size());
}
+ @Override
public void testRetainAll_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
try {
- set.retainAll(new HashSet());
+ set.retainAll(new HashSet<Object>());
fail("No expected AccessControlException");
} catch (AccessControlException e) {
assertEquals(e, AuthPermission.class);
}
}
+ @Override
public void testRetainAll_NotExistingElement() {
setSecure();
super.testRetainAll_NotExistingElement();
}
+ @Override
public void testRetainAll_NullParameter_EmptySet() {
setSecure();
super.testRetainAll_NullParameter_EmptySet();
}
+ @Override
public void testRetainAll_NullParameter_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
try {
@@ -1683,21 +1782,24 @@
}
}
+ @Override
public void testToArray_EmptySet() {
setSecure();
super.testToArray_EmptySet();
}
+ @Override
public void testToArray_Immutability() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
set.toArray()[0] = null;
assertTrue("Element", set.toArray()[0] == element);
}
+ @Override
public void testToArray_NotEmptySet() {
- set.add(element);
+ ((Set<Object>)set).add(element);
setSecure();
assertEquals("Set is not empty", set.toArray().length, 1);
@@ -1718,10 +1820,11 @@
public Object obj3;
// Set of objects that are not equal to obj1, obj2, obj3
- public Vector notEqual;
+ public Vector<Object> notEqual;
// Checks that references to testing objects are different
// because we are not going to test Object.equals(Object)
+ @Override
protected void setUp() throws Exception {
super.setUp();
@@ -1755,7 +1858,7 @@
}
public void testEquals_NotEqual() {
- for (Enumeration e = notEqual.elements(); e.hasMoreElements();) {
+ for (Enumeration<Object> e = notEqual.elements(); e.hasMoreElements();) {
assertFalse(obj1.equals(e.nextElement()));
}
}
@@ -1788,7 +1891,7 @@
// init obj3
- HashSet hash = new HashSet();
+ HashSet<MyClass1> hash = new HashSet<MyClass1>();
hash.add(element1);
hash.add(element2);
@@ -1796,19 +1899,19 @@
obj3 = hash;
// init obj3
- HashSet hash1 = new HashSet();
+ HashSet<Principal> hash1 = new HashSet<Principal>();
hash1.add(element1);
hash1.add(new MyClass1());
Subject s1 = new Subject(false, hash1, hash1, hash1);
- HashSet hash2 = new HashSet();
+ HashSet<MyClass2> hash2 = new HashSet<MyClass2>();
hash1.add(element2);
hash1.add(new MyClass2());
Subject s2 = new Subject(false, hash2, hash2, hash2);
Subject s3 = new Subject();
- notEqual = new Vector();
+ notEqual = new Vector<Object>();
notEqual.add(s1.getPrincipals());
notEqual.add(s1.getPrivateCredentials());
@@ -1831,7 +1934,7 @@
notEqual.add(s3.getPrivateCredentials(MyClass1.class));
notEqual.add(s3.getPublicCredentials(MyClass1.class));
- notEqual.add(new HashSet());
+ notEqual.add(new HashSet<Object>());
notEqual.add(new Object());
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/login/DefaultConfigParserTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/login/DefaultConfigParserTest.java?view=diff&rev=451816&r1=451815&r2=451816
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/login/DefaultConfigParserTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/login/DefaultConfigParserTest.java Sun Oct 1 14:42:03 2006
@@ -30,6 +30,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -57,7 +58,7 @@
URL url;
- LinkedList entriesList;
+ LinkedList<?> entriesList;
public static void main(String[] args) {
junit.textui.TestRunner.run(DefaultConfigParserTest.class);
@@ -87,25 +88,25 @@
* @throws Exception
*/
public final void testConfigParser_01() throws Exception {
- Map config = null;
- config = DefaultConfigurationParser.configParser(url, p, new HashMap());
- entriesList = (LinkedList) config.get("Login1");
+ Map<?, ?> config = null;
+ config = DefaultConfigurationParser.configParser(url, p, new HashMap<String, List<AppConfigurationEntry>>());
+ entriesList = (LinkedList<?>) config.get("Login1");
assertNotNull(entriesList);
- entriesList = (LinkedList) config.get("other");
+ entriesList = (LinkedList<?>) config.get("other");
assertNotNull(entriesList);
- entriesList = (LinkedList) config.get("Login2");
+ entriesList = (LinkedList<?>) config.get("Login2");
assertNotNull(entriesList);
- entriesList = (LinkedList) config.get("Login3");
+ entriesList = (LinkedList<?>) config.get("Login3");
assertNotNull(entriesList);
- entriesList = (LinkedList) config.get("Login4");
+ entriesList = (LinkedList<?>) config.get("Login4");
assertNotNull(entriesList);
- entriesList = (LinkedList) config.get("Login5");
+ entriesList = (LinkedList<?>) config.get("Login5");
assertNotNull(entriesList);
- entriesList = (LinkedList) config.get("Login6");
+ entriesList = (LinkedList<?>) config.get("Login6");
assertNotNull(entriesList);
- entriesList = (LinkedList) config.get("Login7");
+ entriesList = (LinkedList<?>) config.get("Login7");
assertNotNull(entriesList);
- entriesList = (LinkedList) config.get("Login8");
+ entriesList = (LinkedList<?>) config.get("Login8");
assertNull(entriesList);
}
@@ -115,14 +116,14 @@
*/
public final void testConfigParser_02() throws Exception {
- Map config = DefaultConfigurationParser.configParser(url, p, new HashMap());
- entriesList = (LinkedList) config.get("Login1");
+ Map<?, ?> config = DefaultConfigurationParser.configParser(url, p, new HashMap<String, List<AppConfigurationEntry>>());
+ entriesList = (LinkedList<?>) config.get("Login1");
if (entriesList == null || entriesList.size() == 0) {
fail("Unable to read configuration");
}
- Iterator i = entriesList.iterator();
+ Iterator<?> i = entriesList.iterator();
while (i.hasNext()) {
AppConfigurationEntry e = (AppConfigurationEntry) i.next();
assertEquals("com.intel.security.auth.module.LoginModule1", e
@@ -132,7 +133,7 @@
assertEquals(
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
e.getControlFlag());
- Map m = new HashMap();
+ Map<String, String> m = new HashMap<String, String>();
m.put("debug1", "true");
m.put("test1", "false");
assertEquals(m, e.getOptions());
@@ -177,7 +178,7 @@
os.flush();
os.close();
try {
- DefaultConfigurationParser.configParser(file.toURL(), p, new HashMap());
+ DefaultConfigurationParser.configParser(file.toURL(), p, new HashMap<String, List<AppConfigurationEntry>>());
fail("no expected InvalidFormatException" + i);
} catch (NullPointerException e) {
System.out.println(file.getCanonicalPath());
Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/login/DefaultConfigurationTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/login/DefaultConfigurationTest.java?view=diff&rev=451816&r1=451815&r2=451816
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/login/DefaultConfigurationTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/login/DefaultConfigurationTest.java Sun Oct 1 14:42:03 2006
@@ -108,7 +108,7 @@
ents = dc.getAppConfigurationEntry("LoginNew");
assertNotNull(ents);
assertEquals("com.intel.security.auth.module.LoginModule1", ents[0].getLoginModuleName());
- Map m = new HashMap();
+ Map<String, String> m = new HashMap<String, String>();
m.put("debug", "true");
m.put("test", "false");
assertEquals(m, ents[0].getOptions());
@@ -149,7 +149,7 @@
assertNotNull(ents);
ents = dc.getAppConfigurationEntry("Login1");
assertNotNull(ents);
- Map m = new HashMap();
+ Map<String, String> m = new HashMap<String, String>();
for (AppConfigurationEntry element : ents) {
assertEquals("com.intel.security.auth.module.LoginModule1",
element.getLoginModuleName());
Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/login/LoginContextTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/login/LoginContextTest.java?view=diff&rev=451816&r1=451815&r2=451816
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/login/LoginContextTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/login/LoginContextTest.java Sun Oct 1 14:42:03 2006
@@ -38,7 +38,7 @@
MyPrincipal pri = new MyPrincipal();
HashSet<Principal> set = new HashSet<Principal>();
set.add(pri);
- Subject sub = new Subject(false, set, new HashSet(), new HashSet());
+ Subject sub = new Subject(false, set, new HashSet<Object>(), new HashSet<Object>());
Configuration.setConfiguration(new MyConfig());
LoginContext context = new LoginContext("moduleName", sub);
context.login();
@@ -53,7 +53,7 @@
assertNotNull(context.getSubject());
}
static class MyConfig extends Configuration{
- AppConfigurationEntry[] entries = new AppConfigurationEntry[]{new AppConfigurationEntry(MyModule.class.getName(), LoginModuleControlFlag.REQUIRED, new HashMap())};
+ AppConfigurationEntry[] entries = new AppConfigurationEntry[]{new AppConfigurationEntry(MyModule.class.getName(), LoginModuleControlFlag.REQUIRED, new HashMap<String, Object>())};
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
return entries;
@@ -64,7 +64,7 @@
}
public static class MyModule implements LoginModule{
Subject sub;
- public void MyModule(){
+ public MyModule(){
}
public boolean abort() throws LoginException {
return false;
Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/support/SpiEngUtils.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/support/SpiEngUtils.java?view=diff&rev=451816&r1=451815&r2=451816
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/support/SpiEngUtils.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/support/SpiEngUtils.java Sun Oct 1 14:42:03 2006
@@ -73,6 +73,7 @@
return res;
}
+ @SuppressWarnings("serial")
public class MyProvider extends Provider {
public MyProvider(String name, String info, String key, String clName) {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/linux/org/apache/harmony/auth/module/UnixLoginModuleTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/linux/org/apache/harmony/auth/module/UnixLoginModuleTest.java?view=diff&rev=451816&r1=451815&r2=451816
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/linux/org/apache/harmony/auth/module/UnixLoginModuleTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/linux/org/apache/harmony/auth/module/UnixLoginModuleTest.java Sun Oct 1 14:42:03 2006
@@ -38,24 +38,14 @@
*/
public class UnixLoginModuleTest extends TestCase {
- /**
- * Standalone entry point.
- * @param args
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(UnixLoginModuleTest.class);
- }
-
UnixLoginModule lm = new UnixLoginModule();
- /*
- * @see TestCase#setUp()
- */
+ @Override
protected void setUp() throws Exception {
Subject subj = new Subject();
CallbackHandler cbh = new TestCallbackHandler();
- Map sharedState = new HashMap();
- Map options = new HashMap();
+ Map<String, ?> sharedState = new HashMap<String, Object>();
+ Map<String, ?> options = new HashMap<String, Object>();
lm.initialize(subj, cbh, sharedState, options);
}
@@ -72,8 +62,8 @@
// Need new, non initialized instance of LoginModule
lm = new UnixLoginModule();
- Map shared = new HashMap();
- Map options = new HashMap();
+ Map<String, ?> shared = new HashMap<String, Object>();
+ Map<String, ?> options = new HashMap<String, Object>();
CallbackHandler cbh = new TestCallbackHandler();
// must not accept null for subject
try {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/windows/org/apache/harmony/auth/module/NTLoginModuleTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/windows/org/apache/harmony/auth/module/NTLoginModuleTest.java?view=diff&rev=451816&r1=451815&r2=451816
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/windows/org/apache/harmony/auth/module/NTLoginModuleTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/windows/org/apache/harmony/auth/module/NTLoginModuleTest.java Sun Oct 1 14:42:03 2006
@@ -38,24 +38,14 @@
*/
public class NTLoginModuleTest extends TestCase {
- /**
- * Standalone entry point.
- * @param args
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(NTLoginModuleTest.class);
- }
-
NTLoginModule lm = new NTLoginModule();
- /*
- * @see TestCase#setUp()
- */
+ @Override
protected void setUp() throws Exception {
Subject subj = new Subject();
CallbackHandler cbh = new TestCallbackHandler();
- Map sharedState = new HashMap();
- Map options = new HashMap();
+ Map<String, ?> sharedState = new HashMap<String, Object>();
+ Map<String, ?> options = new HashMap<String, Object>();
lm.initialize(subj, cbh, sharedState, options);
}
@@ -72,8 +62,8 @@
// Need new, non initialized instance of LoginModule
lm = new NTLoginModule();
- Map shared = new HashMap();
- Map options = new HashMap();
+ Map<String, ?> shared = new HashMap<String, Object>();
+ Map<String, ?> options = new HashMap<String, Object>();
CallbackHandler cbh = new TestCallbackHandler();
// must not accept null for subject
try {