geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r896187 [3/6] - in /geronimo/xbean/trunk/xbean-blueprint: ./ src/main/java/org/apache/xbean/blueprint/ src/main/java/org/apache/xbean/blueprint/context/ src/main/java/org/apache/xbean/blueprint/context/impl/ src/main/java/org/apache/xbean/b...
Date Tue, 05 Jan 2010 19:31:42 GMT
Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/WikiDocumentationGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/WikiDocumentationGenerator.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/WikiDocumentationGenerator.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/WikiDocumentationGenerator.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,212 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.generator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * @author Hiram Chirino
+ * @version $Id$
+ * @since 1.0
+ */
+public class WikiDocumentationGenerator implements GeneratorPlugin {
+    private final File destFile;
+    private LogFacade log;
+
+    public WikiDocumentationGenerator(File destFile) {
+        this.destFile = destFile;
+    }
+
+    public void generate(NamespaceMapping namespaceMapping) throws IOException {
+        String namespace = namespaceMapping.getNamespace();
+        File file = new File(destFile.getParentFile(), destFile.getName() + ".wiki");
+        log.log("Generating WIKI documentation file: " + file + " for namespace: " + namespace);
+        PrintWriter out = new PrintWriter(new FileWriter(file));
+        try {
+            generateDocumentation(out, namespaceMapping);
+        } finally {
+            out.close();
+        }
+    }
+
+    private void generateDocumentation(PrintWriter out, NamespaceMapping namespaceMapping) {
+        HashMap refercencedTypes = new HashMap();
+    	
+        // Build of map of types that are referenced by element types. 
+        for (Iterator iter = namespaceMapping.getElements().iterator(); iter.hasNext();) {
+            ElementMapping element = (ElementMapping) iter.next();
+            for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();) {
+                AttributeMapping attribute = (AttributeMapping) iterator.next();
+                Type type = getNestedType( attribute.getType() );
+				
+                if( namespaceMapping.isSimpleType( type) )
+                    continue;
+				
+                if( !refercencedTypes.containsKey(type.getName()) )
+                    refercencedTypes.put(type.getName(), new ArrayList());
+            }
+        }
+        
+        // Add all the elements that implement those types.
+        for (Iterator iter = refercencedTypes.entrySet().iterator(); iter.hasNext();) {
+        	
+            Map.Entry entry = (Map.Entry) iter.next();
+            String type = (String) entry.getKey();
+            ArrayList implementations = (ArrayList) entry.getValue();
+
+            for (Iterator iterator = namespaceMapping.getElements().iterator(); iterator.hasNext();) {
+                ElementMapping element = (ElementMapping) iterator.next();
+	            
+                // Check to see if the class is matches
+                boolean matched=false;
+                if (type.equals(element.getClassName())) {
+                    implementations.add(element);
+                    matched=true;
+                }
+	            
+                // Perhaps a super class matches.
+                if(!matched) {
+                    for (Iterator j = element.getSuperClasses().iterator(); j.hasNext();) {
+                        String t = (String) j.next();
+                        if( type.equals(t) ) {
+                            implementations.add(element);
+                            matched=true;
+                            break;
+                        }
+                    }
+                }
+	            
+                // Or it might be an interface.
+                if(!matched) {
+                    for (Iterator j = element.getInterfaces().iterator(); j.hasNext();) {
+                        String t = (String) j.next();
+                        if( type.equals(t) ) {
+                            implementations.add(element);
+                            matched=true;
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        
+        // Remove any entries that did not have associated elements
+        for (Iterator iter = refercencedTypes.values().iterator(); iter.hasNext();) {        	
+            ArrayList implementations = (ArrayList) iter.next();
+            if( implementations.isEmpty() )
+                iter.remove();
+        }        
+
+        generateElementsByType(out, namespaceMapping, refercencedTypes);
+        generateElementsDetail(out, namespaceMapping, refercencedTypes);
+        generateElementsIndex(out, namespaceMapping, refercencedTypes);
+    }
+
+    private Type getNestedType(Type type) {
+        if( type.isCollection() ) {
+            return getNestedType(type.getNestedType());
+        } else {
+            return type;
+        }
+    }
+    
+    private void generateElementsByType(PrintWriter out, NamespaceMapping namespaceMapping, HashMap refercencedTypes) {
+        out.println("h3. Elements By Type");
+        for (Iterator iter = refercencedTypes.entrySet().iterator(); iter.hasNext();) {
+            Entry entry = (Entry) iter.next();
+            String className = (String) entry.getKey();
+            Collection elements = (Collection) entry.getValue();
+
+            out.println("{anchor:"+className+"-types}");
+            out.println("h4. The _["+className+"|#"+className+"-types]_ Type Implementations");
+
+            for (Iterator iterator = elements.iterator(); iterator.hasNext();) {
+                ElementMapping element = (ElementMapping) iterator.next();
+                out.println("    | _[<"+element.getElementName() +">|#"+element.getElementName() +"-element]_ | {html}"+element.getDescription()+"{html} |");
+            }
+            out.println();        	
+        }
+        out.println();
+    }
+
+	private void generateElementsIndex(PrintWriter out, NamespaceMapping namespaceMapping, HashMap refercencedTypes) {
+    	
+        out.println("h3. Element Index");
+        for (Iterator iter = namespaceMapping.getElements().iterator(); iter.hasNext();) {
+            ElementMapping element = (ElementMapping) iter.next();
+        	out.println("    | _[<"+element.getElementName() +">|#"+element.getElementName() +"-element]_ | {html}"+element.getDescription()+"{html} |");
+        }
+        out.println();
+    }
+
+    private void generateElementsDetail(PrintWriter out, NamespaceMapping namespaceMapping, HashMap refercencedTypes) {
+        for (Iterator iter = namespaceMapping.getElements().iterator(); iter.hasNext();) {
+            ElementMapping element = (ElementMapping) iter.next();
+            generateElementDetail(out, namespaceMapping, element, refercencedTypes);
+        }
+    }
+
+    private void generateElementDetail(PrintWriter out, NamespaceMapping namespaceMapping, ElementMapping element, HashMap refercencedTypes) {    
+
+        out.println("{anchor:" + element.getElementName() + "-element}");
+        out.println("h3. The _[<" + element.getElementName() + ">|#" + element.getElementName() + "-element]_ Element");
+
+        out.println("    {html}"+element.getDescription()+"{html}");
+
+        if( element.getAttributes().size() > 0 ) {
+            out.println("h4. Properties");
+            out.println("    || Property Name || Type || Description ||");
+
+            for ( Iterator iterator = element.getAttributes().iterator(); iterator.hasNext(); ) {
+                AttributeMapping attribute = (AttributeMapping) iterator.next();
+                Type type = attribute.getPropertyEditor() != null ? Type.newSimpleType(String.class.getName()): attribute.getType();
+                out.println("    | " + attribute.getAttributeName() + " | "+getTypeLink(type, refercencedTypes)+" | {html}"+attribute.getDescription()+"{html} |");	
+	          }
+        }
+        out.println();
+    }
+
+    private String getTypeLink(Type type, HashMap refercencedTypes) {
+        if (type.isCollection()) {
+            return "(" + getTypeLink(type.getNestedType(), refercencedTypes) +  ")\\*";
+        } else {
+        	  if( refercencedTypes.containsKey(type.getName()) ) {
+        		    return "_["+type.getName()+"|#"+type.getName()+"-types]_";
+        	  } else {
+                return "_"+type.getName()+"_";
+            }
+        }        
+    }
+
+    public LogFacade getLog() {
+        return log;
+    }
+
+    public void setLog(LogFacade log) {
+        this.log = log;
+    }
+}
+

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/WikiDocumentationGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/WikiDocumentationGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/WikiDocumentationGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlMetadataGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlMetadataGenerator.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlMetadataGenerator.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlMetadataGenerator.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,274 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.generator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Properties;
+
+import org.apache.xbean.blueprint.context.impl.NamespaceHelper;
+
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public class XmlMetadataGenerator implements GeneratorPlugin {
+    private final String metaInfDir;
+    private LogFacade log;
+    private final File schema;
+
+    public static final String NAMESPACE_HANDLER = "org.apache.xbean.blueprint.context.v2.XBeanNamespaceHandler";
+	private final boolean generateSpringSchemasFile;
+	private final boolean generateSpringHandlersFile;
+
+    public XmlMetadataGenerator(String metaInfDir, File schema) {
+    	this(metaInfDir, schema, true, true);
+    }
+    
+    public XmlMetadataGenerator(String metaInfDir, File schema, boolean generateSpringSchemasFile, boolean generateSpringHandlersFile) {
+        this.metaInfDir = metaInfDir;
+        this.schema = schema;
+		this.generateSpringSchemasFile = generateSpringSchemasFile;
+		this.generateSpringHandlersFile = generateSpringHandlersFile;
+    }
+
+    public void generate(NamespaceMapping namespaceMapping) throws IOException {
+        String namespace = namespaceMapping.getNamespace();
+        if (namespace == null) {
+            return;
+        }
+
+        File file = new File(metaInfDir, NamespaceHelper.createDiscoveryPathName(namespace));
+        file.getParentFile().mkdirs();
+        log.log("Generating META-INF properties file: " + file + " for namespace: " + namespace);
+        PrintWriter out = new PrintWriter(new FileWriter(file));
+        try {
+            generatePropertiesFile(out, namespaceMapping.getElements());
+        } finally {
+            out.close();
+        }
+        
+        if( generateSpringHandlersFile ) {
+        	
+            // Generate spring 2.0 mapping
+	        file = new File(metaInfDir, "META-INF/spring.handlers");
+
+            Properties properties = new Properties();
+            if (!file.exists()) {
+                log.log("Generating Spring 2.0 handler mapping: " + file + " for namespace: " + namespace);
+            } else {
+                log.log("Updating Spring 2.0 handler mapping: " + file + " for namespace: " + namespace);
+
+                // read in current file
+                InputStream in = new FileInputStream(file);
+                try {
+                    properties.load(in);
+                } catch (IOException e) {
+                    in.close();
+                }
+            }
+
+            // add property
+            properties.put(namespace,  NAMESPACE_HANDLER);
+
+            // write properties
+            OutputStream fout = new FileOutputStream(file);
+            try {
+                properties.store(fout, "Generated by xbean-spring");
+            } finally {
+                fout.close();
+            }
+        }
+
+        if (schema != null && generateSpringSchemasFile ) {
+            String cp = new File(metaInfDir).toURI().relativize(schema.toURI()).toString();
+            file = new File(metaInfDir, "META-INF/spring.schemas");
+
+            Properties properties = new Properties();
+            if (!file.exists()) {
+                log.log("Generating Spring 2.0 schema mapping: " + file + " for namespace: " + namespace);
+            } else {
+                log.log("Updating Spring 2.0 schema mapping: " + file + " for namespace: " + namespace);
+
+                // read in current file
+                InputStream in = new FileInputStream(file);
+                try {
+                    properties.load(in);
+                } catch (IOException e) {
+                    in.close();
+                }
+            }
+
+            // add property
+            String uri = namespace;
+            if (!uri.endsWith("/")) {
+                uri += "/";
+            }
+            properties.put(uri + cp,  cp);
+
+            // write properties
+            OutputStream fout = new FileOutputStream(file);
+            try {
+                properties.store(fout, "Generated by xbean-spring");
+            } finally {
+                fout.close();
+            }
+        }
+    }
+
+    private void generatePropertiesFile(PrintWriter out, Set elements) {
+        out.println("# NOTE: this file is autogenerated by Apache XBean");
+        out.println();
+        out.println("# beans");
+
+        for (Iterator iter = elements.iterator(); iter.hasNext();) {
+            ElementMapping element = (ElementMapping) iter.next();
+            out.println(element.getElementName() + " = " + element.getClassName());
+
+            generatePropertiesFileContent(out, element);
+            generatePropertiesFilePropertyAliases(out, element);
+            generatePropertiesFileConstructors(out, element);
+            out.println();
+        }
+    }
+
+    private void generatePropertiesFileContent(PrintWriter out, ElementMapping element) {
+        String contentProperty = element.getContentProperty();
+        if (contentProperty != null) {
+            out.println(element.getElementName() + ".contentProperty = " + contentProperty);
+        }
+        String initMethod = element.getInitMethod();
+        if (initMethod != null) {
+            out.println(element.getElementName() + ".initMethod = " + initMethod);
+        }
+
+        String destroyMethod = element.getDestroyMethod();
+        if (destroyMethod != null) {
+            out.println(element.getElementName() + ".destroyMethod = " + destroyMethod);
+        }
+
+        String factoryMethod = element.getFactoryMethod();
+        if (factoryMethod != null) {
+            out.println(element.getElementName() + ".factoryMethod = " + factoryMethod);
+        }
+
+        for (Iterator iter = element.getAttributes().iterator(); iter.hasNext();) {
+            AttributeMapping attribute = (AttributeMapping) iter.next();
+            if( attribute.getPropertyEditor() !=null ) {
+                out.println(element.getElementName() + "."+attribute.getPropertyName()+ ".propertyEditor = " + attribute.getPropertyEditor());
+            }
+        }
+
+        List flatProperties = element.getFlatProperties();
+        for (Iterator itr = flatProperties.iterator(); itr.hasNext();) {
+            out.println(element.getElementName() + "." + itr.next() + ".flat");
+        }
+
+        Map maps = element.getMapMappings();
+        for (Iterator itr = maps.entrySet().iterator(); itr.hasNext();) {
+            Map.Entry entry = (Map.Entry) itr.next();
+            MapMapping mm = (MapMapping) entry.getValue();
+            if (mm.getEntryName() != null) {
+                out.println(element.getElementName() + "." + entry.getKey() + ".map.entryName = " + mm.getEntryName());
+            }
+            if (mm.getKeyName() != null) {
+                out.println(element.getElementName() + "." + entry.getKey() + ".map.keyName = " + mm.getKeyName());
+            }
+            if (mm.isFlat()) {
+                out.println(element.getElementName() + "." + entry.getKey() + ".map.flat = " + Boolean.toString(mm.isFlat()));
+            }
+            if (mm.getDupsMode() != null) {
+                out.println(element.getElementName() + "." + entry.getKey() + ".map.dups = " + mm.getDupsMode());
+            }
+            if (mm.getDefaultKey() != null) {
+                out.println(element.getElementName() + "." + entry.getKey() + ".map.defaultKey = " + mm.getDefaultKey());
+            }
+        }
+
+        Map flatCollections = element.getFlatCollections();
+        for (Iterator itr = flatCollections.entrySet().iterator(); itr.hasNext();) {
+            Map.Entry entry = (Map.Entry) itr.next();
+            String child = (String) entry.getValue();
+            out.println(element.getElementName() + "." + child + ".flatCollection = " + entry.getKey());
+        }
+    }
+
+    private void generatePropertiesFileConstructors(PrintWriter out, ElementMapping element) {
+        List constructors = element.getConstructors();
+        for (Iterator iterator = constructors.iterator(); iterator.hasNext();) {
+            List args = (List) iterator.next();
+            generatePropertiesFileConstructor(out, element, args);
+        }
+    }
+
+    private void generatePropertiesFileConstructor(PrintWriter out, ElementMapping element, List args) {
+        out.print(element.getClassName());
+        if (element.getFactoryMethod() != null) {
+            out.print("." + element.getFactoryMethod());
+        }
+        out.print("(");
+        for (Iterator iterator = args.iterator(); iterator.hasNext();) {
+            ParameterMapping parameterMapping = (ParameterMapping) iterator.next();
+            out.print(parameterMapping.getType().getName());
+            if (iterator.hasNext()) {
+                out.print(",");
+            }
+        }
+        out.print(").parameterNames =");
+        for (Iterator iterator = args.iterator(); iterator.hasNext();) {
+            ParameterMapping parameterMapping = (ParameterMapping) iterator.next();
+            out.print(" ");
+            out.print(parameterMapping.getName());
+        }
+        out.println();
+    }
+
+    private void generatePropertiesFilePropertyAliases(PrintWriter out, ElementMapping element) {
+        for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();) {
+            AttributeMapping attributeMapping = (AttributeMapping) iterator.next();
+            String propertyName = attributeMapping.getPropertyName();
+            String attributeName = attributeMapping.getAttributeName();
+            if (!propertyName.equals(attributeName)) {
+                if (List.class.getName().equals(attributeMapping.getType().getName())) {
+                    out.println(element.getElementName() + ".list." + attributeName + " = " + propertyName);
+                } else {
+                    out.println(element.getElementName() + ".alias." + attributeName + " = " + propertyName);
+                }
+            }
+        }
+    }
+
+    public LogFacade getLog() {
+        return log;
+    }
+
+    public void setLog(LogFacade log) {
+        this.log = log;
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlMetadataGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlMetadataGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlMetadataGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlWriter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlWriter.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlWriter.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlWriter.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,215 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.generator;
+
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.LinkedList;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public class XmlWriter {
+    private PrintWriter writer;
+
+    private LinkedList elementStack = new LinkedList();
+
+    private boolean tagInProgress;
+
+    private int depth;
+
+    private String lineIndenter;
+
+    private String encoding;
+
+    private String docType;
+
+    private boolean readyForNewLine;
+
+    private boolean tagIsEmpty;
+
+    public XmlWriter(PrintWriter writer, String lineIndenter) {
+        this(writer, lineIndenter, null, null);
+    }
+
+    public XmlWriter(Writer writer, String lineIndenter) {
+        this(new PrintWriter(writer), lineIndenter);
+    }
+
+    public XmlWriter(PrintWriter writer) {
+        this(writer, null, null);
+    }
+
+    public XmlWriter(Writer writer) {
+        this(new PrintWriter(writer));
+    }
+
+    public XmlWriter(PrintWriter writer, String lineIndenter, String encoding, String doctype) {
+        this.writer = writer;
+
+        this.lineIndenter = lineIndenter;
+
+        this.encoding = encoding;
+
+        this.docType = doctype;
+
+        if (docType != null || encoding != null) {
+            writeDocumentHeaders();
+        }
+    }
+
+    public XmlWriter(Writer writer, String lineIndenter, String encoding, String doctype) {
+        this(new PrintWriter(writer), lineIndenter, encoding, doctype);
+    }
+
+    public XmlWriter(PrintWriter writer, String encoding, String doctype) {
+        this(writer, "  ", encoding, doctype);
+    }
+
+    public XmlWriter(Writer writer, String encoding, String doctype) {
+        this(new PrintWriter(writer), encoding, doctype);
+    }
+
+    public void startElement(String name) {
+        tagIsEmpty = false;
+
+        finishTag();
+
+        write("<");
+
+        write(name);
+
+        elementStack.addLast(name);
+
+        tagInProgress = true;
+
+        depth++;
+
+        readyForNewLine = true;
+
+        tagIsEmpty = true;
+    }
+
+    public void writeText(String text) {
+        writeText(text, true);
+    }
+
+    public void writeMarkup(String text) {
+        writeText(text, false);
+    }
+
+    private void writeText(String text, boolean escapeHtml) {
+        readyForNewLine = false;
+
+        tagIsEmpty = false;
+
+        finishTag();
+
+        if (escapeHtml) {
+            text = text.replaceAll("&", "&amp;");
+
+            text = text.replaceAll("<", "&lt;");
+
+            text = text.replaceAll(">", "&gt;");
+        }
+
+        write(text);
+    }
+
+    public void addAttribute(String key, String value) {
+        write(" ");
+
+        write(key);
+
+        write("=\"");
+
+        write(value);
+
+        write("\"");
+    }
+
+    public void endElement() {
+        depth--;
+
+        if (tagIsEmpty) {
+            write("/");
+
+            readyForNewLine = false;
+
+            finishTag();
+
+            elementStack.removeLast();
+        } else {
+            finishTag();
+
+            write("</" + elementStack.removeLast() + ">");
+        }
+
+        readyForNewLine = true;
+    }
+
+    private void write(String str) {
+        writer.write(str);
+    }
+
+    private void finishTag() {
+        if (tagInProgress) {
+            write(">");
+        }
+
+        tagInProgress = false;
+
+        if (readyForNewLine) {
+            endOfLine();
+        }
+        readyForNewLine = false;
+
+        tagIsEmpty = false;
+    }
+
+    protected void endOfLine() {
+        write("\n");
+
+        for (int i = 0; i < depth; i++) {
+            write(lineIndenter);
+        }
+    }
+
+    private void writeDocumentHeaders() {
+        write("<?xml version=\"1.0\"");
+
+        if (encoding != null) {
+            write(" encoding=\"" + encoding + "\"");
+        }
+
+        write("?>");
+
+        endOfLine();
+
+        if (docType != null) {
+            write("<!DOCTYPE ");
+
+            write(docType);
+
+            write(">");
+
+            endOfLine();
+        }
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlWriter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XmlWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XsdGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XsdGenerator.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XsdGenerator.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XsdGenerator.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,218 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.generator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public class XsdGenerator implements GeneratorPlugin {
+    private final File destFile;
+    private LogFacade log;
+
+    public XsdGenerator(File destFile) {
+        this.destFile = destFile;
+    }
+
+    public void generate(NamespaceMapping namespaceMapping) throws IOException {
+        // TODO can only handle 1 schema document so far...
+        File file = destFile;
+        log.log("Generating XSD file: " + file + " for namespace: " + namespaceMapping.getNamespace());
+        PrintWriter out = new PrintWriter(new FileWriter(file));
+        try {
+            generateSchema(out, namespaceMapping);
+        } finally {
+            out.close();
+        }
+    }
+
+    public void generateSchema(PrintWriter out, NamespaceMapping namespaceMapping) {
+        out.println("<?xml version='1.0'?>");
+        out.println("<!-- NOTE: this file is autogenerated by Apache XBean -->");
+        out.println();
+        out.println("<xs:schema elementFormDefault='qualified'");
+        out.println("           targetNamespace='" + namespaceMapping.getNamespace() + "'");
+        out.println("           xmlns:xs='http://www.w3.org/2001/XMLSchema'");
+        out.println("           xmlns:tns='" + namespaceMapping.getNamespace() + "'>");
+
+        for (Iterator iter = namespaceMapping.getElements().iterator(); iter.hasNext();) {
+            ElementMapping element = (ElementMapping) iter.next();
+            generateElementMapping(out, namespaceMapping, element);
+        }
+
+        out.println();
+        out.println("</xs:schema>");
+    }
+
+    private void generateElementMapping(PrintWriter out, NamespaceMapping namespaceMapping, ElementMapping element) {
+        out.println();
+        out.println("  <!-- element for type: " + element.getClassName() + " -->");
+
+        String localName = element.getElementName();
+
+        out.println("  <xs:element name='" + localName + "'>");
+
+        if (!isEmptyString(element.getDescription())) {
+            out.println("    <xs:annotation>");
+            out.println("      <xs:documentation><![CDATA[");
+            out.println("        " + element.getDescription());
+            out.println("      ]]></xs:documentation>");
+            out.println("    </xs:annotation>");
+        }
+
+        out.println("    <xs:complexType>");
+
+        int complexCount = 0;
+        for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();) {
+            AttributeMapping attributeMapping = (AttributeMapping) iterator.next();
+            if (!namespaceMapping.isSimpleType(attributeMapping.getType())) {
+                complexCount++;
+            }
+        }
+        if (complexCount > 0) {
+            out.println("      <xs:sequence>");
+            for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();) {
+                AttributeMapping attributeMapping = (AttributeMapping) iterator.next();
+                if (!namespaceMapping.isSimpleType(attributeMapping.getType())) {
+                    generateElementMappingComplexProperty(out, namespaceMapping, attributeMapping);
+                }
+            }
+            out.println("        <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded'/>");
+            out.println("      </xs:sequence>");
+        }
+
+        for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();) {
+            AttributeMapping attributeMapping = (AttributeMapping) iterator.next();
+            if (namespaceMapping.isSimpleType(attributeMapping.getType())) {
+                generateElementMappingSimpleProperty(out, attributeMapping);
+            } else if (!attributeMapping.getType().isCollection()) {
+                generateElementMappingComplexPropertyAsRef(out, attributeMapping);
+            }
+        }
+        generateIDAttributeMapping(out, namespaceMapping, element);
+
+        out.println("      <xs:anyAttribute namespace='##other' processContents='lax'/>");
+        out.println("    </xs:complexType>");
+        out.println("  </xs:element>");
+        out.println();
+    }
+
+    private boolean isEmptyString(String str) {
+        if (str == null) {
+            return true;
+        }
+        for (int i = 0; i < str.length(); i++) {
+            if (!Character.isWhitespace(str.charAt(i))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private void generateIDAttributeMapping(PrintWriter out, NamespaceMapping namespaceMapping, ElementMapping element) {
+        for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();) {
+            AttributeMapping attributeMapping = (AttributeMapping) iterator.next();
+            if ("id".equals(attributeMapping.getAttributeName())) {
+                return;
+            }
+        }
+        out.println("      <xs:attribute name='id' type='xs:ID'/>");
+    }
+
+    private void generateElementMappingSimpleProperty(PrintWriter out, AttributeMapping attributeMapping) {
+    	// types with property editors need to be xs:string in the schema to validate
+    	String type = attributeMapping.getPropertyEditor() != null ? 
+    			Utils.getXsdType(Type.newSimpleType(String.class.getName())) : Utils.getXsdType(attributeMapping.getType());
+        if (!isEmptyString(attributeMapping.getDescription())) {
+            out.println("      <xs:attribute name='" + attributeMapping.getAttributeName() + "' type='" + type + "'>");
+            out.println("        <xs:annotation>");
+            out.println("          <xs:documentation><![CDATA[");
+            out.println("            " + attributeMapping.getDescription());
+            out.println("          ]]></xs:documentation>");
+            out.println("        </xs:annotation>");
+            out.println("      </xs:attribute>");
+        } else {
+            out.println("      <xs:attribute name='" + attributeMapping.getAttributeName() + "' type='" + type + "'/>");
+        }
+    }
+
+    private void generateElementMappingComplexPropertyAsRef(PrintWriter out, AttributeMapping attributeMapping) {
+        if (!isEmptyString(attributeMapping.getDescription())) {
+            out.println("      <xs:attribute name='" + attributeMapping.getAttributeName() + "' type='xs:string'>");
+            out.println("        <xs:annotation>");
+            out.println("          <xs:documentation><![CDATA[");
+            out.println("            " + attributeMapping.getDescription());
+            out.println("          ]]></xs:documentation>");
+            out.println("        </xs:annotation>");
+            out.println("      </xs:attribute>");
+        } else {
+            out.println("      <xs:attribute name='" + attributeMapping.getAttributeName() + "' type='xs:string'/>");
+        }
+    }
+
+    private void generateElementMappingComplexProperty(PrintWriter out, NamespaceMapping namespaceMapping, AttributeMapping attributeMapping) {
+        Type type = attributeMapping.getType();
+        List types;
+        if (type.isCollection()) {
+            types = Utils.findImplementationsOf(namespaceMapping, type.getNestedType());
+        } else {
+            types = Utils.findImplementationsOf(namespaceMapping, type);
+        }
+        String maxOccurs = type.isCollection() || "java.util.Map".equals(type.getName()) ? "unbounded" : "1";
+
+        out.println("        <xs:element name='" + attributeMapping.getAttributeName() + "' minOccurs='0' maxOccurs='1'>");
+        if (!isEmptyString(attributeMapping.getDescription())) {
+            out.println("          <xs:annotation>");
+            out.println("            <xs:documentation><![CDATA[");
+            out.println("              " + attributeMapping.getDescription());
+            out.println("            ]]></xs:documentation>");
+            out.println("          </xs:annotation>");
+        }
+        out.println("          <xs:complexType>");
+        if (types.isEmpty()) {
+            // We don't know the type because it's generic collection.  Allow folks to insert objets from any namespace
+            out.println("            <xs:sequence minOccurs='0' maxOccurs='" + maxOccurs + "'><xs:any minOccurs='0' maxOccurs='unbounded'/></xs:sequence>");
+        } else {
+            out.println("            <xs:choice minOccurs='0' maxOccurs='" + maxOccurs + "'>");
+            for (Iterator iterator = types.iterator(); iterator.hasNext();) {
+                ElementMapping element = (ElementMapping) iterator.next();
+                out.println("              <xs:element ref='tns:" + element.getElementName() + "'/>");
+            }
+            out.println("              <xs:any namespace='##other'/>");
+            out.println("            </xs:choice>");
+        }
+        out.println("          </xs:complexType>");
+        out.println("        </xs:element>");
+    }
+
+    public LogFacade getLog() {
+        return log;
+    }
+
+    public void setLog(LogFacade log) {
+        this.log = log;
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XsdGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XsdGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/XsdGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadAttributeTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadAttributeTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadAttributeTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadAttributeTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Guillaume Nodet
+ * @version $Id$
+ * @since 2.3
+ */
+public class BadAttributeTest extends TestCase {
+    
+    public void testBadNs() throws Exception {
+    	try {
+    		BlueprintTestSupport.parse("org/apache/xbean/blueprint/context/bad-attribute.xml");
+    		fail("This should have thrown an exception");
+    	} catch (Exception e) {
+    		System.out.println(e.getMessage());
+    	}
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadAttributeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadAttributeTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadAttributeTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadElementTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadElementTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadElementTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadElementTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Guillaume Nodet
+ * @version $Id$
+ * @since 2.3
+ */
+public class BadElementTest extends TestCase {
+    
+    public void testBadNs() throws Exception {
+    	try {
+    		BlueprintTestSupport.parse("org/apache/xbean/blueprint/context/bad-element.xml");
+    		fail("This should have thrown an exception");
+    	} catch (Exception e) {
+    		System.out.println(e.getMessage());
+    	}
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadElementTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadElementTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadElementTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadNamespaceTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadNamespaceTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadNamespaceTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadNamespaceTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Guillaume Nodet
+ * @version $Id$
+ * @since 2.3
+ */
+public class BadNamespaceTest extends TestCase {
+    
+    public void testBadNs() throws Exception {
+    	try {
+    		BlueprintTestSupport.parse("org/apache/xbean/blueprint/context/bad-namespace.xml");
+    		fail("This should have thrown an exception");
+    	} catch (Exception e) {
+    		System.out.println(e.getMessage());
+    	}
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadNamespaceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadNamespaceTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BadNamespaceTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerNullTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerNullTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerNullTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerNullTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+import org.apache.xbean.blueprint.example.BeerService;
+import org.apache.aries.blueprint.ComponentDefinitionRegistry;
+import org.apache.aries.blueprint.reflect.BeanMetadataImpl;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 2.6
+ */
+public class BeerNullTest extends BlueprintTestSupport {
+
+    public void testBeer() throws Exception {
+        ComponentDefinitionRegistry reg = parse(getPlan());
+        BeanMetadataImpl meta = (BeanMetadataImpl) reg.getComponentDefinition("beerService");
+
+        checkPropertyValue("name", "Stella", meta);
+        checkPropertyValue("id", "123", meta);
+        //no property set since this is the default
+//        checkPropertyValue("source", "tap", meta);
+
+        BeanMetadataImpl meta2 = (BeanMetadataImpl) reg.getComponentDefinition("beerService2");
+
+        checkPropertyValue("name", "Blue Moon", meta2);
+        checkPropertyValue("id", "123", meta2);
+        //TODO blueprint null handling?
+        checkPropertyValue("source", "#null", meta2);
+    }
+
+    protected String getPlan() {
+        return "org/apache/xbean/blueprint/context/beer-xbean-null.xml";
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerNullTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerNullTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerNullTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingSpringTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingSpringTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingSpringTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingSpringTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+import org.apache.aries.blueprint.ComponentDefinitionRegistry;
+import org.apache.aries.blueprint.reflect.BeanMetadataImpl;
+
+/**
+ * @author James Strachan
+ * @version $Id$
+ * @since 1.0
+ */
+public class BeerUsingSpringTest extends BlueprintTestSupport {
+    
+    public void testBeer() throws Exception {
+        ComponentDefinitionRegistry reg = parse(getPlan());
+        BeanMetadataImpl meta = (BeanMetadataImpl) reg.getComponentDefinition("beerService");
+        checkPropertyValue("name", "Stella", meta);
+        checkPropertyValue("id", "123", meta);
+        assertEquals("id", "beerService", meta.getId());
+    }
+
+    protected String getPlan() {
+        return "org/apache/xbean/blueprint/context/beer-normal.xml";
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingSpringTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingSpringTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingSpringTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanNSTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanNSTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanNSTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanNSTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+
+/**
+ * @author Guillaume Nodet
+ * @version $Id$
+ * @since 2.2
+ */
+public class BeerUsingXBeanNSTest extends BeerUsingSpringTest {
+
+    protected String getPlan() {
+        return "org/apache/xbean/blueprint/context/beer-xbean-ns.xml";
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanNSTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanNSTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanNSTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanSystemPropTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanSystemPropTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanSystemPropTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanSystemPropTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+/**
+ * @author Hiram Chirino
+ * @version $Id$
+ * @since 2.0
+ */
+public class BeerUsingXBeanSystemPropTest extends BeerUsingSpringTest {
+
+    protected String getPlan() {
+        return "org/apache/xbean/blueprint/context/beer-xbean-system-prop.xml";
+    }
+
+    protected void setUp() throws Exception {
+        System.setProperty("beerType", "Stella");
+        super.setUp();
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanSystemPropTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanSystemPropTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanSystemPropTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+/**
+ * @author James Strachan
+ * @version $Id$
+ * @since 2.0
+ */
+public class BeerUsingXBeanTest extends BeerUsingSpringTest {
+
+    protected String getPlan() {
+        return "org/apache/xbean/blueprint/context/beer-xbean.xml";
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BeerUsingXBeanTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BlueprintTestSupport.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BlueprintTestSupport.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BlueprintTestSupport.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BlueprintTestSupport.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,155 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+import junit.framework.TestCase;
+import org.apache.aries.blueprint.NamespaceHandler;
+import org.apache.aries.blueprint.reflect.BeanMetadataImpl;
+import org.apache.aries.blueprint.container.NamespaceHandlerRegistry;
+import org.apache.aries.blueprint.container.Parser;
+import org.apache.aries.blueprint.namespace.ComponentDefinitionRegistryImpl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.xbean.blueprint.context.impl.XBeanNamespaceHandler;
+import org.apache.xbean.blueprint.example.BeerService;
+import org.apache.xbean.blueprint.example.ContainerBean;
+import org.apache.xbean.blueprint.example.DummyBean;
+import org.apache.xbean.blueprint.example.FavoriteService;
+import org.apache.xbean.blueprint.example.FlatMapService;
+import org.apache.xbean.blueprint.example.GinService;
+import org.apache.xbean.blueprint.example.InnerBean;
+import org.apache.xbean.blueprint.example.KegService;
+import org.apache.xbean.blueprint.example.MilliLittersPropertyEditor;
+import org.apache.xbean.blueprint.example.PizzaService;
+import org.apache.xbean.blueprint.example.QNameService;
+import org.apache.xbean.blueprint.example.Recipe;
+import org.apache.xbean.blueprint.example.RecipeService;
+import org.apache.xbean.blueprint.example.RestaurantService;
+import org.apache.xbean.blueprint.example.SaladService;
+import org.xml.sax.SAXException;
+import org.osgi.service.blueprint.reflect.BeanProperty;
+import org.osgi.service.blueprint.reflect.ValueMetadata;
+import org.osgi.service.blueprint.reflect.BeanArgument;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+
+import javax.xml.validation.Schema;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A useful base class for testing spring based utilities.
+ * 
+ * @author James Strachan
+ * @version $Id$
+ * @since 2.0
+ */
+public abstract class BlueprintTestSupport extends TestCase {
+    protected Log log = LogFactory.getLog(getClass());
+    private static final URI NAMESPACE_URI = URI.create("http://xbean.apache.org/schemas/pizza");
+
+    protected ComponentDefinitionRegistryImpl reg;
+
+    protected void setUp() throws Exception {
+        reg = parse(getPlan());
+    }
+
+    protected static ComponentDefinitionRegistryImpl parse(String plan) throws Exception {
+        Properties properties = new Properties();
+        URL propUrl = BlueprintTestSupport.class.getClassLoader().getResource("META-INF/services/org/apache/xbean/blueprint/http/xbean.apache.org/schemas/pizza");
+        InputStream in = propUrl.openStream();
+        try {
+            properties.load(in);
+        } finally {
+            in.close();
+        }
+
+        Set<Class> classes = new HashSet<Class>();
+        ClassLoader cl = BlueprintTestSupport.class.getClassLoader();
+        for (Map.Entry entry: properties.entrySet()) {
+            String key = (String) entry.getKey();
+            if (!key.contains(".")) {
+                String className = (String) entry.getValue();
+                Class clazz = cl.loadClass(className);
+                classes.add(clazz);
+            }
+        }
+
+        final NamespaceHandler xbeanHandler = new XBeanNamespaceHandler(NAMESPACE_URI.toString(), BlueprintTestSupport.class.getClassLoader().getResource("restaurant.xsd"), classes, properties);
+        NamespaceHandlerRegistry.NamespaceHandlerSet handlers = new NamespaceHandlerRegistry.NamespaceHandlerSet() {
+            public Set<URI> getNamespaces() {
+                return Collections.singleton(NAMESPACE_URI);
+            }
+            public NamespaceHandler getNamespaceHandler(URI namespace) {
+                return xbeanHandler;
+            }
+            public void removeListener(NamespaceHandlerRegistry.Listener listener) {
+            }
+            public Schema getSchema() throws SAXException, IOException {
+                return null;
+            }
+            public boolean isComplete() {
+                return false;
+            }
+            public void addListener(NamespaceHandlerRegistry.Listener listener) {
+            }
+            public void destroy() {
+            }
+        };
+        return parse(plan, handlers);
+    }
+
+    // from aries blueprint core AbstractBlueprintTest
+    protected static ComponentDefinitionRegistryImpl parse(String plan, NamespaceHandlerRegistry.NamespaceHandlerSet handlers) throws Exception {
+        ComponentDefinitionRegistryImpl registry = new ComponentDefinitionRegistryImpl();
+        Parser parser = new Parser();
+        parser.parse(Collections.singletonList(BlueprintTestSupport.class.getClassLoader().getResource(plan)));
+        parser.populate(handlers, registry);
+        return registry;
+    }
+
+    protected abstract String getPlan();
+
+    protected void checkPropertyValue(String name, String expectedValued, BeanMetadataImpl meta) {
+        List<BeanProperty> props = meta.getProperties();
+        for (BeanProperty prop: props) {
+            if (name.equals(prop.getName())) {
+                assertEquals(expectedValued, ((ValueMetadata)prop.getValue()).getStringValue());
+                return;
+            }
+        }
+        throw new RuntimeException("No such property: " + name + " in metadata: " + meta);
+    }
+
+    protected void checkArgumentValue(int index, String expectedValued, BeanMetadataImpl meta, boolean allowNesting) {
+        List<BeanArgument> props = meta.getArguments();
+        Metadata metadata = props.get(index).getValue();
+        if (allowNesting && metadata instanceof BeanMetadata) {
+            metadata = ((BeanMetadata)metadata).getArguments().get(0).getValue();
+        }
+        assertEquals(expectedValued, ((ValueMetadata) metadata).getStringValue());
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BlueprintTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BlueprintTestSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/BlueprintTestSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/ComponentTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/ComponentTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/ComponentTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/ComponentTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+import junit.framework.TestCase;
+
+import org.apache.xbean.blueprint.example.ContainerBean;
+import org.apache.xbean.blueprint.example.InnerBean;
+import org.apache.aries.blueprint.ComponentDefinitionRegistry;
+import org.apache.aries.blueprint.reflect.BeanMetadataImpl;
+
+public class ComponentTest extends TestCase {
+
+    protected void setUp() throws Exception {
+        InnerBean.INSTANCE = null;
+    }
+    
+    public void test1() throws Exception {
+        test("org/apache/xbean/blueprint/context/component-spring.xml");
+    }
+
+    public void test2() throws Exception {
+        test("org/apache/xbean/blueprint/context/component-xbean.xml");
+    }
+    
+    protected void test(String file) throws Exception {
+        ComponentDefinitionRegistry f = BlueprintTestSupport.parse(file);
+        BeanMetadataImpl meta = (BeanMetadataImpl) f.getComponentDefinition("container");
+        assertNotNull(meta);
+        //TODO blueprint look at bean metadata?
+//        assertNotNull(meta.getBeans());
+//        assertEquals(1, meta.getBeans().length);
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/ComponentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/ComponentTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/ComponentTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingSpringTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingSpringTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingSpringTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingSpringTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.xbean.blueprint.example.FavoriteService;
+import org.apache.xbean.blueprint.example.GinService;
+import org.apache.aries.blueprint.reflect.BeanMetadataImpl;
+
+/**
+ * @author James Strachan
+ * @version $Id$
+ * @since 1.0
+ */
+public class FavoriteUsingSpringTest extends BlueprintTestSupport {
+    
+    public void testFavs() throws Exception {
+        BeanMetadataImpl meta = (BeanMetadataImpl)  reg.getComponentDefinition("favoriteService");
+       //TODO blueprint understand maps
+        Map favorites = null;//fs.getFavorites();
+//        assertNotNull(favorites);
+//        assertEquals(3, favorites.size());
+//
+//        assertEquals("Grey Goose", favorites.get("Dan"));
+//        Object object = favorites.get("IndecisiveDan");
+//        System.out.println(object.getClass());
+//        assertTrue(object instanceof List);
+//        List l = (List) object;
+//        assertEquals(2, l.size());
+//        object = l.get(0);
+//        System.out.println(object.getClass());
+//        assertTrue(object instanceof String);
+//        object = l.get(1);
+//        System.out.println(object.getClass());
+//        assertTrue(object instanceof Integer);
+//        object = favorites.get("WithInnerBean");
+//        System.out.println(object.getClass());
+//        assertTrue(object instanceof GinService);
+    }
+
+    protected String getPlan() {
+        return "org/apache/xbean/blueprint/context/favorite-normal.xml";
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingSpringTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingSpringTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingSpringTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanMixedTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanMixedTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanMixedTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanMixedTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+/**
+ * @author James Strachan
+ * @version $Id$
+ * @since 2.0
+ */
+public class FavoriteUsingXBeanMixedTest extends FavoriteUsingSpringTest {
+
+    protected String getPlan() {
+        return "org/apache/xbean/blueprint/context/favorite-xbean-mixed.xml";
+    }
+
+}
\ No newline at end of file

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanMixedTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanMixedTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanMixedTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+/**
+ * @author James Strachan
+ * @version $Id$
+ * @since 2.0
+ */
+public class FavoriteUsingXBeanTest extends FavoriteUsingSpringTest {
+
+    protected String getPlan() {
+        return "org/apache/xbean/blueprint/context/favorite-xbean.xml";
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FavoriteUsingXBeanTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FlatMapTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FlatMapTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FlatMapTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FlatMapTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+import java.util.List;
+
+import org.apache.xbean.blueprint.example.FlatMapService;
+import org.apache.xbean.blueprint.example.KegService;
+import org.apache.aries.blueprint.reflect.BeanMetadataImpl;
+
+/**
+ * @author gnodet
+ */
+public class FlatMapTest extends BlueprintTestSupport {
+
+    public void testFlatMap() {
+        BeanMetadataImpl meta = (BeanMetadataImpl)  reg.getComponentDefinition("flat-map");
+        //TODO blueprint
+//        assertEquals(3, fm.getServices().size());
+//        Object obj = fm.getServices().get("key1");
+//        assertTrue(obj instanceof List);
+//        List l = (List) obj;
+//        assertEquals(2, l.size());
+//        System.out.println(l.get(0).getClass());
+//        assertTrue(l.get(0) instanceof KegService);
+//        System.out.println(l.get(1).getClass());
+//        assertTrue(l.get(1) instanceof KegService);
+//        obj = fm.getServices().get("key2");
+//        assertTrue(obj instanceof List);
+//        l = (List) obj;
+//        assertEquals(1, l.size());
+//        System.out.println(l.get(0).getClass());
+//        assertTrue(l.get(0) instanceof KegService);
+//        obj = fm.getServices().get("others");
+//        assertTrue(obj instanceof List);
+//        l = (List) obj;
+//        assertEquals(1, l.size());
+//        System.out.println(l.get(0).getClass());
+//        assertTrue(l.get(0) instanceof KegService);
+    }
+
+    protected String getPlan() {
+        return "org/apache/xbean/blueprint/context/flatmap-xbean.xml";
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FlatMapTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FlatMapTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/FlatMapTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/GinUsingSpringTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/GinUsingSpringTest.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/GinUsingSpringTest.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/GinUsingSpringTest.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.blueprint.context;
+
+import org.apache.xbean.blueprint.example.GinService;
+import org.apache.aries.blueprint.reflect.BeanMetadataImpl;
+
+/**
+ * @author James Strachan
+ * @version $Id$
+ * @since 1.0
+ */
+public class GinUsingSpringTest extends BlueprintTestSupport {
+    
+    public void testWine() throws Exception {
+        BeanMetadataImpl meta = (BeanMetadataImpl)  reg.getComponentDefinition("ginService");
+
+        checkPropertyValue("name", "Bombay Sapphire", meta);
+    }
+
+    protected String getPlan() {
+        return "org/apache/xbean/blueprint/context/gin.xml";
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/GinUsingSpringTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/GinUsingSpringTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/test/java/org/apache/xbean/blueprint/context/GinUsingSpringTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message