@NotNull public static P4ServerName forPortNotNull(@Nullable final String portText) { P4ServerName ret = forPort(portText); if (ret == null) { ret = new P4ServerName("unknown server", IServerAddress.Protocol.P4JAVA); } return ret; }
public MockConfigPart withServerName(String s) { serverName = P4ServerName.forPort(s); return this; }
@Nullable @Override public P4ServerName getServerName() { return P4ServerName.forPort(trimmedProperty(PORT_KEY)); }
@Test void forPort_null() { assertThat(P4ServerName.forPort(null), nullValue()); }
@SuppressWarnings("SameParameterValue") @NotNull private static String portName(@NotNull String serverName) { return Objects.requireNonNull(P4ServerName.forPort(serverName)).getDisplayName(); } }
password = props.getProperty("P4PASSWD"); rawPort = props.getProperty("P4PORT"); serverName = P4ServerName.forPort(rawPort); tickets = toFile(props.getProperty("P4TICKETS")); trust = toFile(props.getProperty("P4TRUST"));
P4ServerName serverName = P4ServerName.forPort(dataInput.readUTF()); assert serverName != null;
@Test void forPort_justPort() { P4ServerName name = P4ServerName.forPort("1667"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(false)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTS)); assertThat("port", name.getServerPort(), is("localhost:1667")); assertThat("display", name.getDisplayName(), is("localhost:1667")); assertThat("url", name.getUrl(), is("p4jrpcnts://localhost:1667")); assertThat("full port", name.getFullPort(), is("localhost:1667")); assertThat("protocol name", name.getProtocolName(), is("java")); }
@Test void forPort_simpleProtocolPort() { P4ServerName name = P4ServerName.forPort("tcp:host:1234"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(false)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTS)); assertThat("port", name.getServerPort(), is("host:1234")); assertThat("display", name.getDisplayName(), is("host:1234")); assertThat("url", name.getUrl(), is("p4jrpcnts://host:1234")); assertThat("full port", name.getFullPort(), is("host:1234")); assertThat("protocol name", name.getProtocolName(), is("java")); }
@Test void forPort_hostPort() { P4ServerName name = P4ServerName.forPort("host:1234"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(false)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTS)); assertThat("port", name.getServerPort(), is("host:1234")); assertThat("display", name.getDisplayName(), is("host:1234")); assertThat("url", name.getUrl(), is("p4jrpcnts://host:1234")); assertThat("full port", name.getFullPort(), is("host:1234")); assertThat("protocol name", name.getProtocolName(), is("java")); }
@Test void forPort_ssl() { P4ServerName name = P4ServerName.forPort("ssl://host:1234"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(true)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTSSSL)); assertThat("port", name.getServerPort(), is("host:1234")); assertThat("display", name.getDisplayName(), is("ssl:host:1234")); assertThat("url", name.getUrl(), is("p4jrpcntsssl://host:1234")); assertThat("full port", name.getFullPort(), is("ssl://host:1234")); assertThat("protocol name", name.getProtocolName(), is("ssl")); }
@ExtendWith(TemporaryFolderExtension.class) @Test void forPort_rsh(TemporaryFolder tmpDir) { // This is what the TestServer uses as the protocol. String port = "p4jrsh://" + tmpDir.newFile("p4d").getAbsolutePath() + " -r " + tmpDir.newFile("root").getAbsolutePath() + ' ' + " -L log -i --java"; P4ServerName name = P4ServerName.forPort(port); assertNotNull(name); assertThat(name.getServerProtocol(), is(IServerAddress.Protocol.P4JRSHNTS)); }
@Override public boolean reload() { try { rawPort = readRegString(PerforceEnvironment.P4PORT); serverName = P4ServerName.forPort(rawPort); clientName = readRegString(PerforceEnvironment.P4CLIENT); userName = readRegString(PerforceEnvironment.P4USER); password = decodePassword(readRegString(PerforceEnvironment.P4PASSWD)); authTicketPath = readRegString(PerforceEnvironment.P4TICKETS); trustTicket = readRegString(PerforceEnvironment.P4TRUST); configFile = readRegString(PerforceEnvironment.P4CONFIG); enviroFile = readRegString(PerforceEnvironment.P4ENVIRO); clientHostname = readRegString(PerforceEnvironment.P4HOST); ignoreFileName = readRegString(PerforceEnvironment.P4IGNORE); charset = readRegString(PerforceEnvironment.P4CHARSET); loginSso = readRegString("P4LOGINSSO"); if (LOG.isDebugEnabled()) { Map<String, String> props = ConfigPropertiesUtil.toProperties( this, "<unset>", "<empty encodedPassword>", "<encodedPassword>"); props.put(PerforceEnvironment.P4CONFIG, configFile); props.put(PerforceEnvironment.P4ENVIRO, enviroFile); LOG.debug("Loaded windows registry " + keys[0] + " " + props); } } catch (IllegalAccessException | InvocationTargetException e) { // Do not mark as an actual problem. This is a JVM incompatible issue. LOG.debug("Could not access Windows registry", e); } return hasError(); }
@Test void createFrom_empty() { ServerConfig sc = ServerConfig.createFrom( new MockConfigPart() .withUsername("username") .withServerName("servername") ); assertEquals(P4ServerName.forPort("servername"), sc.getServerName()); assertEquals("username", sc.getUsername()); assertNull(sc.getServerFingerprint()); assertNull(sc.getAuthTicket()); assertNull(sc.getTrustTicket()); assertNull(sc.getLoginSso()); assertThat(sc.getConfigVersion(), greaterThan(0)); assertFalse(sc.hasServerFingerprint()); assertFalse(sc.hasAuthTicket()); assertFalse(sc.hasTrustTicket()); assertFalse(sc.hasLoginSso()); assertFalse(sc.usesStoredPassword()); assertEquals("localhost:servername" + SEP + "username" + SEP + "null" + SEP + "null" + SEP + "null", sc.getServerId()); }
assertTrue(part.hasError()); assertTrue(part.hasServerNameSet()); assertEquals(P4ServerName.forPort("abc"), part.getServerName()); assertTrue(part.hasClientnameSet()); assertEquals("client1", part.getClientname());
assertEquals(P4ServerName.forPort("abc"), part.getServerName()); assertTrue(part.hasClientnameSet()); assertEquals("client1", part.getClientname());