Example #1
0
 public Attachment getBytesFromUrlWithoutError() {
   try {
     final URL url = new URL("http://localhost:8080/junittest/validoutput"); // $NON-NLS-1$
     return new Attachment(url);
   } catch (final MalformedURLException e) {
     Nop.reason("do nothing"); // $NON-NLS-1$
   } catch (final IOException e) {
     Nop.reason("do nothing"); // $NON-NLS-1$
   }
   return null;
 }
Example #2
0
 public Attachment getBytesFromUrlWithError() {
   try {
     return new Attachment(
         new URL("http://localhost:8080/junittest/errorinthemiddle")); // $NON-NLS-1$
   } catch (final MalformedURLException e) {
     Nop.reason("do nothing"); // $NON-NLS-1$
   } catch (final IOException e) {
     Nop.reason("do nothing"); // $NON-NLS-1$
   }
   return null;
 }
Example #3
0
  /** {@inheritDoc} */
  public Attachment getBytesFromInvalidUrl() throws IOException {
    try {
      // intentionally a invalid port
      return new Attachment(
          new URL("http://localhost:24444/unittest/errorinthemiddle")); // $NON-NLS-1$
    } catch (final MalformedURLException e) {
      Nop.reason("do nothing"); // $NON-NLS-1$
    }

    return null;
  }
Example #4
0
 public Attachment getBytesFromUrlWithErrorAtStart() {
   try {
     final URL url = new URL("http://localhost:20080/"); // $NON-NLS-1$
     final HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
     if (httpConn.getResponseCode() > 399) {
       final String errorMsg = "no error msg"; // $NON-NLS-1$
       if (httpConn.getErrorStream().available() > 0) {
         final byte[] buffer = new byte[httpConn.getErrorStream().available()];
         httpConn.getErrorStream().read(buffer, 0, buffer.length);
       }
       throw new RuntimeException(
           "rc=" + httpConn.getResponseCode() + " msg=" + errorMsg); // $NON-NLS-1$ //$NON-NLS-2$
     }
     return new Attachment(url);
   } catch (final IOException e) {
     Nop.reason("do nothing"); // $NON-NLS-1$
   }
   return null;
 }
Example #5
0
 public void unwire(final Object bean, final BundleContext context) {
   Nop.reason("May be overridden."); // $NON-NLS-1$
 }