Search in sources :

Example 6 with OperationResourceInfoStack

use of org.apache.cxf.jaxrs.model.OperationResourceInfoStack in project cxf by apache.

the class UriInfoImplTest method testGetMatchedURIsSubResourceLocatorSubPath.

@Test
public void testGetMatchedURIsSubResourceLocatorSubPath() throws Exception {
    System.out.println("testGetMatchedURIsSubResourceLocatorSubPath");
    Message m = mockMessage("http://localhost:8080/app", "/foo/sub/subSub");
    OperationResourceInfoStack oriStack = new OperationResourceInfoStack();
    ClassResourceInfo rootCri = getCri(RootResource.class, true);
    OperationResourceInfo rootOri = getOri(rootCri, "getSubResourceLocator");
    MethodInvocationInfo miInfo = new MethodInvocationInfo(rootOri, RootResource.class, new ArrayList<String>());
    oriStack.push(miInfo);
    ClassResourceInfo subCri = getCri(SubResource.class, false);
    OperationResourceInfo subOri = getOri(subCri, "getFromSubSub");
    miInfo = new MethodInvocationInfo(subOri, SubResource.class, new ArrayList<String>());
    oriStack.push(miInfo);
    m.put(OperationResourceInfoStack.class, oriStack);
    UriInfoImpl u = new UriInfoImpl(m);
    List<String> matchedUris = getMatchedURIs(u);
    assertEquals(3, matchedUris.size());
    assertEquals("foo/sub/subSub", matchedUris.get(0));
    assertEquals("foo/sub", matchedUris.get(1));
    assertEquals("foo", matchedUris.get(2));
}
Also used : Message(org.apache.cxf.message.Message) ClassResourceInfo(org.apache.cxf.jaxrs.model.ClassResourceInfo) ArrayList(java.util.ArrayList) OperationResourceInfoStack(org.apache.cxf.jaxrs.model.OperationResourceInfoStack) OperationResourceInfo(org.apache.cxf.jaxrs.model.OperationResourceInfo) MethodInvocationInfo(org.apache.cxf.jaxrs.model.MethodInvocationInfo) Test(org.junit.Test)

Example 7 with OperationResourceInfoStack

use of org.apache.cxf.jaxrs.model.OperationResourceInfoStack in project cxf by apache.

the class UriInfoImplTest method testGetMatchedURIsRoot.

@Test
public void testGetMatchedURIsRoot() throws Exception {
    System.out.println("testGetMatchedURIsRoot");
    Message m = mockMessage("http://localhost:8080/app", "/foo");
    OperationResourceInfoStack oriStack = new OperationResourceInfoStack();
    ClassResourceInfo cri = getCri(RootResource.class, true);
    OperationResourceInfo ori = getOri(cri, "get");
    MethodInvocationInfo miInfo = new MethodInvocationInfo(ori, RootResource.class, new ArrayList<String>());
    oriStack.push(miInfo);
    m.put(OperationResourceInfoStack.class, oriStack);
    UriInfoImpl u = new UriInfoImpl(m);
    List<String> matchedUris = getMatchedURIs(u);
    assertEquals(1, matchedUris.size());
    assertTrue(matchedUris.contains("foo"));
}
Also used : Message(org.apache.cxf.message.Message) ClassResourceInfo(org.apache.cxf.jaxrs.model.ClassResourceInfo) OperationResourceInfoStack(org.apache.cxf.jaxrs.model.OperationResourceInfoStack) OperationResourceInfo(org.apache.cxf.jaxrs.model.OperationResourceInfo) MethodInvocationInfo(org.apache.cxf.jaxrs.model.MethodInvocationInfo) Test(org.junit.Test)

Aggregations

OperationResourceInfoStack (org.apache.cxf.jaxrs.model.OperationResourceInfoStack)7 MethodInvocationInfo (org.apache.cxf.jaxrs.model.MethodInvocationInfo)5 Message (org.apache.cxf.message.Message)5 ClassResourceInfo (org.apache.cxf.jaxrs.model.ClassResourceInfo)4 OperationResourceInfo (org.apache.cxf.jaxrs.model.OperationResourceInfo)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 Application (javax.ws.rs.core.Application)1 ConstructorInterceptorInvocationContext (org.apache.webbeans.intercept.ConstructorInterceptorInvocationContext)1