@@ -91,6 +91,55 @@ public void configure() throws Exception {
9191 });
9292 }
9393
94+ @ SuppressWarnings ("unchecked" )
95+ @ Test
96+ public void configureWith2Names () throws Exception {
97+ new MockUnit (Env .class , Binder .class )
98+ .expect (props ("com.ibm.db2.jcc.DB2SimpleDataSource" , "jdbc:db2://127.0.0.1/mydb" ,
99+ "db2.mydb" , null , "" , false ))
100+ .expect (hikariConfig ())
101+ .expect (hikariDataSource ())
102+ .expect (serviceKey ("mydb" ))
103+ .expect (containerConfig )
104+ .expect (unit -> {
105+ ServerConfig serverConfig = unit .mockConstructor (ServerConfig .class );
106+
107+ serverConfig .setName ("mydb" );
108+ serverConfig .addPackage ("my.model" );
109+ serverConfig .setContainerConfig (unit .get (ContainerConfig .class ));
110+ serverConfig .setDataSource (isA (DataSource .class ));
111+ serverConfig .loadFromProperties (isA (Properties .class ));
112+ serverConfig .setDefaultServer (true );
113+ serverConfig .setRegister (true );
114+
115+ unit .registerMock (ServerConfig .class , serverConfig );
116+ })
117+ .expect (enhancer ("my.model" ))
118+ .expect (ebeanProperties ())
119+ .expect (unit -> {
120+ Binder binder = unit .get (Binder .class );
121+
122+ ScopedBindingBuilder sbbES = unit .mock (ScopedBindingBuilder .class );
123+ sbbES .asEagerSingleton ();
124+ sbbES .asEagerSingleton ();
125+ sbbES .asEagerSingleton ();
126+
127+ LinkedBindingBuilder <EbeanServer > lbbES = unit .mock (LinkedBindingBuilder .class );
128+ expect (lbbES .toProvider (isA (EbeanManaged .class ))).andReturn (sbbES ).times (3 );
129+
130+ expect (binder .bind (Key .get (EbeanServer .class ))).andReturn (lbbES );
131+ expect (binder .bind (Key .get (EbeanServer .class , Names .named ("db" )))).andReturn (lbbES );
132+ expect (binder .bind (Key .get (EbeanServer .class , Names .named ("mydb" )))).andReturn (lbbES );
133+ })
134+ .expect (onStop )
135+ .run (unit -> {
136+ new Ebeanby ("db" )
137+ .configure (unit .get (Env .class ), config ()
138+ .withValue ("db" , ConfigValueFactory .fromAnyRef ("jdbc:db2://127.0.0.1/mydb" )),
139+ unit .get (Binder .class ));
140+ });
141+ }
142+
94143 @ Test
95144 public void configureWithPackages () throws Exception {
96145 new MockUnit (Env .class , Binder .class )
0 commit comments