You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2006/07/12 20:02:44 UTC

svn commit: r421355 - in /incubator/tuscany/sandbox/chianti/sca/core/src: main/java/org/apache/tuscany/core/implementation/composite/ main/java/org/apache/tuscany/core/loader/ test/java/org/apache/tuscany/core/loader/

Author: jboynes
Date: Wed Jul 12 11:02:43 2006
New Revision: 421355

URL: http://svn.apache.org/viewvc?rev=421355&view=rev
Log:
add loader for include element

Added:
    incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java   (with props)
    incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java   (with props)
Modified:
    incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java

Modified: incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java?rev=421355&r1=421354&r2=421355&view=diff
==============================================================================
--- incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java (original)
+++ incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java Wed Jul 12 11:02:43 2006
@@ -42,7 +42,11 @@
         return IMPLEMENTATION_COMPOSITE;
     }
 
-    public CompositeImplementation load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+    public CompositeImplementation load(CompositeComponent parent,
+                                        XMLStreamReader reader,
+                                        DeploymentContext deploymentContext)
+        throws XMLStreamException, LoaderException {
+
         assert IMPLEMENTATION_COMPOSITE.equals(reader.getName());
         String name = reader.getAttributeValue(null, "name");
         CompositeImplementation impl = new CompositeImplementation();

Added: incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java?rev=421355&view=auto
==============================================================================
--- incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java (added)
+++ incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java Wed Jul 12 11:02:43 2006
@@ -0,0 +1,56 @@
+/*
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ *  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.apache.tuscany.core.loader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.model.Include;
+
+/**
+ * Loader that handles <include> elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public class IncludeLoader extends LoaderExtension<Include> {
+    private static final QName INCLUDE = new QName(XML_NAMESPACE_1_0, "include");
+
+    public QName getXMLType() {
+        return INCLUDE;
+    }
+
+    public Include load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+        throws XMLStreamException, LoaderException {
+
+        assert INCLUDE.equals(reader.getName());
+        String name = reader.getAttributeValue(null, "name");
+
+        Include include = new Include();
+        include.setName(name);
+
+        LoaderUtil.skipToEndElement(reader);
+        return include;
+    }
+}

Propchange: incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/loader/IncludeLoader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java?rev=421355&view=auto
==============================================================================
--- incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java (added)
+++ incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java Wed Jul 12 11:02:43 2006
@@ -0,0 +1,57 @@
+/*
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ *  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.apache.tuscany.core.loader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+import org.osoa.sca.Version;
+
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.Include;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class IncludeLoaderTestCase extends MockObjectTestCase {
+    private static final QName INCLUDE = new QName(Version.XML_NAMESPACE_1_0, "include");
+
+    private IncludeLoader loader;
+    private Mock mockReader;
+
+    public void testName() throws LoaderException, XMLStreamException {
+        String name = "foo";
+        mockReader.expects(once()).method("getName").will(returnValue(IncludeLoaderTestCase.INCLUDE));
+        mockReader.expects(atLeastOnce()).method("getAttributeValue")
+                .with(ANYTHING, ANYTHING)
+                .will(returnValue(name));
+        mockReader.expects(once()).method("next").will(returnValue(XMLStreamConstants.END_ELEMENT));
+        Include include = loader.load(null, (XMLStreamReader) mockReader.proxy(), null);
+        assertEquals(name, include.getName());
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        this.loader = new IncludeLoader();
+        mockReader = mock(XMLStreamReader.class);
+
+    }
+}

Propchange: incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/loader/IncludeLoaderTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org