Ejemplo n.º 1
0
 def java_home_exe(self):
   with distribution(executables=EXE('bin/java', version='1')) as jdk1_home:
     with distribution(executables=EXE('bin/java', version='2')) as jdk2_home:
       with temporary_file() as osx_java_home_exe:
         osx_java_home_exe.write(textwrap.dedent("""
               #!/bin/sh
               echo '<?xml version="1.0" encoding="UTF-8"?>
               <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
                                      "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
               <plist version="1.0">
               <array>
                 <dict>
                   <key>JVMHomePath</key>
                   <string>{jdk1_home}</string>
                 </dict>
                 <dict>
                   <key>JVMHomePath</key>
                   <string>{jdk2_home}</string>
                 </dict>
               </array>
               </plist>
               '
             """.format(jdk1_home=jdk1_home, jdk2_home=jdk2_home)).strip())
         osx_java_home_exe.close()
         chmod_plus_x(osx_java_home_exe.name)
         locator = _Locator(_UnknownEnvironment(_EnvVarEnvironment(),
                                                _OSXEnvironment(osx_java_home_exe.name)))
         yield locator, jdk1_home, jdk2_home
Ejemplo n.º 2
0
 def java_home_exe(self):
     with distribution(
             executables=EXE("bin/java", version="1")) as jdk1_home:
         with distribution(
                 executables=EXE("bin/java", version="2")) as jdk2_home:
             with temporary_file(binary_mode=False) as osx_java_home_exe:
                 osx_java_home_exe.write(
                     textwrap.dedent("""
                         #!/bin/sh
                         echo '<?xml version="1.0" encoding="UTF-8"?>
                         <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
                                                "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
                         <plist version="1.0">
                         <array>
                           <dict>
                             <key>JVMHomePath</key>
                             <string>{jdk1_home}</string>
                           </dict>
                           <dict>
                             <key>JVMHomePath</key>
                             <string>{jdk2_home}</string>
                           </dict>
                         </array>
                         </plist>
                         '
                         """.format(jdk1_home=jdk1_home,
                                    jdk2_home=jdk2_home)).strip())
                 osx_java_home_exe.close()
                 chmod_plus_x(osx_java_home_exe.name)
                 locator = _Locator(
                     _UnknownEnvironment(
                         _EnvVarEnvironment(),
                         _OSXEnvironment(osx_java_home_exe.name)))
                 yield locator, jdk1_home, jdk2_home
Ejemplo n.º 3
0
 def locator(self):
   with distribution(executables=EXE('bin/java', version='1')) as jdk1_home:
     with distribution(executables=EXE('bin/java', version='2')) as jdk2_home:
       with temporary_dir() as java_dist_dir1, temporary_dir() as java_dist_dir2:
         locator = _Locator(_UnknownEnvironment(_EnvVarEnvironment(),
                                                _LinuxEnvironment(java_dist_dir1, java_dist_dir2)))
         jdk1_home_link = os.path.join(java_dist_dir1, 'jdk1_home')
         jdk2_home_link = os.path.join(java_dist_dir2, 'jdk2_home')
         os.symlink(jdk1_home, jdk1_home_link)
         os.symlink(jdk2_home, jdk2_home_link)
         yield locator, jdk1_home_link, jdk2_home_link
Ejemplo n.º 4
0
 def locator(self):
   with distribution(executables=EXE('bin/java', version='1')) as jdk1_home:
     with distribution(executables=EXE('bin/java', version='2')) as jdk2_home:
       with temporary_dir() as java_dist_dir1, temporary_dir() as java_dist_dir2:
         locator = _Locator(_UnknownEnvironment(_EnvVarEnvironment(),
                                                _LinuxEnvironment(java_dist_dir1, java_dist_dir2)))
         jdk1_home_link = os.path.join(java_dist_dir1, 'jdk1_home')
         jdk2_home_link = os.path.join(java_dist_dir2, 'jdk2_home')
         os.symlink(jdk1_home, jdk1_home_link)
         os.symlink(jdk2_home, jdk2_home_link)
         yield locator, jdk1_home_link, jdk2_home_link
Ejemplo n.º 5
0
 def locator(self):
     with temporary_dir() as java_dist_dir1, temporary_dir() as java_dist_dir2, distribution(
         executables=EXE("bin/java", version="1"), dist_dir=java_dist_dir1
     ) as jdk1_home, distribution(
         executables=EXE("bin/java", version="2"), dist_dir=java_dist_dir2
     ) as jdk2_home:
         locator = _Locator(
             _UnknownEnvironment(
                 _EnvVarEnvironment(), _LinuxEnvironment(java_dist_dir1, java_dist_dir2)
             )
         )
         yield locator, jdk1_home, jdk2_home
Ejemplo n.º 6
0
 def test_locate_java_home_cache_uses_lub(self):
     # NB this ensures that looking into the cache follows a consistent ordering
     # it looks up min=1, min=3, which puts both dists into the cache
     # then it looks for min=1;max=3. Because traversing the cached dists goes lowest first,
     # it finds 1.
     with temporary_dir() as dist_dir, distribution(
         executables=EXE("bin/java", version="1"), dist_dir=dist_dir
     ) as jdk1_home, distribution(
         executables=EXE("bin/java", version="3"), dist_dir=dist_dir
     ) as jdk3_home:
         locator = _Locator(
             _UnknownEnvironment(_EnvVarEnvironment(), _LinuxEnvironment(dist_dir))
         )
         with env(JAVA_HOME=jdk1_home):
             dist = locator.locate(minimum_version="1")
             self.assertEqual(jdk1_home, dist.home)
             dist = locator.locate(minimum_version="3")
             self.assertEqual(jdk3_home, dist.home)
             dist = locator.locate(minimum_version="1", maximum_version="3")
             self.assertEqual(jdk1_home, dist.home)
Ejemplo n.º 7
0
 def setUp(self):
     super().setUp()
     self.locator = _Locator(_EnvVarEnvironment())
Ejemplo n.º 8
0
 def setUp(self):
     super(DistributionEnvLocationTest, self).setUp()
     self.locator = _Locator(_EnvVarEnvironment())
Ejemplo n.º 9
0
 def setUp(self):
   super(DistributionEnvLocationTest, self).setUp()
   self.locator = _Locator(_EnvVarEnvironment())