public void testImport() throws Exception {
    // no import
    ConfigurationManager cm = new ConfigurationManagerImpl();
    cm.addConfiguration(
        "classpath:/org/exoplatform/container/configuration/config-manager-configuration-a.xml");
    Configuration conf = cm.getConfiguration();
    assertNotNull(conf.getComponent("A"));
    assertTrue(
        conf.getComponent("A")
            .getDocumentURL()
            .getFile()
            .endsWith("config-manager-configuration-a.xml"));
    assertNull(conf.getComponent("B"));
    assertNull(conf.getComponent("C"));

    // b import a
    cm = new ConfigurationManagerImpl();
    cm.addConfiguration(
        "classpath:/org/exoplatform/container/configuration/config-manager-configuration-b.xml");
    conf = cm.getConfiguration();
    assertNotNull(conf.getComponent("A"));
    assertTrue(
        conf.getComponent("A")
            .getDocumentURL()
            .getFile()
            .endsWith("config-manager-configuration-a.xml"));
    assertNotNull(conf.getComponent("B"));
    assertTrue(
        conf.getComponent("B")
            .getDocumentURL()
            .getFile()
            .endsWith("config-manager-configuration-b.xml"));
    assertNull(conf.getComponent("C"));

    // c import b and b import a
    cm = new ConfigurationManagerImpl();
    cm.addConfiguration(
        "classpath:/org/exoplatform/container/configuration/config-manager-configuration-c.xml");
    conf = cm.getConfiguration();
    assertNotNull(conf.getComponent("A"));
    assertTrue(
        conf.getComponent("A")
            .getDocumentURL()
            .getFile()
            .endsWith("config-manager-configuration-a.xml"));
    assertNotNull(conf.getComponent("B"));
    assertTrue(
        conf.getComponent("B")
            .getDocumentURL()
            .getFile()
            .endsWith("config-manager-configuration-b.xml"));
    assertNotNull(conf.getComponent("C"));
    assertTrue(
        conf.getComponent("C")
            .getDocumentURL()
            .getFile()
            .endsWith("config-manager-configuration-c.xml"));
  }
  @VisibleForTesting
  protected void fetchConfiguration() {
    if (mConfigurationRequestAttempts >= 3) {
      postCallback(
          new ConfigurationException(
              "Configuration retry limit has been exceeded. Create a new "
                  + "BraintreeFragment and try again."));
      return;
    }

    mConfigurationRequestAttempts++;

    ConfigurationManager.getConfiguration(
        this,
        new ConfigurationListener() {
          @Override
          public void onConfigurationFetched(Configuration configuration) {
            setConfiguration(configuration);
            postOrQueueCallback(
                new QueuedCallback() {
                  @Override
                  public boolean shouldRun() {
                    return mConfigurationListener != null;
                  }

                  @Override
                  public void run() {
                    mConfigurationListener.onConfigurationFetched(getConfiguration());
                  }
                });
            flushCallbacks();
          }
        },
        new BraintreeResponseListener<Exception>() {
          @Override
          public void onResponse(final Exception e) {
            final ConfigurationException exception =
                new ConfigurationException(
                    "Request for configuration has failed: "
                        + e.getMessage()
                        + ". "
                        + "Future requests will retry up to 3 times");
            postCallback(exception);
            postOrQueueCallback(
                new QueuedCallback() {
                  @Override
                  public boolean shouldRun() {
                    return mConfigurationErrorListener != null;
                  }

                  @Override
                  public void run() {
                    mConfigurationErrorListener.onResponse(exception);
                  }
                });
            flushCallbacks();
          }
        });
  }
  @Test
  public final void testLoad() throws Exception {
    final Configuration locDefaultConfiguration = ConfigurationManager.getConfiguration();

    final Configuration locNewConfiguration = new DefaultConfiguration();
    locNewConfiguration.load();
    assertEquals(locDefaultConfiguration, locNewConfiguration);
  }
 @Test(expected = org.deegree.client.mdeditor.configuration.ConfigurationException.class)
 public void testdoubleIDException() {
   try {
     ConfigurationManager.getConfiguration().getConfiguration("simple");
   } catch (ConfigurationException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
  @Test
  public void testParseMapping() throws ConfigurationException {
    FormConfiguration configuration =
        ConfigurationManager.getConfiguration().getConfiguration("simple");
    List<URL> mappings = configuration.getMappingURLs();

    assertNotNull(mappings);
    assertEquals(1, mappings.size());
    assertTrue(mappings.get(0).getPath().endsWith("mappingTest.xml"));
  }
  @Test
  public void testParseOccurence() throws ConfigurationException {
    FormConfiguration configuration =
        ConfigurationManager.getConfiguration().getConfiguration("simple");
    List<FormGroup> formGroups = configuration.getFormGroups();

    assertNotNull(formGroups);
    assertTrue(formGroups.size() == 4);

    assertEquals("FormGroup", formGroups.get(1).getId());
    assertTrue(formGroups.get(1).getOccurence() < 1);
  }
  @Test
  public void testParseFormConfiguration() throws ConfigurationException {
    FormConfiguration configuration =
        ConfigurationManager.getConfiguration().getConfiguration("simple");

    assertEquals(LAYOUT_TYPE.TAB, configuration.getLayoutType());

    assertNotNull(configuration.getPathToIdentifier());
    assertEquals("FormGroup3/ref", configuration.getPathToIdentifier().toString());

    assertNotNull(configuration.getPathToTitle());
    assertEquals("FormGroup/text1", configuration.getPathToTitle().toString());

    assertNotNull(configuration.getPathToDescription());
    assertEquals("FormGroup/FormGroup11/text2", configuration.getPathToDescription().toString());
  }
  @Test
  public void testParseFormGroups() throws ConfigurationException {
    FormConfiguration configuration =
        ConfigurationManager.getConfiguration().getConfiguration("simple");
    List<FormGroup> formGroups = configuration.getFormGroups();

    assertNotNull(formGroups);
    assertTrue(formGroups.size() == 4);

    assertEquals("FormGroup3", formGroups.get(0).getId());
    assertEquals("FormGroup", formGroups.get(1).getId());

    assertEquals(2, formGroups.get(0).getFormElements().size());
    assertEquals(3, formGroups.get(1).getFormElements().size());

    FormElement formElement = formGroups.get(1).getFormElements().get(2);
    assertTrue(formElement instanceof FormGroup);
    assertEquals(5, ((FormGroup) formElement).getFormElements().size());
  }
  @Test
  public void testParseReferencedFormElementAndIdentifier() throws ConfigurationException {
    FormConfiguration configuration =
        ConfigurationManager.getConfiguration().getConfiguration("simple");
    List<FormGroup> formGroups = configuration.getFormGroups();

    assertNotNull(formGroups);
    assertTrue(formGroups.size() == 4);

    assertEquals("FormGroup3", formGroups.get(0).getId());
    assertEquals("FormGroup", formGroups.get(1).getId());

    assertEquals(2, formGroups.get(0).getFormElements().size());
    assertEquals(3, formGroups.get(1).getFormElements().size());

    FormElement refFormElement = formGroups.get(0).getFormElements().get(1);
    assertTrue(refFormElement instanceof ReferencedElement);
    assertEquals("generateIdBean", ((ReferencedElement) refFormElement).getBeanName());
  }
  @Test
  public void testParseFormElements() throws ConfigurationException {
    FormConfiguration configuration =
        ConfigurationManager.getConfiguration().getConfiguration("simple");
    List<FormGroup> formGroups = configuration.getFormGroups();

    assertNotNull(formGroups);
    assertTrue(formGroups.size() == 4);

    assertEquals("FormGroup", formGroups.get(1).getId());
    assertEquals(3, formGroups.get(1).getFormElements().size());

    FormElement select1 = formGroups.get(1).getFormElements().get(0);
    assertTrue(select1 instanceof SelectFormField);
    assertEquals("selectOne1", select1.getId());
    assertFalse(((SelectFormField) select1).isRequired());

    FormElement input = formGroups.get(1).getFormElements().get(1);
    assertTrue(input instanceof InputFormField);
    FormFieldPath inputPath = new FormFieldPath("FormGroup", "text1");
    assertEquals(inputPath, ((InputFormField) input).getPath());
    InputFormField iff = (InputFormField) input;
    assertNotNull(iff.getValidation());
    assertEquals(5, iff.getValidation().getLength());
    assertTrue(iff.isRequired());

    FormElement formElement = formGroups.get(1).getFormElements().get(2);
    assertTrue(formElement instanceof FormGroup);
    assertEquals(5, ((FormGroup) formElement).getFormElements().size());

    FormElement select = ((FormGroup) formElement).getFormElements().get(3);
    assertTrue(select instanceof SelectFormField);
    FormFieldPath selectPath = new FormFieldPath("FormGroup", "FormGroup11", "selectOne2");
    assertEquals(selectPath, ((SelectFormField) select).getPath());
    assertFalse(((SelectFormField) select).isRequired());
  }