Women in Technology

Hear us Roar



Article:
  Subverting Java Access Protection for Unit Testing
Subject:   Public Introductions for Private Methods
Date:   2003-11-13 13:05:51
From:   anonymous2
Another option is to apply privileged public introductions that provide pass-through delegation to non-public methods and fields. A simple combination of a doclet and an aspect compiler can provide this level of access for all of your non-public members at once. The doclet generates the aspect source files for application by the aspect compiler prior to the unit test compile.


Write the unit tests against the introductions if you need to test non-public code. I prefer this simple unit test compile-time option to mucking about with the security manager.

Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • Public Introductions for Private Methods
    2010-01-04 23:52:18  sw1527 [View]

    Can you point me to the reference material or show me an example on how to do it using doclet and aspect compiler?

    thanks a lot
  • Public Introductions for Private Methods
    2003-11-21 16:06:55  anonymous2 [View]

    A nice alternative - but thats just mucking around with doclets and a aspect compiler dont you think? :-)
    And how often do you run your testcases in an environment where the security manager would complain?
    • Public Introductions for Private Methods
      2005-10-05 08:53:29  pizza22005 [View]

      aol.com