here")
- .toString();
- }
-
- @RequestMapping(value = "/willitconnect")
- public String connect(@RequestParam("host") String host,
- @RequestParam ("port") int port) {
- if (Connection.checkConnection(host, port))
- return "I can connect to " + host + " on " + port;
- return "I cannot connect to " + host + " on " + port;
- }
-
- //TODO: refactor to remove code duplication
- @RequestMapping(value = "/willitconnectproxy")
- public String proxyConnect(@RequestParam("host") String host,
- @RequestParam ("port") int port,
- @RequestParam("proxyHost") String proxyHost,
- @RequestParam ("proxyPort") int proxyPort) {
- if (Connection.checkProxyConnection(
- host, port, proxyHost, proxyPort, "http"))
- return "I can connect to " + host + " on " + port;
- return "I cannot connect to " + host + " on " + port;
- }
-
- @RequestMapping(value = "/serviceresults", method = RequestMethod.GET)
- public @ResponseBody List getServiceResults() {
- return this.vcapServicesChecker.getConnectionResults();
- }
-
- @RequestMapping(value = "/proxy", method = RequestMethod.PUT)
- public void proxy(@RequestParam("proxy") String proxy,
- @RequestParam("proxyPort") int proxyPort,
- @RequestParam("proxyType") String proxyType)
- {
- vcapServicesChecker.setProxy(proxy, proxyPort, proxyType);
- }
-}
diff --git a/src/main/java/willitconnect/service/VcapServicesChecker.java b/src/main/java/willitconnect/service/VcapServicesChecker.java
deleted file mode 100644
index e8560f35..00000000
--- a/src/main/java/willitconnect/service/VcapServicesChecker.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package willitconnect.service;
-
-import org.apache.log4j.Logger;
-import org.json.JSONObject;
-import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
-import willitconnect.model.CheckedEntry;
-import willitconnect.service.util.EntryConsumer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Checks VCAP_SERVICES for keys named host and values that look like URI's
- */
-@Service
-public class VcapServicesChecker {
- private String proxy;
- private String proxyType;
- private int proxyPort;
- private JSONObject vcapServices;
- private Logger log = Logger.getLogger(VcapServicesChecker.class);
- private EntryChecker checker;
-
- public List getConnectionResults() {
- return results;
- }
-
- public VcapServicesChecker(JSONObject vcapServices) {
- log.info("Creating service checker with " + vcapServices);
- this.vcapServices = vcapServices;
- checker = new EntryChecker(new RestTemplate());
- initialize();
- }
-
- private ArrayList results;
-
- private void parse() {
- java.util.Objects.requireNonNull(vcapServices);
-
- if (0 == vcapServices.length())
- return;
-
- vcapServices.keys().forEachRemaining(new EntryConsumer(results,
- vcapServices));
- }
-
- private void check() {
- results.forEach(e -> checkEntry(e));
- }
-
- public void checkEntry(CheckedEntry e) {
- if ( null != proxy ) {
- e.setHttpProxy(proxy + ":" + proxyPort);
- }
- checker.check(e);
- }
-
- private boolean hasProxy() {
- return null != getProxy();
- }
-
- public void setProxy(String proxy, int port, String proxyType) {
- this.proxy = proxy;
- this.proxyPort = port;
- this.proxyType = proxyType;
- // validate connection status with proxy set
- initialize();
- }
-
- public void unSetProxy() {
- this.proxy = null;
- this.proxyPort = 0;
- this.proxyType = null;
- // validate connection with proxy removed
- initialize();
- }
-
- private void initialize() {
- results = new ArrayList<>();
- this.parse();
- this.check();
- }
-
- public String getProxy() {
- return proxy;
- }
-
- public String getProxyType() {
- return proxyType;
- }
-}
diff --git a/src/main/java/willitconnect/service/util/EntryConsumer.java b/src/main/java/willitconnect/service/util/EntryConsumer.java
deleted file mode 100644
index 99b2be06..00000000
--- a/src/main/java/willitconnect/service/util/EntryConsumer.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package willitconnect.service.util;
-
-import org.apache.log4j.Logger;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.springframework.core.io.support.ResourcePatternUtils;
-import willitconnect.model.CheckedEntry;
-
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.List;
-import java.util.function.Consumer;
-import java.util.stream.IntStream;
-
-import static willitconnect.service.util.HostMatcher.hasPort;
-import static willitconnect.service.util.HostMatcher.isHost;
-
-public class EntryConsumer implements Consumer {
- private Logger log = Logger.getLogger(EntryConsumer.class);
- private final JSONObject vcapServices;
- private final List entries;
-
- public EntryConsumer(List entries, JSONObject vcapServices) {
- this.entries = entries;
- this.vcapServices = vcapServices;
- }
-
- @Override
- public void accept(String key) {
- if (isHost(key)) {
- String hostname = vcapServices.optString(key);
- if (!hasPort(hostname))
- hostname += ":" + getPort();
- addNewEntry(hostname);
- return;
- } else if (isUrl(key) || isUri(key) || isJSONObject(key) || isJSONArray(key))
- {
- return;
- }
- }
-
- private boolean isUrl(String key) {
- if (!ResourcePatternUtils.isUrl(vcapServices.optString(key))) {
-
- return false;
- }
- try {
- URL url = new URL(vcapServices.getString(key));
- int port = url.getPort() == -1 ? url.getDefaultPort() : url.getPort();
- addNewEntry(url.getHost() + ":" + port);
- } catch (MalformedURLException e) {
- log.error("Malformed URL -- How did we get here?");
- return false;
- }
- return true;
- }
-
- private boolean isUri(String key) {
- if (!key.toLowerCase().contains("uri")
- && !key.toLowerCase().contains("syslog_drain_url")) {
- return false;
- }
-
- try {
- URI url = new URI(vcapServices.optString(key));
- addNewEntry(url.getHost() + ":" + url.getPort());
- } catch (URISyntaxException e) {
- log.error("Malformed URL -- How did we get here?");
- return false;
- }
- return true;
- }
-
- private int getPort() {
- int port = -1;
- if ( vcapServices.has("port") ) {
- String portAsAString = vcapServices.optString("port");
- if ( null != portAsAString ) {
- port = Integer.parseInt(portAsAString);
- }
- }
- return port;
- }
-
- private boolean isJSONArray(String key) {
- JSONArray array = vcapServices.optJSONArray(key);
- if (null == array) return false;
-
- IntStream.range(0, array.length())
- .filter(i -> array.optJSONObject(i) != null)
- .forEach(i -> array.getJSONObject(i).keys().forEachRemaining(
- new EntryConsumer(entries, array.getJSONObject(i))));
- return true;
- }
-
- private boolean isJSONObject(String key) {
- JSONObject possibleObject = vcapServices.optJSONObject(key);
- if ( null != possibleObject ) {
- possibleObject.keys().forEachRemaining(
- new EntryConsumer(entries, possibleObject));
- return true;
- }
- return false;
- }
-
- private void addNewEntry(String host) {
- //TODO: cleaner way to do this?
- if(!(host.equals("null:-1"))) {
- CheckedEntry entry;
- log.info("Entry To Add == " + host);
- entry = new CheckedEntry(host);
- entries.add(entry);
- }
- }
-}
diff --git a/src/test/java/willitconnect/config/VcapServicesCheckerConfigTest.java b/src/test/java/willitconnect/config/VcapServicesCheckerConfigTest.java
deleted file mode 100644
index 2fc7dc57..00000000
--- a/src/test/java/willitconnect/config/VcapServicesCheckerConfigTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package willitconnect.config;
-
-import org.junit.Test;
-import willitconnect.service.VcapServicesChecker;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasSize;
-
-public class VcapServicesCheckerConfigTest {
-
- /**
- * WARNING!
- * This test assumes you don't have VCAP_SERVICES set in your
- * environment when running it!
- */
- @Test
- public void itHandlesANullVcapServices() {
- VcapServicesCheckerConfig config = new VcapServicesCheckerConfig();
- VcapServicesChecker checker = config.vcapServicesChecker();
- assertThat(checker.getConnectionResults(), hasSize(0));
-
- }
-}
\ No newline at end of file
diff --git a/src/test/java/willitconnect/controller/WillItConnectControllerTest.java b/src/test/java/willitconnect/controller/WillItConnectControllerTest.java
deleted file mode 100644
index 03760381..00000000
--- a/src/test/java/willitconnect/controller/WillItConnectControllerTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package willitconnect.controller;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.springframework.http.MediaType;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import willitconnect.model.CheckedEntry;
-import willitconnect.service.VcapServicesChecker;
-import willitconnect.service.util.Connection;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.is;
-import static org.mockito.Mockito.verify;
-import static org.powermock.api.mockito.PowerMockito.when;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-public class WillItConnectControllerTest {
-
- private MockMvc mockMvc;
-
- @Mock
- VcapServicesChecker checker;
-
- @PrepareForTest(Connection.class)
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mockMvc = MockMvcBuilders.standaloneSetup(
- new WillItConnectController(checker)).build();
- }
-
- @Test
- public void resultsShouldReturnEmptyJsonWithNoServices() throws Exception {
- when(checker.getConnectionResults()).thenReturn(new ArrayList<>());
-
- mockMvc.perform(get("/serviceresults").accept(MediaType.APPLICATION_JSON))
- .andExpect(jsonPath("$").isArray())
- .andExpect(jsonPath("$", hasSize(0)));
- }
-
- @Test
- public void resultsShouldContainOneServiceWithVcapServices() throws Exception{
- List entryList = new ArrayList<>();
- entryList.add(new CheckedEntry("foo"));
- entryList.add(new CheckedEntry("bar"));
-
- when(checker.getConnectionResults()).thenReturn(entryList);
-
- mockMvc.perform(get("/serviceresults").accept(MediaType
- .APPLICATION_JSON))
- .andExpect(jsonPath("$").isArray())
- .andExpect(jsonPath("$", hasSize(2)))
- // It's false because we default everything to false before
- // parsing
- .andExpect(jsonPath("$[0].canConnect", is(false)));
- }
-
- @Test
- public void itSavesAProxy() throws Exception {
- mockMvc.perform(put("/proxy")
- .param("proxy", "proxy.example.com")
- .param("proxyPort", "80")
- .param("proxyType", "http")
- ).andExpect(status().isOk());
-
- verify(checker).setProxy("proxy.example.com", 80, "http");
- }
-}
\ No newline at end of file
diff --git a/src/test/java/willitconnect/service/VcapServicesCheckerTest.java b/src/test/java/willitconnect/service/VcapServicesCheckerTest.java
deleted file mode 100644
index b1dbaf29..00000000
--- a/src/test/java/willitconnect/service/VcapServicesCheckerTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package willitconnect.service;
-
-import org.json.JSONObject;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-import willitconnect.model.CheckedEntry;
-import willitconnect.service.util.Connection;
-
-import java.sql.Date;
-import java.time.Instant;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.times;
-import static org.powermock.api.mockito.PowerMockito.*;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(Connection.class)
-public class VcapServicesCheckerTest {
-
- VcapServicesChecker checker;
-
- @Test(expected = NullPointerException.class)
- public void itShouldComplainAboutNullVcapServices() {
- new VcapServicesChecker(null);
- }
-
- @Test
- public void itShouldNotComplainAboutEmptyVcapServices() {
- JSONObject services = new JSONObject();
- new VcapServicesChecker(services);
- }
-
- @Test
- public void itShouldFindTwoHostnamesToCheck() {
-
- checker = new VcapServicesChecker(
- new JSONObject(VcapServicesStrings.cleardb));
-
- List shouldBeASingleHostName = checker.getConnectionResults();
- assertThat(shouldBeASingleHostName, hasSize(2));
- assertThat(shouldBeASingleHostName.get(0).getEntry(),
- is(equalTo("us-cdbr-iron-east-02.cleardb.net:3306")));
- assertThat(shouldBeASingleHostName.get(1).getEntry(),
- is(equalTo("us-cdbr-iron-east-02.cleardb.net:3306")));
- }
-
- @Test
- public void itShouldCheckOnlyValidHostnames() {
- String json = "{ a: [{'hostname':'a.com:80'},{'hostname':'e.com'}]}";
- checker = new VcapServicesChecker(new JSONObject(json));
- assertThat(checker.getConnectionResults().get(0).getLastChecked(),
- is(not(equalTo(Date.from(Instant.EPOCH)))));
- assertThat(checker.getConnectionResults().get(1).getLastChecked(),
- is(equalTo(Date.from(Instant.EPOCH))));
- }
-
- @Test
- public void validHostsReceiveAConnectionCheck() {
- mockStatic(Connection.class);
- when(Connection.checkConnection("a.com", 80)).thenReturn(true);
-
- String json = "{ a: [{'hostname':'a.com:80'},{'hostname':'e.com'}]}";
- checker = new VcapServicesChecker(new JSONObject(json));
- checker.getConnectionResults();
-
- verifyStatic(times(1));
- Connection.checkConnection("a.com", 80);
- }
-
- @Test
- public void successfulConnectionsAreReflectedInTheResultsSet() {
- mockStatic(Connection.class);
- when(Connection.checkConnection("a.com", 80)).thenReturn(true);
- when(Connection.checkProxyConnection(anyString(), anyInt(),
- anyString(), anyInt(), anyString())).thenThrow(
- new IllegalArgumentException());
-
- String json = "{ a: [{'hostname':'a.com:80'},{'hostname':'e.com'}]}";
- checker = new VcapServicesChecker(new JSONObject(json));
-
- assertTrue(checker.getConnectionResults().get(0).canConnect());
- assertFalse(checker.getConnectionResults().get(1).canConnect());
-
- }
-
- @Test
- public void itShouldHandleAnEmptyVcapServices() {
- checker = new VcapServicesChecker(new JSONObject("{}"));
- assertThat(checker.getConnectionResults(), hasSize(0));
- }
-
- @Test
- public void itShouldHandleAFullVcapServices() {
- checker = new VcapServicesChecker(
- new JSONObject("{ VCAP_SERVICES: " + VcapServicesStrings.cleardb + "}"));
- assertThat(checker.getConnectionResults(), hasSize(2));
- }
-
- @Test
- public void itUsesAHttpProxy() {
- String json = "{ a: [{'hostname':'a.com:80'}]}";
- checker = new VcapServicesChecker(new JSONObject(json));
-
- mockStatic(Connection.class);
- when(Connection.checkProxyConnection("a.com", 80, "proxy.com", 80,
- "http"))
- .thenReturn(true);
- when(Connection.checkConnection(anyString(), anyInt())).thenThrow(new
- IllegalArgumentException());
-
- checker.setProxy("proxy.com", 80, "http");
- assertTrue(checker.getConnectionResults().get(0).canConnect());
- }
-
- @Test
- public void itRemovesAHttpProxy() {
- String json = "{ a: [{'hostname':'a.com:80'}]}";
- checker = new VcapServicesChecker(new JSONObject(json));
- checker.setProxy("proxy.com", 80, "http");
-
- mockStatic(Connection.class);
- when(Connection.checkConnection("a.com", 80))
- .thenReturn(true);
- when(Connection.checkProxyConnection(anyString(), anyInt(), anyString(), anyInt(), anyString())).thenThrow(new
- IllegalArgumentException());
-
- checker.unSetProxy();
-
- assertTrue(checker.getConnectionResults().get(0).canConnect());
- }
-
-}
diff --git a/src/test/java/willitconnect/service/VcapServicesStrings.java b/src/test/java/willitconnect/service/VcapServicesStrings.java
deleted file mode 100644
index c39bf002..00000000
--- a/src/test/java/willitconnect/service/VcapServicesStrings.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package willitconnect.service;
-
-public class VcapServicesStrings {
- public static String cleardb="{'cleardb': [{'credentials': " +
- "{" +
- "'hostname':'us-cdbr-iron-east-02.cleardb.net'," +
- "'jdbcUrl': 'jdbc:mysql://us-cdbr-iron-east-02.cleardb.net/ad_d0a5bca8ed4c8e2?user=bcecef672208bf\u0026password=fd270135'," +
- "'name': 'ad_d0a5bca8ed4c8e2'," +
- "'password': 'fd270135'," +
- "'port': '3306'," +
- "'uri': 'mysql://bcecef672208bf:fd270135@us-cdbr-iron-east-02.cleardb.net:3306/ad_d0a5bca8ed4c8e2?reconnect=true'," +
- "'username': 'bcecef672208bf'" +
- "}," +
- "'label': 'cleardb'," +
- "'name': 'hellodb'," +
- "'plan': 'spark'," +
- "'tags': ['Data Stores','Data Store','relational','mysql']" +
- "}]}";
- public static String empty = "{}";
-}
diff --git a/src/test/java/willitconnect/service/util/EntryConsumerTest.java b/src/test/java/willitconnect/service/util/EntryConsumerTest.java
deleted file mode 100644
index dfe9c74a..00000000
--- a/src/test/java/willitconnect/service/util/EntryConsumerTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-package willitconnect.service.util;
-
-import org.json.JSONObject;
-import org.junit.Test;
-import willitconnect.model.CheckedEntry;
-import willitconnect.service.VcapServicesStrings;
-
-import java.util.ArrayList;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class EntryConsumerTest {
- ArrayList entries = new ArrayList();
-
- @Test
- public void itShouldFindOneHostnameToCheckInASimpleObject() {
- JSONObject services = new JSONObject("{ 'hostname': 'example.com:1212' }");
- EntryConsumer consumer = new EntryConsumer(entries, services);
- consumer.accept("hostname");
- String shouldBeAHostName = entries.get(0).getEntry();
-
- assertThat(entries, hasSize(1));
- assertThat(shouldBeAHostName, is(equalTo("example.com:1212")));
- }
-
- @Test
- public void itFindsAnObjectWithAHostnameInAnArray() {
- JSONObject services = new JSONObject(
- "{a:[{'hostname':'example.com:1000'},'foo'," +
- "{'hostname':'example2.com:1000'}]}");
- EntryConsumer consumer = new EntryConsumer(entries, services);
- consumer.accept("a");
-
- String shoudlBeExampleDotCom = entries.get(0).getEntry();
- assertThat(entries, hasSize(2));
- assertThat(shoudlBeExampleDotCom, is(equalTo("example.com:1000")));
- }
-
- @Test
- public void itShouldFindTwoHostnamesToCheck() {
- EntryConsumer consumer =
- new EntryConsumer(
- entries, new JSONObject(VcapServicesStrings.cleardb));
- consumer.accept("cleardb");
-
- String shouldBeAHostName = entries.get(0).getEntry();
-
- assertThat(entries, hasSize(2));
- assertThat(shouldBeAHostName,
- is(equalTo("us-cdbr-iron-east-02.cleardb.net:3306")));
- }
-
- @Test
- public void itShouldBeInvalidIfAHostnameDoesNotHaveAPort() {
- EntryConsumer consumer = new EntryConsumer(entries,
- new JSONObject("{a:[{'hostname':'example.com'}]}"));
-
- consumer.accept("a");
-
- CheckedEntry shouldNotBeValid = entries.get(0);
- assertFalse(shouldNotBeValid.isValidHostname());
- }
-
- @Test
- public void itShouldBeValidIfTheHostnameHasAPort() {
- EntryConsumer consumer = new EntryConsumer(entries,
- new JSONObject("{a:[{'hostname':'example:8212'}]}"));
-
- consumer.accept("a");
-
- CheckedEntry shouldBeValid = entries.get(0);
- assertTrue(shouldBeValid.isValidHostname());
- }
-
- @Test
- public void itShouldBeValidIfTheFQDNHasAPort() {
- EntryConsumer consumer = new EntryConsumer(entries,
- new JSONObject("{a:[{'hostname':'foo.example.com:8212'}]}"));
-
- consumer.accept("a");
- CheckedEntry shouldBeValid = entries.get(0);
- assertTrue(shouldBeValid.isValidHostname());
-
- }
-
- @Test
- public void itShouldProduceAHostWithAPortWhenItIsPartOfTheKey() {
- EntryConsumer consumer = new EntryConsumer(entries,
- new JSONObject("{a:[{'hostname':'foo.example.com:8212'}]}"));
-
- consumer.accept("a");
- CheckedEntry shouldHavePort = entries.get(0);
- assertTrue(shouldHavePort.getEntry().matches(".*:\\d+"));
- }
-
- @Test
- public void itShouldProduceAHostWIthAPortWhenThePortIsAPeerToTheHostname() {
- EntryConsumer consumer = new EntryConsumer(entries,
- new JSONObject("{a:[{'hostname':'foo.example.com', " +
- "'port': 3210}]}"));
-
- consumer.accept("a");
- CheckedEntry shouldHavePort = entries.get(0);
- String port = getPort(shouldHavePort);
- assertEquals(port, "3210");
- assertTrue(shouldHavePort.getEntry().matches(".*:\\d+"));
- assertTrue(shouldHavePort.isValidHostname());
- }
-
- private String getPort(CheckedEntry shouldHavePort) {
- return shouldHavePort.getEntry().substring(shouldHavePort.getEntry()
- .length() - 4);
- }
-
- @Test
- public void itGetsThePortCorrectlyWhenItsAString() {
- EntryConsumer consumer = new EntryConsumer(entries,
- new JSONObject("{a:[{'hostname':'foo.example.com', " +
- "'port': '3210'}]}"));
-
- consumer.accept("a");
- CheckedEntry shouldHavePort = entries.get(0);
- String port = getPort(shouldHavePort);
- assertEquals(port, "3210");
- assertTrue(shouldHavePort.getEntry().matches(".*:\\d+"));
- assertTrue(shouldHavePort.isValidHostname());
- }
-
- @Test
- public void itShouldAcceptAUrl() {
- EntryConsumer consumer = new EntryConsumer(entries,
- new JSONObject("{a:[{'url':'http://foo.example.com:3210'}]}"));
- consumer.accept("a");
- CheckedEntry shouldBeValid = entries.get(0);
- assertTrue(shouldBeValid.isValidHostname());
- String entry = shouldBeValid.getEntry();
- String port = entry.substring(entry.length() - 4);
- assertEquals("3210", port);
- }
-
- @Test
- public void itShouldAcceptAUrlWithoutAPort() {
- EntryConsumer consumer = new EntryConsumer(entries,
- new JSONObject("{a:[{'url':'http://foo.example.com'}]}"));
- consumer.accept("a");
- CheckedEntry shouldBeValid = entries.get(0);
- assertTrue(shouldBeValid.isValidHostname());
- String entry = shouldBeValid.getEntry();
- String port = entry.substring(entry.length() - 2);
- assertEquals("80", port);
- }
-
- @Test
- public void itHandlesAMySQLUri() {
- EntryConsumer consumer = new EntryConsumer(
- entries, new JSONObject(
- "{a: [{'uri': 'mysql://bcecef672208bf:fd270135@us-cdbr-iron" +
- "-east-02.cleardb" +
- ".net:3306/ad_d0a5bca8ed4c8e2?reconnect=true'}]}"));
-
- consumer.accept("a");
- CheckedEntry shouldBeValid = entries.get(0);
- }
-
- @Test
- public void itHandlesASyslogUrl() {
- EntryConsumer consumer = new EntryConsumer(
- entries, new JSONObject(
- "{a: [{'syslog_drain_url': 'syslog://papertrailapp.com:12434'}]}"));
-
- consumer.accept("a");
- CheckedEntry shouldBeValid = entries.get(0);
-
- }
-
-}
diff --git a/wercker.yml b/wercker.yml
index df6ad252..f49e6d37 100644
--- a/wercker.yml
+++ b/wercker.yml
@@ -32,6 +32,5 @@ deploy:
- script:
name: smoke test
code: |
- curl -v -i willitconnect-smoke-test.cfapps.io/willitconnect -d host=amazon.com -d port=80 | grep -v cannot
curl -v -i willitconnect-smoke-test.cfapps.io/v2/willitconnect -d '{"target":"http://amazon.com"}' -H "Content-Type: application/json" | grep 200
curl -v -i willitconnect-smoke-test.cfapps.io/v2/willitconnect -H "Content-Type: application/json" -d '{"target":"http://google.com", "http_proxy":"http-proxy-postnecrotic-complaint.cfapps.io:80"}'
\ No newline at end of file
diff --git a/willitconnect.iml b/willitconnect.iml
new file mode 100644
index 00000000..bb53d0ff
--- /dev/null
+++ b/willitconnect.iml
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file