198 checkSuccess(null, "-o", simpleJar.toString(), 199 getInputFilePath("simple.h").toString()); 200 try { 201 assertTrue(Files.isRegularFile(simpleJar)); 202 } finally { 203 deleteFile(simpleJar); 204 } 205 } 206 207 @Test 208 public void testOutputClass() { 209 Path helloJar = getOutputFilePath("hello.jar"); 210 deleteFile(helloJar); 211 Path helloH = getInputFilePath("hello.h"); 212 checkSuccess(null, "-o", helloJar.toString(), helloH.toString()); 213 try { 214 Class<?> cls = loadClass("hello", helloJar); 215 // check NativeHeader annotation 216 NativeHeader header = cls.getAnnotation(NativeHeader.class); 217 assertNotNull(header); 218 assertEquals(header.headerPath(), helloH.toString()); 219 220 // check a method for "void func()" 221 assertNotNull(findMethod(cls, "func", Object[].class)); 222 } finally { 223 deleteFile(helloJar); 224 } 225 } 226 227 private void testTargetPackage(String targetPkgOption) { 228 Path helloJar = getOutputFilePath("hello.jar"); 229 deleteFile(helloJar); 230 Path helloH = getInputFilePath("hello.h"); 231 checkSuccess(null, targetPkgOption, "com.acme", "-o", helloJar.toString(), helloH.toString()); 232 try { 233 Class<?> cls = loadClass("com.acme.hello", helloJar); 234 // check NativeHeader annotation 235 NativeHeader header = cls.getAnnotation(NativeHeader.class); 236 assertNotNull(header); 237 assertEquals(header.headerPath(), helloH.toString()); 238 239 // check a method for "void func()" 240 assertNotNull(findMethod(cls, "func", Object[].class)); 241 } finally { 242 deleteFile(helloJar); 243 } 244 } 245 246 @Test 247 public void testTargetPackageOption() { 248 testTargetPackage("-t"); 249 } 250 251 @Test 252 public void testTargetPackageLongOption() { 253 testTargetPackage("--target-package"); 254 } 255 256 private void testPackageMapping(String pkgMapOption) { 257 Path worldJar = getOutputFilePath("world.jar"); | 198 checkSuccess(null, "-o", simpleJar.toString(), 199 getInputFilePath("simple.h").toString()); 200 try { 201 assertTrue(Files.isRegularFile(simpleJar)); 202 } finally { 203 deleteFile(simpleJar); 204 } 205 } 206 207 @Test 208 public void testOutputClass() { 209 Path helloJar = getOutputFilePath("hello.jar"); 210 deleteFile(helloJar); 211 Path helloH = getInputFilePath("hello.h"); 212 checkSuccess(null, "-o", helloJar.toString(), helloH.toString()); 213 try { 214 Class<?> cls = loadClass("hello", helloJar); 215 // check NativeHeader annotation 216 NativeHeader header = cls.getAnnotation(NativeHeader.class); 217 assertNotNull(header); 218 assertEquals(header.path(), helloH.toString()); 219 assertFalse(header.declarations().isEmpty()); 220 221 // check a method for "void func()" 222 assertNotNull(findMethod(cls, "func", Object[].class)); 223 } finally { 224 deleteFile(helloJar); 225 } 226 } 227 228 private void testTargetPackage(String targetPkgOption) { 229 Path helloJar = getOutputFilePath("hello.jar"); 230 deleteFile(helloJar); 231 Path helloH = getInputFilePath("hello.h"); 232 checkSuccess(null, targetPkgOption, "com.acme", "-o", helloJar.toString(), helloH.toString()); 233 try { 234 Class<?> cls = loadClass("com.acme.hello", helloJar); 235 // check NativeHeader annotation 236 NativeHeader header = cls.getAnnotation(NativeHeader.class); 237 assertNotNull(header); 238 assertEquals(header.path(), helloH.toString()); 239 240 // check a method for "void func()" 241 assertNotNull(findMethod(cls, "func", Object[].class)); 242 } finally { 243 deleteFile(helloJar); 244 } 245 } 246 247 @Test 248 public void testTargetPackageOption() { 249 testTargetPackage("-t"); 250 } 251 252 @Test 253 public void testTargetPackageLongOption() { 254 testTargetPackage("--target-package"); 255 } 256 257 private void testPackageMapping(String pkgMapOption) { 258 Path worldJar = getOutputFilePath("world.jar"); |