Package org.glassfish.tests.utils.mock
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 Summary
Constructors Constructor Description MockGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SubjectcreateAsadminSubject()Creates a newSubjectinstance holding two principals: asadmin _InternalSystemAdministrator_<T> org.glassfish.hk2.utilities.AbstractActiveDescriptor<T>createMockDescriptor(Class<T> iface)Creates a mock implementation for the given interface and a descriptor for it.<T> TcreateMockThrowingExceptions(Class<T> clazz)Creates a mock implementation for the given interface.
-
-
-
Method Detail
-
createAsadminSubject
public Subject createAsadminSubject()
Creates a newSubjectinstance holding two principals:- asadmin
- _InternalSystemAdministrator_
- Returns:
- new
Subjectinstance
-
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 throwUnsupportedOperationException, 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 throwUnsupportedOperationException- Type Parameters:
T-- Parameters:
clazz-- Returns:
- the implementation
-
-