Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 10:23
    xvik commented #252
  • 08:03
    krutsko commented #252
  • 05:56

    dependabot[bot] on gradle

    (compare)

  • 05:56

    xvik on master

    Bump spock-junit5 from 1.0.1 to… Merge pull request #247 from xv… (compare)

  • 05:56
    xvik closed #247
  • 05:50
    dependabot[bot] edited #247
  • 05:49
    dependabot[bot] synchronize #247
  • 05:49
    dependabot[bot] edited #247
  • 05:49

    dependabot[bot] on gradle

    Bump spock-junit5 from 1.0.1 to… (compare)

  • 05:49
    dependabot[bot] edited #247
  • 05:48
    dependabot[bot] edited #247
  • 05:48

    dependabot[bot] on gradle

    (compare)

  • 05:48

    xvik on master

    Bump spock-core from 2.2-groovy… Merge pull request #251 from xv… (compare)

  • 05:48
    xvik closed #251
  • 05:44
    xvik commented #252
  • Sep 29 23:58
    abhishekkaura opened #252
  • Sep 29 23:15
    dependabot[bot] labeled #251
  • Sep 29 23:15

    dependabot[bot] on gradle

    Bump spock-core from 2.2-groovy… (compare)

  • Sep 29 23:15
    dependabot[bot] opened #251
  • Sep 22 05:55

    dependabot[bot] on gradle

    (compare)

Vyacheslav Rusakov
@xvik

does that mean I can't use DropwizardAppExtension<HttpServerConfiguration> any more since it loads from a yml file

It's not a problem, in dropwizard you always have control how configuration is applied to code and always can modify it

Eddie Xie
@oeddyo

sorry I should've asked this better.

So my question really is for writing an extension using DropwizardAppExtension and dynamically set database (with embededPostgres). In the extension I'll construct a dropwizard app, and then for each test class I'll have a different port for postgres so they don’t conflict with each other.

Then let's say there are two test classes A, B uses this extension. So in A, the system property of database.url will be set to pg://A. When A starts, A will set the system property "dw.database.url" to "pg://A"

and when B starts, B will sets it to "pg://B". However A didn’t knonw and will keep using "pg://B" which causes problems when run in parallel.

So I guess this is where the confusion comes from. I think there might be one possibility and would like to hear what you think:

I would like to not use the same system property for A and B. Maybe "A.dw.database.url" and "B.dw.database.url". But I need to let DW know that it’s no longer "dw.database.url" that it should read DB settings from

Vyacheslav Rusakov
@xvik
mmm! i just thought! there is a way to overcome property limitation!
ConfigOverride maps configuration properties to system properties with custom prefix (dw. by default). And you can(!!!) change this prefix!
Eddie Xie
@oeddyo
saw the "prefix" param too. But I assume in DW internal it's expecting dw.database.url instead of A.dw.database.url?
Vyacheslav Rusakov
@xvik
 new DropwizardAppExtension<>(
            HttpServer.class,
            "src/test/resources/dropwizard-test-config.yml",
          "randomPrefixString",
            ConfigOverride.config("randomPrefixString",
                "database.url",
                singleInstancePostgresExtension.getEmbeddedPostgres().getJdbcUrl(
                    "postgres", "postgres")
            ),
            ConfigOverride.config("randomPrefixString",
                "server.applicationConnectors[0].port", String.valueOf(0)
            ),
            ConfigOverride.config("randomPrefixString",
                "server.adminConnectors[0].port", String.valueOf(0)
            ),
            ConfigOverride.config("randomPrefixString",
                "engine.indexDataPrefix",
                tempDir.toAbsolutePath().toString()
            )
        );
you configure prefix for DropwizardAppExtension and use the same prefix in each ConfigOverride
"randomPrefixString"
I will use this technique in guicey extensions so they would be independent out of the box! thank you for the idea! :)
Eddie Xie
@oeddyo
lol credits are all yours. I'm standing on your shoulder and peeking only
I meant that: if I use a prefix like you mentioned, for instance use the test class's name
io.dropwizard.configuration.ConfigurationValidationException: src/test/resources/dropwizard-test-config.yml has an error:
  * dataSourceFactory.url must not be empty
it complains that it needs to have url
oh
Vyacheslav Rusakov
@xvik
I suppose "oh" means you got what was wrong
Eddie Xie
@oeddyo
let me try it out. was missing the "each" part
ah!
oh my god can't believe this is real
image.png
yes your solution works!
Vyacheslav Rusakov
@xvik
))
Eddie Xie
@oeddyo
amazing! Not going to be ass kissing but this guicey project is the most amazing one-man OS project I've seen lol
Vyacheslav Rusakov
@xvik
thank you))
Eddie Xie
@oeddyo

Hi @xvik ! I'm using a guava cache in my filter: ``` @Inject
private SessionFactory sessionFactory;

@Inject
public CredentialRequiredFilter(AppDao appDao, Cache<String, App> appCache) {
this.appDao = appDao;
this.appCache = appCache;
}
```

sorry gitter code format is always a mystery to me
image.png
now I'm trying to replace the cache with a mock cache in test. I saw in GuiceyHook it's possible but I'm using junit-5. Is there anything I can do now or shall I wait for your changes?
Vyacheslav Rusakov
@xvik
hi!

hooks is a generic mechanism:

GuiceyConfigurationHook hook  = builder -> builder.extensions(...);

here lambda used instead of direct inteface implementation

to register hook: hook.register()
there only problem is to register it before application startap
your junit extension use BeforeAll hook, so it is impossible to register anything beofre extension execution
so you will have to add hooks support inside your extension (to register them before startup)
Eddie Xie
@oeddyo
i see. I'll try out and see if I can get it work
Vyacheslav Rusakov
@xvik
and about formatting: just start ''' on new line. To activate syntax highlighting put language name after it like '''java
Eddie Xie
@oeddyo
ah ok
thanks
hooks doc
Eddie Xie
@oeddyo
neat!
Eddie Xie
@oeddyo
image.png
I seem to get it working in the extension via:
i pass the overrideModule in the extension's constructor, and in the overrideModule I override the cache I wanted to mock. from the guice print it seems to be overridden
image.png
does this sound reasonable?
Vyacheslav Rusakov
@xvik
yes ofc, report confirms that
Eddie Xie
@oeddyo
it works!
Fazeem Mohammed
@fazeem84
@xvik i had a suggestion to dropwizard core project to add the application build version during startup,which is rejected unfortunately..i want to know your opinion about this feature dropwizard/dropwizard#3331
Vyacheslav Rusakov
@xvik
I agree that it is too specific addition (and could be easily done in the application if required).
Fazeem Mohammed
@fazeem84
Ok.. thanks for your opinion :)