use of org.apache.cxf.jaxrs.model.OperationResourceInfo in project cxf by apache.
the class UriInfoImplTest method testGetMatchedURIsSubResourceLocator.
@Test
public void testGetMatchedURIsSubResourceLocator() throws Exception {
System.out.println("testGetMatchedURIsSubResourceLocator");
Message m = mockMessage("http://localhost:8080/app", "/foo/sub");
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, "getFromSub");
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(2, matchedUris.size());
assertEquals("foo/sub", matchedUris.get(0));
assertEquals("foo", matchedUris.get(1));
}
use of org.apache.cxf.jaxrs.model.OperationResourceInfo in project cxf by apache.
the class UriInfoImplTest method testGetMatchedURIsRootSub.
@Test
public void testGetMatchedURIsRootSub() throws Exception {
System.out.println("testGetMatchedURIsRootSub");
Message m = mockMessage("http://localhost:8080/app", "/foo/bar");
OperationResourceInfoStack oriStack = new OperationResourceInfoStack();
ClassResourceInfo cri = getCri(RootResource.class, true);
OperationResourceInfo ori = getOri(cri, "getSubMethod");
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(2, matchedUris.size());
assertEquals("foo/bar", matchedUris.get(0));
assertEquals("foo", matchedUris.get(1));
}
use of org.apache.cxf.jaxrs.model.OperationResourceInfo in project cxf by apache.
the class ResourceUtilsTest method testClassResourceInfoWithOverride.
@Test
public void testClassResourceInfoWithOverride() throws Exception {
ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(ExampleImpl.class, ExampleImpl.class, true, true);
assertNotNull(cri);
Method m = ExampleImpl.class.getMethod("get");
OperationResourceInfo ori = cri.getMethodDispatcher().getOperationResourceInfo(m);
assertNotNull(ori);
assertEquals("GET", ori.getHttpMethod());
}
use of org.apache.cxf.jaxrs.model.OperationResourceInfo in project cxf by apache.
the class ResourceUtilsTest method testGenericClassResourceInfoWithBridgeMethod.
@Test
public void testGenericClassResourceInfoWithBridgeMethod() throws Exception {
ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(GenericExampleBridgeImpl.class, GenericExampleBridgeImpl.class, true, true);
assertNotNull(cri);
assertEquals(1, cri.getMethodDispatcher().getOperationResourceInfos().size());
Method m = GenericExampleBridgeImpl.class.getMethod("get");
OperationResourceInfo ori = cri.getMethodDispatcher().getOperationResourceInfo(m);
assertNotNull(ori);
assertEquals("GET", ori.getHttpMethod());
m = Arrays.stream(GenericExampleBridgeImpl.class.getMethods()).filter(method -> method.getName().equals("get")).filter(Method::isBridge).findAny().orElse(null);
ori = cri.getMethodDispatcher().getOperationResourceInfo(m);
assertNotNull(ori);
assertEquals("GET", ori.getHttpMethod());
}
use of org.apache.cxf.jaxrs.model.OperationResourceInfo in project cxf by apache.
the class ResourceUtilsTest method testClassResourceInfoWithOverriddenMethods.
@Test
public void testClassResourceInfoWithOverriddenMethods() throws Exception {
ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(OverriddenInterfaceImpl.class, OverriddenInterfaceImpl.class, true, true);
assertNotNull(cri);
Method notSynthetic = OverriddenInterfaceImpl.class.getMethod("read", new Class[] { String.class });
assertFalse(notSynthetic.isSynthetic());
cri.hasSubResources();
final Set<OperationResourceInfo> oris = cri.getMethodDispatcher().getOperationResourceInfos();
assertEquals("there must be one read method", 1, oris.size());
assertEquals(notSynthetic, oris.iterator().next().getMethodToInvoke());
}
Aggregations