Exemple #1
0
    def test_env(self):
        plugin = ant.AntPlugin('test-part', self.options, self.project_options)

        os.makedirs(os.path.join(plugin.installdir, 'jar'))
        open(os.path.join(plugin.installdir, 'jar', 'lib1.jar'), 'w').close()
        open(os.path.join(plugin.installdir, 'jar', 'lib2.jar'), 'w').close()
        plugin.env(plugin.partdir)
Exemple #2
0
    def test_get_non_defaul_openjdk(self):
        self.options.ant_openjdk_version = "8"

        plugin = ant.AntPlugin("test-part", self.options, self.project)

        self.assertThat(plugin.stage_packages, Equals(["openjdk-8-jre-headless"]))
        self.assertThat(plugin.build_packages, Equals(["openjdk-8-jdk-headless"]))
Exemple #3
0
    def test_build_fail(self, run_mock):
        plugin = ant.AntPlugin('test-part', self.options, self.project_options)

        os.makedirs(plugin.sourcedir)
        with self.assertRaises(RuntimeError):
            plugin.build()

        run_mock.assert_has_calls([
            mock.call(['ant']),
        ])
Exemple #4
0
    def test_env(self):
        plugin = ant.AntPlugin('test-part', self.options, self.project_options)

        os.makedirs(os.path.join(plugin.installdir, 'jar'))
        open(os.path.join(plugin.installdir, 'jar', 'lib1.jar'), 'w').close()
        open(os.path.join(plugin.installdir, 'jar', 'lib2.jar'), 'w').close()
        env = plugin.env(plugin.partdir)
        self.assertIn(
            'CLASSPATH={}/jar/lib1.jar:{}/jar/lib2.jar:$CLASSPATH'.format(
                plugin.partdir, plugin.partdir), env)
Exemple #5
0
    def test_stage_and_build_packages(self):
        plugin = ant.AntPlugin("test-part", self.options, self.project)

        self.assertThat(
            plugin.stage_packages,
            Equals(["openjdk-{}-jre-headless".format(self.expected_java_version)]),
        )
        self.assertThat(
            plugin.build_packages,
            Equals(["openjdk-{}-jdk-headless".format(self.expected_java_version)]),
        )
Exemple #6
0
    def test_build_with_explicit_buildfile(self):
        self.options.ant_buildfile = "test.xml"

        plugin = ant.AntPlugin("test-part", self.options, self.project)

        self.create_assets(plugin)

        plugin.build()

        self.run_mock.assert_called_once_with(
            ["ant", "-f", "test.xml"], cwd=plugin.builddir, env=mock.ANY
        )
Exemple #7
0
    def test_env(self):
        plugin = ant.AntPlugin("test-part", self.options, self.project)

        os.makedirs(os.path.join(plugin.installdir, "jar"))
        open(os.path.join(plugin.installdir, "jar", "lib1.jar"), "w").close()
        open(os.path.join(plugin.installdir, "jar", "lib2.jar"), "w").close()
        env = plugin.env(plugin.partdir)
        self.assertIn(
            "CLASSPATH={}/jar/lib1.jar:{}/jar/lib2.jar:$CLASSPATH".format(
                plugin.partdir, plugin.partdir),
            env,
        )
Exemple #8
0
    def test_build(self, run_mock):
        plugin = ant.AntPlugin("test-part", self.options, self.project_options)

        def side(l):
            os.makedirs(os.path.join(plugin.builddir, "target"))
            open(os.path.join(plugin.builddir, "target", "dummy.jar"), "w").close()

        run_mock.side_effect = side
        os.makedirs(plugin.sourcedir)

        plugin.build()

        run_mock.assert_has_calls([mock.call(["ant"])])
Exemple #9
0
    def test_env_proxies(self):
        env_vars = (
            ('http_proxy', 'http://localhost:3132'),
            ('https_proxy', 'http://localhost2:3133'),
        )
        for v in env_vars:
            self.useFixture(fixtures.EnvironmentVariable(v[0], v[1]))
        plugin = ant.AntPlugin('test-part', self.options, self.project_options)

        env = plugin.env(plugin.partdir)
        self.assertIn(
            "ANT_OPTS='"
            "-Dhttp.proxyHost=localhost -Dhttp.proxyPort=3132 "
            "-Dhttps.proxyHost=localhost2 -Dhttps.proxyPort=3133'", env)
