congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
H2EmbeddedDataSourceModule.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
io.airlift.dbpool.H2EmbeddedDataSourceModule
constructor

Best Java code snippets using io.airlift.dbpool.H2EmbeddedDataSourceModule.<init> (Showing top 18 results out of 315)

origin: airlift/airlift

@Test(expectedExceptions = NullPointerException.class)
public void testNullAnnotationInConstructionThrows()
{
  H2EmbeddedDataSourceModule notActuallyConstructed = new H2EmbeddedDataSourceModule("test", null);
}
origin: airlift/airlift

@Test(expectedExceptions = IllegalArgumentException.class)
public void testEmptyPrefixStringInConstructionThrows()
{
  H2EmbeddedDataSourceModule notActuallyConstructed = new H2EmbeddedDataSourceModule("", MainBinding.class);
}
origin: io.airlift/dbpool

@Test(expectedExceptions = NullPointerException.class)
public void testNullPrefixInConstructionThrows()
{
  H2EmbeddedDataSourceModule notActuallyConstructed = new H2EmbeddedDataSourceModule(null, MainBinding.class);
}
origin: io.airlift/dbpool

@Test(expectedExceptions = NullPointerException.class)
public void testNullAnnotationInConstructionThrows()
{
  H2EmbeddedDataSourceModule notActuallyConstructed = new H2EmbeddedDataSourceModule("test", null);
}
origin: airlift/airlift

@Test(expectedExceptions = NullPointerException.class)
public void testNullPrefixInConstructionThrows()
{
  H2EmbeddedDataSourceModule notActuallyConstructed = new H2EmbeddedDataSourceModule(null, MainBinding.class);
}
origin: io.airlift/dbpool

@Test(expectedExceptions = IllegalArgumentException.class)
public void testEmptyPrefixStringInConstructionThrows()
{
  H2EmbeddedDataSourceModule notActuallyConstructed = new H2EmbeddedDataSourceModule("", MainBinding.class);
}
origin: io.airlift/dbpool

@Test(groups = "requiresTempFile", expectedExceptions = CreationException.class)
public void testIncorrectConfigurationPrefixThrows()
{
  final String configurationPrefix = "configuration";
  final String constructionPrefix = "differentFromConfiguration";
  Map<String, String> properties = createDefaultConfigurationProperties(configurationPrefix, temporaryFile.getAbsolutePath());
  // Will throw because construction will fail due to the incorrect prefixing.
  createInjector(properties, new H2EmbeddedDataSourceModule(constructionPrefix, MainBinding.class));
}
origin: airlift/airlift

@Test(groups = "requiresTempFile", expectedExceptions = CreationException.class)
public void testIncorrectConfigurationPrefixThrows()
{
  final String configurationPrefix = "configuration";
  final String constructionPrefix = "differentFromConfiguration";
  Map<String, String> properties = createDefaultConfigurationProperties(configurationPrefix, temporaryFile.getAbsolutePath());
  // Will throw because construction will fail due to the incorrect prefixing.
  createInjector(properties, new H2EmbeddedDataSourceModule(constructionPrefix, MainBinding.class));
}
origin: airlift/airlift

@Test(groups = "requiresTempFile")
public void testObjectBindingFromInjector()
{
  final String prefix = "test";
  Map<String, String> properties = createDefaultConfigurationProperties(prefix, temporaryFile.getAbsolutePath());
  Injector injector = createInjector(properties, new H2EmbeddedDataSourceModule(prefix, MainBinding.class));
  ObjectHolder objectHolder = injector.getInstance(ObjectHolder.class);
  assertInstanceOf(objectHolder.dataSource, H2EmbeddedDataSource.class);
}
origin: io.airlift/dbpool

@Test(groups = "requiresTempFile")
public void testObjectBindingFromInjector()
{
  final String prefix = "test";
  Map<String, String> properties = createDefaultConfigurationProperties(prefix, temporaryFile.getAbsolutePath());
  Injector injector = createInjector(properties, new H2EmbeddedDataSourceModule(prefix, MainBinding.class));
  ObjectHolder objectHolder = injector.getInstance(ObjectHolder.class);
  assertInstanceOf(objectHolder.dataSource, H2EmbeddedDataSource.class);
}
origin: io.airlift/dbpool

