/** Test fail-fast for components without interface. */
 public void testComponentMustImplementInterface() {
   try {
     new ThreadLocalizing.ThreadLocalized(
         new ConstructorInjection.ConstructorInjector(Object.class, Object.class));
     fail("PicoCompositionException expected");
   } catch (final PicoCompositionException e) {
     assertTrue(e.getMessage().endsWith("It does not implement any interfaces."));
   }
 }
  public void testDuplicateRegistrationWithTypeAndObject() throws PicoCompositionException {
    DefaultPicoContainer pico = new DefaultPicoContainer();

    pico.addComponent(SimpleTouchable.class);
    try {
      pico.addComponent(SimpleTouchable.class, new SimpleTouchable());
      fail("Should have barfed with dupe registration");
    } catch (PicoCompositionException e) {
      // expected
      assertTrue(e.getMessage().startsWith("Duplicate"));
      assertTrue(e.getMessage().indexOf(SimpleTouchable.class.getName()) > 0);
    }
  }
  @Test
  public void testGrantPermissionInWrongPlace() {
    DefaultClassLoadingPicoContainer parent = new DefaultClassLoadingPicoContainer();
    try {
      Reader script =
          new StringReader(
              "TestHelper = org.picocontainer.script.TestHelper\n"
                  + "SocketPermission = java.net.SocketPermission\n"
                  + "testCompJar = TestHelper.getTestCompJarFile()\n"
                  + "container {\n"
                  + "  grant(:perm => SocketPermission.new('google.com','connect'))\n"
                  + "}");

      buildContainer(script, parent, ASSEMBLY_SCOPE);
      fail("should barf with RaiseException");
    } catch (PicoCompositionException e) {
      assertNotNull(e.getCause());
      assertTrue(e.getCause() instanceof RaiseException);
    }
  }