NativeLibraryLoader_Test.java (2be43276) NativeLibraryLoader_Test.java (9cbd97ce)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 9 unchanged lines hidden (view full) ---

18 * under the License.
19 *
20 *************************************************************/
21
22
23
24package com.sun.star.lib.util;
25
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 9 unchanged lines hidden (view full) ---

18 * under the License.
19 *
20 *************************************************************/
21
22
23
24package com.sun.star.lib.util;
25
26import complexlib.ComplexTestCase;
27import java.io.File;
28import java.net.MalformedURLException;
29import java.net.URL;
30
26import java.io.File;
27import java.net.MalformedURLException;
28import java.net.URL;
29
31public final class NativeLibraryLoader_Test extends ComplexTestCase {
32 public String[] getTestMethodNames() {
33 return new String[] { "testEncoded", "testUnencoded" };
34 }
30import org.junit.Test;
31import static org.junit.Assert.*;
35
32
33public final class NativeLibraryLoader_Test {
34 @Test
36 public void testEncoded() throws MalformedURLException {
37 File dir = new File(System.getProperty("user.dir"));
38 File subdir = new File(dir, "with space");
39 File file1 = new File(subdir, "file");
40
41 String fileUrl = dir.toURL().toString();
42 if (!fileUrl.endsWith("/")) {
43 fileUrl += "/";
44 }
45 fileUrl += "with%20space/file";
46 final URL url = new URL(fileUrl);
47
48 File file2 = NativeLibraryLoader.getResource(
49 new ClassLoader() {
50 public URL getResource(String name) {
51 return url;
52 }
53 },
54 "dummy");
35 public void testEncoded() throws MalformedURLException {
36 File dir = new File(System.getProperty("user.dir"));
37 File subdir = new File(dir, "with space");
38 File file1 = new File(subdir, "file");
39
40 String fileUrl = dir.toURL().toString();
41 if (!fileUrl.endsWith("/")) {
42 fileUrl += "/";
43 }
44 fileUrl += "with%20space/file";
45 final URL url = new URL(fileUrl);
46
47 File file2 = NativeLibraryLoader.getResource(
48 new ClassLoader() {
49 public URL getResource(String name) {
50 return url;
51 }
52 },
53 "dummy");
55 assure("Files are equal", file2.equals(file1));
54 assertTrue("Files are equal", file2.equals(file1));
56 }
57
55 }
56
57 @Test
58 public void testUnencoded() throws MalformedURLException {
59 File dir = new File(System.getProperty("user.dir"));
60 File subdir = new File(dir, "with space");
61 File file1 = new File(subdir, "file");
62
63 String fileUrl = dir.toURL().toString();
64 if (!fileUrl.endsWith("/")) {
65 fileUrl += "/";
66 }
67 fileUrl += "with space/file";
68 final URL url = new URL(fileUrl);
69
70 File file2 = NativeLibraryLoader.getResource(
71 new ClassLoader() {
72 public URL getResource(String name) {
73 return url;
74 }
75 },
76 "dummy");
58 public void testUnencoded() throws MalformedURLException {
59 File dir = new File(System.getProperty("user.dir"));
60 File subdir = new File(dir, "with space");
61 File file1 = new File(subdir, "file");
62
63 String fileUrl = dir.toURL().toString();
64 if (!fileUrl.endsWith("/")) {
65 fileUrl += "/";
66 }
67 fileUrl += "with space/file";
68 final URL url = new URL(fileUrl);
69
70 File file2 = NativeLibraryLoader.getResource(
71 new ClassLoader() {
72 public URL getResource(String name) {
73 return url;
74 }
75 },
76 "dummy");
77 assure("Files are equal", file2.equals(file1));
77 assertTrue("Files are equal", file2.equals(file1));
78 }
79}
78 }
79}