@Test(groups = "requiresTempFile")
public void testBoundObjectIsASingleton()
{
  final String prefix = "test";
  Map<String, String> properties = createDefaultConfigurationProperties(prefix, temporaryFile.getAbsolutePath());
  Injector injector = createInjector(properties, new H2EmbeddedDataSourceModule(prefix, MainBinding.class));
  ObjectHolder objectHolder1 = injector.getInstance(ObjectHolder.class);
  ObjectHolder objectHolder2 = injector.getInstance(ObjectHolder.class);
  // Holding objects should be different
  assertNotSame(objectHolder1, objectHolder2, "Expected holding objects to be different");
  // But held data source objects should be the same
  assertSame(objectHolder1.dataSource, objectHolder2.dataSource);
}
origin: airlift/airlift

@Test(groups = "requiresTempFile")
public void testBoundObjectIsASingleton()
{
  final String prefix = "test";
  Map<String, String> properties = createDefaultConfigurationProperties(prefix, temporaryFile.getAbsolutePath());
  Injector injector = createInjector(properties, new H2EmbeddedDataSourceModule(prefix, MainBinding.class));
  ObjectHolder objectHolder1 = injector.getInstance(ObjectHolder.class);
  ObjectHolder objectHolder2 = injector.getInstance(ObjectHolder.class);
  // Holding objects should be different
  assertNotSame(objectHolder1, objectHolder2, "Expected holding objects to be different");
  // But held data source objects should be the same
  assertSame(objectHolder1.dataSource, objectHolder2.dataSource);
}
origin: airlift/airlift

@Test(groups = "requiresTempFile")
public void testCorrectConfigurationPrefix()
{
  final String expectedPrefix = "expected";
  final String otherPrefix = "additional";
  final String propertySuffixToTest = ".db.connections.max";
  final int expectedValue = 1234;
  // Required properties for construction
  Map<String, String> properties = createDefaultConfigurationProperties(expectedPrefix, temporaryFile.getAbsolutePath());
  // Optional property added with two different prefixes, two different values
  properties.put(otherPrefix + propertySuffixToTest, Integer.toString(expectedValue + 5678));
  properties.put(expectedPrefix + propertySuffixToTest, Integer.toString(expectedValue));
  Injector injector = createInjector(properties, new H2EmbeddedDataSourceModule(expectedPrefix, MainBinding.class));
  ObjectHolder objectHolder = injector.getInstance(ObjectHolder.class);
  // Make sure we picked up the value with the expected prefix
  assertInstanceOf(objectHolder.dataSource, H2EmbeddedDataSource.class);
  H2EmbeddedDataSource created = (H2EmbeddedDataSource) objectHolder.dataSource;
  assertEquals(created.getMaxConnections(), expectedValue, "Property value not loaded from correct prefix");
}
origin: io.airlift/dbpool

@Test(groups = "requiresTempFile")
public void testCorrectConfigurationPrefix()
{
  final String expectedPrefix = "expected";
  final String otherPrefix = "additional";
  final String propertySuffixToTest = ".db.connections.max";
  final int expectedValue = 1234;
  // Required properties for construction
  Map<String, String> properties = createDefaultConfigurationProperties(expectedPrefix, temporaryFile.getAbsolutePath());
  // Optional property added with two different prefixes, two different values
  properties.put(otherPrefix + propertySuffixToTest, Integer.toString(expectedValue + 5678));
  properties.put(expectedPrefix + propertySuffixToTest, Integer.toString(expectedValue));
  Injector injector = createInjector(properties, new H2EmbeddedDataSourceModule(expectedPrefix, MainBinding.class));
  ObjectHolder objectHolder = injector.getInstance(ObjectHolder.class);
  // Make sure we picked up the value with the expected prefix
  assertInstanceOf(objectHolder.dataSource, H2EmbeddedDataSource.class);
  H2EmbeddedDataSource created = (H2EmbeddedDataSource) objectHolder.dataSource;
  assertEquals(created.getMaxConnections(), expectedValue, "Property value not loaded from correct prefix");
}
origin: airlift/airlift

