testcontainers / testcontainers-java

Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.org
MIT License
7.99k stars 1.64k forks source link

Class org.testcontainers.containers.MySQLContainer generic with no purpose? #1776

Closed raffig closed 5 years ago

raffig commented 5 years ago

Either I do not see something or there is no purpose for class

org.testcontainers.containers.MySQLContainer

to be generic, and the fact that is generic generates lots of warnings (I don't know what could be provided as SELF parameter).

bsideup commented 5 years ago

You can use new MySQLContainer<>() to avoid the warnings.

Testcontainers 2.0 will not use the self-typing anymore. It is being tracked in https://github.com/testcontainers/testcontainers-java/issues/107 and you can find a bit of info here: https://speakerdeck.com/bsideup/geecon-2019-testcontainers-a-year-in-review?slide=74

raffig commented 5 years ago

Diamond operator cannot be used in declaration, so warning remains. It's good to know that it will be changed :-).

sanderploegsma commented 4 years ago

I don't see why the containers like MySQLContainer have a type argument though, what is wrong with the following?

public class MySQLContainer extends JdbcDatabaseContainer<MySQLContainer> {
    public MySQLContainer withX() {
        // configure X
        return self();
    }
}
matul3jan commented 1 year ago

This works for me (to avoid the warnings)

MySQLContainer<?> mySQLContainer = new MySQLContainer<>("");

kiview commented 1 year ago

@sanderploegsma You are right with regards to MySQLContainer, it is there for legacy reasons.