summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-08-04 07:22:31 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-08-04 07:22:31 +0000
commitdfb138a817c77845b3e528aa0254063636120676 (patch)
tree97c7eb589b46c1738202877d8939b6d203229d8d /java/sca
parent4e9809ebb27bc0846076822b0140bef424367b63 (diff)
TUSCANY-2403 - Applying patch from Ram
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@682275 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--java/sca/itest/validation/pom.xml7
-rw-r--r--java/sca/itest/validation/src/main/resources/impl/ejb/EJBLinkAttributeMissing/ejb.composite29
-rw-r--r--java/sca/itest/validation/src/main/resources/impl/osgi/MissingComponentTypeFile/OSGiTestService.jarbin1324 -> 1325 bytes
-rw-r--r--java/sca/itest/validation/src/main/resources/impl/osgi/PropertyShouldSpecifySR/OSGiTestService.jarbin1324 -> 1325 bytes
-rw-r--r--java/sca/itest/validation/src/test/java/impl/ejb/EJBLinkAttributeMissingTestCase.java60
-rw-r--r--java/sca/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java19
-rw-r--r--java/sca/modules/implementation-ejb/src/main/resources/impl-ejb-validation-messages.properties21
7 files changed, 136 insertions, 0 deletions
diff --git a/java/sca/itest/validation/pom.xml b/java/sca/itest/validation/pom.xml
index c196680e5a..f71bed0957 100644
--- a/java/sca/itest/validation/pom.xml
+++ b/java/sca/itest/validation/pom.xml
@@ -83,6 +83,13 @@
<artifactId>tuscany-implementation-osgi</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-ejb</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
diff --git a/java/sca/itest/validation/src/main/resources/impl/ejb/EJBLinkAttributeMissing/ejb.composite b/java/sca/itest/validation/src/main/resources/impl/ejb/EJBLinkAttributeMissing/ejb.composite
new file mode 100644
index 0000000000..94ee650207
--- /dev/null
+++ b/java/sca/itest/validation/src/main/resources/impl/ejb/EJBLinkAttributeMissing/ejb.composite
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample/ejb"
+ xmlns:sc="http://sample/composite"
+ name="TestEJB">
+
+ <component name="TestEJB">
+ <implementation.ejb/>
+ </component>
+
+</composite>
diff --git a/java/sca/itest/validation/src/main/resources/impl/osgi/MissingComponentTypeFile/OSGiTestService.jar b/java/sca/itest/validation/src/main/resources/impl/osgi/MissingComponentTypeFile/OSGiTestService.jar
index f15155b471..94a99a787b 100644
--- a/java/sca/itest/validation/src/main/resources/impl/osgi/MissingComponentTypeFile/OSGiTestService.jar
+++ b/java/sca/itest/validation/src/main/resources/impl/osgi/MissingComponentTypeFile/OSGiTestService.jar
Binary files differ
diff --git a/java/sca/itest/validation/src/main/resources/impl/osgi/PropertyShouldSpecifySR/OSGiTestService.jar b/java/sca/itest/validation/src/main/resources/impl/osgi/PropertyShouldSpecifySR/OSGiTestService.jar
index c9851107a8..df69e5a8c2 100644
--- a/java/sca/itest/validation/src/main/resources/impl/osgi/PropertyShouldSpecifySR/OSGiTestService.jar
+++ b/java/sca/itest/validation/src/main/resources/impl/osgi/PropertyShouldSpecifySR/OSGiTestService.jar
Binary files differ
diff --git a/java/sca/itest/validation/src/test/java/impl/ejb/EJBLinkAttributeMissingTestCase.java b/java/sca/itest/validation/src/test/java/impl/ejb/EJBLinkAttributeMissingTestCase.java
new file mode 100644
index 0000000000..b31451c433
--- /dev/null
+++ b/java/sca/itest/validation/src/test/java/impl/ejb/EJBLinkAttributeMissingTestCase.java
@@ -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 impl.ejb;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.logging.impl.DefaultLoggingMonitorImpl;
+
+import domain.CustomCompositeBuilder;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class EJBLinkAttributeMissingTestCase extends TestCase {
+
+ private CustomCompositeBuilder customDomain;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ customDomain = CustomCompositeBuilder.getInstance();
+ try {
+ customDomain.loadContribution("src/main/resources/impl/ejb/EJBLinkAttributeMissing/ejb.composite",
+ "TestContribution", "src/main/resources/impl/ejb/EJBLinkAttributeMissing/");
+ } catch (Exception ex){
+ //throw ex;
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ //nothing to do
+ }
+
+ public void testCalculator() {
+ Monitor monitor = customDomain.getMonitorInstance();
+ Problem problem = ((DefaultLoggingMonitorImpl)monitor).getLastLoggedProblem();
+
+ assertNotNull(problem);
+ assertEquals("EJBLinkAttributeMissing", problem.getMessageId());
+ }
+}
diff --git a/java/sca/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java b/java/sca/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java
index b28766f387..b3e5e3394c 100644
--- a/java/sca/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java
+++ b/java/sca/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java
@@ -27,6 +27,7 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl;
import org.apache.tuscany.sca.assembly.xml.Constants;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
@@ -38,6 +39,8 @@ import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
import org.apache.tuscany.sca.implementation.ejb.EJBImplementation;
import org.apache.tuscany.sca.implementation.ejb.EJBImplementationFactory;
import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
/**
@@ -57,6 +60,20 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem
this.implementationFactory = modelFactories.getFactory(EJBImplementationFactory.class);
this.monitor = monitor;
}
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = new ProblemImpl(this.getClass().getName(), "impl-ejb-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
public QName getArtifactType() {
// Returns the QName of the XML element processed by this processor
@@ -87,6 +104,8 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem
} else {
implementation.setURI(ejbLink);
}
+ } else {
+ error("EJBLinkAttributeMissing", reader);
}
// Skip to end element
diff --git a/java/sca/modules/implementation-ejb/src/main/resources/impl-ejb-validation-messages.properties b/java/sca/modules/implementation-ejb/src/main/resources/impl-ejb-validation-messages.properties
new file mode 100644
index 0000000000..4eaf2b9007
--- /dev/null
+++ b/java/sca/modules/implementation-ejb/src/main/resources/impl-ejb-validation-messages.properties
@@ -0,0 +1,21 @@
+#
+#
+# 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.
+#
+#
+EJBLinkAttributeMissing = Reading implementation.ejb - ejb-link attribute missing \ No newline at end of file