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
aec8ec43
Unverified
Commit
aec8ec43
authored
Nov 07, 2016
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken test.
parent
93cd1e7a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
26 deletions
+27
-26
EurekaControllerReplicasTest.java
...d/netflix/eureka/server/EurekaControllerReplicasTest.java
+27
-26
No files found.
spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaControllerReplicasTest.java
View file @
aec8ec43
...
...
@@ -9,7 +9,6 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.netflix.appinfo.ApplicationInfoManager
;
import
com.netflix.appinfo.DataCenterInfo
;
import
com.netflix.appinfo.InstanceInfo
;
...
...
@@ -22,67 +21,69 @@ import org.junit.Test;
import
com.netflix.eureka.util.StatusInfo
;
public
class
EurekaControllerReplicasTest
{
String
noAuthList1
=
"http://test1.com"
;
String
noAuthList2
=
noAuthList1
+
",http://test2.com"
;
String
noAuthList2
=
noAuthList1
+
",http://test2.com"
;
String
authList1
=
"http://user:pwd@test1.com"
;
String
authList2
=
authList1
+
",http://user2:pwd2@test2.com"
;
String
authList2
=
authList1
+
",http://user2:pwd2@test2.com"
;
String
empty
=
new
String
();
private
ApplicationInfoManager
original
;
private
InstanceInfo
instanceInfo
;
@Before
public
void
setup
()
throws
Exception
{
this
.
original
=
ApplicationInfoManager
.
getInstance
();
setInstance
(
mock
(
ApplicationInfoManager
.
class
));
instanceInfo
=
mock
(
InstanceInfo
.
class
);
}
@After
public
void
teardown
()
throws
Exception
{
setInstance
(
this
.
original
);
instanceInfo
=
null
;
}
@Test
public
void
testFilterReplicasNoAuth
()
throws
Exception
{
Map
<
String
,
Object
>
model
=
new
HashMap
<
String
,
Object
>();
StatusInfo
statusInfo
=
StatusInfo
.
Builder
.
newBuilder
()
.
add
(
"registered-replicas"
,
empty
).
add
(
"available-replicas"
,
noAuthList1
).
add
(
"unavailable-replicas"
,
noAuthList2
).
build
();
Map
<
String
,
Object
>
model
=
new
HashMap
<
>();
StatusInfo
statusInfo
=
StatusInfo
.
Builder
.
newBuilder
()
.
add
(
"registered-replicas"
,
empty
)
.
add
(
"available-replicas"
,
noAuthList1
)
.
add
(
"unavailable-replicas"
,
noAuthList2
)
.
withInstanceInfo
(
this
.
instanceInfo
).
build
();
EurekaController
controller
=
new
EurekaController
(
null
);
controller
.
filterReplicas
(
model
,
statusInfo
);
controller
.
filterReplicas
(
model
,
statusInfo
);
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
String
>
results
=
(
Map
<
String
,
String
>)
model
.
get
(
"applicationStats"
);
assertEquals
(
empty
,
results
.
get
(
"registered-replicas"
));
assertEquals
(
noAuthList1
,
results
.
get
(
"available-replicas"
));
assertEquals
(
noAuthList2
,
results
.
get
(
"unavailable-replicas"
));
Map
<
String
,
String
>
results
=
(
Map
<
String
,
String
>)
model
.
get
(
"applicationStats"
);
assertEquals
(
empty
,
results
.
get
(
"registered-replicas"
));
assertEquals
(
noAuthList1
,
results
.
get
(
"available-replicas"
));
assertEquals
(
noAuthList2
,
results
.
get
(
"unavailable-replicas"
));
}
@Test
public
void
testFilterReplicasAuth
()
throws
Exception
{
Map
<
String
,
Object
>
model
=
new
HashMap
<
String
,
Object
>();
StatusInfo
statusInfo
=
StatusInfo
.
Builder
.
newBuilder
()
.
add
(
"registered-replicas"
,
authList2
).
add
(
"available-replicas"
,
authList1
).
add
(
"unavailable-replicas"
,
empty
).
build
();
Map
<
String
,
Object
>
model
=
new
HashMap
<
>();
StatusInfo
statusInfo
=
StatusInfo
.
Builder
.
newBuilder
()
.
add
(
"registered-replicas"
,
authList2
)
.
add
(
"available-replicas"
,
authList1
)
.
add
(
"unavailable-replicas"
,
empty
)
.
withInstanceInfo
(
instanceInfo
).
build
();
EurekaController
controller
=
new
EurekaController
(
null
);
controller
.
filterReplicas
(
model
,
statusInfo
);
controller
.
filterReplicas
(
model
,
statusInfo
);
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
String
>
results
=
(
Map
<
String
,
String
>)
model
.
get
(
"applicationStats"
);
assertEquals
(
empty
,
results
.
get
(
"unavailable-replicas"
));
assertEquals
(
noAuthList1
,
results
.
get
(
"available-replicas"
));
assertEquals
(
noAuthList2
,
results
.
get
(
"registered-replicas"
));
Map
<
String
,
String
>
results
=
(
Map
<
String
,
String
>)
model
.
get
(
"applicationStats"
);
assertEquals
(
empty
,
results
.
get
(
"unavailable-replicas"
));
assertEquals
(
noAuthList1
,
results
.
get
(
"available-replicas"
));
assertEquals
(
noAuthList2
,
results
.
get
(
"registered-replicas"
));
}
...
...
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