AbstractControlFlowTests.java
上传用户:jiancairen
上传日期:2007-08-27
资源大小:26458k
文件大小:2k
源码类别:

Java编程

开发平台:

Java

  1. /*
  2.  * Copyright 2002-2004 the original author or authors.
  3.  * 
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  * 
  8.  *      http://www.apache.org/licenses/LICENSE-2.0
  9.  * 
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */ 
  16. package org.springframework.core;
  17. import junit.framework.TestCase;
  18. /**
  19.  * @author Rod Johnson
  20.  */
  21. public abstract class AbstractControlFlowTests extends TestCase {
  22. protected abstract ControlFlow createControlFlow();
  23. /*
  24.  * Class to test for boolean under(Class)
  25.  */
  26. public void testUnderClassAndMethod() {
  27. new One().test();
  28. new Two().testing();
  29. }
  30. /*
  31. public void testUnderPackage() {
  32. ControlFlow cflow = new ControlFlow();
  33. assertFalse(cflow.underPackage("org.springframework.aop"));
  34. assertTrue(cflow.underPackage("org.springframework.aop.support"));
  35. assertFalse(cflow.underPackage("com.interface21"));
  36. }
  37. */
  38. public class One {
  39. public void test() {
  40. ControlFlow cflow = createControlFlow();
  41. assertTrue(cflow.under(One.class));
  42. assertTrue(cflow.under(AbstractControlFlowTests.class));
  43. assertFalse(cflow.under(Two.class));
  44. assertTrue(cflow.under(One.class, "test"));
  45. assertFalse(cflow.under(One.class, "hashCode"));
  46. }
  47. }
  48. public class Two {
  49. public void testing() {
  50. ControlFlow cflow = createControlFlow();
  51. assertTrue(cflow.under(Two.class));
  52. assertTrue(cflow.under(AbstractControlFlowTests.class));
  53. assertFalse(cflow.under(One.class));
  54. assertFalse(cflow.under(Two.class, "test"));
  55. assertTrue(cflow.under(Two.class, "testing"));
  56. }
  57. }
  58. }