You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/08/28 03:49:05 UTC

svn commit: r437500 - in /incubator/tuscany/java/sca: commands/launcher/src/main/resources/META-INF/tuscany/ core/src/main/java/org/apache/tuscany/core/implementation/system/wire/ core/src/main/java/org/apache/tuscany/core/launcher/ core/src/test/java/...

Author: jmarino
Date: Sun Aug 27 18:48:58 2006
New Revision: 437500

URL: http://svn.apache.org/viewvc?rev=437500&view=rev
Log:
make autowire throw a TargetException when the target cannot be resolved (this will avoid NPEs being thrown in components as a result of configuration error; cleanup of system SCDLs to resolve all autowires; introduce test cases into webapp and webapp-host so that we can verify autowire configuration and basic bootstrap operation; cleanup of webapp and webapp-host projects

Added:
    incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowireTestCase.java   (with props)
    incubator/tuscany/java/sca/runtime/webapp-host/.ruleset
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/Foo.java   (with props)
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/FooImpl.java   (with props)
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletHostTestCase.java   (with props)
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletLauncherListenerTestCase.java   (with props)
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/resources/
    incubator/tuscany/java/sca/runtime/webapp-host/src/test/resources/testapp.scdl
    incubator/tuscany/java/sca/runtime/webapp/.ruleset
    incubator/tuscany/java/sca/runtime/webapp/src/test/
    incubator/tuscany/java/sca/runtime/webapp/src/test/java/
    incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/
    incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/
    incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/
    incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/
    incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/
    incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java   (with props)
    incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyServletTestCase.java   (with props)
Modified:
    incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java
    incubator/tuscany/java/sca/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl
    incubator/tuscany/java/sca/runtime/webapp-host/pom.xml
    incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java
    incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherListener.java
    incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/sca/webapp.system.scdl
    incubator/tuscany/java/sca/runtime/webapp/pom.xml
    incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java
    incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl

Modified: incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl?rev=437500&r1=437499&r2=437500&view=diff
==============================================================================
--- incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl (original)
+++ incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl Sun Aug 27 18:48:58 2006
@@ -114,4 +114,12 @@
         <system:implementation.system class="org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler"/>
     </component>
 
+    <component name="policyBuilderRegistry">
+         <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+    </component>
+
+    <component name="propertyFactory">
+        <system:implementation.system class="org.apache.tuscany.core.loader.StringParserPropertyFactory"/>
+    </component>
+
 </composite>

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java?rev=437500&r1=437499&r2=437500&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java Sun Aug 27 18:48:58 2006
@@ -24,6 +24,7 @@
 
 import org.apache.tuscany.spi.QualifiedName;
 import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.TargetNotFoundException;
 import org.apache.tuscany.spi.wire.InboundInvocationChain;
 import org.apache.tuscany.spi.wire.InboundWire;
 import org.apache.tuscany.spi.wire.OutboundInvocationChain;
@@ -39,12 +40,12 @@
 public class SystemOutboundAutowire<T> implements OutboundAutowire<T>, SystemOutboundWire<T> {
     private String referenceName;
     private Class<T> businessInterface;
-    private AutowireComponent<?> context;
+    private AutowireComponent<?> component;
 
-    public SystemOutboundAutowire(String referenceName, Class<T> businessInterface, AutowireComponent<?> context) {
+    public SystemOutboundAutowire(String referenceName, Class<T> businessInterface, AutowireComponent<?> component) {
         this.referenceName = referenceName;
         this.businessInterface = businessInterface;
-        this.context = context;
+        this.component = component;
     }
 
     public String getReferenceName() {
@@ -63,7 +64,13 @@
     }
 
     public T getTargetService() throws TargetException {
-        return context.resolveInstance(businessInterface);
+        T service = component.resolveInstance(businessInterface);
+        if (service == null) {
+            TargetNotFoundException e = new TargetNotFoundException("Autowire target not found");
+            e.setIdentifier(businessInterface.getName());
+            throw e;
+        }
+        return service;
     }
 
     public Class<T> getBusinessInterface() {

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java?rev=437500&r1=437499&r2=437500&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java Sun Aug 27 18:48:58 2006
@@ -85,6 +85,9 @@
         RuntimeInfo runtimeInfo = new LauncherRuntimeInfo(getInstallDirectory(), getApplicationRootDirectory());
         parent.registerJavaObject("RuntimeInfo", RuntimeInfo.class, runtimeInfo);
 
+        // registory the monitor factory
+        parent.registerJavaObject("MonitorFactory", MonitorFactory.class, monitor);
+        
         // create a ComponentDefinition to represent the component we are going to deploy
         SystemCompositeImplementation moduleImplementation = new SystemCompositeImplementation();
         moduleImplementation.setScdlLocation(systemScdl);

Added: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowireTestCase.java?rev=437500&view=auto
==============================================================================
--- incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowireTestCase.java (added)
+++ incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowireTestCase.java Sun Aug 27 18:48:58 2006
@@ -0,0 +1,41 @@
+package org.apache.tuscany.core.implementation.system.wire;
+
+import org.apache.tuscany.spi.component.TargetNotFoundException;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.AutowireComponent;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SystemOutboundAutowireTestCase extends TestCase {
+
+    public void testAutowire() {
+        AutowireComponent<?> component = createMock(AutowireComponent.class);
+        expect(component.resolveInstance(Object.class)).andReturn(new Object());
+        replay(component);
+        SystemOutboundAutowire<Object> wire = new SystemOutboundAutowire<Object>("foo", Object.class, component);
+        assertNotNull(wire.getTargetService());
+        verify(component);
+    }
+
+
+    public void testNonExistentAutowire() {
+        AutowireComponent<?> component = createMock(AutowireComponent.class);
+        expect(component.resolveInstance(Object.class)).andReturn(null);
+        replay(component);
+        SystemOutboundAutowire<Object> wire = new SystemOutboundAutowire<Object>("foo", Object.class, component);
+        try {
+            wire.getTargetService();
+            fail();
+        } catch (TargetNotFoundException e) {
+            // expected
+        }
+        verify(component);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowireTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowireTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl?rev=437500&r1=437499&r2=437500&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl (original)
+++ incubator/tuscany/java/sca/core/src/test/resources/org/apache/tuscany/core/deployer/boot2.scdl Sun Aug 27 18:48:58 2006
@@ -87,8 +87,31 @@
         <system:implementation.system class="org.apache.tuscany.core.loader.ServiceLoader"/>
     </component>
 
+    <component name="wireService">
+            <system:implementation.system class="org.apache.tuscany.core.wire.jdk.JDKWireService"/>
+    </component>
+
     <!-- Composite implementation type -->
     <component name="composite.loader">
         <system:implementation.system class="org.apache.tuscany.core.implementation.composite.CompositeLoader"/>
     </component>
+
+    <component name="interfaceJava.introspector">
+        <system:implementation.system class="org.apache.tuscany.core.idl.java.InterfaceJavaIntrospectorImpl"/>
+    </component>
+
+    <component name="artifactRepository">
+        <system:implementation.system class="org.apache.tuscany.core.services.artifact.LocalMavenRepository"/>
+        <property name="repository">.m2/repository</property>
+    </component>
+
+    <component name="propertyFactory">
+        <system:implementation.system class="org.apache.tuscany.core.loader.StringParserPropertyFactory"/>
+    </component>
+
+    <component name="policyBuilderRegistry">
+        <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+    </component>
+
+
 </composite>

Added: incubator/tuscany/java/sca/runtime/webapp-host/.ruleset
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/.ruleset?rev=437500&view=auto
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/.ruleset (added)
+++ incubator/tuscany/java/sca/runtime/webapp-host/.ruleset Sun Aug 27 18:48:58 2006
@@ -0,0 +1,190 @@
+<?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.
+-->
+<ruleset name="pmd-eclipse">
+  <description>PMD Plugin preferences rule set</description>
+  
+  
+  <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+  <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+  <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+  <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+  <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+  <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+  <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+  <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+  <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+  <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+  <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+  
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+  
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+  <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+  <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+  <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+  
+  <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+  <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+  <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+  <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+  <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+  <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+  <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+  <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+  <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+  <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+  <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+  <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+  <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+  <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+ 
+  <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+  <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+  <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+  <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+  <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+  
+  <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+  <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+  
+  <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+  <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+  <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+  <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+  
+</ruleset>

Modified: incubator/tuscany/java/sca/runtime/webapp-host/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/pom.xml?rev=437500&r1=437499&r2=437500&view=diff
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/pom.xml (original)
+++ incubator/tuscany/java/sca/runtime/webapp-host/pom.xml Sun Aug 27 18:48:58 2006
@@ -71,13 +71,20 @@
             <scope>test</scope>
         </dependency>
 
+        <!-- test dependencies -->
         <dependency>
-            <groupId>jmock</groupId>
-            <artifactId>jmock</artifactId>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymockclassextension</artifactId>
+            <version>2.2</version>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.easymock</groupId>
-            <artifactId>easymock</artifactId>
+            <groupId>org.apache.tuscany</groupId>
+            <artifactId>test</artifactId>
+            <version>${sca.version}</version>
+            <scope>test</scope>
         </dependency>
+
     </dependencies>
 </project>

Modified: incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java?rev=437500&r1=437499&r2=437500&view=diff
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java Sun Aug 27 18:48:58 2006
@@ -21,21 +21,22 @@
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
-
 import javax.servlet.Servlet;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.tuscany.host.servlet.ServletRequestInjector;
-import org.apache.tuscany.spi.host.ServletHost;
 import org.osoa.sca.annotations.Init;
 import org.osoa.sca.annotations.Service;
 
+import org.apache.tuscany.spi.host.ServletHost;
+
+import org.apache.tuscany.host.servlet.ServletRequestInjector;
+
 /**
- * ServletHost impl that forwards requests to registered servlets
- * TODO: TUSCANY-649, move this and ServletLauncherListener to a new webapp-host module
+ * ServletHost impl that forwards requests to registered servlets TODO: TUSCANY-649, move this and
+ * ServletLauncherListener to a new webapp-host module
  */
 @Service(ServletHost.class)
 public class ServletHostImpl implements ServletHost, ServletRequestInjector {
@@ -51,17 +52,19 @@
     }
 
     public void service(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
+        assert req instanceof HttpServletRequest : "implementation only supports HttpServletRequest";
         String path = ((HttpServletRequest) req).getPathInfo();
         Servlet servlet = servlets.get(path);
         if (servlet == null) {
-            throw new IllegalStateException("no servlet registered for path: " + path);
+            throw new IllegalStateException("No servlet registered for path: " + path);
         }
         servlet.service(req, resp);
     }
 
     public void registerMapping(String path, Servlet servlet) {
+
         if (servlets.containsKey(path)) {
-            throw new IllegalStateException("servlet already registered at path: " + path);
+            throw new IllegalStateException("Servlet already registered at path: " + path);
         }
         servlets.put(path, servlet);
     }

Modified: incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherListener.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherListener.java?rev=437500&r1=437499&r2=437500&view=diff
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherListener.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletLauncherListener.java Sun Aug 27 18:48:58 2006
@@ -23,27 +23,27 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.logging.Level;
-
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+
 import org.apache.tuscany.core.launcher.CompositeContextImpl;
 import org.apache.tuscany.core.launcher.LauncherImpl;
 import org.apache.tuscany.core.monitor.MonitorFactoryUtil;
 import org.apache.tuscany.host.MonitorFactory;
-import org.apache.tuscany.spi.component.CompositeComponent;
-import org.apache.tuscany.spi.loader.LoaderException;
 
 /**
- * LauncherImpl for runtime environment that loads info from servlet context params.
- * This listener manages one top-level LauncherImpl (and hence one Tuscany runtime context)
- * per servlet context; the lifecycle of that runtime corresponds to the the lifecycle of the
- * associated servlet context.
- *
+ * LauncherImpl for runtime environment that loads info from servlet context params. This listener manages one top-level
+ * LauncherImpl (and hence one Tuscany runtime context) per servlet context; the lifecycle of that runtime corresponds
+ * to the the lifecycle of the associated servlet context.
+ * <p/>
  * Web application code may obtain the top-level CompositeContext via
- * {@link org.osoa.sca.CurrentCompositeContext#getContext()}.  If that returns null,
- * it is likely the runtime failed to boot: the context param {@link LAUNCHER_THROWABLE_ATTRIBUTE}
+ * {@link org.osoa.sca.CurrentCompositeContext#getContext()}.
+ * If that returns null, it is likely the runtime failed to boot: the context param {@link LAUNCHER_THROWABLE_ATTRIBUTE}
  * will contain a {@link Throwable} with diagnostic information.
  *
  * @version $$Rev$$ $$Date$$
@@ -59,9 +59,8 @@
      */
     public static final String APPLICATION_SCDL_PATH_PARAM = "applicationScdlPath";
     /**
-     * Servlet context-param name for system monitoring level.
-     * Supported values are the names of statics defined in java.util.logging.Level.
-     * If absent, no monitoring will take place.
+     * Servlet context-param name for system monitoring level. Supported values are the names of statics defined in
+     * java.util.logging.Level. If absent, no monitoring will take place.
      */
     public static final String SYSTEM_MONITORING_PARAM = "tuscanyMonitoringLevel";
 
@@ -71,17 +70,18 @@
     public static final String DEFAULT_APPLICATION_SCDL_PATH = "/WEB-INF/default.scdl";
 
     /**
-     * Context attribute to which an Exception or Error object will be bound to if the
-     * launcher fails to initialize.
+     * Context attribute to which an Exception or Error object will be bound to if the launcher fails to initialize.
      */
     public static final String LAUNCHER_THROWABLE_ATTRIBUTE = "Tuscany.LauncherImpl.Throwable";
 
     /**
-     * Context attribute to which the active {@link LauncherImpl} managing the runtime for this
-     * servlet context is stored.
+     * Context attribute to which the active {@link LauncherImpl} managing the runtime for this servlet context is
+     * stored.
      */
     private static final String LAUNCHER_ATTRIBUTE = "Tuscany.LauncherImpl";
 
+    private URL testSystemScdl;
+
     public void contextInitialized(ServletContextEvent servletContextEvent) {
         ServletContext servletContext = servletContextEvent.getServletContext();
 
@@ -111,10 +111,21 @@
         CompositeContextImpl context;
 
         try {
-            URL systemScdl = getClass().getResource(systemScdlPath);
+            URL systemScdl;
+            if (testSystemScdl != null) {
+                systemScdl = testSystemScdl;
+            } else {
+                systemScdl = getClass().getResource(systemScdlPath);
+                if (systemScdl == null) {
+                    MissingResourceException e = new MissingResourceException("System SCDL not found");
+                    e.setIdentifier(systemScdlPath);
+                    throw e;
+                }
+            }
             CompositeComponent<?> rt = launcher.bootRuntime(systemScdl, mf);
             servletContext.setAttribute(LAUNCHER_ATTRIBUTE, launcher);
-            servletContext.setAttribute("Tuscany.ServletRequestInjector", rt.getChild("servletHost").getServiceInstance());
+            servletContext
+                .setAttribute("Tuscany.ServletRequestInjector", rt.getChild("servletHost").getServiceInstance());
 
             URL appScdl;
             if (applicationScdlPath.startsWith("/")) {
@@ -143,7 +154,7 @@
 
         } catch (Throwable t) {
             servletContext.setAttribute(LAUNCHER_THROWABLE_ATTRIBUTE, t);
-            t.printStackTrace();
+            servletContext.log("Error launching Tuscany Runtime", t);
         }
     }
 
@@ -155,6 +166,13 @@
         if (launcher != null) {
             launcher.shutdownRuntime();
         }
+    }
+
+    /**
+     * Sets the system SCDL url for testing
+     */
+    void setTestSystemScdl(URL testSystemScdl) {
+        this.testSystemScdl = testSystemScdl;
     }
 
     private MonitorFactory getMonitorFactory(String loggingLevel) {

Modified: incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/sca/webapp.system.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/sca/webapp.system.scdl?rev=437500&r1=437499&r2=437500&view=diff
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/sca/webapp.system.scdl (original)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/sca/webapp.system.scdl Sun Aug 27 18:48:58 2006
@@ -113,11 +113,26 @@
     <component name="servletHost">
         <system:implementation.system class="org.apache.tuscany.runtime.webapp.ServletHostImpl"/>
     </component>
-    
-    <!-- TODO: Hack the Axis extension in  -->
-    <include name="binding.axis2" scdlLocation="binding.axis2.scdl"/>
+
+    <component name="policyBuilderRegistry">
+         <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+    </component>
+
+    <component name="propertyFactory">
+        <system:implementation.system class="org.apache.tuscany.core.loader.StringParserPropertyFactory"/>
+    </component>
+
+    <component name="artifactRepository">
+            <system:implementation.system class="org.apache.tuscany.core.services.artifact.LocalMavenRepository"/>
+            <!-- this value needs to change to a correct one -->
+            <property name = "repository">.</property>
+    </component>
+
+
+    <!-- TODO: Hack the Axis extension in -->
+    <include name="binding.axis2" scdlLocation="binding.axis2.scdl"/> 
     
     <!-- TODO: Hack the SDO DataBinding extension in -->
-    <include name="databinding.sdo" scdlLocation="databinding.sdo.scdl"/>
+    <include name="databinding.sdo" scdlLocation="databinding.sdo.scdl"/>  
 
 </composite>

Added: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/Foo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/Foo.java?rev=437500&view=auto
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/Foo.java (added)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/Foo.java Sun Aug 27 18:48:58 2006
@@ -0,0 +1,25 @@
+/*
+ * 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.runtime.webapp;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface Foo {
+}

Propchange: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/Foo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/Foo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/FooImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/FooImpl.java?rev=437500&view=auto
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/FooImpl.java (added)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/FooImpl.java Sun Aug 27 18:48:58 2006
@@ -0,0 +1,25 @@
+/*
+ * 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.runtime.webapp;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FooImpl implements Foo {
+}

Propchange: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/FooImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/FooImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletHostTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletHostTestCase.java?rev=437500&view=auto
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletHostTestCase.java (added)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletHostTestCase.java Sun Aug 27 18:48:58 2006
@@ -0,0 +1,83 @@
+/*
+ * 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.runtime.webapp;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.verify;
+
+import javax.servlet.Servlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServletHostTestCase extends TestCase {
+
+    public void testDispatch() throws Exception {
+        HttpServletRequest req = createMock(HttpServletRequest.class);
+        expect(req.getPathInfo()).andReturn("foo");
+        replay(req);
+        HttpServletResponse res = createMock(HttpServletResponse.class);
+        Servlet servlet = createMock(Servlet.class);
+        servlet.service(req, res);
+        EasyMock.expectLastCall();
+        replay(servlet);
+        ServletHostImpl host = new ServletHostImpl();
+        host.registerMapping("foo", servlet);
+        host.service(req, res);
+        verify(servlet);
+    }
+
+    public void testDuplicateRegistration() throws Exception {
+        Servlet servlet = createMock(Servlet.class);
+        ServletHostImpl host = new ServletHostImpl();
+        host.registerMapping("foo", servlet);
+        try {
+            host.registerMapping("foo", servlet);
+            fail();
+        } catch (IllegalStateException e) {
+            // expected
+        }
+    }
+
+    public void testUnregister() throws Exception {
+        HttpServletRequest req = createMock(HttpServletRequest.class);
+        expect(req.getPathInfo()).andReturn("foo");
+        replay(req);
+        HttpServletResponse res = createMock(HttpServletResponse.class);
+        Servlet servlet = createMock(Servlet.class);
+        replay(servlet);
+        ServletHostImpl host = new ServletHostImpl();
+        host.registerMapping("foo", servlet);
+        host.unregisterMapping("foo");
+        try {
+            host.service(req, res);
+        } catch (IllegalStateException e) {
+            // expected
+        }
+        verify(servlet);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletHostTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletHostTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletLauncherListenerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletLauncherListenerTestCase.java?rev=437500&view=auto
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletLauncherListenerTestCase.java (added)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletLauncherListenerTestCase.java Sun Aug 27 18:48:58 2006
@@ -0,0 +1,123 @@
+/*
+ * 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.runtime.webapp;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+
+import junit.framework.TestCase;
+import static org.apache.tuscany.runtime.webapp.ServletLauncherListener.APPLICATION_SCDL_PATH_PARAM;
+import static org.apache.tuscany.runtime.webapp.ServletLauncherListener.SYSTEM_MONITORING_PARAM;
+import static org.apache.tuscany.runtime.webapp.ServletLauncherListener.SYSTEM_SCDL_PATH_PARAM;
+import static org.easymock.EasyMock.expect;
+import org.easymock.classextension.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServletLauncherListenerTestCase extends TestCase {
+
+    /**
+     * Verifies the web app host is configured properly to perform a basic boot
+     * <p/>
+     * FIXME Uncomment this test case when the webapp project is fixed by removing the dependency on web services
+     */
+    public void testBoot() throws Exception {
+//        final Launcher[] launcher = new Launcher[1];
+//        ServletLauncherListener listener = new ServletLauncherListener();
+//        listener.setTestSystemScdl(getClass().getClassLoader().getResource("META-INF/sca/webapp.system.scdl"));
+//        ServletContext context = EasyMock.createMock(ServletContext.class);
+//        expect(context.getServletContextName()).andReturn("foo").anyTimes();
+//        expect(context.getInitParameter(SYSTEM_SCDL_PATH_PARAM)).andReturn(null);
+//        expect(context.getInitParameter(APPLICATION_SCDL_PATH_PARAM)).andReturn(null);
+//        expect(context.getInitParameter(SYSTEM_MONITORING_PARAM)).andReturn(null);
+//        context.setAttribute(EasyMock.eq("Tuscany.LauncherImpl"), EasyMock.isA(Launcher.class));
+//        EasyMock.expectLastCall().andStubAnswer(new IAnswer() {
+//            public Object answer() throws Throwable {
+//                Object o = EasyMock.getCurrentArguments()[1];
+//                launcher[0] = (Launcher) o;
+//                return null;
+//            }
+//        });
+//        context.setAttribute(EasyMock.eq("Tuscany.ServletRequestInjector"), EasyMock.isA(ServletHost.class));
+//        expect(context.getResource("/WEB-INF/default.scdl"))
+//            .andReturn(getClass().getClassLoader().getResource("testapp.scdl"));
+//        expect(context.getAttribute(EasyMock.eq("Tuscany.LauncherImpl"))).andReturn(launcher[0]);
+//        EasyMock.replay(context);
+//        ServletContextEvent event = EasyMock.createMock(ServletContextEvent.class);
+//        EasyMock.expect(event.getServletContext()).andReturn(context).anyTimes();
+//        EasyMock.replay(event);
+//        listener.contextInitialized(event);
+//        listener.contextDestroyed(event);
+//        EasyMock.verify(context);
+    }
+
+    /**
+     * Verifies a {@link LoaderException} is thrown when the application SCDL is not found
+     * <p/>
+     * FIXME Uncomment this test case when the webapp project is fixed by removing the dependency on web services
+     */
+    public void testApplicationSCDLNotFound() throws Exception {
+//        ServletLauncherListener listener = new ServletLauncherListener();
+//        listener.setTestSystemScdl(getClass().getClassLoader().getResource("META-INF/sca/webapp.system.scdl"));
+//        ServletContext context = EasyMock.createMock(ServletContext.class);
+//        expect(context.getInitParameter(SYSTEM_SCDL_PATH_PARAM)).andReturn(null);
+//        expect(context.getServletContextName()).andReturn("foo").anyTimes();
+//        context.setAttribute(EasyMock.eq("Tuscany.LauncherImpl"), EasyMock.isA(Launcher.class));
+//        context.setAttribute(EasyMock.eq("Tuscany.ServletRequestInjector"), EasyMock.isA(ServletHost.class));
+//        expect(context.getInitParameter(APPLICATION_SCDL_PATH_PARAM)).andReturn(null);
+//        expect(context.getInitParameter(SYSTEM_MONITORING_PARAM)).andReturn(null);
+//        expect(context.getResource("/WEB-INF/default.scdl")).andReturn(null);
+//        context.setAttribute(EasyMock.eq("Tuscany.LauncherImpl.Throwable"), EasyMock.isA(LoaderException.class));
+//        context.log(EasyMock.isA(String.class), EasyMock.isA(Throwable.class));
+//        EasyMock.replay(context);
+//        ServletContextEvent event = EasyMock.createMock(ServletContextEvent.class);
+//        expect(event.getServletContext()).andReturn(context);
+//        EasyMock.replay(event);
+//        listener.contextInitialized(event);
+//        EasyMock.verify(context);
+    }
+
+    /**
+     * Verifies a {@link MissingResourceException} is thrown if the system SCDL is not found
+     *
+     * @throws Exception
+     */
+    public void testSystemSCDLNotFound() throws Exception {
+        ServletLauncherListener listener = new ServletLauncherListener();
+        ServletContext context = EasyMock.createMock(ServletContext.class);
+        expect(context.getInitParameter(SYSTEM_SCDL_PATH_PARAM)).andReturn("notthere");
+        context
+            .setAttribute(EasyMock.eq("Tuscany.LauncherImpl.Throwable"), EasyMock.isA(MissingResourceException.class));
+        expect(context.getInitParameter(APPLICATION_SCDL_PATH_PARAM)).andReturn(null);
+        expect(context.getInitParameter(SYSTEM_MONITORING_PARAM)).andReturn(null);
+        context.log(EasyMock.isA(String.class), EasyMock.isA(Throwable.class));
+        EasyMock.replay(context);
+        ServletContextEvent event = EasyMock.createMock(ServletContextEvent.class);
+        EasyMock.expect(event.getServletContext()).andReturn(context);
+        EasyMock.replay(event);
+        listener.contextInitialized(event);
+        EasyMock.verify(context);
+    }
+
+
+}

Propchange: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletLauncherListenerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/runtime/webapp-host/src/test/java/org/apache/tuscany/runtime/webapp/ServletLauncherListenerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/runtime/webapp-host/src/test/resources/testapp.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/test/resources/testapp.scdl?rev=437500&view=auto
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/test/resources/testapp.scdl (added)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/test/resources/testapp.scdl Sun Aug 27 18:48:58 2006
@@ -0,0 +1,26 @@
+<?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" name="testapp">
+
+    <component name="component">
+        <implementation.java class="org.apache.tuscany.runtime.webapp.FooImpl"/>
+    </component>
+
+</composite>

Added: incubator/tuscany/java/sca/runtime/webapp/.ruleset
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/.ruleset?rev=437500&view=auto
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/.ruleset (added)
+++ incubator/tuscany/java/sca/runtime/webapp/.ruleset Sun Aug 27 18:48:58 2006
@@ -0,0 +1,190 @@
+<?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.
+-->
+<ruleset name="pmd-eclipse">
+  <description>PMD Plugin preferences rule set</description>
+  
+  
+  <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+  <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+  <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+  <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+  <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+  <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+  <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+  <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+  <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+  <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+  <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+  
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+  
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+  <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+  <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+  <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+  
+  <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+  <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+  <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+  <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+  <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+  <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+  <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+  <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+  <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+  <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+  <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+  <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+  <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+  <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+ 
+  <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+  <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+  <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+  <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+  <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+  
+  <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+  <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+  
+  <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+  <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+  <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+  <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+  
+</ruleset>

Modified: incubator/tuscany/java/sca/runtime/webapp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/pom.xml?rev=437500&r1=437499&r2=437500&view=diff
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/pom.xml (original)
+++ incubator/tuscany/java/sca/runtime/webapp/pom.xml Sun Aug 27 18:48:58 2006
@@ -43,13 +43,19 @@
             <scope>compile</scope>
         </dependency>
 
+        <!-- test dependencies -->
         <dependency>
-            <groupId>jmock</groupId>
-            <artifactId>jmock</artifactId>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymockclassextension</artifactId>
+            <version>2.2</version>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
-            <groupId>org.easymock</groupId>
-            <artifactId>easymock</artifactId>
+            <groupId>org.apache.tuscany</groupId>
+            <artifactId>test</artifactId>
+            <version>${sca.version}</version>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 </project>

Modified: incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java?rev=437500&r1=437499&r2=437500&view=diff
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java Sun Aug 27 18:48:58 2006
@@ -34,6 +34,7 @@
  */
 public class TuscanyServlet extends HttpServlet {
 
+    public static final String TUSCANY_SERVLET_REQUEST_INJECTOR = "Tuscany.ServletRequestInjector";
     private static final long serialVersionUID = 1L;
 
     private ServletRequestInjector servletRequestInjector;
@@ -42,7 +43,7 @@
     public void init(ServletConfig config) {
         ServletContext servletContext = config.getServletContext();
         this.servletRequestInjector =
-            (ServletRequestInjector) servletContext.getAttribute("Tuscany.ServletRequestInjector");
+            (ServletRequestInjector) servletContext.getAttribute(TUSCANY_SERVLET_REQUEST_INJECTOR);
     }
 
     @Override

Added: incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java?rev=437500&view=auto
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java (added)
+++ incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java Sun Aug 27 18:48:58 2006
@@ -0,0 +1,76 @@
+/*
+ * 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.runtime.webapp;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.expect;
+import org.easymock.classextension.EasyMock;
+
+/**
+ * Verifies a context listener is properly instantiated and lifecycle events are sent to it
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyContextListenerTestCase extends TestCase {
+
+    public void testLifecycle() {
+        ServletContext context = EasyMock.createMock(ServletContext.class);
+        expect(context.getInitParameter(TuscanyContextListener.BOOTDIR_PARAM)).andReturn("foo");
+        expect(context.getResourcePaths("foo")).andReturn(null);
+        expect(context.getInitParameter(TuscanyContextListener.LAUNCHER_PARAM)).andReturn(TestLauncher.class.getName());
+        EasyMock.replay(context);
+        ServletContextEvent event = EasyMock.createMock(ServletContextEvent.class);
+        EasyMock.expect(event.getServletContext()).andReturn(context);
+        EasyMock.replay(event);
+        TuscanyContextListener listener = new TuscanyContextListener();
+        listener.contextInitialized(event);
+        assertEquals(1, TestLauncher.getInitialized());
+        listener.contextDestroyed(event);
+        assertEquals(1, TestLauncher.getDestroyed());
+    }
+
+    public static class TestLauncher implements ServletContextListener {
+
+        private static int initialized;
+        private static int destroyed;
+
+        public TestLauncher() {
+        }
+
+        public static int getInitialized() {
+            return initialized;
+        }
+
+        public static int getDestroyed() {
+            return destroyed;
+        }
+
+        public void contextInitialized(ServletContextEvent servletContextEvent) {
+            ++initialized;
+        }
+
+        public void contextDestroyed(ServletContextEvent servletContextEvent) {
+            ++destroyed;
+        }
+    }
+}

Propchange: incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyServletTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyServletTestCase.java?rev=437500&view=auto
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyServletTestCase.java (added)
+++ incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyServletTestCase.java Sun Aug 27 18:48:58 2006
@@ -0,0 +1,58 @@
+/*
+ * 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.runtime.webapp;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.host.servlet.ServletRequestInjector;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+
+/**
+ * Verifies {@link TuscanyServlet} properly services a request
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyServletTestCase extends TestCase {
+
+    public void testService() throws Exception {
+        ServletRequestInjector requestInjector = EasyMock.createMock(ServletRequestInjector.class);
+        requestInjector.service(isA(ServletRequest.class), isA(ServletResponse.class));
+        EasyMock.expectLastCall();
+        EasyMock.replay(requestInjector);
+        ServletContext context = org.easymock.classextension.EasyMock.createMock(ServletContext.class);
+        expect(context.getAttribute(TuscanyServlet.TUSCANY_SERVLET_REQUEST_INJECTOR)).andReturn(requestInjector);
+        org.easymock.classextension.EasyMock.replay(context);
+        ServletConfig config = EasyMock.createMock(ServletConfig.class);
+        EasyMock.expect(config.getServletContext()).andReturn(context);
+        EasyMock.replay(config);
+        TuscanyServlet servlet = new TuscanyServlet();
+        servlet.init(config);
+        ServletRequest req = EasyMock.createNiceMock(ServletRequest.class);
+        ServletResponse res = EasyMock.createNiceMock(ServletResponse.class);
+        servlet.service(req, res);
+        EasyMock.verify(requestInjector);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyServletTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/runtime/webapp/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyServletTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl?rev=437500&r1=437499&r2=437500&view=diff
==============================================================================
--- incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl (original)
+++ incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl Sun Aug 27 18:48:58 2006
@@ -117,4 +117,12 @@
         <system:implementation.system class="org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler"/>
     </component>
 
+    <component name="policyBuilderRegistry">
+         <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+    </component>
+
+    <component name="propertyFactory">
+        <system:implementation.system class="org.apache.tuscany.core.loader.StringParserPropertyFactory"/>
+    </component>
+    
 </composite>



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