Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
9823d078
Commit
9823d078
authored
May 17, 2016
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Add support in SpringMvcContract for query string in Class @RequestMapping"
This reverts commit
2c502e39
.
parent
2b58487a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
46 deletions
+20
-46
SpringMvcContract.java
...mework/cloud/netflix/feign/support/SpringMvcContract.java
+9
-16
SpringMvcContractTests.java
...k/cloud/netflix/feign/support/SpringMvcContractTests.java
+11
-30
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/support/SpringMvcContract.java
View file @
9823d078
...
@@ -107,33 +107,26 @@ public class SpringMvcContract extends Contract.BaseContract
...
@@ -107,33 +107,26 @@ public class SpringMvcContract extends Contract.BaseContract
}
}
@Override
@Override
protected
void
processAnnotationOnClass
(
MethodMetadata
data
,
Class
<?>
clz
)
{
public
MethodMetadata
parseAndValidateMetadata
(
Class
<?>
targetType
,
Method
method
)
{
if
(
clz
.
getInterfaces
().
length
==
0
)
{
this
.
processedMethods
.
put
(
Feign
.
configKey
(
targetType
,
method
),
method
);
RequestMapping
classAnnotation
=
findMergedAnnotation
(
clz
,
MethodMetadata
md
=
super
.
parseAndValidateMetadata
(
targetType
,
method
);
RequestMapping
classAnnotation
=
findMergedAnnotation
(
targetType
,
RequestMapping
.
class
);
RequestMapping
.
class
);
if
(
classAnnotation
!=
null
)
{
if
(
classAnnotation
!=
null
)
{
// Prepend path from class annotation if specified
// Prepend path from class annotation if specified
if
(
classAnnotation
.
value
().
length
>
0
)
{
if
(
classAnnotation
.
value
().
length
>
0
)
{
String
pathValue
=
emptyToNull
(
classAnnotation
.
value
()[
0
]);
String
pathValue
=
emptyToNull
(
classAnnotation
.
value
()[
0
]);
checkState
(
pathValue
!=
null
,
"RequestMapping.value() was empty on type %s"
,
method
.
getDeclaringClass
().
getName
());
pathValue
=
resolve
(
pathValue
);
pathValue
=
resolve
(
pathValue
);
if
(!
pathValue
.
startsWith
(
"/"
))
{
if
(!
pathValue
.
startsWith
(
"/"
))
{
pathValue
=
"/"
+
pathValue
;
pathValue
=
"/"
+
pathValue
;
}
}
data
.
template
().
insert
(
0
,
pathValue
);
md
.
template
().
insert
(
0
,
pathValue
);
}
}
}
}
}
@Override
public
MethodMetadata
parseAndValidateMetadata
(
Class
<?>
targetType
,
Method
method
)
{
this
.
processedMethods
.
put
(
Feign
.
configKey
(
targetType
,
method
),
method
);
MethodMetadata
md
=
super
.
parseAndValidateMetadata
(
targetType
,
method
);
RequestMapping
classAnnotation
=
findMergedAnnotation
(
targetType
,
RequestMapping
.
class
);
if
(
classAnnotation
!=
null
)
{
// produces - use from class annotation only if method has not specified this
// produces - use from class annotation only if method has not specified this
if
(!
md
.
template
().
headers
().
containsKey
(
ACCEPT
))
{
if
(!
md
.
template
().
headers
().
containsKey
(
ACCEPT
))
{
parseProduces
(
md
,
method
,
classAnnotation
);
parseProduces
(
md
,
method
,
classAnnotation
);
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/support/SpringMvcContractTests.java
View file @
9823d078
...
@@ -72,51 +72,39 @@ public class SpringMvcContractTests {
...
@@ -72,51 +72,39 @@ public class SpringMvcContractTests {
String
.
class
);
String
.
class
);
MethodMetadata
data
=
this
.
contract
MethodMetadata
data
=
this
.
contract
.
parseAndValidateMetadata
(
method
.
getDeclaringClass
(),
method
);
.
parseAndValidateMetadata
(
method
.
getDeclaringClass
(),
method
);
MethodMetadata
extendingData
=
this
.
contract
.
parseAndValidateMetadata
(
method
.
getDeclaringClass
(),
method
);
assertEquals
(
"/prepend/{anotherId}"
,
data
.
template
().
url
());
assertEquals
(
"/test/{id}"
,
data
.
template
().
url
());
assertEquals
(
data
.
template
().
url
(),
extendingData
.
template
().
url
());
assertEquals
(
"GET"
,
data
.
template
().
method
());
assertEquals
(
"GET"
,
data
.
template
().
method
());
assertEquals
(
data
.
template
().
method
(),
extendingData
.
template
().
method
());
assertEquals
(
MediaType
.
APPLICATION_JSON_VALUE
,
assertEquals
(
MediaType
.
APPLICATION_JSON_VALUE
,
data
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
());
data
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
());
assertEquals
(
data
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
(),
extendingData
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
());
assertEquals
(
"anotherId"
,
data
.
indexToName
().
get
(
0
).
iterator
().
next
());
assertEquals
(
data
.
indexToName
().
get
(
0
).
iterator
().
next
(),
extendingData
.
indexToName
().
get
(
0
).
iterator
().
next
());
}
}
@Test
@Test
public
void
testProcessAnnotations_Simple
()
throws
Exception
{
public
void
testProcessAnnotations_Simple
()
throws
Exception
{
Method
method
=
TestTemplate_Simple
.
class
.
getDeclaredMethod
(
"getTest"
,
Method
method
=
TestTemplate_Simple
.
class
.
getDeclaredMethod
(
"getTest"
,
String
.
class
,
String
.
class
);
String
.
class
);
MethodMetadata
data
=
this
.
contract
MethodMetadata
data
=
this
.
contract
.
parseAndValidateMetadata
(
method
.
getDeclaringClass
(),
method
);
.
parseAndValidateMetadata
(
method
.
getDeclaringClass
(),
method
);
assertEquals
(
"/
prepend/{anotherId}/
test/{id}"
,
data
.
template
().
url
());
assertEquals
(
"/test/{id}"
,
data
.
template
().
url
());
assertEquals
(
"GET"
,
data
.
template
().
method
());
assertEquals
(
"GET"
,
data
.
template
().
method
());
assertEquals
(
MediaType
.
APPLICATION_JSON_VALUE
,
assertEquals
(
MediaType
.
APPLICATION_JSON_VALUE
,
data
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
());
data
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
());
assertEquals
(
"anotherId"
,
data
.
indexToName
().
get
(
0
).
iterator
().
next
());
assertEquals
(
"id"
,
data
.
indexToName
().
get
(
0
).
iterator
().
next
());
assertEquals
(
"id"
,
data
.
indexToName
().
get
(
1
).
iterator
().
next
());
}
}
@Test
@Test
public
void
testProcessAnnotations_SimplePost
()
throws
Exception
{
public
void
testProcessAnnotations_SimplePost
()
throws
Exception
{
Method
method
=
TestTemplate_Simple
.
class
.
getDeclaredMethod
(
"postTest"
,
Method
method
=
TestTemplate_Simple
.
class
.
getDeclaredMethod
(
"postTest"
,
String
.
class
,
TestObject
.
class
);
TestObject
.
class
);
MethodMetadata
data
=
this
.
contract
MethodMetadata
data
=
this
.
contract
.
parseAndValidateMetadata
(
method
.
getDeclaringClass
(),
method
);
.
parseAndValidateMetadata
(
method
.
getDeclaringClass
(),
method
);
assertEquals
(
"
/prepend/{anotherId}
"
,
data
.
template
().
url
());
assertEquals
(
""
,
data
.
template
().
url
());
assertEquals
(
"POST"
,
data
.
template
().
method
());
assertEquals
(
"POST"
,
data
.
template
().
method
());
assertEquals
(
MediaType
.
APPLICATION_JSON_VALUE
,
assertEquals
(
MediaType
.
APPLICATION_JSON_VALUE
,
data
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
());
data
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
());
assertEquals
(
"anotherId"
,
data
.
indexToName
().
get
(
0
).
iterator
().
next
());
}
}
...
@@ -200,16 +188,14 @@ public class SpringMvcContractTests {
...
@@ -200,16 +188,14 @@ public class SpringMvcContractTests {
@Test
@Test
public
void
testProcessAnnotations_Advanced3
()
throws
Exception
{
public
void
testProcessAnnotations_Advanced3
()
throws
Exception
{
Method
method
=
TestTemplate_Simple
.
class
.
getDeclaredMethod
(
"getTest"
,
Method
method
=
TestTemplate_Simple
.
class
.
getDeclaredMethod
(
"getTest"
);
String
.
class
);
MethodMetadata
data
=
this
.
contract
MethodMetadata
data
=
this
.
contract
.
parseAndValidateMetadata
(
method
.
getDeclaringClass
(),
method
);
.
parseAndValidateMetadata
(
method
.
getDeclaringClass
(),
method
);
assertEquals
(
"
/prepend/{anotherId}
"
,
data
.
template
().
url
());
assertEquals
(
""
,
data
.
template
().
url
());
assertEquals
(
"GET"
,
data
.
template
().
method
());
assertEquals
(
"GET"
,
data
.
template
().
method
());
assertEquals
(
MediaType
.
APPLICATION_JSON_VALUE
,
assertEquals
(
MediaType
.
APPLICATION_JSON_VALUE
,
data
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
());
data
.
template
().
headers
().
get
(
"Accept"
).
iterator
().
next
());
assertEquals
(
"anotherId"
,
data
.
indexToName
().
get
(
0
).
iterator
().
next
());
}
}
@Test
@Test
...
@@ -276,20 +262,15 @@ public class SpringMvcContractTests {
...
@@ -276,20 +262,15 @@ public class SpringMvcContractTests {
return
false
;
return
false
;
}
}
@RequestMapping
(
"/prepend/{anotherId}"
)
public
interface
TestTemplate_Simple
{
public
interface
TestTemplate_Simple
{
@RequestMapping
(
value
=
"/test/{id}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/test/{id}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
ResponseEntity
<
TestObject
>
getTest
(
@PathVariable
String
anotherId
,
@PathVariable
String
id
);
ResponseEntity
<
TestObject
>
getTest
(
@PathVariable
(
"id"
)
String
id
);
@RequestMapping
(
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
TestObject
getTest
(
@PathVariable
String
anotherId
);
TestObject
getTest
();
@RequestMapping
(
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
TestObject
postTest
(
@PathVariable
String
anotherId
,
@RequestBody
TestObject
object
);
TestObject
postTest
(
@RequestBody
TestObject
object
);
}
public
interface
TestTemplate_Simple_Extending
extends
TestTemplate_Simple
{
}
}
public
interface
TestTemplate_Headers
{
public
interface
TestTemplate_Headers
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment