public void testRealWorld() {

    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    String json =
        "{ \"firstname\": \"Richard\", \"surname\": \"Kennard\", \"notes\": \"Software developer\" }";
    String jsonSchema =
        "{ properties: { \"firstname\": { \"required\": true }, \"notes\": { \"large\": true }}}";

    SwtMetawidget metawidget = new SwtMetawidget(shell, SWT.None);
    metawidget.setInspector(
        new CompositeInspector(
            new CompositeInspectorConfig()
                .setInspectors(
                    new JsonInspector(
                        new JsonInspectorConfig()
                            .setInputStream(new ByteArrayInputStream(json.getBytes()))),
                    new JsonSchemaInspector(
                        new JsonInspectorConfig()
                            .setInputStream(new ByteArrayInputStream(jsonSchema.getBytes()))))));
    metawidget.setInspectionPath("fooObject");

    assertEquals("Firstname*:", ((Label) metawidget.getChildren()[0]).getText());
    assertTrue(metawidget.getChildren()[1] instanceof Text);
    assertEquals("Surname:", ((Label) metawidget.getChildren()[2]).getText());
    assertTrue(metawidget.getChildren()[3] instanceof Text);
    assertEquals("Notes:", ((Label) metawidget.getChildren()[4]).getText());
    assertTrue(metawidget.getChildren()[5] instanceof Text);
    assertEquals((metawidget.getChildren()[5].getStyle() & SWT.MULTI), SWT.MULTI);
    assertEquals(6, metawidget.getChildren().length);
  }
  public void testFlatSectionAroundNestedSectionLayoutDecorator() {

    SwtMetawidget metawidget =
        new SwtMetawidget(new Shell(SwtMetawidgetTests.TEST_DISPLAY, SWT.NONE), SWT.NONE);
    metawidget.setMetawidgetLayout(
        new SeparatorLayoutDecorator(
            new SeparatorLayoutDecoratorConfig()
                .setLayout(
                    new TabFolderLayoutDecorator(
                        new TabFolderLayoutDecoratorConfig().setLayout(new GridLayout())))));
    metawidget.setToInspect(new Baz());

    Composite composite = (Composite) metawidget.getChildren()[0];
    assertEquals(((org.eclipse.swt.layout.GridLayout) composite.getLayout()).marginWidth, 0);
    assertEquals("Foo", ((Label) composite.getChildren()[0]).getText());
    assertEquals((composite.getChildren()[1].getStyle() & SWT.SEPARATOR), SWT.SEPARATOR);

    TabFolder innerTabFolder = (TabFolder) metawidget.getChildren()[1];
    assertEquals("Bar", innerTabFolder.getItem(0).getText());
    Composite innerPanel = (Composite) innerTabFolder.getChildren()[0];
    assertEquals("Abc:", ((Label) innerPanel.getChildren()[0]).getText());
    assertTrue(innerPanel.getChildren()[1] instanceof Text);
    assertEquals(2, innerPanel.getChildren().length);

    composite = (Composite) metawidget.getChildren()[2];
    assertEquals(((org.eclipse.swt.layout.GridLayout) composite.getLayout()).marginWidth, 0);
    assertEquals("Baz", ((Label) composite.getChildren()[0]).getText());
    assertEquals((composite.getChildren()[1].getStyle() & SWT.SEPARATOR), SWT.SEPARATOR);

    assertEquals("Def:", ((Label) metawidget.getChildren()[3]).getText());
    assertTrue(metawidget.getChildren()[4] instanceof Button);
    assertEquals((metawidget.getChildren()[4].getStyle() & SWT.CHECK), SWT.CHECK);
    assertEquals(5, metawidget.getChildren().length);
  }
  public void testNestedTabs() {

    SwtMetawidget metawidget =
        new SwtMetawidget(new Shell(SwtMetawidgetTests.TEST_DISPLAY, SWT.NONE), SWT.NONE);
    metawidget.setMetawidgetLayout(
        new TabFolderLayoutDecorator(
            new TabFolderLayoutDecoratorConfig()
                .setLayout(
                    new TabFolderLayoutDecorator(
                        new TabFolderLayoutDecoratorConfig().setLayout(new GridLayout())))));
    metawidget.setToInspect(new Bar());

    assertEquals("Abc:", ((Label) metawidget.getChildren()[0]).getText());
    assertTrue(metawidget.getChildren()[1] instanceof Text);

    TabFolder outerTabFolder = (TabFolder) metawidget.getChildren()[2];
    assertEquals("Foo", outerTabFolder.getItem(0).getText());
    Composite outerPanel = (Composite) outerTabFolder.getChildren()[0];
    assertEquals(4, outerPanel.getChildren().length);

    TabFolder innerTabFolder = (TabFolder) outerPanel.getChildren()[0];
    assertEquals("Bar", innerTabFolder.getItem(0).getText());
    Composite barComposite = (Composite) innerTabFolder.getChildren()[0];
    assertEquals("Def:", ((Label) barComposite.getChildren()[0]).getText());
    assertTrue(barComposite.getChildren()[1] instanceof Button);
    assertEquals((barComposite.getChildren()[1].getStyle() & SWT.CHECK), SWT.CHECK);
    assertEquals("Ghi:", ((Label) barComposite.getChildren()[2]).getText());
    assertEquals((barComposite.getChildren()[3].getStyle() & SWT.MULTI), SWT.MULTI);
    assertEquals((barComposite.getChildren()[3].getStyle() & SWT.BORDER), SWT.BORDER);
    assertEquals((barComposite.getChildren()[3].getStyle() & SWT.V_SCROLL), SWT.V_SCROLL);
    assertEquals((barComposite.getChildren()[3].getStyle() & SWT.WRAP), SWT.WRAP);

    assertEquals(4, barComposite.getChildren().length);

    assertEquals("Baz", innerTabFolder.getItem(1).getText());
    Composite bazComposite = (Composite) innerTabFolder.getChildren()[1];
    assertEquals("Jkl:", ((Label) bazComposite.getChildren()[0]).getText());
    assertTrue(bazComposite.getChildren()[1] instanceof Text);
    assertEquals(2, bazComposite.getChildren().length);

    assertEquals("Mno:", ((Label) outerPanel.getChildren()[1]).getText());
    assertTrue(outerPanel.getChildren()[2] instanceof Button);
    assertEquals((outerPanel.getChildren()[2].getStyle() & SWT.CHECK), SWT.CHECK);

    innerTabFolder = (TabFolder) outerPanel.getChildren()[3];
    assertEquals("Moo", innerTabFolder.getItem(0).getText());
    Composite mooComposite = (Composite) innerTabFolder.getChildren()[0];
    assertEquals("Pqr:", ((Label) mooComposite.getChildren()[0]).getText());
    assertTrue(mooComposite.getChildren()[1] instanceof Text);
    assertEquals(2, mooComposite.getChildren().length);

    assertEquals("Stu:", ((Label) metawidget.getChildren()[3]).getText());
    assertTrue(metawidget.getChildren()[4] instanceof Text);
    assertEquals(5, metawidget.getChildren().length);

    // Test components within nested tabs still accessible by name

    assertEquals(metawidget.getChildren()[1], metawidget.getControl("abc"));
    assertEquals(barComposite.getChildren()[1], metawidget.getControl("def"));
    assertEquals(barComposite.getChildren()[3], metawidget.getControl("ghi"));
    assertEquals(bazComposite.getChildren()[1], metawidget.getControl("jkl"));
    assertEquals(outerPanel.getChildren()[2], metawidget.getControl("mno"));
    assertEquals(mooComposite.getChildren()[1], metawidget.getControl("pqr"));
    assertEquals(metawidget.getChildren()[4], metawidget.getControl("stu"));
  }