Skip to content

Commit

Permalink
Test case and fix for RESTEASY-1212
Browse files Browse the repository at this point in the history
  • Loading branch information
mihxil committed Feb 10, 2016
1 parent 9a06565 commit bed81b7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;

import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.MessageBodyWriter;
Expand Down Expand Up @@ -413,14 +412,20 @@ private static Class<?> getBeanClass(String name, BeanDefinition beanDef,
}
}

final Class<?> beanClass = getBeanClass(factoryClassName);
final Method[] methods = ReflectionUtils.getAllDeclaredMethods(beanClass);
for (Method method : methods) {
if (method.getName().equals(factoryMethodName)) {
Class<?> factoryClass = getBeanClass(factoryClassName);
while (factoryClass != Object.class)
{
for (Method method : factoryClass.getDeclaredMethods())
{
if (method.getName().equals(factoryMethodName)) {
return method.getReturnType();
}
}

}
}
factoryClass = factoryClass.getSuperclass();
}
final Class<?> beanClass = getBeanClass(factoryClassName);
final Method[] methods = beanClass.getDeclaredMethods();

/*
https://github.com/resteasy/Resteasy/issues/585
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ public void testRegistration() throws Exception
ClientResponse<String> resp = createClientRequest("/registered/singleton/count").post(
String.class);
check(resp, 200, "0");
}

@Test
// test for https://issues.jboss.org/browse/RESTEASY-1212
public void testRegistrationViaSuper() throws Exception
{
ClientResponse<String> resp = createClientRequest("/registered/super/count").post(
String.class);
check(resp, 200, "0");
}

@Test
public void testNotRegisteredAtRoot() throws Exception {
Assert.assertEquals(404, createClientRequest("/count").post().getStatus());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.jboss.resteasy.spring.beanprocessor;

import org.springframework.context.annotation.Bean;

/**
* @author Michiel Meeuwissen
*/
public abstract class AbstractResourceConfiguration
{
@Bean
Counter superCounter()
{
return new Counter();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.springframework.context.annotation.Scope;

@Configuration
public class ResourceConfiguration
public class ResourceConfiguration extends AbstractResourceConfiguration
{
@Bean
public ResteasyRegistration singletonRegistration()
Expand All @@ -20,6 +20,12 @@ public ResteasyRegistration prototypeRegistration()
return new ResteasyRegistration("/registered/prototype", "prototypeCounter");
}

@Bean
public ResteasyRegistration superRegistration()
{
return new ResteasyRegistration("/registered/super", "superCounter");
}

@Bean
Counter singletonCounter()
{
Expand Down

0 comments on commit bed81b7

Please sign in to comment.