diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /branches/sca-java-0.91/itest/exceptions |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-0.91/itest/exceptions')
10 files changed, 516 insertions, 0 deletions
diff --git a/branches/sca-java-0.91/itest/exceptions/pom.xml b/branches/sca-java-0.91/itest/exceptions/pom.xml new file mode 100644 index 0000000000..e2144e9dbb --- /dev/null +++ b/branches/sca-java-0.91/itest/exceptions/pom.xml @@ -0,0 +1,45 @@ +<?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. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-itest</artifactId> + <version>0.91-incubating-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-itest-exceptions</artifactId> + <name>Apache Tuscany Exceptions Integration Tests</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-embedded</artifactId> + <version>0.91-incubating-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>0.91-incubating-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + </dependencies> +</project> diff --git a/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java new file mode 100644 index 0000000000..e90289a07d --- /dev/null +++ b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java @@ -0,0 +1,57 @@ +/* + * 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.tuscany.sca.test.exceptions; + + +public class Checked extends Exception { + + /** + * + */ + public Checked() { + + } + + /** + * @param message + */ + public Checked(String message) { + super(message); + + } + + /** + * @param cause + */ + public Checked(Throwable cause) { + super(cause); + + } + + /** + * @param message + * @param cause + */ + public Checked(String message, Throwable cause) { + super(message, cause); + + } + +} diff --git a/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java new file mode 100644 index 0000000000..0d14240513 --- /dev/null +++ b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java @@ -0,0 +1,32 @@ +/* + * 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.tuscany.sca.test.exceptions; + +public interface ExceptionHandler { + + public abstract void testing(); + + public abstract Checked getTheBad(); + + public abstract String getTheGood(); + + public abstract UnChecked getTheUgly(); + +}
\ No newline at end of file diff --git a/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java new file mode 100644 index 0000000000..80073e7679 --- /dev/null +++ b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java @@ -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.tuscany.sca.test.exceptions; + +public interface ExceptionThrower { + public static final String SO_THEY_SAY = "All is good that ends good."; + + public String theGood() throws org.apache.tuscany.sca.test.exceptions.Checked; + + public String theBad() throws org.apache.tuscany.sca.test.exceptions.Checked; + + public String theUgly() throws org.apache.tuscany.sca.test.exceptions.Checked; + +} diff --git a/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java new file mode 100644 index 0000000000..1a439711dd --- /dev/null +++ b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java @@ -0,0 +1,56 @@ +/* + * 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.tuscany.sca.test.exceptions; + +public class UnChecked extends RuntimeException { + + /** + * + */ + public UnChecked() { + + } + + /** + * @param message + */ + public UnChecked(String message) { + super(message); + + } + + /** + * @param cause + */ + public UnChecked(Throwable cause) { + super(cause); + + } + + /** + * @param message + * @param cause + */ + public UnChecked(String message, Throwable cause) { + super(message, cause); + + } + +} diff --git a/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java new file mode 100644 index 0000000000..32a23c5e7d --- /dev/null +++ b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java @@ -0,0 +1,120 @@ +/* + * 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.tuscany.sca.test.exceptions.impl; + +import org.apache.tuscany.sca.test.exceptions.Checked; +import org.apache.tuscany.sca.test.exceptions.ExceptionHandler; +import org.apache.tuscany.sca.test.exceptions.ExceptionThrower; +import org.apache.tuscany.sca.test.exceptions.UnChecked; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +@Scope("COMPOSITE") +public class ExceptionHandlerImpl implements ExceptionHandler { + static final String INIT = "INIT"; + + private ExceptionThrower exceptionThrower; + + private String theGood; + + private Checked theBad; + + private UnChecked theUgly; + + /* + * (non-Javadoc) + * + * @see org.apache.tuscany.sca.test.exceptions.impl.ExceptionHandler#testing() + */ + public void testing() { + + assert exceptionThrower != null : "'exceptionThrower' never wired"; + String result = INIT; + try { + theGood = result = exceptionThrower.theGood(); + assert result == ExceptionThrower.SO_THEY_SAY; + } catch (Throwable e) { + assert result == INIT; + assert false; + e.printStackTrace(); + } + + result = INIT; + try { + result = exceptionThrower.theBad(); + // incredible + assert false : "Expected 'Check' Exception"; + + } catch (Checked e) { + // This is good... + assert result == INIT; + theBad = e; + } catch (Throwable t) { + // This is not so good. + t.printStackTrace(); + assert result == INIT; + assert false : "Got wrong exception '" + t.getClass().getName(); + } + + result = INIT; + try { + result = exceptionThrower.theUgly(); + // incredible + assert false : "Expected 'UnCheck' Exception"; + + } catch (Checked e) { + // This is not so good... + assert false : "Got wrong exception '" + e.getClass().getName(); + assert result == INIT; + } catch (UnChecked e) { + theUgly = e; + + } catch (Throwable t) { + // This is not good. + assert false; + assert result == INIT; + + System.out.println(ExceptionThrower.SO_THEY_SAY + " " + INIT); + } + + } + + @Reference + public void setExceptionThrower(ExceptionThrower exceptionThrower) { + this.exceptionThrower = exceptionThrower; + } + + public String getTheGood() { + return theGood; + } + + public Checked getTheBad() { + return theBad; + } + + public UnChecked getTheUgly() { + return theUgly; + } + + public ExceptionThrower getExceptionThrower() { + return exceptionThrower; + } + +} diff --git a/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java new file mode 100644 index 0000000000..c1b7c23d5d --- /dev/null +++ b/branches/sca-java-0.91/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java @@ -0,0 +1,63 @@ +/* + * 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.tuscany.sca.test.exceptions.impl; + +import org.apache.tuscany.sca.test.exceptions.Checked; +import org.apache.tuscany.sca.test.exceptions.ExceptionThrower; +import org.apache.tuscany.sca.test.exceptions.UnChecked; + +/** + * @author rineholt + * + */ +public class ExceptionThrowerImpl implements ExceptionThrower { + + /* + * (non-Javadoc) + * + * @see org.apache.tuscany.sca.test.exceptions.ExceptionThrower#theBad() + */ + public String theBad() throws Checked { + + throw new Checked("theBad"); + + } + + /* + * (non-Javadoc) + * + * @see org.apache.tuscany.sca.test.exceptions.ExceptionThrower#theGood() + */ + public String theGood() throws Checked { + + return SO_THEY_SAY; + } + + /* + * (non-Javadoc) + * + * @see org.apache.tuscany.sca.test.exceptions.ExceptionThrower#theUgly() + */ + public String theUgly() throws Checked { + + throw new UnChecked("theUgly"); + } + +} diff --git a/branches/sca-java-0.91/itest/exceptions/src/main/resources/ExceptionTest.composite b/branches/sca-java-0.91/itest/exceptions/src/main/resources/ExceptionTest.composite new file mode 100644 index 0000000000..a725864d30 --- /dev/null +++ b/branches/sca-java-0.91/itest/exceptions/src/main/resources/ExceptionTest.composite @@ -0,0 +1,27 @@ +<?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" + xmlns:foo="http://foo" + targetNamespace = "http://foo" + name="ExceptionTest"> + + <include name="foo:intracomposite"/> + +</composite> diff --git a/branches/sca-java-0.91/itest/exceptions/src/main/resources/intracomposite.composite b/branches/sca-java-0.91/itest/exceptions/src/main/resources/intracomposite.composite new file mode 100644 index 0000000000..efe1c5e207 --- /dev/null +++ b/branches/sca-java-0.91/itest/exceptions/src/main/resources/intracomposite.composite @@ -0,0 +1,34 @@ +<?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" + xmlns:foo="http://foo" + targetNamespace="http://foo" + name="intracomposite"> + + <component name="main"> + <implementation.java class="org.apache.tuscany.sca.test.exceptions.impl.ExceptionHandlerImpl"/> + <reference name="exceptionThrower" target="exceptionThrower"/> + </component> + + <component name="exceptionThrower"> + <implementation.java class="org.apache.tuscany.sca.test.exceptions.impl.ExceptionThrowerImpl"/> + </component> + +</composite> diff --git a/branches/sca-java-0.91/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/IntraCompositeTestCase.java b/branches/sca-java-0.91/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/IntraCompositeTestCase.java new file mode 100644 index 0000000000..4f719a26c4 --- /dev/null +++ b/branches/sca-java-0.91/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/IntraCompositeTestCase.java @@ -0,0 +1,51 @@ +/* + * 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.tuscany.sca.test.exceptions; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class IntraCompositeTestCase extends TestCase { + + private SCADomain domain; + private ExceptionHandler exceptionHandler; + + public void testALL() { + exceptionHandler.testing(); + assertEquals(ExceptionThrower.SO_THEY_SAY, exceptionHandler.getTheGood() ); + assertNotNull(exceptionHandler.getTheBad()); + assertEquals( Checked.class, exceptionHandler.getTheBad().getClass()); + assertNotNull(exceptionHandler.getTheUgly()); + assertEquals( UnChecked.class, exceptionHandler.getTheUgly().getClass()); + + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("ExceptionTest.composite"); + exceptionHandler = domain.getService(ExceptionHandler.class, "main"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} |