Package com.google.inject

Examples of com.google.inject.CreationException


    InputStream is = null;
    try {
      is = ResourceLoader.openResource(propertyFile);
      properties.load(is);
    } catch (IOException e) {
      throw new CreationException(Arrays.asList(
          new Message("Unable to load properties: " + propertyFile)));
    } finally {
      IOUtils.closeQuietly( is );
    }
    return properties;
View Full Code Here


        throw new IOException("Failed to open " + DEFAULT_PROPERTIES);
      }
      properties = new Properties();
      properties.load(is);
    } catch (IOException e) {
      throw new CreationException(Arrays.asList(new Message(
          "Unable to load properties: " + DEFAULT_PROPERTIES)));
    } finally {
      IOUtils.closeQuietly( is );
    }
  }
View Full Code Here

        if (value != null && value.contains("%contextRoot%")){
          properties.put(key, value.replace(("%contextRoot%"),contextRoot));
        }
      }
    } catch (IOException e) {
      throw new CreationException(Arrays.asList(
          new Message("Unable to load properties: " + propertyFile)));
    } finally {
      IOUtils.closeQuietly(is);
    }
    return properties;
View Full Code Here

            Properties initProperties = loadPropertiesFromPropertyResource(propertyResource);
            overridePropertyValuesWithSystemProperties(initProperties, overridableProperties());
            replacePlaceholderWithValue(initProperties, "%contextRoot%", getContextRootValue(initProperties));
            return initProperties;
        } catch (IOException e) {
            throw new CreationException(Arrays.asList(
                    new Message("Unable to load properties from resource"
                            + ". " + e.getMessage())
            ));
        }
    }
View Full Code Here

   }

   public void testGetCauseCreation() {
      AuthorizationException aex = createMock(AuthorizationException.class);
      Message message = new Message(ImmutableList.of(), "test", aex);
      CreationException pex = new CreationException(ImmutableSet.of(message));
      assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex);
   }
View Full Code Here

   }

   public void testGetFirstThrowableOfTypeInnerCreation() {
      AuthorizationException aex = createMock(AuthorizationException.class);
      Message message = new Message(ImmutableList.of(), "test", aex);
      CreationException pex = new CreationException(ImmutableSet.of(message));
      assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex);
   }
View Full Code Here

   }

   public void testGetFirstThrowableOfTypeFailCreation() {
      TimeoutException aex = createMock(TimeoutException.class);
      Message message = new Message(ImmutableList.of(), "test", aex);
      CreationException pex = new CreationException(ImmutableSet.of(message));
      assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
   }
View Full Code Here

      assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
   }

   public void testGetFirstThrowableOfTypeWhenCauseIsNullCreation() {
      Message message = new Message(ImmutableList.of(), "test", null);
      CreationException pex = new CreationException(ImmutableSet.of(message));
      assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
   }
View Full Code Here

   @Test(expectedExceptions = AuthorizationException.class)
   public void testPropagateCreationExceptionAuthorizationException() throws Throwable {
      Exception e = new AuthorizationException();
      propagateIfPossible(
            new CreationException(ImmutableSet.of(new Message(ImmutableList.of(), "Error in custom provider", e))),
            ImmutableSet.<TypeToken<? extends Throwable>> of());
   }
View Full Code Here

  public void throwCreationExceptionIfErrorsExist() {
    if (!hasErrors()) {
      return;
    }

    throw new CreationException(getMessages());
  }
View Full Code Here

TOP

Related Classes of com.google.inject.CreationException

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.