Exemple #10
0
    def test_build_with_options(self):
        self.options.ant_build_targets = ["artifacts", "jar"]
        self.options.ant_properties = {"basedir": "."}

        plugin = ant.AntPlugin("test-part", self.options, self.project)

        self.create_assets(plugin)

        plugin.build()

        self.run_mock.assert_called_once_with(
            ["ant", "artifacts", "jar", "-Dbasedir=."],
            cwd=plugin.builddir,
            env=mock.ANY,
        )
Exemple #11
0
    def test_build(self, run_mock):
        plugin = ant.AntPlugin('test-part', self.options, self.project_options)

        def side(l):
            os.makedirs(os.path.join(plugin.builddir, 'target'))
            open(os.path.join(plugin.builddir, 'target', 'dummy.jar'),
                 'w').close()

        run_mock.side_effect = side
        os.makedirs(plugin.sourcedir)

        plugin.build()

        run_mock.assert_has_calls([
            mock.call(['ant']),
        ])
Exemple #12
0
    def test_build(self):
        plugin = ant.AntPlugin("test-part", self.options, self.project)

        self.create_assets(plugin)

        def side(l, **kwargs):
            os.makedirs(os.path.join(plugin.builddir, "target"))
            open(os.path.join(plugin.builddir, "target", "dummy.jar"), "w").close()

        self.run_mock.side_effect = side

        plugin.build()

        self.run_mock.assert_called_once_with(
            ["ant"], cwd=plugin.builddir, env=mock.ANY
        )
Exemple #13
0
    def test_env_proxies(self):
        env_vars = (
            ('http_proxy', 'http://*****:*****@localhost:3132'),
            ('https_proxy', 'http://*****:*****@localhost2:3133'),
        )
        for key, value in env_vars:
            self.useFixture(fixtures.EnvironmentVariable(key, value))
        plugin = ant.AntPlugin('test-part', self.options, self.project_options)

        env = plugin.env(plugin.partdir)
        self.assertIn(
            "ANT_OPTS='"
            "-Dhttp.proxyHost=localhost -Dhttp.proxyPort=3132 "
            "-Dhttp.proxyUser=user -Dhttp.proxyPassword=pass "
            "-Dhttps.proxyHost=localhost2 -Dhttps.proxyPort=3133 "
            "-Dhttps.proxyUser=user2 -Dhttps.proxyPassword=pass2'", env)
Exemple #14
0
    def test_build_with_options(self, run_mock):
        options = copy.deepcopy(self.options)
        plugin = ant.AntPlugin("test-part", options, self.project_options)
        options.ant_build_targets = ["artifacts", "jar"]
        options.ant_properties = {"basedir": ".", "dist.dir": plugin.installdir}

        os.makedirs(plugin.sourcedir)
        plugin.build()

        destination = "-Ddist.dir={}".format(plugin.installdir)
        basedir = "-Dbasedir=."
        args = run_mock.call_args[0][0]
        self.assertThat(args[0], Equals("ant"))
        self.assertThat(args[1], Equals("artifacts"))
        self.assertThat(args[2], Equals("jar"))
        self.assertIn(destination, args)
        self.assertIn(basedir, args)
Exemple #15
0
    def test_build_with_explicit_buildfile(self):
        self.options.ant_buildfile = "test.xml"

        plugin = ant.AntPlugin("test-part", self.options, self.project)

        self.create_assets(plugin)

        plugin.build()

        self.run_mock.assert_called_once_with(["ant", "-f", "test.xml"],
                                              cwd=plugin.builddir,
                                              env=mock.ANY)
        self.tar_mock.assert_called_once_with(
            ant._ANT_ARCHIVE_FORMAT_URL.format(
                version=self.options.ant_version),
            mock.ANY,
            source_checksum=self.options.ant_version_checksum,
        )
