private static final String GIT_SCHEME = "git://";
+ @Test
+ public void shouldRaiseErrorOnEmptyURI() throws Exception {
+ try {
+ new URIish("");
+ fail("expecting an exception");
+ } catch (URISyntaxException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void shouldRaiseErrorOnNullURI() throws Exception {
+ try {
+ new URIish((String) null);
+ fail("expecting an exception");
+ } catch (URISyntaxException e) {
+ // expected
+ }
+ }
+
@Test
public void testUnixFile() throws Exception {
final String str = "/home/m y";
import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.util.StringUtils;
/**
* This URI like construct used for referencing Git archives over the net, as
* @throws URISyntaxException
*/
public URIish(String s) throws URISyntaxException {
+ if (StringUtils.isEmptyOrNull(s)) {
+ throw new URISyntaxException("The uri was empty or null",
+ JGitText.get().cannotParseGitURIish);
+ }
Matcher matcher = SINGLE_SLASH_FILE_URI.matcher(s);
if (matcher.matches()) {
scheme = matcher.group(1);
private StringUtils() {
// Do not create instances
}
+
+ /**
+ * Test if a string is empty or null.
+ *
+ * @param stringValue
+ * the string to check
+ * @return <code>true</code> if the string is <code>null</code> or empty
+ */
+ public static boolean isEmptyOrNull(String stringValue) {
+ return stringValue == null || stringValue.length() == 0;
+ }
}