You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JoinPointImplTest.java 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*******************************************************************************
  2. * Copyright (c) 2004 IBM Corporation and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * IBM Corporation - initial API and implementation
  10. *******************************************************************************/
  11. package org.aspectj.runtime.reflect;
  12. import junit.framework.TestCase;
  13. /**
  14. * @author colyer
  15. *
  16. */
  17. public class JoinPointImplTest extends TestCase {
  18. public void testGetArgs() {
  19. String arg1 = "abc";
  20. StringBuffer arg2 = new StringBuffer("def");
  21. Object arg3 = new Object();
  22. Object[] args = new Object[] { arg1, arg2, arg3 };
  23. JoinPointImpl jpi = new JoinPointImpl(null,null,null,args);
  24. Object[] retrievedArgs = jpi.getArgs();
  25. assertEquals("First arg unchanged",arg1,retrievedArgs[0]);
  26. assertEquals("Second arg unchanged",arg2,retrievedArgs[1]);
  27. assertEquals("Third arg unchanged",arg3,retrievedArgs[2]);
  28. retrievedArgs[0] = "xyz";
  29. ((StringBuffer)retrievedArgs[1]).append("ghi");
  30. retrievedArgs[2] = "jkl";
  31. Object[] afterUpdateArgs = jpi.getArgs();
  32. assertEquals("Object reference not changed",arg1,afterUpdateArgs[0]);
  33. assertEquals("Object reference unchanged",arg2,afterUpdateArgs[1]);
  34. assertEquals("state of referenced object updated","defghi",afterUpdateArgs[1].toString());
  35. assertEquals("Object reference not changed",arg3,afterUpdateArgs[2]);
  36. }
  37. }