Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit b2d18dc

Browse files
committed
MVC Routes: prefix route attributes with annotation name fix jooby-project#1099
1 parent 0e3f687 commit b2d18dc

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

jooby/src/main/java/org/jooby/internal/mvc/MvcRoutes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ private static String attrName(final Annotation annotation, final Method attr) {
381381
return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL,
382382
annotation.annotationType().getSimpleName());
383383
}
384-
return name;
384+
return annotation.annotationType().getSimpleName() + "." + name;
385385
}
386386

387387
private static List<MediaType> produces(final Method method) {

modules/coverage-report/src/test/java/org/jooby/issues/Issue346.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package org.jooby.issues;
22

3+
import com.google.common.collect.ImmutableMap;
4+
import org.jooby.Request;
5+
import org.jooby.mvc.GET;
6+
import org.jooby.mvc.Path;
7+
import org.jooby.test.ServerFeature;
38
import static org.junit.Assert.assertEquals;
9+
import org.junit.Test;
410

511
import java.lang.annotation.ElementType;
612
import java.lang.annotation.Retention;
@@ -9,14 +15,6 @@
915
import java.util.HashMap;
1016
import java.util.Map;
1117

12-
import org.jooby.Request;
13-
import org.jooby.mvc.GET;
14-
import org.jooby.mvc.Path;
15-
import org.jooby.test.ServerFeature;
16-
import org.junit.Test;
17-
18-
import com.google.common.collect.ImmutableMap;
19-
2018
public class Issue346 extends ServerFeature {
2119

2220
@Target({ElementType.METHOD, ElementType.TYPE, ElementType.ANNOTATION_TYPE })
@@ -60,17 +58,17 @@ public Object admin(final Request req) {
6058

6159
{
6260
use("/1", (req, rsp) -> {
63-
assertEquals(ImmutableMap.of("priority", 1.0, "changefreq", "always"),
61+
assertEquals(ImmutableMap.of("SitemapUrl.priority", 1.0, "SitemapUrl.changefreq", "always"),
6462
req.route().attributes());
6563
});
6664

6765
use("/2", (req, rsp) -> {
68-
assertEquals(ImmutableMap.of("priority", 0.5, "changefreq", "always"),
66+
assertEquals(ImmutableMap.of("SitemapUrl.priority", 0.5, "SitemapUrl.changefreq", "always"),
6967
req.route().attributes());
7068
});
7169

7270
use("/3", (req, rsp) -> {
73-
assertEquals(ImmutableMap.of("priority", 0.5, "changefreq", "always", "role", "admin"),
71+
assertEquals(ImmutableMap.of("SitemapUrl.priority", 0.5, "SitemapUrl.changefreq", "always", "role", "admin"),
7472
req.route().attributes());
7573
});
7674
use(Resource.class);
@@ -81,19 +79,19 @@ public void mvcAttrs() throws Exception {
8179
request().get("/1")
8280
.expect(value -> {
8381
Map<String, Object> hash = toMap(value.substring(1, value.length() - 1));
84-
assertEquals(ImmutableMap.of("priority", "1.0", "changefreq", "always"), hash);
82+
assertEquals(ImmutableMap.of("SitemapUrl.priority", "1.0", "SitemapUrl.changefreq", "always"), hash);
8583
});
8684

8785
request().get("/2")
8886
.expect(value -> {
8987
Map<String, Object> hash = toMap(value.substring(1, value.length() - 1));
90-
assertEquals(ImmutableMap.of("priority", "0.5", "changefreq", "always"), hash);
88+
assertEquals(ImmutableMap.of("SitemapUrl.priority", "0.5", "SitemapUrl.changefreq", "always"), hash);
9189
});
9290

9391
request().get("/3")
9492
.expect(value -> {
9593
Map<String, Object> hash = toMap(value.substring(1, value.length() - 1));
96-
assertEquals(ImmutableMap.of("priority", "0.5", "changefreq", "always", "role", "admin"),
94+
assertEquals(ImmutableMap.of("SitemapUrl.priority", "0.5", "SitemapUrl.changefreq", "always", "role", "admin"),
9795
hash);
9896
});
9997
}

0 commit comments

Comments
 (0)