diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-16 09:44:31 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-16 09:44:31 +0000 |
commit | 8359dbd6260d3c662668e1d644385e1728fcf7d2 (patch) | |
tree | 0879b160ce958c62dee078d62da991fb5a36bdcf /branches/sca-java-1.x/itest/java-init-exceptions/src | |
parent | cc8390a108db502b965721392f1df0a7be221754 (diff) |
TUSCANY-2851, start of an itest for exceptions in Java component initilization
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@765542 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/itest/java-init-exceptions/src')
6 files changed, 265 insertions, 0 deletions
diff --git a/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/ConstructorException.java b/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/ConstructorException.java new file mode 100644 index 0000000000..375e8c2986 --- /dev/null +++ b/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/ConstructorException.java @@ -0,0 +1,47 @@ +/*
+ * 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 itest;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+public class ConstructorException implements Service {
+
+ public static boolean initRun;
+ public static boolean destroyRun;
+
+ public ConstructorException() {
+ throw new RuntimeException();
+ }
+
+ public void doit() {
+ }
+
+ @Init
+ public void init() {
+ initRun = true;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyRun = true;
+ }
+
+}
diff --git a/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/InitException.java b/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/InitException.java new file mode 100644 index 0000000000..b9e3f7955f --- /dev/null +++ b/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/InitException.java @@ -0,0 +1,43 @@ +/*
+ * 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 itest;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+public class InitException implements Service {
+
+ public static boolean initRun;
+ public static boolean destroyRun;
+
+ public void doit() {
+ }
+
+ @Init
+ public void init() {
+ throw new RuntimeException();
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyRun = true;
+ }
+
+}
diff --git a/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/OkImpl.java b/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/OkImpl.java new file mode 100644 index 0000000000..4ff6bc6f0a --- /dev/null +++ b/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/OkImpl.java @@ -0,0 +1,46 @@ +/*
+ * 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 itest;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+public class OkImpl implements Service {
+
+ public static boolean initRun;
+ public static boolean destroyRun;
+
+ public OkImpl() {
+ }
+
+ public void doit() {
+ }
+
+ @Init
+ public void init() {
+ initRun = true;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyRun = true;
+ }
+
+}
diff --git a/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/Service.java b/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/Service.java new file mode 100644 index 0000000000..f6f292c4c8 --- /dev/null +++ b/branches/sca-java-1.x/itest/java-init-exceptions/src/main/java/itest/Service.java @@ -0,0 +1,26 @@ +/*
+ * 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 itest;
+
+public interface Service {
+
+ void doit();
+
+}
diff --git a/branches/sca-java-1.x/itest/java-init-exceptions/src/main/resources/test.composite b/branches/sca-java-1.x/itest/java-init-exceptions/src/main/resources/test.composite new file mode 100644 index 0000000000..00bf842625 --- /dev/null +++ b/branches/sca-java-1.x/itest/java-init-exceptions/src/main/resources/test.composite @@ -0,0 +1,37 @@ +<?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://itest"
+ xmlns:itest="http://itest"
+ name="Test">
+
+ <component name="OkService">
+ <implementation.java class="itest.OkImpl"/>
+ </component>
+
+ <component name="ConstructorException">
+ <implementation.java class="itest.ConstructorException"/>
+ </component>
+
+ <component name="InitException">
+ <implementation.java class="itest.InitException"/>
+ </component>
+
+</composite>
diff --git a/branches/sca-java-1.x/itest/java-init-exceptions/src/test/java/itest/InitTestCase.java b/branches/sca-java-1.x/itest/java-init-exceptions/src/test/java/itest/InitTestCase.java new file mode 100644 index 0000000000..846c2779e3 --- /dev/null +++ b/branches/sca-java-1.x/itest/java-init-exceptions/src/test/java/itest/InitTestCase.java @@ -0,0 +1,66 @@ +/*
+ * 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 itest;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ */
+public class InitTestCase {
+
+ private static SCADomain scaDomain;
+
+ @Before
+ public void init() {
+ scaDomain = SCADomain.newInstance("http://localhost", "/", "test.composite");
+ }
+
+ @Test
+ public void testOk() throws Exception {
+ Service client1 = scaDomain.getService(Service.class, "OkService");
+ client1.doit();
+ assertTrue(OkImpl.initRun);
+ }
+
+ //@Test
+ public void testConstructorException() throws Exception {
+ Service client1 = scaDomain.getService(Service.class, "ConstructorException");
+ client1.doit();
+ assertTrue(OkImpl.initRun);
+ }
+
+ //@Test
+ public void testInitException() throws Exception {
+ Service client1 = scaDomain.getService(Service.class, "InitException");
+ client1.doit();
+ assertTrue(OkImpl.initRun);
+ }
+
+ @After
+ public void end() {
+ if (scaDomain != null) {
+ scaDomain.close();
+ }
+ }
+}
|