harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r406613 - in /incubator/harmony/enhanced/classlib/trunk/modules/auth/src: main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java
Date Mon, 15 May 2006 11:04:01 GMT
Author: smishura
Date: Mon May 15 04:04:00 2006
New Revision: 406613

URL: http://svn.apache.org/viewcvs?rev=406613&view=rev
Log:
Unit test for KerberosPrincipal class + minor fix

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java
  (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java
  (contents, props changed)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java?rev=406613&r1=406612&r2=406613&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java
Mon May 15 04:04:00 2006
@@ -112,7 +112,7 @@
         // should be throw
         init(name);
         //TODO: it is gag
-        if (type > KRB_NT_UID) {
+        if (type < 0 || type > KRB_NT_UID) {
             throw new IllegalArgumentException("Invalid name type");
         }
         this.type = type;

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java?rev=406613&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java
Mon May 15 04:04:00 2006
@@ -0,0 +1,110 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.
+ */
+
+package javax.security.auth.kerberos;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests KerberosPrincipal class implementation.
+ */
+public class KerberosPrincipalTest extends TestCase {
+
+    /**
+     * @tests javax.security.auth.kerberos.KerberosPrincipal#KerberosPrincipal(
+     *        java.lang.String)
+     */
+    public void test_Ctor1() {
+
+        // null value is invalid
+        try {
+            new KerberosPrincipal(null);
+            fail("No expected IllegalArgumentException for null");
+        } catch (IllegalArgumentException e) {
+        }
+
+        // valid values
+        KerberosPrincipal principal = new KerberosPrincipal("name@apache.org");
+
+        assertEquals("name@apache.org", principal.getName());
+        assertEquals("apache.org", principal.getRealm());
+        assertEquals(KerberosPrincipal.KRB_NT_PRINCIPAL, principal
+                .getNameType());
+
+    }
+
+    /**
+     * @tests javax.security.auth.kerberos.KerberosPrincipal#KerberosPrincipal(
+     *        java.lang.String, int)
+     */
+    public void test_Ctor2() {
+
+        // null value is invalid
+        try {
+            new KerberosPrincipal(null, KerberosPrincipal.KRB_NT_UNKNOWN);
+            fail("No expected IllegalArgumentException for null");
+        } catch (IllegalArgumentException e) {
+        }
+
+        // '-1' nameType value is invalid
+        try {
+            new KerberosPrincipal("name@apache.org", -1);
+            fail("No expected IllegalArgumentException for -1 nameType value");
+        } catch (IllegalArgumentException e) {
+        }
+
+        // '6' nameType value is invalid
+        try {
+            new KerberosPrincipal("name@apache.org", 6);
+            fail("No expected IllegalArgumentException 6 nameType value");
+        } catch (IllegalArgumentException e) {
+        }
+
+        // valid values
+        KerberosPrincipal principal = new KerberosPrincipal("name@apache.org",
+                KerberosPrincipal.KRB_NT_UNKNOWN);
+
+        assertEquals("name@apache.org", principal.getName());
+        assertEquals("apache.org", principal.getRealm());
+        assertEquals(KerberosPrincipal.KRB_NT_UNKNOWN, principal.getNameType());
+    }
+
+    /**
+     * @tests javax.security.auth.kerberos.KerberosPrincipal#hashCode()
+     */
+    public void test_hashCode() {
+        KerberosPrincipal principal = new KerberosPrincipal("name@apache.org");
+
+        assertEquals(principal.getName().hashCode(), principal.hashCode());
+    }
+
+    /**
+     * @tests javax.security.auth.kerberos.KerberosPrincipal#toString()
+     */
+    public void test_toString() {
+        // FIXME
+        // KerberosPrincipal principal = new
+        // KerberosPrincipal("name@apache.org");
+        //
+        // assertEquals("javax.security.auth.kerberos.KerberosPrincipal@"
+        // + Integer.toHexString(principal.hashCode()), principal
+        // .toString());
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(KerberosPrincipalTest.class);
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message