    1   /* Copyright 2004 Acegi Technology Pty Limited
    2    *
    3    * Licensed under the Apache License, Version 2.0 (the "License");
    4    * you may not use this file except in compliance with the License.
    5    * You may obtain a copy of the License at
    6    *
    7    *     http://www.apache.org/licenses/LICENSE-2.0
    8    *
    9    * Unless required by applicable law or agreed to in writing, software
    10   * distributed under the License is distributed on an "AS IS" BASIS,
    11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12   * See the License for the specific language governing permissions and
    13   * limitations under the License.
    14   */
    15
    16  package org.acegisecurity;
    17
    18  import org.aspectj.lang.JoinPoint;
    19  import org.aspectj.lang.Signature;
    20  import org.aspectj.lang.reflect.CodeSignature;
    21  import org.aspectj.lang.reflect.SourceLocation;
    22
    23  import java.lang.reflect.Method;
    24
    25
    26  /***
    27   * A mock AspectJ <code>JoinPoint</code>.
    28   *
    29   * @author Ben Alex
    30   * @version $Id: MockJoinPoint.java,v 1.2 2005/11/17 00:55:47 benalex Exp $
    31   */
    32  public class MockJoinPoint implements JoinPoint {
    33      //~ Instance fields ========================================================
    34
    35      private Method beingInvoked;
    36      private Object object;
    37
    38      //~ Constructors ===========================================================
    39
    40      public MockJoinPoint(Object object, Method beingInvoked) {
    41          this.object = object;
    42          this.beingInvoked = beingInvoked;
    43      }
    44
    45      private MockJoinPoint() {}
    46
    47      //~ Methods ================================================================
    48
    49      public Object[] getArgs() {
    50          throw new UnsupportedOperationException("mock not implemented");
    51      }
    52
    53      public String getKind() {
    54          throw new UnsupportedOperationException("mock not implemented");
    55      }
    56
    57      public Signature getSignature() {
    58          throw new UnsupportedOperationException("mock not implemented");
    59      }
    60
    61      public SourceLocation getSourceLocation() {
    62          throw new UnsupportedOperationException("mock not implemented");
    63      }
    64
    65      public StaticPart getStaticPart() {
    66          return new MockStaticPart(beingInvoked);
    67      }
    68
    69      public Object getTarget() {
    70          return object;
    71      }
    72
    73      public Object getThis() {
    74          throw new UnsupportedOperationException("mock not implemented");
    75      }
    76
    77      public String toLongString() {
    78          throw new UnsupportedOperationException("mock not implemented");
    79      }
    80
    81      public String toShortString() {
    82          throw new UnsupportedOperationException("mock not implemented");
    83      }
    84
    85      //~ Inner Classes ==========================================================
    86
    87      private class MockCodeSignature implements CodeSignature {
    88          private Method beingInvoked;
    89
    90          public MockCodeSignature(Method beingInvoked) {
    91              this.beingInvoked = beingInvoked;
    92          }
    93
    94          private MockCodeSignature() {}
    95
    96          public Class getDeclaringType() {
    97              throw new UnsupportedOperationException("mock not implemented");
    98          }
    99
    100         public String getDeclaringTypeName() {
    101             throw new UnsupportedOperationException("mock not implemented");
    102         }
    103
    104         public Class[] getExceptionTypes() {
    105             throw new UnsupportedOperationException("mock not implemented");
    106         }
    107
    108         public int getModifiers() {
    109             throw new UnsupportedOperationException("mock not implemented");
    110         }
    111
    112         public String getName() {
    113             return beingInvoked.getName();
    114         }
    115
    116         public String[] getParameterNames() {
    117             throw new UnsupportedOperationException("mock not implemented");
    118         }
    119
    120         public Class[] getParameterTypes() {
    121             return beingInvoked.getParameterTypes();
    122         }
    123
    124         public String toLongString() {
    125             throw new UnsupportedOperationException("mock not implemented");
    126         }
    127
    128         public String toShortString() {
    129             throw new UnsupportedOperationException("mock not implemented");
    130         }
    131     }
    132
    133     private class MockStaticPart implements StaticPart {
    134         private Method beingInvoked;
    135
    136         public MockStaticPart(Method beingInvoked) {
    137             this.beingInvoked = beingInvoked;
    138         }
    139
    140         private MockStaticPart() {}
    141
    142         public String getKind() {
    143             throw new UnsupportedOperationException("mock not implemented");
    144         }
    145
    146         public Signature getSignature() {
    147             return new MockCodeSignature(beingInvoked);
    148         }
    149
    150         public SourceLocation getSourceLocation() {
    151             throw new UnsupportedOperationException("mock not implemented");
    152         }
    153
    154         public String toLongString() {
    155             throw new UnsupportedOperationException("mock not implemented");
    156         }
    157
    158         public String toShortString() {
    159             throw new UnsupportedOperationException("mock not implemented");
    160         }
    161     }
    162 }