Exemple #16
0
    def test_build_env_proxies(self):
        env_vars = (
            ("http_proxy", "http://*****:*****@localhost:3132"),
            ("https_proxy", "http://*****:*****@localhost2:3133"),
        )
        for key, value in env_vars:
            self.useFixture(fixtures.EnvironmentVariable(key, value))

        plugin = ant.AntPlugin("test-part", self.options, self.project)

        env = plugin._build_environment()
        self.assertThat(env, Contains("ANT_OPTS"))
        self.assertThat(
            env["ANT_OPTS"],
            Equals("-Dhttp.proxyHost=localhost -Dhttp.proxyPort=3132 "
                   "-Dhttp.proxyUser=user -Dhttp.proxyPassword=pass "
                   "-Dhttps.proxyHost=localhost2 -Dhttps.proxyPort=3133 "
                   "-Dhttps.proxyUser=user2 -Dhttps.proxyPassword=pass2"),
        )
Exemple #17
0
    def test_build_with_options(self, run_mock):
        options = copy.deepcopy(self.options)
        plugin = ant.AntPlugin('test-part', options,
                               self.project_options)
        options.ant_build_targets = ['artifacts', 'jar']
        options.ant_properties = {'basedir': '.',
                                  'dist.dir': plugin.installdir}

        os.makedirs(plugin.sourcedir)
        plugin.build()

        destination = '-Ddist.dir={}'.format(plugin.installdir)
        basedir = '-Dbasedir=.'
        args = run_mock.call_args[0][0]
        self.assertEqual(args[0], 'ant')
        self.assertEqual(args[1], 'artifacts')
        self.assertEqual(args[2], 'jar')
        self.assertIn(destination, args)
        self.assertIn(basedir, args)
Exemple #18
0
    def test_build_with_default_snap(self):
        plugin = ant.AntPlugin("test-part", self.options, self.project)

        self.create_assets(plugin)

        def side(l, **kwargs):
            os.makedirs(os.path.join(plugin.builddir, "target"))
            open(os.path.join(plugin.builddir, "target", "dummy.jar"),
                 "w").close()

        self.run_mock.side_effect = side

        plugin.build()

        self.tar_mock.assert_not_called()
        self.run_mock.assert_called_once_with(["ant"],
                                              cwd=plugin.builddir,
                                              env=mock.ANY)
        self.assertEqual(plugin.build_snaps,
                         ["ant/" + ant._DEFAULT_ANT_SNAP_CHANNEL])
Exemple #19
0
    def test_build_with_explicit_snap(self):
        self.options.ant_channel = "other/channel"
        plugin = ant.AntPlugin("test-part", self.options, self.project)

        self.create_assets(plugin)

        def side(l, **kwargs):
            os.makedirs(os.path.join(plugin.builddir, "target"))
            open(os.path.join(plugin.builddir, "target", "dummy.jar"),
                 "w").close()

        self.run_mock.side_effect = side

        plugin.build()

        self.tar_mock.assert_not_called()
        self.run_mock.assert_called_once_with(["ant"],
                                              cwd=plugin.builddir,
                                              env=mock.ANY)
        self.assertEqual(plugin.build_snaps, ["ant/other/channel"])
Exemple #20
0
    def test_build_with_options(self):
        self.options.ant_build_targets = ["artifacts", "jar"]
        self.options.ant_properties = {"basedir": "."}

        plugin = ant.AntPlugin("test-part", self.options, self.project)

        self.create_assets(plugin)

        plugin.build()

        self.run_mock.assert_called_once_with(
            ["ant", "artifacts", "jar", "-Dbasedir=."],
            cwd=plugin.builddir,
            env=mock.ANY,
        )
        self.tar_mock.assert_called_once_with(
            ant._ANT_ARCHIVE_FORMAT_URL.format(
                version=self.options.ant_version),
            mock.ANY,
            source_checksum=self.options.ant_version_checksum,
        )
Exemple #21
0
    def test_build(self):
        plugin = ant.AntPlugin("test-part", self.options, self.project)

        self.create_assets(plugin)

        def side(l, **kwargs):
            os.makedirs(os.path.join(plugin.builddir, "target"))
            open(os.path.join(plugin.builddir, "target", "dummy.jar"),
                 "w").close()

        self.run_mock.side_effect = side

        plugin.build()

        self.run_mock.assert_called_once_with(["ant"],
                                              cwd=plugin.builddir,
                                              env=mock.ANY)
        self.tar_mock.assert_called_once_with(
            ant._ANT_ARCHIVE_FORMAT_URL.format(
                version=self.options.ant_version),
            mock.ANY,
            source_checksum=self.options.ant_version_checksum,
        )