Skip to content

Dead code with side effect in test OpenshiftAPIServiceTest #167

@barkbay

Description

@barkbay

It looks like there is some dead code here :

    @Before
    public void setup() {
        final String basedir = System.getProperty("project.basedir");
        final String password = "changeit";
        final String keyStore = basedir + "/src/it/resources/keystore.jks";
        [...]
        System.setProperty("kubernetes.keystore.file", keyStore);
        [...]
}

System.getProperty("project.basedir") always returns null and the system property kubernetes.keystore.file is always set to null/src/it/resources/keystore.jks
Please also note that tests are not failing if you delete the file src/it/resources/keystore.jks, so it looks like this file is not used too.

Looking at the pom.xml I guess that the first idea was to use the environment variable PROJECT_DIR :

...
                    <environmentVariables>
                        <ENV_VAR_EXISTS>value</ENV_VAR_EXISTS>
                        <ENV_VAR_EXISTS_BOOLEAN>true</ENV_VAR_EXISTS_BOOLEAN>
                        <PROJECT_DIR>${project.basedir}</PROJECT_DIR>
                    </environmentVariables>
...

System.getProperty("project.basedir") should be replaced with System.getenv("PROJECT_DIR")

The problem is that by setting a wrong system property with System.setProperty("..") without further cleanup with a @After it has some side effects on other piece of code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions