Examples of ConstructorArgs


Examples of org.easymock.classextension.ConstructorArgs

    public void testDumbJUnit() {
        // this test is needed to make JUnit happy since the rest of the tests are disabled temporarily
    }

    public void disable_testExecuteReturnsOKWhencaptureSystemScreenshotSucceeds() throws Exception {
        final ConstructorArgs args;

        args = new ConstructorArgs(CaptureScreenshotCommand.class.getConstructor(String.class), fileName);
        command = createMock(CaptureScreenshotCommand.class,
                             args,
                             CaptureScreenshotCommand.class.getDeclaredMethod("captureSystemScreenshot"));
        command.captureSystemScreenshot();
View Full Code Here

Examples of org.easymock.classextension.ConstructorArgs

        verify(command);
    }

    public void disable_testExecuteReturnsAnErrorWhencaptureSystemScreenshotRaise() throws Exception {

        final ConstructorArgs args;

        args = new ConstructorArgs(CaptureScreenshotCommand.class.getConstructor(String.class), fileName);
        command = createMock(CaptureScreenshotCommand.class,
                             args,
                             CaptureScreenshotCommand.class.getDeclaredMethod("captureSystemScreenshot"));
        command.captureSystemScreenshot();
        expectLastCall().andThrow(new RuntimeException("an error message"));
View Full Code Here

Examples of org.easymock.classextension.ConstructorArgs

        Class mockClass = enhancer.createClass();
        Enhancer.registerCallbacks(mockClass, new Callback[] { interceptor });

        if (ClassExtensionHelper.getCurrentConstructorArgs() != null) {
            // Really instantiate the class
            ConstructorArgs args = ClassExtensionHelper
                    .getCurrentConstructorArgs();
            Constructor cstr;
            try {
                // Get the constructor with the same params
                cstr = mockClass.getDeclaredConstructor(args.getConstructor()
                        .getParameterTypes());
            } catch (NoSuchMethodException e) {
                // Shouldn't happen, constructor is checked when ConstructorArgs is instantiated
                // ///CLOVER:OFF
                throw new RuntimeException(
                        "Fail to find constructor for param types", e);
                // ///CLOVER:ON
            }
            T mock;
            try {
                cstr.setAccessible(true); // So we can call a protected
                // constructor
                mock = (T) cstr.newInstance(args.getInitArgs());
            } catch (InstantiationException e) {
                // ///CLOVER:OFF
                throw new RuntimeException(
                        "Failed to instantiate mock calling constructor", e);
                // ///CLOVER:ON
View Full Code Here

Examples of org.easymock.classextension.ConstructorArgs

        Class mockClass = enhancer.createClass();
        Enhancer.registerCallbacks(mockClass, new Callback[] { interceptor });

        if (ClassExtensionHelper.getCurrentConstructorArgs() != null) {
            // Really instantiate the class
            ConstructorArgs args = ClassExtensionHelper
                    .getCurrentConstructorArgs();
            Constructor cstr;
            try {
                // Get the constructor with the same params
                cstr = mockClass.getDeclaredConstructor(args.getConstructor()
                        .getParameterTypes());
            } catch (NoSuchMethodException e) {
                // Shouldn't happen, constructor is checked when ConstructorArgs is instantiated
                // ///CLOVER:OFF
                throw new RuntimeException(
                        "Fail to find constructor for param types", e);
                // ///CLOVER:ON
            }
            T mock;
            try {
                cstr.setAccessible(true); // So we can call a protected
                // constructor
                mock = (T) cstr.newInstance(args.getInitArgs());
            } catch (InstantiationException e) {
                // ///CLOVER:OFF
                throw new RuntimeException(
                        "Failed to instantiate mock calling constructor", e);
                // ///CLOVER:ON
View Full Code Here

Examples of org.easymock.classextension.ConstructorArgs

  }

  public void testGetBooleanArray() throws Exception {
    final HttpCommandProcessor processor;
    final ConstructorArgs constArgs = new ConstructorArgs(
        HttpCommandProcessor.class.getConstructor(String.class,  int.class, String.class, String.class),
        "localhost", 4444, "*chrome", "http://www.openqa.org");
    Method getStringArray = HttpCommandProcessor.class.getDeclaredMethod("getStringArray", String.class, String[].class);
    processor = org.easymock.classextension.EasyMock.createMock(HttpCommandProcessor.class, constArgs, getStringArray);

View Full Code Here

Examples of org.easymock.classextension.ConstructorArgs

    public void testDumbJUnit() {
        // this test is needed to make JUnit happy since the rest of the tests are disabled temporarily
    }

    public void disable_testExecuteReturnsOKWhencaptureSystemScreenshotSucceeds() throws Exception {
        final ConstructorArgs args;

        args = new ConstructorArgs(CaptureScreenshotCommand.class.getConstructor(String.class), fileName);
        command = createMock(CaptureScreenshotCommand.class,
                             args,
                             CaptureScreenshotCommand.class.getDeclaredMethod("captureSystemScreenshot"));
        command.captureSystemScreenshot();
View Full Code Here

Examples of org.easymock.classextension.ConstructorArgs

        verify(command);
    }

    public void disable_testExecuteReturnsAnErrorWhencaptureSystemScreenshotRaise() throws Exception {

        final ConstructorArgs args;

        args = new ConstructorArgs(CaptureScreenshotCommand.class.getConstructor(String.class), fileName);
        command = createMock(CaptureScreenshotCommand.class,
                             args,
                             CaptureScreenshotCommand.class.getDeclaredMethod("captureSystemScreenshot"));
        command.captureSystemScreenshot();
        expectLastCall().andThrow(new RuntimeException("an error message"));
View Full Code Here

Examples of org.easymock.classextension.ConstructorArgs

        final String testGroupName = "testGroup";

        Database mockDatabase = EasyMock.createMock(Database.class);

        SecurityManagerImpl mockSecurityManager = EasyMock.createMock(SecurityManagerImpl.class,
                new ConstructorArgs(
                    SecurityManagerImpl.class.getConstructor(Database.class),
                    new Object[] {
                        mockDatabase
                    }
                )
        );

        Configuration mockConfiguration = EasyMock.createMock(Configuration.class);

        AbstractRealm mockRealm = EasyMock.createMock(AbstractRealm.class,
                new ConstructorArgs(
                    AbstractRealm.class.getDeclaredConstructor(SecurityManager.class, Configuration.class),
                    new Object[] {
                        mockSecurityManager,
                        mockConfiguration
                    }
                )
        );

        AccountImpl mockAccountImpl = EasyMock.createMock(AccountImpl.class,
            new ConstructorArgs(
                AccountImpl.class.getDeclaredConstructor(AbstractRealm.class, String.class),
                new Object[] {
                    mockRealm,
                    testAccountName
                }
View Full Code Here

Examples of org.mongodb.morphia.annotations.ConstructorArgs

            c = mf.isSingleValue() ? mf.getConcreteType() : mf.getSubClass();
        }
        try {
            return createInstance(c, dbObj);
        } catch (RuntimeException e) {
            final ConstructorArgs argAnn = mf.getAnnotation(ConstructorArgs.class);
            if (argAnn == null) {
                throw e;
            }
            //TODO: now that we have a mapper, get the arg types that way by getting the fields by name. + Validate names
            final Object[] args = new Object[argAnn.value().length];
            final Class[] argTypes = new Class[argAnn.value().length];
            for (int i = 0; i < argAnn.value().length; i++) {
                //TODO: run converters and stuff against these. Kinda like the List of List stuff,
                // using a fake MappedField to hold the value
                final Object val = dbObj.get(argAnn.value()[i]);
                args[i] = val;
                argTypes[i] = val.getClass();
            }
            try {
                final Constructor constructor = c.getDeclaredConstructor(argTypes);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.