/* ***************************************************************************
 * Copyright (c) 2008 Brabenetz Harald, Austria.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 *****************************************************************************/

package org.settings4j.objectresolver;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.settings4j.ContentResolver;
import org.settings4j.contentresolver.ClasspathContentResolver;
import org.settings4j.contentresolver.FSContentResolver;
import org.settings4j.contentresolver.UnionContentResolver;

import junit.framework.TestCase;

public class JavaXMLBeansObjectResolverTest extends TestCase {
    public void test1(){
        JavaXMLBeansObjectResolver objectResolver = new JavaXMLBeansObjectResolver();
        
        FSContentResolver fsContentResolver = new FSContentResolver();
        fsContentResolver.setRootFolderPath("./test/JavaXMLBeans");
        ContentResolver contentResolver = new UnionContentResolver(fsContentResolver);
        contentResolver.addContentResolver(new ClasspathContentResolver());
        
        Map testData =  new HashMap();
        List testList = new ArrayList();
        String testValue1 = "testValue1";
        String testValue2 = "testValue2";
        String testValue3 = "testValue3";
        String testValue4 = "testValue4";
        testList.add(testValue1);
        testList.add(testValue2);
        testList.add(testValue3);
        testList.add(testValue4);
        
        testData.put("irgendwas", "blablablablablabla");
        testData.put("liste", testList);
        
        objectResolver.setObject("org/settings4j/objectResolver/test1", contentResolver, testData);
        
        Map result = (Map) objectResolver.getObject("org/settings4j/objectResolver/test1", contentResolver);
        assertEquals("blablablablablabla", result.get("irgendwas"));
        Object liste = result.get("liste");
        assertNotNull(liste);
        assertTrue(liste instanceof List);
        assertEquals(4, ((List)liste).size());
        
        Map result2 = (Map) objectResolver.getObject("org/settings4j/objectResolver/test1", contentResolver);
        // difference Objects but same content.
        assertTrue(result != result2);
        assertEquals(result2.get("irgendwas"), result.get("irgendwas"));
        
        
    }
}

@@ -817,32 +817,54 @@
 ectresolver;%0D%0A%0D%0A
+import java.io.File;%0D%0A
 import java.util
@@ -872,24 +872,24 @@
 ArrayList;%0D%0A
-
 import java.
@@ -948,24 +948,65 @@
 til.Map;%0D%0A%0D%0A
+import org.apache.commons.io.FileUtils;%0D%0A
 import org.s
@@ -1318,16 +1318,404 @@
 tCase %7B%0D
+%0A%0D%0A    private File testDir;%0D%0A    %0D%0A    protected void setUp() throws Exception %7B%0D%0A        super.setUp();%0D%0A        testDir = (new File(%22test/JavaXMLBeans/%22.toLowerCase())).getAbsoluteFile();%0D%0A        FileUtils.forceMkdir(testDir);%0D%0A    %7D%0D%0A    %0D%0A    protected void tearDown() throws Exception %7B%0D%0A        FileUtils.deleteDirectory(new File(%22test%22));%0D%0A        super.tearDown();%0D%0A    %7D%0D%0A    %0D
 %0A    pub
@@ -1950,29 +1950,33 @@
 ath(
-%22./
 test
-/JavaXMLBeans%22
+Dir.getAbsolutePath()
 );%0D%0A

add setup and teardown methods for unittest (delete test-folder after testing)