@Test public void bind_to_specific_address() { Properties p = new Properties(); p.setProperty("sonar.web.port", "9000"); p.setProperty("sonar.web.host", "1.2.3.4"); TomcatConnectors.configure(tomcat, new Props(p)); verify(tomcat.getService()) .addConnector(argThat(c -> c.getScheme().equals("http") && c.getPort() == 9000 && ((InetAddress) c.getProperty("address")).getHostAddress().equals("1.2.3.4"))); }
@Test public void bind_to_all_addresses_by_default() { Properties p = new Properties(); p.setProperty("sonar.web.port", "9000"); TomcatConnectors.configure(tomcat, new Props(p)); verify(tomcat.getService()).addConnector(argThat(c -> c.getScheme().equals("http") && c.getPort() == 9000 && ((InetAddress) c.getProperty("address")).getHostAddress().equals("0.0.0.0"))); }
private void verifyHttpConnector(int expectedPort, Map<String, Object> expectedProps) { verify(tomcat.getService()).addConnector(argThat(c -> { if (!c.getScheme().equals("http")) { return false; } if (!c.getProtocol().equals(TomcatConnectors.HTTP_PROTOCOL)) { return false; } if (c.getPort() != expectedPort) { return false; } for (Map.Entry<String, Object> expectedProp : expectedProps.entrySet()) { if (!expectedProp.getValue().equals(c.getProperty(expectedProp.getKey()))) { return false; } } return true; })); } }
/** * Return a property from the protocol handler. * * @param name the property name * @return the property value */ public Object getAttribute(String name) { return getProperty(name); }
/** * Return a configured property. */ public Object getAttribute(String name) { return getProperty(name); }
/** * Return a configured property. */ public Object getAttribute(String name) { return getProperty(name); }
/** * Return a configured property. */ public Object getAttribute(String name) { return getProperty(name); }
/** * Return a configured property. */ public Object getAttribute(String name) { return getProperty(name); }
/** * Return a configured property. */ public Object getAttribute(String name) { return getProperty(name); }
/** * Return a configured property. */ public Object getAttribute(String name) { return getProperty(name); }
/** * @return the port number on which this connector is listening to requests. * If the special value for {@link #getPort} of zero is used then this method * will report the actual port bound. */ public int getLocalPort() { return ((Integer) getProperty("localPort")).intValue(); }
/** * Return the port number on which this connector is listening to requests. * If the special value for {@link #port} of zero is used then this method * will report the actual port bound. */ public int getLocalPort() { return ((Integer) getProperty("localPort")).intValue(); }
/** * @return the port number on which this connector is listening to requests. * If the special value for {@link #getPort} of zero is used then this method * will report the actual port bound. */ public int getLocalPort() { return ((Integer) getProperty("localPort")).intValue(); }
/** * Return the maximum number of headers that are allowed by the container. A * value of less than 0 means no limit. */ public int getMaxHeaderCount() { return ((Integer) getProperty("maxHeaderCount")).intValue(); }
/** * Return the port number on which this connector is listening to requests. * If the special value for {@link #port} of zero is used then this method * will report the actual port bound. */ public int getLocalPort() { return ((Integer) getProperty("localPort")).intValue(); }
/** * Return the maximum number of headers that are allowed by the container. A * value of less than 0 means no limit. */ public int getMaxHeaderCount() { return ((Integer) getProperty("maxHeaderCount")).intValue(); }
protected ObjectName createSipConnectorObjectName(Connector connector, String domain, String type) throws MalformedObjectNameException { String encodedAddr = null; if (connector.getProperty("address") != null) { encodedAddr = URLEncoder.encode(connector.getProperty("address").toString()); } String addSuffix = (connector.getProperty("address") == null) ? "" : ",address=" + encodedAddr; ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port=" + connector.getPort() + ",transport=" + connector.getProperty("transport") + addSuffix); return _oname; }
protected ObjectName createSipConnectorObjectName(Connector connector, String domain, String type) throws MalformedObjectNameException { String encodedAddr = null; if (connector.getProperty("address") != null) { encodedAddr = URLEncoder.encode(connector.getProperty("address").toString()); } String addSuffix = (connector.getProperty("address") == null) ? "" : ",address=" + encodedAddr; ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port=" + connector.getPort() + ",transport=" + connector.getProperty("transport") + addSuffix); return _oname; }
protected ObjectName createObjectName(String domain, String type) throws MalformedObjectNameException { String encodedAddr = null; if (getProperty("address") != null) { encodedAddr = URLEncoder.encode(getProperty("address").toString()); } String addSuffix = (getProperty("address") == null) ? "" : ",address=" + encodedAddr; ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port=" + getPort() + addSuffix); return _oname; }
protected ObjectName createObjectName(String domain, String type) throws MalformedObjectNameException { String encodedAddr = null; if (getAddress() != null) { encodedAddr = URLEncoder.encode(getProperty("address")); } String addSuffix = (getAddress() == null) ? "" : ",address=" + encodedAddr; ObjectName _oname = new ObjectName(domain + ":type=" + type + ",port=" + getPort() + addSuffix); return _oname; }