From 75c4045c9663debea932437ed12954e74e7e27bd Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 23 Jun 2008 21:21:18 +0000 Subject: Delete obsolete contents git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@670762 13f79535-47bb-0310-9956-ffa450edef68 --- .../core/util/JavaIntrospectionHelperTestCase.java | 180 --------------------- 1 file changed, 180 deletions(-) delete mode 100644 sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java (limited to 'sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java') diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java deleted file mode 100644 index 797b147b54..0000000000 --- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/util/JavaIntrospectionHelperTestCase.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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.tuscany.core.util; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import junit.framework.TestCase; -import org.apache.tuscany.core.mock.component.Target; - -public class JavaIntrospectionHelperTestCase extends TestCase { - - private List testNoGenericsList; - private List testList; - private Map testMap; - private Target[] testArray; - private String[] testStringArray; - - public JavaIntrospectionHelperTestCase() { - super(); - } - - public JavaIntrospectionHelperTestCase(String arg0) { - super(arg0); - } - - public void testBean1AllPublicProtectedFields() throws Exception { - Set beanFields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(Bean1.class); - assertEquals(4, beanFields.size()); //Bean1.ALL_BEAN1_PUBLIC_PROTECTED_FIELDS - } - - public void testGetSuperAllMethods() throws Exception { - Set superBeanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(SuperBean.class); - assertEquals(SuperBean.ALL_SUPER_METHODS, superBeanMethods.size()); - } - - public void testGetBean1AllMethods() throws Exception { - Set beanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class); - assertEquals(Bean1.ALL_BEAN1_METHODS, beanMethods.size()); - } - - public void testOverrideMethod() throws Exception { - Set beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class); - boolean invoked = false; - for (Method method : beanFields) { - if (method.getName().equals("override")) { - method.invoke(new Bean1(), "foo"); - invoked = true; - } - } - if (!invoked) { - throw new Exception("Override never invoked"); - } - } - - public void testNoOverrideMethod() throws Exception { - Set beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class); - boolean found = false; - for (Method method : beanFields) { - if (method.getName().equals("noOverride") && method.getParameterTypes().length == 0) { - found = true; - } - } - if (!found) { - throw new Exception("No override not found"); - } - } - - public void testDefaultConstructor() throws Exception { - Constructor ctr = JavaIntrospectionHelper.getDefaultConstructor(Bean2.class); - assertEquals(ctr, Bean2.class.getConstructor()); - assertTrue(Bean2.class == ctr.newInstance((Object[]) null).getClass()); - } - - - public void testGetAllInterfaces() { - Set interfaces = JavaIntrospectionHelper.getAllInterfaces(Z.class); - assertEquals(2, interfaces.size()); - assertTrue(interfaces.contains(W.class)); - assertTrue(interfaces.contains(W2.class)); - } - - - public void testGetAllInterfacesObject() { - Set interfaces = JavaIntrospectionHelper.getAllInterfaces(Object.class); - assertEquals(0, interfaces.size()); - } - - public void testGetAllInterfacesNoInterfaces() { - Set interfaces = JavaIntrospectionHelper.getAllInterfaces(NoInterface.class); - assertEquals(0, interfaces.size()); - } - - /** - * Tests generics introspection capabilities - */ - public void testGenerics() throws Exception { - - List classes = JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testList").getGenericType()); - assertEquals(1, classes.size()); - assertEquals(String.class, classes.get(0)); - - classes = - JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testNoGenericsList").getGenericType()); - assertEquals(0, classes.size()); - - classes = JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testMap").getGenericType()); - assertEquals(2, classes.size()); - assertEquals(String.class, classes.get(0)); - assertEquals(Bean1.class, classes.get(1)); - - classes = JavaIntrospectionHelper - .getGenerics(getClass().getDeclaredMethod("fooMethod", Map.class).getGenericParameterTypes()[0]); - assertEquals(2, classes.size()); - assertEquals(String.class, classes.get(0)); - assertEquals(Bean1.class, classes.get(1)); - - classes = JavaIntrospectionHelper - .getGenerics(getClass().getDeclaredMethod("fooMethod", List.class).getGenericParameterTypes()[0]); - assertEquals(1, classes.size()); - assertEquals(String.class, classes.get(0)); - - } - - private void fooMethod(List foo) { - - } - - private void fooMethod(Map foo) { - - } - - public void setTestArray(Target[] array) { - } - - private interface W { - - } - - private interface W2 { - - } - - private class X implements W { - - } - - private class Y extends X implements W, W2 { - - } - - private class Z extends Y { - - } - - private class NoInterface { - - } - -} -- cgit v1.2.3