Package by.stub.exception

Examples of by.stub.exception.Stubby4JException


      if (StringUtils.isSet(foundStubResponse.getLatency())) {
         try {
            final long latency = Long.parseLong(foundStubResponse.getLatency());
            TimeUnit.MILLISECONDS.sleep(latency);
         } catch (final InterruptedException e) {
            throw new Stubby4JException(e);
         }
      }

      response.setStatus(Integer.parseInt(foundStubResponse.getStatus()));
      response.setHeader(HttpHeaders.LOCATION, foundStubResponse.getHeaders().get("location"));
View Full Code Here


      if (StringUtils.isSet(foundStubResponse.getLatency())) {
         try {
            final long latency = Long.parseLong(foundStubResponse.getLatency());
            TimeUnit.MILLISECONDS.sleep(latency);
         } catch (final InterruptedException e) {
            throw new Stubby4JException(e);
         }
      }
      response.setStatus(Integer.parseInt(foundStubResponse.getStatus()));

      final byte[] responseBody = foundStubResponse.getResponseBody();
View Full Code Here

   public static String getHtmlResourceByName(final String templateSuffix) {
      final String htmlTemplatePath = String.format("/ui/html/templates/%s.html", templateSuffix);
      final InputStream inputStream = HandlerUtils.class.getResourceAsStream(htmlTemplatePath);
      if (inputStream == null) {
         throw new Stubby4JException(String.format("Could not find resource %s", htmlTemplatePath));
      }
      return StringUtils.inputStreamToString(inputStream);
   }
View Full Code Here

      } catch (final ParseException ex) {
         final String msg =
               String.format("Could not parse provided command line arguments, error: %s",
                     ex.toString());

         throw new Stubby4JException(msg);
      }
   }
View Full Code Here

      final String msg =
            String.format("YAML data was not provided using command line option '--%s'. %s"
                  + "To see all command line options run again with option '--%s'",
                  CommandLineIntepreter.OPTION_CONFIG, "\n", CommandLineIntepreter.OPTION_HELP);

      throw new Stubby4JException(msg);
   }
View Full Code Here

      } catch (final Exception ex) {
         final String msg =
               String.format("Could not init stubby4j, error: %s", ex.toString());

         throw new Stubby4JException(msg, ex);
      }
   }
View Full Code Here

            final SSLContext defaultSslContext = SSLContext.getInstance("TLS");
            defaultSslContext.init(new KeyManager[0], new TrustManager[]{new DefaultTrustManager()}, new SecureRandom());
            SSLContext.setDefault(defaultSslContext);
            HttpsURLConnection.setDefaultSSLSocketFactory(defaultSslContext.getSocketFactory());
         } catch (final Exception ex) {
            throw new Stubby4JException(ex.toString(), ex);
         }

         return sslFactory;
      }
View Full Code Here

   }

   HttpURLConnection constructHttpConnection() throws IOException {

      if (!isMethodSupported(clientHttpRequest.getMethod())) {
         throw new Stubby4JException(String.format("HTTP method '%s' not supported when contacting stubby4j", clientHttpRequest.getMethod()));
      }

      final URL url = new URL(constructUrlFromClientRequest());
      final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
View Full Code Here

   private void relaxSslTrustManager() {
      try {
         new FakeX509TrustManager().allowAllSSL();
      } catch (final Exception ex) {
         throw new Stubby4JException(ex.toString(), ex);
      }
   }
View Full Code Here

      if (StringUtils.isSet(foundStubResponse.getLatency())) {
         try {
            final long latency = Long.parseLong(foundStubResponse.getLatency());
            TimeUnit.MILLISECONDS.sleep(latency);
         } catch (final InterruptedException e) {
            throw new Stubby4JException(e);
         }
      }
      response.setStatus(Integer.parseInt(foundStubResponse.getStatus()));
      response.getWriter().println(foundStubResponse.getResponseBody());
   }
View Full Code Here

TOP

Related Classes of by.stub.exception.Stubby4JException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.