コード例 #1
0
 /**
  * This should be called when we catch an exception after calling a dispatcher. (We should never
  * get an exception in those circumstances however....)
  *
  * @param e
  * @return
  */
 protected DispatchReturn handleUnexpectedException(Exception e) {
   RaptureException raptException =
       RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, "Unknown error", e);
   String response = BaseDispatcher.error(raptException);
   log.error(raptException.getFormattedMessage());
   Kernel.writeAuditEntry("exception", 2, e.getMessage());
   return new DispatchReturn(response);
 }
コード例 #2
0
  @Test
  public void testIllegalRepoPaths() {
    String repo = "series://";
    String docPath = repo + "x/x";

    try {
      Kernel.getSeries()
          .createSeriesRepo(ContextFactory.getKernelUser(), repo, "SERIES {} using MEMORY {}");
      fail("Cannot create a repository without an authority");
    } catch (RaptureException e) {
      assertEquals("Cannot create a repository without an authority", e.getMessage());
    }
    try {
      Kernel.getSeries()
          .createSeriesRepo(ContextFactory.getKernelUser(), "", "SERIES {} using MEMORY {}");
      fail("URI cannot be null or empty");
    } catch (RaptureException e) {
      assertEquals("Argument Repository URI cannot be null or empty", e.getMessage());
    }
    try {
      Kernel.getSeries()
          .createSeriesRepo(ContextFactory.getKernelUser(), null, "SERIES {} using MEMORY {}");
      fail("URI cannot be null or empty");
    } catch (RaptureException e) {
      assertEquals("Argument Repository URI cannot be null or empty", e.getMessage());
    }
    try {
      Kernel.getSeries()
          .createSeriesRepo(ContextFactory.getKernelUser(), docPath, "SERIES {} using MEMORY {}");
      fail("Repository Uri can't have a document path component");
    } catch (RaptureException e) {
      assertEquals("A Repository URI may not have a document path component", e.getMessage());
    }
  }
コード例 #3
0
  @Before
  public void setup() {
    sdf.setTimeZone(new SimpleTimeZone(0, "GMT"));
    sdf.applyPattern("dd MMM yyyy HH:mm:ss z");

    CallingContext ctx = ContextFactory.getKernelUser();

    try {
      Kernel.initBootstrap(null, null, true);

      Kernel.getPipeline().getTrusted().registerServerCategory(ctx, "alpha", "Primary servers");
      Kernel.getPipeline().getTrusted().registerServerCategory(ctx, "beta", "Secondary servers");

      Kernel.getPipeline().registerExchangeDomain(ctx, "//main", "EXCHANGE {} USING MEMORY {}");

      RaptureExchange exchange = new RaptureExchange();
      exchange.setName("kernel");
      exchange.setExchangeType(RaptureExchangeType.FANOUT);
      exchange.setDomain("main");

      List<RaptureExchangeQueue> queues = new ArrayList<RaptureExchangeQueue>();
      RaptureExchangeQueue queue = new RaptureExchangeQueue();
      queue.setName("default");
      queue.setRouteBindings(new ArrayList<String>());
      queues.add(queue);

      exchange.setQueueBindings(queues);

      Kernel.getPipeline().getTrusted().registerPipelineExchange(ctx, "kernel", exchange);
      Kernel.getPipeline().getTrusted().bindPipeline(ctx, "alpha", "kernel", "default");
      Kernel.setCategoryMembership("alpha");

    } catch (RaptureException e) {
      e.printStackTrace();
    }
  }