18
18
*/
19
19
package org .neo4j .driver .internal .cluster ;
20
20
21
- import org .hamcrest .CoreMatchers ;
22
21
import org .junit .jupiter .api .Test ;
23
22
import org .junit .jupiter .params .ParameterizedTest ;
24
23
import org .junit .jupiter .params .provider .EnumSource ;
32
31
33
32
import org .neo4j .driver .AccessMode ;
34
33
import org .neo4j .driver .internal .BoltServerAddress ;
35
- import org .neo4j .driver .internal .cluster .RoutingTablesImpl .RoutingTableHandlerFactory ;
34
+ import org .neo4j .driver .internal .cluster .RoutingTableRegistryImpl .RoutingTableHandlerFactory ;
36
35
import org .neo4j .driver .internal .spi .ConnectionPool ;
37
36
import org .neo4j .driver .internal .util .Clock ;
38
37
60
59
import static org .neo4j .driver .internal .util .ClusterCompositionUtil .F ;
61
60
import static org .neo4j .driver .util .TestUtil .await ;
62
61
63
- class RoutingTablesImplTest
62
+ class RoutingTableRegistryImplTest
64
63
{
65
64
@ Test
66
65
void factoryShouldCreateARoutingTableWithSameDatabaseName () throws Throwable
67
66
{
68
67
Clock clock = Clock .SYSTEM ;
69
- BoltServerAddress initialRouter = new BoltServerAddress ( "localhost:7687" );
70
68
RoutingTableHandlerFactory factory =
71
69
new RoutingTableHandlerFactory ( mock ( ConnectionPool .class ), mock ( RediscoveryImpl .class ), clock , DEV_NULL_LOGGER );
72
70
73
71
RoutingTableHandler handler = factory .newInstance ( "Molly" , null );
74
72
RoutingTable table = handler .routingTable ();
75
73
76
74
assertThat ( table .database (), equalTo ( "Molly" ) );
77
- assertThat ( table .servers (), contains ( CoreMatchers .equalTo ( initialRouter ) ) );
78
- assertThat ( Arrays .asList ( table .routers ().toArray () ), contains ( CoreMatchers .equalTo ( initialRouter ) ) );
79
75
80
- assertThat ( table .readers ().size (), CoreMatchers .equalTo ( 0 ) );
81
- assertThat ( table .writers ().size (), CoreMatchers .equalTo ( 0 ) );
76
+ assertThat ( table .routers ().size (), equalTo ( 0 ) );
77
+ assertThat ( table .readers ().size (), equalTo ( 0 ) );
78
+ assertThat ( table .writers ().size (), equalTo ( 0 ) );
82
79
83
80
assertTrue ( table .isStaleFor ( AccessMode .READ ) );
84
81
assertTrue ( table .isStaleFor ( AccessMode .WRITE ) );
@@ -91,7 +88,7 @@ void shouldCreateRoutingTableHandlerIfAbsentWhenFreshRoutingTable( String databa
91
88
// Given
92
89
ConcurrentMap <String ,RoutingTableHandler > map = new ConcurrentHashMap <>();
93
90
RoutingTableHandlerFactory factory = mockedHandlerFactory ();
94
- RoutingTablesImpl routingTables = newRoutingTables ( map , factory );
91
+ RoutingTableRegistryImpl routingTables = newRoutingTables ( map , factory );
95
92
96
93
// When
97
94
routingTables .refreshRoutingTable ( databaseName , AccessMode .READ );
@@ -111,7 +108,7 @@ void shouldReturnExistingRoutingTableHandlerWhenFreshRoutingTable( String databa
111
108
map .put ( databaseName , handler );
112
109
113
110
RoutingTableHandlerFactory factory = mockedHandlerFactory ();
114
- RoutingTablesImpl routingTables = newRoutingTables ( map , factory );
111
+ RoutingTableRegistryImpl routingTables = newRoutingTables ( map , factory );
115
112
116
113
// When
117
114
RoutingTableHandler actual = await ( routingTables .refreshRoutingTable ( databaseName , AccessMode .READ ) );
@@ -130,7 +127,7 @@ void shouldReturnFreshRoutingTable( AccessMode mode ) throws Throwable
130
127
ConcurrentMap <String ,RoutingTableHandler > map = new ConcurrentHashMap <>();
131
128
RoutingTableHandler handler = mockedRoutingTableHandler ();
132
129
RoutingTableHandlerFactory factory = mockedHandlerFactory ( handler );
133
- RoutingTablesImpl routingTables = new RoutingTablesImpl ( map , factory , DEV_NULL_LOGGER );
130
+ RoutingTableRegistryImpl routingTables = new RoutingTableRegistryImpl ( map , factory , DEV_NULL_LOGGER );
134
131
135
132
// When
136
133
routingTables .refreshRoutingTable ( ABSENT_DB_NAME , mode );
@@ -148,7 +145,7 @@ void shouldReturnServersInAllRoutingTables() throws Throwable
148
145
map .put ( "Banana" , mockedRoutingTableHandler ( B , C , D ) );
149
146
map .put ( "Orange" , mockedRoutingTableHandler ( E , F , C ) );
150
147
RoutingTableHandlerFactory factory = mockedHandlerFactory ();
151
- RoutingTablesImpl routingTables = new RoutingTablesImpl ( map , factory , DEV_NULL_LOGGER );
148
+ RoutingTableRegistryImpl routingTables = new RoutingTableRegistryImpl ( map , factory , DEV_NULL_LOGGER );
152
149
153
150
// When
154
151
Set <BoltServerAddress > servers = routingTables .allServers ();
@@ -167,7 +164,7 @@ void shouldRemoveRoutingTableHandler() throws Throwable
167
164
map .put ( "Orange" , mockedRoutingTableHandler ( C ) );
168
165
169
166
RoutingTableHandlerFactory factory = mockedHandlerFactory ();
170
- RoutingTablesImpl routingTables = newRoutingTables ( map , factory );
167
+ RoutingTableRegistryImpl routingTables = newRoutingTables ( map , factory );
171
168
172
169
// When
173
170
routingTables .remove ( "Apple" );
@@ -185,7 +182,7 @@ void shouldRemoveStatleRoutingTableHandlers() throws Throwable
185
182
map .put ( "Orange" , mockedRoutingTableHandler ( C ) );
186
183
187
184
RoutingTableHandlerFactory factory = mockedHandlerFactory ();
188
- RoutingTablesImpl routingTables = newRoutingTables ( map , factory );
185
+ RoutingTableRegistryImpl routingTables = newRoutingTables ( map , factory );
189
186
190
187
// When
191
188
routingTables .purgeAged ();
@@ -201,9 +198,9 @@ private RoutingTableHandler mockedRoutingTableHandler( BoltServerAddress... serv
201
198
return handler ;
202
199
}
203
200
204
- private RoutingTablesImpl newRoutingTables ( ConcurrentMap <String ,RoutingTableHandler > handlers , RoutingTableHandlerFactory factory )
201
+ private RoutingTableRegistryImpl newRoutingTables ( ConcurrentMap <String ,RoutingTableHandler > handlers , RoutingTableHandlerFactory factory )
205
202
{
206
- return new RoutingTablesImpl ( handlers , factory , DEV_NULL_LOGGER );
203
+ return new RoutingTableRegistryImpl ( handlers , factory , DEV_NULL_LOGGER );
207
204
}
208
205
209
206
private RoutingTableHandlerFactory mockedHandlerFactory ( RoutingTableHandler handler )
0 commit comments