Java 8 ConnectException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ConnectException class.

This code example shows how to use the following methods:
	@Test 
	public void shouldReportServerInTimeoutExceptionMessage() throws FileNotFoundException, OpenShiftException, IOException { 
		try { 
			// pre-conditions 
			mockDirector.mockGetAPI( 
					new HttpClientException(new ConnectException("java.net.ConnectException: Connection timed out"))); 
			// operation 
			new TestConnectionFactory().getConnection(clientMock); 
			// verification 
			fail("exception expected"); 
		} catch (OpenShiftEndpointException e) { 
			// verification 
			assertThat(e.getMessage()).contains("https://"); 
		} 
	} 
 
	@Test 
	public void shouldThrowWithTextAndExistCode() throws Throwable { 
			// pre-conditions 
		try { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage
        20000); 
      socket.close();
      fail("Should not have connected"); 
    } catch (ConnectException ce) {
      System.err.println("Got exception: " + ce);
      assertTrue(ce.getMessage().contains("resulted in a loopback"));
    } catch (SocketException se) {
      // Some TCP stacks will actually throw their own Invalid argument exception 
      // here. This is also OK. 
      assertTrue(se.getMessage().contains("Invalid argument"));
    } 
  } 
   
  @Test 
  public void testSocketReadTimeoutWithChannel() throws Exception { 
    doSocketReadTimeoutTest(true); 
  } 
   
  @Test 
  public void testSocketReadTimeoutWithoutChannel() throws Exception { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
     * http://cwiki.apache.org/confluence/display/MAVEN/ConnectException 
     * </p> 
     */ 
    public void testJdk7ipv6() 
    { 
        ConnectException connEx = new ConnectException( "Connection refused: connect" );
        IOException ioEx = new IOException( "Unable to establish loopback connection" );
        ioEx.initCause( connEx );
        MojoExecutionException mojoEx =
            new MojoExecutionException( "Error executing Jetty: Unable to establish loopback connection", ioEx );
 
        ExceptionHandler exceptionHandler = new DefaultExceptionHandler();
        ExceptionSummary exceptionSummary = exceptionHandler.handleException( mojoEx );
 
        String expectedReference = "http://cwiki.apache.org/confluence/display/MAVEN/ConnectException";
        assertEquals( expectedReference, exceptionSummary.getReference() );
 
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    // daemon is down, so we'll treat it like connection refused. 
    if (socket.getLocalPort() == socket.getPort() &&
        socket.getLocalAddress().equals(socket.getInetAddress())) {
      LOG.info("Detected a loopback TCP socket, disconnecting it");
      socket.close();
      throw new ConnectException(
        "Localhost targeted connection resulted in a loopback. " + 
        "No daemon is listening on the target port."); 
    } 
  } 
   
  /**  
   * Given a string representation of a host, return its ip address 
   * in textual presentation. 
   *  
   * @param name a string representation of a host: 
   *             either a textual representation its IP address or its host name 
   * @return its IP address in the string format 
   */ 
  public static String normalizeHostName(String name) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage
        try { 
 
            converter = new JodConverter();
 
        } catch (ConnectException e) {
            logger.error("Error creating JodConverter - " + e.getMessage(), e);
            throw new RODAServiceException("Error creating JodConverter - " 
                    + e.getMessage(), e);
        } 
    } 
 
    /** 
     * 
     * 
     * @throws ConverterException 
     * 
     * @see SynchronousConverter#convert(RepresentationObject) 
     */ 
    public ConversionResult convert(RepresentationObject representation)
            throws RepresentationAlreadyConvertedException, 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage
        20000); 
      socket.close();
      fail("Should not have connected"); 
    } catch (ConnectException ce) {
      System.err.println("Got exception: " + ce);
      assertTrue(ce.getMessage().contains("resulted in a loopback"));
    } 
  } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
			conn.setReadTimeout(1000);
			conn.connect();
			return DefaultSaxParser.parse(conn.getInputStream());
		} catch (Exception e) {
			m_logger.warn(String.format("Read cmdb failed [%s]", url), e);
			throw new ConnectException(String.format("Read cmdb failed [%s]", url));
		} 
	} 
 
	@Override 
	public void enableLogging(Logger logger) { 
		m_logger = logger; 
	} 
 
	@Override 
	public List<Device> getDevices(String name) throws ConnectException {
		List<Device> devices = new ArrayList<Device>();
		if (name != null && name.trim().length() > 0) {
			String cmdbQuery = String.format(m_configManager.getCmdbBaseUrl(),
					String.format("/s?q=app:%s&fl=private_ip,status,rd_duty,env", name.trim()));
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:e, getMessage, printStackTrace
		examService.setVTAgetnt(vTAgent);
		try { 
			gateway.execute(messageListener);
 
		} catch (ConnectException ce) {
			ce.printStackTrace();
			Log.e(TAG, ce.getMessage(), ce);
		} catch (Exception e1) {
			e1.printStackTrace();
			Log.e(TAG, e1.getMessage(), e1);
		} 
 
	} 
 
	public void onDisconnected() { 
		Log.i(TAG, "Disconnected from JADE container");
 
	} 
 
	public void onTerminate() { 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage, printStackTrace
		     "TestApplication"); 
      conn.close();
    } 
 
    catch (ConnectException e){
      Log.writeToLog(e.getMessage(),"TestApplication");
      e.printStackTrace();
    } 
    catch (UnknownHostException e){
      Log.writeToLog(e.getMessage(),"TestApplication");
      e.printStackTrace();
    } 
    catch (IOException e){
      Log.writeToLog(e.getMessage(),"TestApplication");
      e.printStackTrace();
    } 
 
    System.out.println("CLIENT TEST FINISHED");
    Log.writeToLog("CLIENT TEST FINISHED","TestApplication"); 
  } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
    public void testInterceptConnectionException() throws Exception { 
        IMocksControl mcClient = org.easymock.classextension.EasyMock.createControl();
        XmlRpcClient client = mcClient.createMock(XmlRpcClient.class);
        client.execute(anyRequest());
        mcClient.andThrow(new ConnectException("test"));
        mcClient.replay();
 
        XmlRpcClientInterceptor interceptor = new XmlRpcClientInterceptor();
        interceptor.setServiceInterface(TestFunctions.class);
        interceptor.setXmlRpcClient(client);
 
        TestFunctions proxy = (TestFunctions) ProxyFactory.getProxy(TestFunctions.class,
                interceptor);
 
        try { 
            proxy.multiplyTest("x", 5);
            fail("Should throw exception");
        } catch (XmlRpcRemoteException e) {
            assertEquals(0, e.getFaultCode());
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 ConnectException Questions & Answers:

See Code Examples for Java 8 ConnectException Methods: