openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1521967 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util: ClassUtilTest.java MySubClass.java MySuperClass.java differentPackage/ differentPackage/MyOtherPackageSubClass.java
Date Wed, 11 Sep 2013 18:08:06 GMT
Author: struberg
Date: Wed Sep 11 18:08:05 2013
New Revision: 1521967

URL: http://svn.apache.org/r1521967
Log:
OWB-898 add test for ClassUtil#isOverridden

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/MySubClass.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/MySuperClass.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/differentPackage/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/differentPackage/MyOtherPackageSubClass.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java?rev=1521967&r1=1521966&r2=1521967&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java
Wed Sep 11 18:08:05 2013
@@ -22,6 +22,7 @@ import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.webbeans.util.differentPackage.MyOtherPackageSubClass;
 import org.junit.Test;
 
 import junit.framework.Assert;
@@ -35,4 +36,27 @@ public class ClassUtilTest {
         nonPrivateMethods.removeAll(Arrays.asList(Object.class.getDeclaredMethods()));
         Assert.assertEquals(SpecificClass.class.getDeclaredMethods().length, nonPrivateMethods.size());
     }
+
+    @Test
+    public void testIsOverridden() throws Exception
+    {
+        Assert.assertTrue(isOverridden(MySubClass.class, "publicMethod"));
+        Assert.assertTrue(isOverridden(MySubClass.class, "protectedMethod"));
+
+        Assert.assertTrue(isOverridden(MySubClass.class, "packageMethod"));
+        Assert.assertFalse(isOverridden(MyOtherPackageSubClass.class, "packageMethod"));
+
+        Assert.assertFalse(isOverridden(MySubClass.class, "privateMethod"));
+        Assert.assertFalse(isOverridden(MyOtherPackageSubClass.class, "privateMethod"));
+    }
+
+    private boolean isOverridden(Class subClass, String methodName) throws Exception
+    {
+        Method superClassMethod = MySuperClass.class.getDeclaredMethod(methodName);
+        Method subClassMethod   = subClass.getDeclaredMethod(methodName);
+
+        return ClassUtil.isOverridden(subClassMethod, superClassMethod);
+    }
+
 }
+

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/MySubClass.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/MySubClass.java?rev=1521967&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/MySubClass.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/MySubClass.java
Wed Sep 11 18:08:05 2013
@@ -0,0 +1,45 @@
+/*
+ * 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.webbeans.util;
+
+/**
+*
+*/
+public class MySubClass extends MySuperClass
+{
+    public void publicMethod()
+    {
+        // do nothing
+    }
+
+    protected void protectedMethod()
+    {
+        // do nothing
+    }
+
+    void packageMethod()
+    {
+        // do nothing
+    }
+
+    private void privateMethod()
+    {
+        // do nothing
+    }
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/MySuperClass.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/MySuperClass.java?rev=1521967&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/MySuperClass.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/MySuperClass.java
Wed Sep 11 18:08:05 2013
@@ -0,0 +1,45 @@
+/*
+ * 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.webbeans.util;
+
+/**
+*
+*/
+public class MySuperClass
+{
+    public void publicMethod()
+    {
+        // do nothing
+    }
+
+    protected void protectedMethod()
+    {
+        // do nothing
+    }
+
+    void packageMethod()
+    {
+        // do nothing
+    }
+
+    private void privateMethod()
+    {
+        // do nothing
+    }
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/differentPackage/MyOtherPackageSubClass.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/differentPackage/MyOtherPackageSubClass.java?rev=1521967&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/differentPackage/MyOtherPackageSubClass.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/differentPackage/MyOtherPackageSubClass.java
Wed Sep 11 18:08:05 2013
@@ -0,0 +1,47 @@
+/*
+ * 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.webbeans.util.differentPackage;
+
+import org.apache.webbeans.util.MySuperClass;
+
+/**
+*
+*/
+public class MyOtherPackageSubClass extends MySuperClass
+{
+    public void publicMethod()
+    {
+        // do nothing
+    }
+
+    protected void protectedMethod()
+    {
+        // do nothing
+    }
+
+    void packageMethod()
+    {
+        // do nothing
+    }
+
+    private void privateMethod()
+    {
+        // do nothing
+    }
+}



Mime
View raw message