-
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
462 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...rg/jobrunr/micronaut/autoconfigure/storage/JobRunrNamedSqlStorageProviderFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.jobrunr.micronaut.autoconfigure.storage; | ||
|
||
|
||
import io.micronaut.context.ApplicationContext; | ||
import io.micronaut.context.annotation.Property; | ||
import io.micronaut.inject.qualifiers.Qualifiers; | ||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Named; | ||
import jakarta.inject.Singleton; | ||
import org.jobrunr.storage.InMemoryStorageProvider; | ||
import org.jobrunr.storage.StorageProvider; | ||
import org.jobrunr.storage.sql.SqlStorageProvider; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.sql.DataSource; | ||
import java.sql.SQLException; | ||
|
||
import static org.jobrunr.micronaut.MicronautAssertions.assertThat; | ||
|
||
@MicronautTest | ||
@Property(name = "jobrunr.database.skip-create", value = "true") | ||
@Property(name = "jobrunr.database.datasource", value = "jobrunr") | ||
class JobRunrNamedSqlStorageProviderFactoryTest { | ||
|
||
@Inject | ||
ApplicationContext context; | ||
|
||
@Test | ||
void sqlStorageProviderAutoConfigurationTestWithMultipleNamedDataSources() throws SQLException { | ||
// GIVEN | ||
context.registerSingleton(dataSource()); | ||
context.registerSingleton(DataSource.class, dataSource(), Qualifiers.byName("jobrunr")); | ||
|
||
// WHEN & THEN | ||
assertThat(context).hasSingleBean(StorageProvider.class); | ||
assertThat(context.getBean(StorageProvider.class)) | ||
.isInstanceOf(SqlStorageProvider.class) | ||
.hasJobMapper(); | ||
assertThat(context).doesNotHaveBean(InMemoryStorageProvider.class); | ||
} | ||
|
||
@Singleton | ||
public DataSource dataSource() throws SQLException { | ||
return Mocks.dataSource(); | ||
} | ||
|
||
@Singleton | ||
@Named("jobrunr") | ||
public DataSource jobRunrDataSource() throws SQLException { | ||
return Mocks.dataSource(); | ||
} | ||
|
||
} |
Oops, something went wrong.