    @Test
    public void testMergeConfigsFromClasspath() throws Exception {

        File tmpDir = createTempDir();
        File cacheDir = new File(tmpDir, "cache");
        File p1 = createMergeConfig(tmpDir, "p1", "Foo", OS.macosx, Arch.x86, false);
        File p2 = createMergeConfig(tmpDir, "p2", "Wooz", OS.linux, Arch.x86, false);
        // Create a jar file with both x86 and x86_64 by first creating a folder for x86 in p3/ 
        // and then passing p3/ again but this time compress it to a jar.
                  createMergeConfig(tmpDir, "p3", "Baaz", OS.macosx, Arch.x86, false);
        File p3 = createMergeConfig(tmpDir, "p3", "Raaz", OS.macosx, Arch.x86_64, true);
        
        Config.Builder builder = new Config.Builder();
        builder.cacheDir(cacheDir);
        builder.os(OS.macosx);
        builder.arch(Arch.x86);
        builder.targetType(ConsoleTarget.TYPE);
        builder.mainClass("Main");
        builder.addClasspathEntry(p1);
        builder.addClasspathEntry(p2);
        builder.addClasspathEntry(p3);
        builder.addExportedSymbol("YADA*");
        builder.addFrameworkPath(new File(p1, "yada"));
        builder.addFramework("Yada");
        builder.addForceLinkClass("org.yada.**");
        builder.addLib(new Lib("yada", true));
        builder.addResource(new Resource(new File(p1, "resources")));
        builder.addWeakFramework("WeakYada");
        builder.home(fakeHome);
        Config config = builder.build();

        File p1X86Root = new File(p1, "META-INF/flexovm/macosx/x86");
        File p3X86Cache = config.getCacheDir(config.getClazzes().getClasspathPaths().get(2));
        File p3X86Root = new File(p3X86Cache.getParentFile(), p3X86Cache.getName() + ".extracted/META-INF/flexovm/macosx/x86");

        assertEquals(Arrays.asList("FOO*", "BAAZ*", "YADA*"), config.getExportedSymbols());
        assertEquals(Arrays.asList("com.foo.**", "com.baaz.**", "org.yada.**"), config.getForceLinkClasses());
        assertEquals(Arrays.asList(
                new File(p1X86Root, "foo/bar"), 
                new File(p3X86Root, "baaz/bar"), 
                new File(p1, "yada")), 
                config.getFrameworkPaths());
        assertEquals(Arrays.asList("Foo", "Baaz", "Yada"), config.getFrameworks());
        assertEquals(Arrays.asList(
                new Lib("foo", true), 
                new Lib(new File(p1X86Root, "libfoo.a").getAbsolutePath(), true), 
                new Lib("baaz", true), 
                new Lib(new File(p3X86Root, "libbaaz.a").getAbsolutePath(), true), 
                new Lib("yada", true)), 
                config.getLibs());
        assertEquals(Arrays.asList(
                new Resource(new File(p1X86Root, "resources")), 
                new Resource(new File(p3X86Root, "resources")), 
                new Resource(new File(p1, "resources"))), 
                config.getResources());
        assertEquals(Arrays.asList("WeakFoo", "WeakBaaz", "WeakYada"), config.getWeakFrameworks());
        
        // Make sure builder() returns a config which merges in x86_64 configs instead
        config = config.builder().arch(Arch.x86_64).build();
        
        File p3X86_64Cache = config.getCacheDir(config.getClazzes().getClasspathPaths().get(2));
        File p3X86_64Root = new File(p3X86_64Cache.getParentFile(), p3X86_64Cache.getName() + ".extracted/META-INF/flexovm/macosx/x86_64");
        
        assertEquals(Arrays.asList("RAAZ*", "YADA*"), config.getExportedSymbols());
        assertEquals(Arrays.asList("com.raaz.**", "org.yada.**"), config.getForceLinkClasses());
        assertEquals(Arrays.asList(
                new File(p3X86_64Root, "raaz/bar"), 
                new File(p1, "yada")), 
                config.getFrameworkPaths());
        assertEquals(Arrays.asList("Raaz", "Yada"), config.getFrameworks());
        assertEquals(Arrays.asList(
                new Lib("raaz", true), 
                new Lib(new File(p3X86_64Root, "libraaz.a").getAbsolutePath(), true), 
                new Lib("yada", true)), 
                config.getLibs());
        assertEquals(Arrays.asList(
                new Resource(new File(p3X86_64Root, "resources")), 
                new Resource(new File(p1, "resources"))), 
                config.getResources());
        assertEquals(Arrays.asList("WeakRaaz", "WeakYada"), config.getWeakFrameworks());
    }