def test_classpath_with_glob(self): with tempfile.TemporaryDirectory() as temp_dir: try: # Avoid having to prefix everything in our test strings. oldwd = os.getcwd() os.chdir(temp_dir) # Touch some files for globing. with open('a1.jar', 'w') as _: pass service = JavaJarExpansionService( 'main.jar', classpath=['a*.jar', 'b.jar']) self.assertEqual( service._default_args(), ['{{PORT}}', '--filesToStage=main.jar,a1.jar,b.jar']) finally: os.chdir(oldwd)
def get_expansion_service(jar="/usr/local/lib/beam-chapter6-1.0.0.jar", args=None): if args == None: args = [ "--defaultEnvironmentType=PROCESS", "--defaultEnvironmentConfig={\"command\": \"/opt/apache/beam/boot\"}", "--experiments=use_deprecated_read" ] return JavaJarExpansionService(jar, ['{{PORT}}'] + args)
def test_classpath_with_url(self, local_jar): def _side_effect_fn(path): return path[path.rindex('/') + 1:] local_jar.side_effect = _side_effect_fn with tempfile.TemporaryDirectory() as temp_dir: try: # Avoid having to prefix everything in our test strings. oldwd = os.getcwd() os.chdir(temp_dir) service = JavaJarExpansionService( 'main.jar', classpath=['https://dummy_path/dummyjar.jar']) self.assertEqual( service._default_args(), ['{{PORT}}', '--filesToStage=main.jar,dummyjar.jar']) finally: os.chdir(oldwd)
def test_maven_central_classpath(self): with tempfile.TemporaryDirectory() as temp_dir: try: # Avoid having to prefix everything in our test strings. oldwd = os.getcwd() os.chdir(temp_dir) # Touch some files for globing. with open('a1.jar', 'w') as _: pass service = JavaJarExpansionService( 'main.jar', classpath=[ 'a*.jar', 'b.jar', 'org.postgresql:postgresql:42.2.16' ]) self.assertEqual(service._default_args(), [ '{{PORT}}', '--filesToStage=main.jar,a1.jar,b.jar,' 'https://repo.maven.apache.org/maven2/org/' 'postgresql/postgresql/42.2.16/postgresql-42.2.16.jar' ]) finally: os.chdir(oldwd)