@Test(groups = "requiresTempFile")
public void testAliasedBindingBindsCorrectly()
{
  final String prefix = "test";
  Map<String, String> properties = createDefaultConfigurationProperties(prefix, temporaryFile.getAbsolutePath());
  Injector injector = createInjector(properties,
      new H2EmbeddedDataSourceModule(prefix, MainBinding.class, AliasBinding.class),
      binder -> binder.bind(TwoObjectsHolder.class));
  ObjectHolder objectHolder = injector.getInstance(ObjectHolder.class);
  TwoObjectsHolder twoObjectsHolder = injector.getInstance(TwoObjectsHolder.class);
  // Held data source objects should all be of the correct type
  assertInstanceOf(twoObjectsHolder.mainDataSource, H2EmbeddedDataSource.class);
  assertInstanceOf(twoObjectsHolder.aliasedDataSource, H2EmbeddedDataSource.class);
  // And should all be references to the same object
  assertSame(objectHolder.dataSource, twoObjectsHolder.mainDataSource);
  assertSame(objectHolder.dataSource, twoObjectsHolder.aliasedDataSource);
}
origin: io.airlift/dbpool

@Test(groups = "requiresTempFile")
public void testAliasedBindingBindsCorrectly()
{
  final String prefix = "test";
  Map<String, String> properties = createDefaultConfigurationProperties(prefix, temporaryFile.getAbsolutePath());
  Injector injector = createInjector(properties,
      new H2EmbeddedDataSourceModule(prefix, MainBinding.class, AliasBinding.class),
      binder -> binder.bind(TwoObjectsHolder.class));
  ObjectHolder objectHolder = injector.getInstance(ObjectHolder.class);
  TwoObjectsHolder twoObjectsHolder = injector.getInstance(TwoObjectsHolder.class);
  // Held data source objects should all be of the correct type
  assertInstanceOf(twoObjectsHolder.mainDataSource, H2EmbeddedDataSource.class);
  assertInstanceOf(twoObjectsHolder.aliasedDataSource, H2EmbeddedDataSource.class);
  // And should all be references to the same object
  assertSame(objectHolder.dataSource, twoObjectsHolder.mainDataSource);
  assertSame(objectHolder.dataSource, twoObjectsHolder.aliasedDataSource);
}
origin: com.facebook.presto/presto-raptor

@Override
protected void setup(Binder ignored)
{
  install(installModuleIf(
      DatabaseConfig.class,
      config -> "mysql".equals(config.getDatabaseType()),
      binder -> {
        binder.install(new MySqlDataSourceModule());
        bindDaoSupplier(binder, ShardDao.class, MySqlShardDao.class);
      }));
  install(installModuleIf(
      DatabaseConfig.class,
      config -> "h2".equals(config.getDatabaseType()),
      binder -> {
        binder.install(new H2EmbeddedDataSourceModule("metadata", ForMetadata.class));
        bindDaoSupplier(binder, ShardDao.class, H2ShardDao.class);
      }));
}
origin: prestosql/presto

@Override
protected void setup(Binder ignored)
{
  install(installModuleIf(
      DatabaseConfig.class,
      config -> "mysql".equals(config.getDatabaseType()),
      binder -> {
        binder.install(new MySqlDataSourceModule());
        bindDaoSupplier(binder, ShardDao.class, MySqlShardDao.class);
      }));
  install(installModuleIf(
      DatabaseConfig.class,
      config -> "h2".equals(config.getDatabaseType()),
      binder -> {
        binder.install(new H2EmbeddedDataSourceModule("metadata", ForMetadata.class));
        bindDaoSupplier(binder, ShardDao.class, H2ShardDao.class);
      }));
}
io.airlift.dbpoolH2EmbeddedDataSourceModule<init>

Popular methods of H2EmbeddedDataSourceModule

    Popular in Java

    • Parsing JSON documents to java classes using gson
    • getSystemService (Context)
    • runOnUiThread (Activity)
    • getOriginalFilename (MultipartFile)
      Return the original filename in the client's filesystem.This may contain path information depending
    • BufferedWriter (java.io)
      Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
    • URI (java.net)
      A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
    • MessageDigest (java.security)
      Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
    • Scanner (java.util)
      A parser that parses a text string of primitive types and strings with the help of regular expressio
    • TimerTask (java.util)
      The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
    • HttpServletRequest (javax.servlet.http)
      Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
    • 21 Best Atom Packages for 2021
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now