@Test public void shouldDetermineTheProtocolOfAHttpURL() { String testUrl = "http: assertThat(determineProtocol(testUrl)).isEqualTo(Protocol.HTTP); }
static Protocol determineProtocol(String server) { checkNotNull(server); String[] splitServer = server.split(":"); Protocol protocol = Protocol.HTTPS; if (splitServer.length > 1) { String port = splitServer[1]; String protocolInTheUrl = splitServer[0].toLowerCase(); if (splitServer[1].startsWith(" if (Objects.equal(protocolInTheUrl, "http")) return Protocol.HTTP; else if (Objects.equal(protocolInTheUrl, "https")) return Protocol.HTTPS; port = splitServer[2]; } if (!"443".equals(port)) { protocol = Protocol.HTTP; } } return protocol; }
Util { static Protocol determineProtocol(String server) { checkNotNull(server); String[] splitServer = server.split(":"); Protocol protocol = Protocol.HTTPS; if (splitServer.length > 1) { String port = splitServer[1]; String protocolInTheUrl = splitServer[0].toLowerCase(); if (splitServer[1].startsWith(" if (Objects.equal(protocolInTheUrl, "http")) return Protocol.HTTP; else if (Objects.equal(protocolInTheUrl, "https")) return Protocol.HTTPS; port = splitServer[2]; } if (!"443".equals(port)) { protocol = Protocol.HTTP; } } return protocol; } }
Util { static Protocol determineProtocol(String server) { checkNotNull(server); String[] splitServer = server.split(":"); Protocol protocol = Protocol.HTTPS; if (splitServer.length > 1) { String port = splitServer[1]; String protocolInTheUrl = splitServer[0].toLowerCase(); if (splitServer[1].startsWith(" if (Objects.equal(protocolInTheUrl, "http")) return Protocol.HTTP; else if (Objects.equal(protocolInTheUrl, "https")) return Protocol.HTTPS; port = splitServer[2]; } if (!"443".equals(port)) { protocol = Protocol.HTTP; } } return protocol; } private  Util(); }
Util { static Protocol determineProtocol(String server) { checkNotNull(server); String[] splitServer = server.split(":"); Protocol protocol = Protocol.HTTPS; if (splitServer.length > 1) { String port = splitServer[1]; String protocolInTheUrl = splitServer[0].toLowerCase(); if (splitServer[1].startsWith(" if (Objects.equal(protocolInTheUrl, "http")) return Protocol.HTTP; else if (Objects.equal(protocolInTheUrl, "https")) return Protocol.HTTPS; port = splitServer[2]; } if (!"443".equals(port)) { protocol = Protocol.HTTP; } } return protocol; } private  Util();  }
Util { static Protocol determineProtocol(String server) { checkNotNull(server); String[] splitServer = server.split(":"); Protocol protocol = Protocol.HTTPS; if (splitServer.length > 1) { String port = splitServer[1]; String protocolInTheUrl = splitServer[0].toLowerCase(); if (splitServer[1].startsWith(" if (Objects.equal(protocolInTheUrl, "http")) return Protocol.HTTP; else if (Objects.equal(protocolInTheUrl, "https")) return Protocol.HTTPS; port = splitServer[2]; } if (!"443".equals(port)) { protocol = Protocol.HTTP; } } return protocol; } private  Util();   }