Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38058

Properly pass context in folder's page objects

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Let's describe the issue with a test. Assumming we already have an injector and a JenkinsController, the following test will fail:

      Jenkins j1 = new Jenkins(injector, jenkinsController);
      FolderItem f = j1.jobs.create(FolderItem.class);
      Assert.assertSame(j1, f.jobs.getJenkins());
      

      The problem reproduced is the same described in JENKINS-37615, but specific to {{FolderItem}}s, since they are not properly receiving their context when created.

        Attachments

          Issue Links

            Activity

            mfranco Manuel Franco created issue -
            mfranco Manuel Franco made changes -
            Field Original Value New Value
            Description Let's describe the issue with a test. Assumming we already have an injector and a JenkinsController, the following test will fail:

            {code:java}
            Jenkins j1 = new Jenkins(injector, jenkinsController);
            Assert.assertSame(j1, j1.jobs.getJenkins());
            {code}

            The problem is that the jenkins instance returned by the {{getJenkins()}} method in the {{JobsMixIn}} object (actually inherited from {{PageObject}}) is not the instance that was passed as a context in the construction of this last one, but an instance that is looked up (and built if needed) using guice.

            This leads to potential inconsistencies for some operations (e.g. {{jobs.create}}) that rely on querying its jenkins instance, for example for the version number.

            Sometimes as an [external user|https://github.com/jenkinsci/acceptance-test-harness/blob/master/docs/EXTERNAL.md] of the ATH I may need to create several instances with different versions, and want each jobs mixin to know exactly to which jenkins they belong to and behave consistently.
            Let's describe the issue with a test. Assumming we already have an injector and a JenkinsController, the following test will fail:

            {code:java}
            Jenkins j1 = new Jenkins(injector, jenkinsController);
            Assert.assertSame(j1, j1.jobs.getJenkins());

            Jenkins j1 = new Jenkins(injector, jc);
                    Assert.assertSame(j1, j1.jobs.getJenkins());
                    
                    FolderItem f = j1.jobs.create(FolderItem.class);
                    Assert.assertSame(j1, f.jobs.getJenkins());
            {code}

            The problem is that the jenkins instance returned by the {{getJenkins()}} method in the {{JobsMixIn}} object (actually inherited from {{PageObject}}) is not the instance that was passed as a context in the construction of this last one, but an instance that is looked up (and built if needed) using guice.

            This leads to potential inconsistencies for some operations (e.g. {{jobs.create}}) that rely on querying its jenkins instance, for example for the version number.

            Sometimes as an [external user|https://github.com/jenkinsci/acceptance-test-harness/blob/master/docs/EXTERNAL.md] of the ATH I may need to create several instances with different versions, and want each jobs mixin to know exactly to which jenkins they belong to and behave consistently.
            mfranco Manuel Franco made changes -
            Description Let's describe the issue with a test. Assumming we already have an injector and a JenkinsController, the following test will fail:

            {code:java}
            Jenkins j1 = new Jenkins(injector, jenkinsController);
            Assert.assertSame(j1, j1.jobs.getJenkins());

            Jenkins j1 = new Jenkins(injector, jc);
                    Assert.assertSame(j1, j1.jobs.getJenkins());
                    
                    FolderItem f = j1.jobs.create(FolderItem.class);
                    Assert.assertSame(j1, f.jobs.getJenkins());
            {code}

            The problem is that the jenkins instance returned by the {{getJenkins()}} method in the {{JobsMixIn}} object (actually inherited from {{PageObject}}) is not the instance that was passed as a context in the construction of this last one, but an instance that is looked up (and built if needed) using guice.

            This leads to potential inconsistencies for some operations (e.g. {{jobs.create}}) that rely on querying its jenkins instance, for example for the version number.

            Sometimes as an [external user|https://github.com/jenkinsci/acceptance-test-harness/blob/master/docs/EXTERNAL.md] of the ATH I may need to create several instances with different versions, and want each jobs mixin to know exactly to which jenkins they belong to and behave consistently.
            Let's describe the issue with a test. Assumming we already have an injector and a JenkinsController, the following test will fail:

            {code:java}
            Jenkins j1 = new Jenkins(injector, jenkinsController);
            FolderItem f = j1.jobs.create(FolderItem.class);
            Assert.assertSame(j1, f.jobs.getJenkins());
            {code}

            The problem reproduced is the same described in JENKINS-XXX, but specific to {{FolderItem}}s, since they are not properly receiving their context when created.
            mfranco Manuel Franco made changes -
            Description Let's describe the issue with a test. Assumming we already have an injector and a JenkinsController, the following test will fail:

            {code:java}
            Jenkins j1 = new Jenkins(injector, jenkinsController);
            FolderItem f = j1.jobs.create(FolderItem.class);
            Assert.assertSame(j1, f.jobs.getJenkins());
            {code}

            The problem reproduced is the same described in JENKINS-XXX, but specific to {{FolderItem}}s, since they are not properly receiving their context when created.
            Let's describe the issue with a test. Assumming we already have an injector and a {{JenkinsController}}, the following test will fail:

            {code:java}
            Jenkins j1 = new Jenkins(injector, jenkinsController);
            FolderItem f = j1.jobs.create(FolderItem.class);
            Assert.assertSame(j1, f.jobs.getJenkins());
            {code}

            The problem reproduced is the same described in JENKINS-XXX, but specific to {{FolderItem}}s, since they are not properly receiving their context when created.
            mfranco Manuel Franco made changes -
            Description Let's describe the issue with a test. Assumming we already have an injector and a {{JenkinsController}}, the following test will fail:

            {code:java}
            Jenkins j1 = new Jenkins(injector, jenkinsController);
            FolderItem f = j1.jobs.create(FolderItem.class);
            Assert.assertSame(j1, f.jobs.getJenkins());
            {code}

            The problem reproduced is the same described in JENKINS-XXX, but specific to {{FolderItem}}s, since they are not properly receiving their context when created.
            Let's describe the issue with a test. Assumming we already have an injector and a {{JenkinsController}}, the following test will fail:

            {code:java}
            Jenkins j1 = new Jenkins(injector, jenkinsController);
            FolderItem f = j1.jobs.create(FolderItem.class);
            Assert.assertSame(j1, f.jobs.getJenkins());
            {code}

            The problem reproduced is the same described in JENKINS-37615, but specific to {{FolderItem}}s, since they are not properly receiving their context when created.
            mfranco Manuel Franco made changes -
            Link This issue relates to JENKINS-37615 [ JENKINS-37615 ]
            mfranco Manuel Franco made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            mfranco Manuel Franco made changes -
            Remote Link This issue links to "PR-186 (Web Link)" [ 14822 ]
            mfranco Manuel Franco made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            mfranco Manuel Franco made changes -
            Status In Review [ 10005 ] In Progress [ 3 ]
            mfranco Manuel Franco made changes -
            Environment ATH 1.38 ATH 1.39
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Manuel Franco
            Path:
            src/main/java/org/jenkinsci/test/acceptance/po/FolderItem.java
            src/main/java/org/jenkinsci/test/acceptance/po/Job.java
            src/main/java/org/jenkinsci/test/acceptance/po/JobsMixIn.java
            src/main/java/org/jenkinsci/test/acceptance/po/PageObject.java
            src/main/java/org/jenkinsci/test/acceptance/po/TopLevelItem.java
            http://jenkins-ci.org/commit/acceptance-test-harness/7454e7762a9fe63e6d2e7761b3cf6c090d869311
            Log:
            JENKINS-38058 pass context when creating 'FolderItem' objects

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Manuel Franco Path: src/main/java/org/jenkinsci/test/acceptance/po/FolderItem.java src/main/java/org/jenkinsci/test/acceptance/po/Job.java src/main/java/org/jenkinsci/test/acceptance/po/JobsMixIn.java src/main/java/org/jenkinsci/test/acceptance/po/PageObject.java src/main/java/org/jenkinsci/test/acceptance/po/TopLevelItem.java http://jenkins-ci.org/commit/acceptance-test-harness/7454e7762a9fe63e6d2e7761b3cf6c090d869311 Log: JENKINS-38058 pass context when creating 'FolderItem' objects
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Manuel Franco
            Path:
            src/main/java/org/jenkinsci/test/acceptance/po/JobsMixIn.java
            http://jenkins-ci.org/commit/acceptance-test-harness/b26cce4360c36228d60393a2d3a4ce8d06497b66
            Log:
            JENKINS-38058 explicit check for constructor existence

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Manuel Franco Path: src/main/java/org/jenkinsci/test/acceptance/po/JobsMixIn.java http://jenkins-ci.org/commit/acceptance-test-harness/b26cce4360c36228d60393a2d3a4ce8d06497b66 Log: JENKINS-38058 explicit check for constructor existence
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Oliver Gondža
            Path:
            src/main/java/org/jenkinsci/test/acceptance/po/FolderItem.java
            src/main/java/org/jenkinsci/test/acceptance/po/Job.java
            src/main/java/org/jenkinsci/test/acceptance/po/JobsMixIn.java
            src/main/java/org/jenkinsci/test/acceptance/po/PageObject.java
            src/main/java/org/jenkinsci/test/acceptance/po/TopLevelItem.java
            http://jenkins-ci.org/commit/acceptance-test-harness/002b21349a9cad8e478e7d44f665517db12a370c
            Log:
            Merge pull request #186 from mafraba/JENKINS-38058

            JENKINS-38058 pass context when creating 'FolderItem' objects

            Compare: https://github.com/jenkinsci/acceptance-test-harness/compare/7d482f4e3315...002b21349a9c

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: src/main/java/org/jenkinsci/test/acceptance/po/FolderItem.java src/main/java/org/jenkinsci/test/acceptance/po/Job.java src/main/java/org/jenkinsci/test/acceptance/po/JobsMixIn.java src/main/java/org/jenkinsci/test/acceptance/po/PageObject.java src/main/java/org/jenkinsci/test/acceptance/po/TopLevelItem.java http://jenkins-ci.org/commit/acceptance-test-harness/002b21349a9cad8e478e7d44f665517db12a370c Log: Merge pull request #186 from mafraba/ JENKINS-38058 JENKINS-38058 pass context when creating 'FolderItem' objects Compare: https://github.com/jenkinsci/acceptance-test-harness/compare/7d482f4e3315...002b21349a9c
            mfranco Manuel Franco made changes -
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Resolved [ 5 ]
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Oliver Gondža
            Path:
            src/main/java/org/jenkinsci/test/acceptance/po/Folder.java
            http://jenkins-ci.org/commit/acceptance-test-harness/88be022841ce43fe79fe57f32a8169314384fd48
            Log:
            Merge pull request #264 from mafraba/JENKINS-38058

            JENKINS-38058 bring back lost constructor for 'Folder'

            Compare: https://github.com/jenkinsci/acceptance-test-harness/compare/252150450053...88be022841ce

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: src/main/java/org/jenkinsci/test/acceptance/po/Folder.java http://jenkins-ci.org/commit/acceptance-test-harness/88be022841ce43fe79fe57f32a8169314384fd48 Log: Merge pull request #264 from mafraba/ JENKINS-38058 JENKINS-38058 bring back lost constructor for 'Folder' Compare: https://github.com/jenkinsci/acceptance-test-harness/compare/252150450053...88be022841ce
            cloudbees CloudBees Inc. made changes -
            Remote Link This issue links to "CloudBees Internal CJP-5611 (Web Link)" [ 19299 ]

              People

              Assignee:
              mfranco Manuel Franco
              Reporter:
              mfranco Manuel Franco
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: