Java Code Examples for com.mockobjects.servlet.MockHttpServletRequest#setSession()

The following examples show how to use com.mockobjects.servlet.MockHttpServletRequest#setSession() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewUserEventTest.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
private NewUserEvent createTestEvent() {
    NewUserEvent evt = new NewUserEvent();
    // In the implementation we use getHeaderNames so we override it with
    // one that returns an empty implementation.
    MockHttpServletRequest request = new MockHttpServletRequest() {
        @Override
        public Enumeration<String> getHeaderNames() {
            return new Vector<String>().elements();
        }
    };
    request.setSession(new MockHttpSession());
    request.setupGetRequestURI("http://localhost:8080");
    request.setupGetMethod("POST");
    User usr = UserTestUtils.findNewUser("testUser",
            "testOrg" + this.getClass().getSimpleName());

    evt.setUser(usr);
    evt.setDomain("someserver.rhndev.redhat.com");
    evt.setAdmins(createAdmins());
    evt.setRequest(request);
    return evt;
}
 
Example 2
Source File: TraceBackEventTest.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
private TraceBackEvent createTestEvent() {
    TraceBackEvent evt = new TraceBackEvent();
    // In the implementation we use getHeaderNames so we override it with
    // one that returns an empty implementation.
    MockHttpServletRequest request = new MockHttpServletRequest() {
        public Enumeration<String> getHeaderNames() {
            return new Vector<String>().elements();
        }
    };
    request.setSession(new MockHttpSession());
    request.setupGetRequestURI("http://localhost:8080");
    request.setupGetMethod("POST");
    Vector<String> v = new Vector<String>();
    v.add("someparam");
    request.setupAddParameter("someparam", "somevalue");
    request.setupGetParameterNames(v.elements());
    evt.setUser(UserTestUtils.findNewUser("testUser",
                "testOrg" + this.getClass().getSimpleName()));
    evt.setRequest(request);
    Throwable e = new RuntimeException(MSG_OUTER_EXC);
    e.initCause(new RuntimeException(MSG_INNER_EXC));
    evt.setException(e);
    return evt;
}
 
Example 3
Source File: TraceBackEventTest.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
private TraceBackEvent createTestEventWithValue(String paramIn, String valueIn) {
    TraceBackEvent evt = new TraceBackEvent();
    // In the implementation we use getHeaderNames so we override it with
    // one that returns an empty implementation.
    MockHttpServletRequest request = new MockHttpServletRequest() {
        public Enumeration<String> getHeaderNames() {
            return new Vector<String>().elements();
        }
    };
    request.setSession(new MockHttpSession());
    request.setupGetRequestURI("http://localhost:8080");
    request.setupGetMethod("POST");
    Vector<String> v = new Vector<String>();
    v.add(paramIn);
    request.setupAddParameter(paramIn, valueIn);
    request.setupGetParameterNames(v.elements());
    evt.setUser(UserTestUtils.findNewUser("testUser",
                "testOrg" + this.getClass().getSimpleName()));
    evt.setRequest(request);
    Throwable e = new RuntimeException(MSG_OUTER_EXC);
    e.initCause(new RuntimeException(MSG_INNER_EXC));
    evt.setException(e);
    return evt;
}
 
Example 4
Source File: NewUserEventTest.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
private NewUserEvent createTestEvent() {
    NewUserEvent evt = new NewUserEvent();
    // In the implementation we use getHeaderNames so we override it with
    // one that returns an empty implementation.
    MockHttpServletRequest request = new MockHttpServletRequest() {
        @Override
        public Enumeration<String> getHeaderNames() {
            return new Vector<String>().elements();
        }
    };
    request.setSession(new MockHttpSession());
    request.setupGetRequestURI("http://localhost:8080");
    request.setupGetMethod("POST");
    User usr = UserTestUtils.findNewUser("testUser",
            "testOrg" + this.getClass().getSimpleName());

    evt.setUser(usr);
    evt.setDomain("someserver.rhndev.redhat.com");
    evt.setAdmins(createAdmins());
    evt.setRequest(request);
    return evt;
}
 
Example 5
Source File: TraceBackEventTest.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
private TraceBackEvent createTestEvent() {
    TraceBackEvent evt = new TraceBackEvent();
    // In the implementation we use getHeaderNames so we override it with
    // one that returns an empty implementation.
    MockHttpServletRequest request = new MockHttpServletRequest() {
        public Enumeration<String> getHeaderNames() {
            return new Vector<String>().elements();
        }
    };
    request.setSession(new MockHttpSession());
    request.setupGetRequestURI("http://localhost:8080");
    request.setupGetMethod("POST");
    Vector<String> v = new Vector<String>();
    v.add("someparam");
    request.setupAddParameter("someparam", "somevalue");
    request.setupGetParameterNames(v.elements());
    evt.setUser(UserTestUtils.findNewUser("testUser",
                "testOrg" + this.getClass().getSimpleName()));
    evt.setRequest(request);
    Throwable e = new RuntimeException(MSG_OUTER_EXC);
    e.initCause(new RuntimeException(MSG_INNER_EXC));
    evt.setException(e);
    return evt;
}
 
Example 6
Source File: TraceBackEventTest.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
private TraceBackEvent createTestEventWithValue(String paramIn, String valueIn) {
    TraceBackEvent evt = new TraceBackEvent();
    // In the implementation we use getHeaderNames so we override it with
    // one that returns an empty implementation.
    MockHttpServletRequest request = new MockHttpServletRequest() {
        public Enumeration<String> getHeaderNames() {
            return new Vector<String>().elements();
        }
    };
    request.setSession(new MockHttpSession());
    request.setupGetRequestURI("http://localhost:8080");
    request.setupGetMethod("POST");
    Vector<String> v = new Vector<String>();
    v.add(paramIn);
    request.setupAddParameter(paramIn, valueIn);
    request.setupGetParameterNames(v.elements());
    evt.setUser(UserTestUtils.findNewUser("testUser",
                "testOrg" + this.getClass().getSimpleName()));
    evt.setRequest(request);
    Throwable e = new RuntimeException(MSG_OUTER_EXC);
    e.initCause(new RuntimeException(MSG_INNER_EXC));
    evt.setException(e);
    return evt;
}