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 19:51:48 UTC

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

Author: jboynes
Date: Wed Jul 12 10:51:47 2006
New Revision: 421348

URL: http://svn.apache.org/viewvc?rev=421348&view=rev
Log:
add loader for implementation.composite element

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

Added: 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=421348&view=auto
==============================================================================
--- incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java (added)
+++ incubator/tuscany/sandbox/chianti/sca/core/src/main/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoader.java Wed Jul 12 10:51:47 2006
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.implementation.composite;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+
+import org.osoa.sca.Version;
+
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+
+/**
+ * Loader that handles an <implementation.composite> element.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImplementationCompositeLoader extends LoaderExtension<CompositeImplementation> {
+    private static final QName IMPLEMENTATION_COMPOSITE =
+            new QName(Version.XML_NAMESPACE_1_0, "implementation.composite");
+
+    public QName getXMLType() {
+        return IMPLEMENTATION_COMPOSITE;
+    }
+
+    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();
+        impl.setName(name);
+        LoaderUtil.skipToEndElement(reader);
+        return impl;
+    }
+}

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

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

Added: incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java?rev=421348&view=auto
==============================================================================
--- incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java (added)
+++ incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.java Wed Jul 12 10:51:47 2006
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.implementation.composite;
+
+import javax.xml.namespace.QName;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+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.CompositeImplementation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ImplementationCompositeLoaderTestCase extends MockObjectTestCase {
+    private static final QName IMPLEMENTATION_COMPOSITE =
+            new QName(Version.XML_NAMESPACE_1_0, "implementation.composite");
+
+    private ImplementationCompositeLoader loader;
+    private Mock mockReader;
+
+    public void testName() throws LoaderException, XMLStreamException {
+        String name = "foo";
+        mockReader.expects(once()).method("getName").will(returnValue(IMPLEMENTATION_COMPOSITE));
+        mockReader.expects(atLeastOnce()).method("getAttributeValue")
+                .with(ANYTHING, ANYTHING)
+                .will(returnValue(name));
+        mockReader.expects(once()).method("next").will(returnValue(END_ELEMENT));
+        CompositeImplementation impl = loader.load(null, (XMLStreamReader) mockReader.proxy(), null);
+        assertEquals(name, impl.getName());
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        this.loader = new ImplementationCompositeLoader();
+        mockReader = mock(XMLStreamReader.class);
+
+    }
+}

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

Propchange: incubator/tuscany/sandbox/chianti/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/ImplementationCompositeLoaderTestCase.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