Class MockGenerator

java.lang.Object
org.glassfish.tests.utils.mock.MockGenerator

public class MockGenerator extends Object
Generates some objects useful for tests, but not simply available in the test context.
Author:
David Matejcek
  • Constructor Details

    • MockGenerator

      public MockGenerator()
  • Method Details

    • createAsadminSubject

      public Subject createAsadminSubject()
      Creates a new Subject instance holding two principals:
      • asadmin
      • _InternalSystemAdministrator_
      Returns:
      new Subject instance
    • createMockDescriptor

      public <T> org.glassfish.hk2.utilities.AbstractActiveDescriptor<T> createMockDescriptor(Class<T> iface)
      Creates a mock implementation for the given interface and a descriptor for it. Every method of the mock will throw UnsupportedOperationException, but it can be useful in cases where we need a mandatory dependency which is unused in real time. The descriptor has maximal ranking and is reified.
      Type Parameters:
      T - Requested API of the generated class.
      Parameters:
      iface -
      Returns:
      generated descriptor of the proxy.
    • createMockThrowingExceptions

      public <T> T createMockThrowingExceptions(Class<T> clazz)
      Creates a mock implementation for the given interface. Every method of the mock will throw UnsupportedOperationException
      Type Parameters:
      T -
      Parameters:
      clazz -
      Returns:
      the implementation