Lines 40-62
Link Here
|
40 |
package org.netbeans.spi.java.project.support; |
40 |
package org.netbeans.spi.java.project.support; |
41 |
|
41 |
|
42 |
import java.io.File; |
42 |
import java.io.File; |
43 |
import java.io.FileOutputStream; |
|
|
44 |
import java.io.FileWriter; |
45 |
import java.io.IOException; |
46 |
import java.io.Writer; |
47 |
import java.net.URL; |
43 |
import java.net.URL; |
48 |
import java.util.zip.CRC32; |
44 |
import java.util.regex.Matcher; |
49 |
import java.util.zip.ZipEntry; |
|
|
50 |
import java.util.zip.ZipOutputStream; |
51 |
import org.netbeans.junit.NbTestCase; |
45 |
import org.netbeans.junit.NbTestCase; |
52 |
import org.openide.filesystems.FileObject; |
46 |
import org.openide.filesystems.FileObject; |
53 |
import org.openide.filesystems.FileUtil; |
47 |
import org.openide.filesystems.FileUtil; |
54 |
import org.openide.filesystems.URLMapper; |
48 |
import org.openide.filesystems.URLMapper; |
55 |
import org.openide.filesystems.test.TestFileUtils; |
49 |
import org.openide.filesystems.test.TestFileUtils; |
56 |
|
50 |
|
57 |
/** |
|
|
58 |
* |
59 |
*/ |
60 |
public class JavadocAndSourceRootDetectionTest extends NbTestCase { |
51 |
public class JavadocAndSourceRootDetectionTest extends NbTestCase { |
61 |
|
52 |
|
62 |
public JavadocAndSourceRootDetectionTest(String testName) { |
53 |
public JavadocAndSourceRootDetectionTest(String testName) { |
Lines 110-113
Link Here
|
110 |
assertEquals(lib.getFileObject("a-library-version-1.0/docs/api"), javadocRoot); |
101 |
assertEquals(lib.getFileObject("a-library-version-1.0/docs/api"), javadocRoot); |
111 |
} |
102 |
} |
112 |
|
103 |
|
|
|
104 |
public void testParsing() throws Exception { |
105 |
assertParse("/**\n * Some license here\n */\n\npackage foo;\n\npublic class Foo {}\n", false, "foo"); |
106 |
assertParse("package foo;", false, "foo"); |
107 |
assertParse("package foo; ", false, "foo"); |
108 |
assertParse("/**/package foo;", false, "foo"); |
109 |
assertParse("/***/package foo;", false, "foo"); |
110 |
assertParse("/*****/package foo;", false, "foo"); |
111 |
// would like to test stack overflow from #154894, but never managed to reproduce it in a unit test (only in standalone j2seproject) |
112 |
} |
113 |
private void assertParse(String text, boolean packageInfo, String expectedPackage) { |
114 |
Matcher m = (packageInfo ? JavadocAndSourceRootDetection.PACKAGE_INFO : JavadocAndSourceRootDetection.JAVA_FILE).matcher(text); |
115 |
assertEquals("Misparse of:\n" + text, expectedPackage, m.matches() ? m.group(1) : null); |
116 |
} |
117 |
|
113 |
} |
118 |
} |