// Path: java/src/main/java/net/razorvine/pyro/PyroException.java
// public class PyroException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 5164514665621511957L;
// 	public String _pyroTraceback;
// 	public String pythonExceptionType;
// 
// 	public PyroException() {
// 		super();
// 	}
// 
// 	public PyroException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public PyroException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: java/src/main/java/net/razorvine/pyro/PyroURI.java
// public class PyroURI implements Serializable {
// 
// 	private static final long serialVersionUID = -7611447798373262153L;
// 	public String protocol = "PYRO";
// 	public String objectid;
// 	public String host;
// 	public int port;
// 
// 	public PyroURI() {
// 	}
// 
// 	public PyroURI(PyroURI other) {
// 		protocol = other.protocol;
// 		objectid = other.objectid;
// 		host = other.host;
// 		port = other.port;
// 	}
// 
// 	public PyroURI(String uri) {
// 		Matcher m = Pattern.compile("(PYRO[A-Z]*):(\\S+?)(@(\\S+))?$").matcher(uri);
// 		if (m.find()) {
// 			protocol = m.group(1);
// 			objectid = m.group(2);
// 			String location = m.group(4);
// 			if(location.charAt(0)=='[') {
// 				// ipv6
// 				if(location.startsWith("[["))
// 					throw new PyroException("invalid ipv6 address: enclosed in too many brackets");
// 				Matcher ipv6locationmatch = Pattern.compile("\\[([0-9a-fA-F:%]+)](:(\\d+))?").matcher(location);
// 				if(ipv6locationmatch.matches()) {
// 					host = ipv6locationmatch.group(1);
// 					port = Integer.parseInt(ipv6locationmatch.group(3));
// 				} else {
// 					throw new PyroException("invalid ipv6 address: the part between brackets must be a numeric ipv6 address");
// 				}
// 			} else {
// 				// regular ipv4
// 				String[] loc = location.split(":");
// 				host = loc[0];
// 				port = Integer.parseInt(loc[1]);
// 			}
// 		} else {
// 			throw new PyroException("invalid URI string");
// 		}
// 	}
// 
// 	public PyroURI(String objectid, String host, int port) {
// 		this.objectid = objectid;
// 		this.host = host;
// 		this.port = port;
// 	}
// 
// 	public String toString() {
// 		return "<PyroURI " + protocol + ":" + objectid + "@" + host + ":" + port + ">";
// 	}
// 
// 
// 	@Override
// 	public int hashCode() {
// 		return toString().hashCode();
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (this == obj)
// 			return true;
// 		if (obj == null)
// 			return false;
// 		if (!(obj instanceof PyroURI))
// 			return false;
// 		PyroURI other = (PyroURI) obj;
// 		return toString().equals(other.toString());
// 	}
// }


