Package org.apache.shindig.gadgets

Examples of org.apache.shindig.gadgets.GadgetException


  }

  @Test
  public void testNextFetchThrowsGadgetException() throws Exception {
    serviceProvider.setThrow(
        new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, "mildly wrong"));
    MakeRequestClient client = makeNonSocialClient("owner", "owner", GADGET_URL);
    HttpResponse response = client.sendGet(FakeOAuthServiceProvider.ACCESS_TOKEN_URL);
    assertEquals("MISSING_SERVER_RESPONSE", response.getMetadata().get("oauthError"));
    assertEquals("", response.getResponseAsString());
    String oauthErrorText = response.getMetadata().get("oauthErrorText");
View Full Code Here


  public void loadUriInlineFetcherFailure() throws Exception {
    Uri uri = Uri.parse("http://apache.org/resource.js");
    Map<String, String> attribs = Maps.newHashMap();
    attribs.put("inline", "true");
    expect(fetcher.fetch(eq(new HttpRequest(uri))))
        .andThrow(new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT));
    replay(fetcher);
    FeatureResource resource = loader.load(uri, attribs);
    assertNull(resource.getContent());
    assertNull(resource.getDebugContent());
    assertFalse(resource.isProxyCacheable());
View Full Code Here

  }

  @Test
  public void testJsServletGivesErrorWhenUriManagerThrowsException() throws Exception {
    setUp(0);
    expect(jsUriManagerMock.processExternJsUri(isA(Uri.class))).andThrow(new GadgetException(null));
    replay();

    servlet.doGet(request, recorder);
    assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode());
    verify();
View Full Code Here

      final Uri contextUri = context.getUrl();
      if ((contextUri != null) && (contextUri.toString().equals(MockUtils.GADGET_URI1))) {
        return new GadgetSpec(context.getUrl(), DummyGadgetSpecFactory.xml);
      }

      throw new GadgetException(GadgetException.Code.OAUTH_STORAGE_ERROR);
    }
View Full Code Here

  @Test
  public void testDoGetException() throws Exception {
    setupRequest(BASIC_SYNTAX_URL);
    expect(proxyHandler.fetch(proxyUri)).andThrow(
            new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE));

    replay();
    servlet.doGet(request, recorder);
    verify();
View Full Code Here

  public void testDoPostException() throws Exception {
    setupRequest(BASIC_SYNTAX_URL);
    expect(request.getInputStream()).andReturn(postContentStream);
    expect(request.getMethod()).andReturn(POST_METHOD);
    expect(proxyHandler.fetch(proxyUri, POST_CONTENT)).andThrow(
            new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE));

    replay();
    servlet.doPost(request, recorder);
    verify();
View Full Code Here

  @Test
  public void testDoGetException() throws Exception {
    setupGet();
    expect(pipeline.execute(internalRequest)).andThrow(
        new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE));
    replay();

    servlet.doGet(request, recorder);

    assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode());
View Full Code Here

  @Test
  public void testDoPostException() throws Exception {
    setupPost();
    expect(pipeline.execute(internalRequest)).andThrow(
        new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE));
    replay();

    servlet.doPost(request, recorder);

    assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode());
View Full Code Here

      int retcode = response.getHttpStatusCode();
      if (retcode == HttpResponse.SC_INTERNAL_SERVER_ERROR) {
        // Convert external "internal error" to gateway error:
        retcode = HttpResponse.SC_BAD_GATEWAY;
      }
      throw new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT,
          "Unable to retrieve template library xml. HTTP error " +
          response.getHttpStatusCode(), retcode);
    }

    String content = response.getResponseAsString();
    try {
      String key = null;
      Element element = null;
      if (!context.getIgnoreCache()) {
        key = HashUtil.checksum(CharsetUtil.getUtf8Bytes(content));
        element = parsedXmlCache.getElement(key);
      }

      if (element == null) {
        element = XmlUtil.parse(content);
        if (key != null) {
          parsedXmlCache.addElement(key, element);
        }
      }

      return new XmlTemplateLibrary(uri, element, content);
    } catch (XmlException e) {
      throw new GadgetException(GadgetException.Code.MALFORMED_XML_DOCUMENT, e,
          HttpResponse.SC_BAD_REQUEST);
    }
  }
View Full Code Here

          loadFile(fileSystem.getFile(uriLoc.getPath()), featureMapBuilder);
        }
      }
      return ImmutableMap.copyOf(featureMapBuilder);
    } catch (IOException e) {
      throw new GadgetException(GadgetException.Code.INVALID_PATH, e);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.GadgetException

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.