Package org.apache.tapestry5.internal.test

Examples of org.apache.tapestry5.internal.test.TestableResponse


    String appPackage = "nu.localhost.testsite";
        String appName = "test";
        PageTester tester = new PageTester(appPackage, appName, "src/test/resources/webapp");
       
        EasyMock.replay(MockFactory.getInstance().getMockedObjects());
        TestableResponse resp = tester.renderPageAndReturnResponse("SecuredMethod");
        EasyMock.verify(MockFactory.getInstance().getMockedObjects());
        assertEquals(500,resp.getStatus()); //err not allowed!

        // login..! (wrong role)
        SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("user1","user1","ROLE_DENIED"));
       
        EasyMock.reset(MockFactory.getInstance().getMockedObjects());
        EasyMock.replay(MockFactory.getInstance().getMockedObjects());
       
       
        try {
          tester.renderPage("securedmethod");
          fail("Should not render a document");
        } catch (Exception e) {
         
        }
        EasyMock.verify(MockFactory.getInstance().getMockedObjects());
        // status = 200 , output = '', coz of redirect to login page
       
        assertEquals(200,resp.getStatus()); //err not allowed!
       
        SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("user1","user1","ROLE_LOGGEDIN"));
       
        EasyMock.reset(MockFactory.getInstance().getMockedObjects());
        EasyMock.replay(MockFactory.getInstance().getMockedObjects());
       
        assertTrue(tester.renderPage("securedmethod").toString().contains("Welcome back user !"));
        EasyMock.verify(MockFactory.getInstance().getMockedObjects());
       
        assertEquals(200,resp.getStatus()); //err not allowed!
       
  }
View Full Code Here


        // start SMTP Server
        Wiser wiser = new Wiser();
        wiser.setPort(getSmtpPort());
        wiser.start();

        TestableResponse response = tester.submitFormAndReturnResponse(form, fieldValues);

        assertFalse(response.getOutput().contains("exception"));

        // verify an account information e-mail was sent
        assertEquals(1, wiser.getMessages().size());
        wiser.stop();
View Full Code Here

        // start SMTP Server
        Wiser wiser = new Wiser();
        wiser.setPort(getSmtpPort());
        wiser.start();

        TestableResponse response = tester.submitFormAndReturnResponse(form, fieldValues);
        assertEquals(response.getRedirectURL(), "signup");

        // verify no account information e-mail was sent
        assertEquals(0, wiser.getMessages().size());
        wiser.stop();
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void cache_control_header()
    {
        PageTester tester = new PageTester("kaptcha.demo", "app");
        final TestableResponse response = tester.renderPageAndReturnResponse("KaptchaDemo");
        final List<String> headers = (List<String>) response.getHeaders("Cache-Control");
        assert "no-store, no-cache, must-revalidate".equals(headers.get(0));
        assert "post-check=0, pre-check=0".equals(headers.get(1));
    }
View Full Code Here

    {
        this.parent = parent;
        this.transformer = transformer;
        this.logger = logger;
        this.internalRequestGlobals = internalRequestGlobals;
        this.changeTracker = new URLChangeTracker(classpathURLConverter);

        initializeService();
    }
View Full Code Here

        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
        Validator validator = mockValidator();
        TypeCoercer coercer = mockTypeCoercer();
        FieldComponent field = newFieldComponent();
        Messages messages = mockMessages();
        MessageFormatter formatter = mockMessageFormatter();
        Object inputValue = new Object();
        ComponentResources resources = mockComponentResources();
        Messages containerMessages = mockMessages();
        FormSupport fs = mockFormSupport();
View Full Code Here

    {
        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
        Validator validator = mockValidator();
        TypeCoercer coercer = mockTypeCoercer();
        FieldComponent field = newFieldComponent();
        MessageFormatter formatter = mockMessageFormatter();
        Object inputValue = new Object();
        ComponentResources resources = mockComponentResources();
        Messages containerMessages = mockMessages();
        FormSupport fs = mockFormSupport();
View Full Code Here

    {
        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
        Validator validator = mockValidator();
        TypeCoercer coercer = mockTypeCoercer();
        FieldComponent field = newFieldComponent();
        MessageFormatter formatter = mockMessageFormatter();
        Object inputValue = new Object();
        ComponentResources resources = mockComponentResources();
        Messages containerMessages = mockMessages();
        FormSupport fs = mockFormSupport();
View Full Code Here

        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
        Validator validator = mockValidator();
        TypeCoercer coercer = mockTypeCoercer();
        FieldComponent field = newFieldComponent();
        Messages messages = mockMessages();
        MessageFormatter formatter = mockMessageFormatter();
        Object inputValue = new Object();
        ComponentResources resources = mockComponentResources();
        Messages containerMessages = mockMessages();
        FormSupport fs = mockFormSupport();
View Full Code Here

        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
        Validator validator = mockValidator();
        TypeCoercer coercer = mockTypeCoercer();
        FieldComponent field = newFieldComponent();
        Messages messages = mockMessages();
        MessageFormatter formatter = mockMessageFormatter();
        Object inputValue = new Object();
        ComponentResources resources = mockComponentResources();
        Messages containerMessages = mockMessages();
        FormSupport fs = mockFormSupport();
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.internal.test.TestableResponse

Copyright © 2018 www.massapicom. 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.