import net.razorvine.pyro.PyroException;
import net.razorvine.pyro.PyroURI;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
		assertEquals("PYRO", uricopy.protocol);

		uri = new PyroURI("objectname", "hostname", 1234);
		assertEquals(1234, uri.port);
		assertEquals("hostname", uri.host);
		assertEquals("objectname", uri.objectid);
		assertEquals("PYRO", uri.protocol);
	}

	@Test
	public void TestIpv6() throws IOException {
		PyroURI uri = new PyroURI("PYRO:objectname@[::1]:1234");
		assertEquals(1234, uri.port);
		assertEquals("::1", uri.host);
		assertEquals("objectname", uri.objectid);
		assertEquals("PYRO", uri.protocol);

		PyroURI uricopy = new PyroURI(uri);
		assertEquals(1234, uricopy.port);
		assertEquals("::1", uricopy.host);
		assertEquals("objectname", uricopy.objectid);
		assertEquals("PYRO", uricopy.protocol);

		uri = new PyroURI("objectname", "::1", 1234);
		assertEquals(1234, uri.port);
		assertEquals("::1", uri.host);
		assertEquals("objectname", uri.objectid);
		assertEquals("PYRO", uri.protocol);

		assertThrows(PyroException.class, () -> new PyroURI("PYRO:objectname@[[::1]]:1234"));
// Path: java/src/main/java/net/razorvine/pyro/PyroException.java
// public class PyroException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 5164514665621511957L;
// 	public String _pyroTraceback;
// 	public String pythonExceptionType;
// 
// 	public PyroException() {
// 		super();
// 	}
// 
// 	public PyroException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public PyroException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: java/src/main/java/net/razorvine/pyro/PyroURI.java
// public class PyroURI implements Serializable {
// 
// 	private static final long serialVersionUID = -7611447798373262153L;
// 	public String protocol = "PYRO";
// 	public String objectid;
// 	public String host;
// 	public int port;
// 
// 	public PyroURI() {
// 	}
// 
// 	public PyroURI(PyroURI other) {
// 		protocol = other.protocol;
// 		objectid = other.objectid;
// 		host = other.host;
// 		port = other.port;
// 	}
// 
// 	public PyroURI(String uri) {
// 		Matcher m = Pattern.compile("(PYRO[A-Z]*):(\\S+?)(@(\\S+))?$").matcher(uri);
// 		if (m.find()) {
// 			protocol = m.group(1);
// 			objectid = m.group(2);
// 			String location = m.group(4);
// 			if(location.charAt(0)=='[') {
// 				// ipv6
// 				if(location.startsWith("[["))
// 					throw new PyroException("invalid ipv6 address: enclosed in too many brackets");
// 				Matcher ipv6locationmatch = Pattern.compile("\\[([0-9a-fA-F:%]+)](:(\\d+))?").matcher(location);
// 				if(ipv6locationmatch.matches()) {
// 					host = ipv6locationmatch.group(1);
// 					port = Integer.parseInt(ipv6locationmatch.group(3));
// 				} else {
// 					throw new PyroException("invalid ipv6 address: the part between brackets must be a numeric ipv6 address");
// 				}
// 			} else {
// 				// regular ipv4
// 				String[] loc = location.split(":");
// 				host = loc[0];
// 				port = Integer.parseInt(loc[1]);
// 			}
// 		} else {
// 			throw new PyroException("invalid URI string");
// 		}
// 	}
// 
// 	public PyroURI(String objectid, String host, int port) {
// 		this.objectid = objectid;
// 		this.host = host;
// 		this.port = port;
// 	}
// 
// 	public String toString() {
// 		return "<PyroURI " + protocol + ":" + objectid + "@" + host + ":" + port + ">";
// 	}
// 
// 
// 	@Override
// 	public int hashCode() {
// 		return toString().hashCode();
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (this == obj)
// 			return true;
// 		if (obj == null)
// 			return false;
// 		if (!(obj instanceof PyroURI))
// 			return false;
// 		PyroURI other = (PyroURI) obj;
// 		return toString().equals(other.toString());
// 	}
// }


// Path: java/src/test/java/net/razorvine/pyro/test/URITest.java
import net.razorvine.pyro.PyroException;
import net.razorvine.pyro.PyroURI;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;

		assertEquals("PYRO", uricopy.protocol);

		uri = new PyroURI("objectname", "hostname", 1234);
		assertEquals(1234, uri.port);
		assertEquals("hostname", uri.host);
		assertEquals("objectname", uri.objectid);
		assertEquals("PYRO", uri.protocol);
	}

	@Test
	public void TestIpv6() throws IOException {
		PyroURI uri = new PyroURI("PYRO:objectname@[::1]:1234");
		assertEquals(1234, uri.port);
		assertEquals("::1", uri.host);
		assertEquals("objectname", uri.objectid);
		assertEquals("PYRO", uri.protocol);

		PyroURI uricopy = new PyroURI(uri);
		assertEquals(1234, uricopy.port);
		assertEquals("::1", uricopy.host);
		assertEquals("objectname", uricopy.objectid);
		assertEquals("PYRO", uricopy.protocol);

		uri = new PyroURI("objectname", "::1", 1234);
		assertEquals(1234, uri.port);
		assertEquals("::1", uri.host);
		assertEquals("objectname", uri.objectid);
		assertEquals("PYRO", uri.protocol);

		assertThrows(PyroException.class, () -> new PyroURI("PYRO:objectname@[[::1]]:1234"));
		assertThrows(PyroException.class, () -> new PyroURI("PYRO:objectname@[invalid-ipv6]:1234"));