geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r882333 [9/11] - in /geronimo/server/trunk/plugins: ./ jetty7/ jetty8/ jetty8/geronimo-jetty7-builder/ jetty8/geronimo-jetty7-clustering-builder-wadi/ jetty8/geronimo-jetty7-clustering-wadi/ jetty8/geronimo-jetty7/ jetty8/geronimo-jetty8-bu...
Date Thu, 19 Nov 2009 22:21:55 GMT
Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettySecurityHandlerFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettySecurityHandlerFactory.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettySecurityHandlerFactory.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettySecurityHandlerFactory.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,111 @@
+/*
+ * 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.geronimo.jetty8.security;
+
+import java.security.AccessControlContext;
+import java.security.Permissions;
+
+import javax.security.auth.Subject;
+
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.jetty8.handler.JaccSecurityHandler;
+import org.apache.geronimo.jetty8.handler.EJBWebServiceSecurityHandler;
+import org.apache.geronimo.jetty8.security.auth.JAASLoginService;
+import org.apache.geronimo.jetty8.security.auth.NoneAuthenticator;
+import org.apache.geronimo.security.ContextManager;
+import org.apache.geronimo.security.jaas.ConfigurationFactory;
+import org.apache.geronimo.security.jacc.RunAsSource;
+import org.eclipse.jetty.security.Authenticator;
+import org.eclipse.jetty.security.IdentityService;
+import org.eclipse.jetty.security.LoginService;
+import org.eclipse.jetty.security.SecurityHandler;
+import org.eclipse.jetty.security.authentication.BasicAuthenticator;
+import org.eclipse.jetty.security.authentication.ClientCertAuthenticator;
+import org.eclipse.jetty.security.authentication.DigestAuthenticator;
+import org.eclipse.jetty.security.authentication.FormAuthenticator;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@GBean
+public class JettySecurityHandlerFactory implements SecurityHandlerFactory {
+
+    private final BuiltInAuthMethod authMethod;
+    private final String loginPage;
+    private final String errorPage;
+    private final String realmName;
+    private final ConfigurationFactory configurationFactory;
+
+    public JettySecurityHandlerFactory(@ParamAttribute(name = "authMethod") BuiltInAuthMethod authMethod,
+                                       @ParamAttribute(name = "loginPage") String loginPage,
+                                       @ParamAttribute(name = "errorPage") String errorPage,
+                                       @ParamAttribute(name = "realmName") String realmName,
+                                       @ParamReference(name = "ConfigurationFactory") ConfigurationFactory configurationFactory) {
+        if (authMethod == null) {
+            throw new NullPointerException("authMethod required");
+        }
+        if (configurationFactory == null) {
+            throw new NullPointerException("configurationFactory required");
+        }
+        this.authMethod = authMethod;
+        this.loginPage = loginPage;
+        this.errorPage = errorPage;
+        this.realmName = realmName;
+        this.configurationFactory = configurationFactory;
+    }
+
+    public SecurityHandler buildSecurityHandler(String policyContextID, Subject defaultSubject, RunAsSource runAsSource, boolean checkRolePermissions) {
+        final LoginService loginService = new JAASLoginService(configurationFactory, realmName);
+        Authenticator authenticator = buildAuthenticator();
+        if (defaultSubject == null) {
+            defaultSubject = ContextManager.EMPTY;
+        }
+        AccessControlContext defaultAcc = ContextManager.registerSubjectShort(defaultSubject, null, null);
+        IdentityService identityService = new JettyIdentityService(defaultAcc, defaultSubject, runAsSource);
+        if (checkRolePermissions) {
+            return new JaccSecurityHandler(policyContextID, authenticator, loginService, identityService, defaultAcc);
+        } else {
+            return new EJBWebServiceSecurityHandler(policyContextID, authenticator, loginService, identityService, defaultAcc);
+        }
+    }
+
+    private Authenticator buildAuthenticator() {
+        Authenticator authenticator;
+        if (authMethod == BuiltInAuthMethod.BASIC) {
+            authenticator = new BasicAuthenticator();
+        } else if (authMethod == BuiltInAuthMethod.DIGEST) {
+            authenticator = new DigestAuthenticator();
+        } else if (authMethod == BuiltInAuthMethod.CLIENTCERT) {
+            authenticator = new ClientCertAuthenticator();
+        } else if (authMethod == BuiltInAuthMethod.FORM) {
+            boolean dispatch = true;
+//            authenticator = new FormAuthenticator(loginPage, errorPage, dispatch);
+            authenticator = new FormAuthenticator(loginPage, errorPage, true);
+        } else if (authMethod == BuiltInAuthMethod.NONE) {
+            authenticator = new NoneAuthenticator();
+        } else {
+            throw new IllegalStateException("someone added a new BuiltInAuthMethod without telling us");
+        }
+        return authenticator;
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettySecurityHandlerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettySecurityHandlerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettySecurityHandlerFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/SecurityHandlerFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/SecurityHandlerFactory.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/SecurityHandlerFactory.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/SecurityHandlerFactory.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,35 @@
+/*
+ * 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.geronimo.jetty8.security;
+
+import javax.security.auth.Subject;
+
+import org.apache.geronimo.security.jacc.RunAsSource;
+import org.eclipse.jetty.security.SecurityHandler;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface SecurityHandlerFactory {
+
+    SecurityHandler buildSecurityHandler(String policyContextID, Subject defaultSubject, RunAsSource runAsSource, boolean checkRolePermissions);
+
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/SecurityHandlerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/SecurityHandlerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/SecurityHandlerFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/JAASLoginService.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/JAASLoginService.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/JAASLoginService.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/JAASLoginService.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,90 @@
+/*
+ * 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.geronimo.jetty8.security.auth;
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.apache.geronimo.security.ContextManager;
+import org.apache.geronimo.security.jaas.ConfigurationFactory;
+import org.apache.geronimo.security.realm.providers.PasswordCallbackHandler;
+import org.eclipse.jetty.security.IdentityService;
+import org.eclipse.jetty.security.LoginService;
+import org.eclipse.jetty.server.UserIdentity;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JAASLoginService implements LoginService {
+    private final String realmName;
+    private final ConfigurationFactory configurationFactory;
+    private IdentityService identityService;
+
+    /**
+     * Construct a JAASLoginService
+     * @param configurationFactory may be null if auth system does not require local jaas login (such as openid)
+     * @param realmName may be null e.g. for jaspi.
+     */
+    public JAASLoginService(ConfigurationFactory configurationFactory, String realmName) {
+        this.configurationFactory = configurationFactory;
+        this.realmName = realmName;
+    }
+
+    public void logout(UserIdentity userIdentity) {
+        //not sure how to do this
+    }
+
+    public String getName() {
+        return realmName;
+    }
+
+    public UserIdentity login(String username, Object credentials) {
+        char[] password = credentials instanceof  String? ((String)credentials).toCharArray(): (char[]) credentials;
+        CallbackHandler callbackHandler = new PasswordCallbackHandler(username, password);
+        try {
+            LoginContext loginContext = ContextManager.login(configurationFactory.getConfigurationName(), callbackHandler, configurationFactory.getConfiguration());
+            Subject establishedSubject = loginContext.getSubject();
+            Principal userPrincipal = ContextManager.getCurrentPrincipal(establishedSubject);
+            return identityService.newUserIdentity(establishedSubject, userPrincipal, null);
+        } catch (LoginException e) {
+            return null;
+//        } catch (Throwable t) {
+//            t.printStackTrace();
+//            return null;
+        }
+    }
+
+    public boolean validate(UserIdentity user) {
+        return true;
+    }
+
+    public IdentityService getIdentityService() {
+        return identityService;
+    }
+
+    public void setIdentityService(IdentityService identityService) {
+        this.identityService = identityService;
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/JAASLoginService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/JAASLoginService.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/JAASLoginService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/NoneAuthenticator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/NoneAuthenticator.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/NoneAuthenticator.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/NoneAuthenticator.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,61 @@
+/*
+ * 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.geronimo.jetty8.security.auth;
+
+import java.io.IOException;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.security.Authenticator;
+import org.eclipse.jetty.security.ServerAuthException;
+import org.eclipse.jetty.server.Authentication;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NoneAuthenticator implements Authenticator {
+
+    public void setConfiguration(Configuration configuration) {
+    }
+
+    public String getAuthMethod() {
+        return "NONE";
+    }
+
+    public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory) throws ServerAuthException {
+        if (mandatory) {
+            try {
+                ((HttpServletResponse)response).sendError(HttpServletResponse.SC_FORBIDDEN);
+            } catch (IOException e) {
+                throw new ServerAuthException(e);
+            }
+            return Authentication.SEND_FAILURE;
+        } else {
+            return Authentication.UNAUTHENTICATED;
+        }
+    }
+
+    public boolean secureResponse(ServletRequest request, ServletResponse response, boolean mandatory, Authentication.User validatedUser) throws ServerAuthException {
+        return true;
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/NoneAuthenticator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/NoneAuthenticator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/auth/NoneAuthenticator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/resources/org/apache/geronimo/jetty/messages.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/resources/org/apache/geronimo/jetty/messages.properties?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/resources/org/apache/geronimo/jetty/messages.properties (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/resources/org/apache/geronimo/jetty/messages.properties Thu Nov 19 22:21:48 2009
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+#
+JettyManagerImpl.0=Jetty NIO HTTP Connector
+JettyManagerImpl.1=Jetty NIO HTTPS Connector
+JettyManagerImpl.2=Jetty Blocking HTTP Connector using NIO
+JettyManagerImpl.3=Jetty BIO HTTP Connector
+JettyManagerImpl.4=Jetty BIO HTTPS Connector
+JettyManagerImpl.5=Jetty NIO AJP Connector
+JettyManagerImpl.30=webmanager.connector.editConnector.JettyManagerImpl.30
+JettyManagerImpl.32=webmanager.connector.editConnector.JettyManagerImpl.32
+JettyManagerImpl.34=webmanager.connector.editConnector.JettyManagerImpl.34
+JettyManagerImpl.36=webmanager.connector.editConnector.JettyManagerImpl.36
+JettyManagerImpl.38=webmanager.connector.editConnector.JettyManagerImpl.38
+JettyManagerImpl.40=webmanager.connector.editConnector.JettyManagerImpl.40
+JettyManagerImpl.42=webmanager.connector.editConnector.JettyManagerImpl.42
+JettyManagerImpl.44=webmanager.connector.editConnector.JettyManagerImpl.44
+JettyManagerImpl.47=webmanager.connector.editConnector.JettyManagerImpl.47
+JettyManagerImpl.50=webmanager.connector.editConnector.JettyManagerImpl.50
+JettyManagerImpl.53=webmanager.connector.editConnector.JettyManagerImpl.53
+JettyManagerImpl.56=webmanager.connector.editConnector.JettyManagerImpl.56
+JettyManagerImpl.57=webmanager.connector.editConnector.JettyManagerImpl.57

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/resources/org/apache/geronimo/jetty/messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/resources/org/apache/geronimo/jetty/messages.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/resources/org/apache/geronimo/jetty/messages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,317 @@
+/**
+ *  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.geronimo.jetty8;
+
+import java.io.File;
+import java.net.URL;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Principal;
+import java.security.AccessControlContext;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+import javax.security.jacc.WebResourcePermission;
+import javax.security.jacc.WebUserDataPermission;
+import javax.transaction.TransactionManager;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
+import org.apache.geronimo.connector.outbound.connectiontracking.GeronimoTransactionListener;
+import org.apache.geronimo.jetty8.connector.HTTPSocketConnector;
+import org.apache.geronimo.jetty8.security.SecurityHandlerFactory;
+import org.apache.geronimo.jetty8.security.ServerAuthenticationGBean;
+import org.apache.geronimo.jetty8.handler.GeronimoUserIdentity;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.osgi.MockBundleContext;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.security.SecurityServiceImpl;
+import org.apache.geronimo.security.ContextManager;
+import org.apache.geronimo.security.deploy.SubjectInfo;
+import org.apache.geronimo.security.jacc.ApplicationPolicyConfigurationManager;
+import org.apache.geronimo.security.jacc.ComponentPermissions;
+import org.apache.geronimo.security.jacc.PrincipalRoleMapper;
+import org.apache.geronimo.security.jacc.RunAsSource;
+import org.apache.geronimo.security.jacc.mappingprovider.ApplicationPrincipalRoleConfigurationManager;
+import org.apache.geronimo.security.jacc.mappingprovider.GeronimoPolicy;
+import org.apache.geronimo.security.jacc.mappingprovider.GeronimoPolicyConfigurationFactory;
+import org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal;
+import org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal;
+import org.apache.geronimo.system.serverinfo.BasicServerInfo;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.testsupport.TestSupport;
+import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
+import org.eclipse.jetty.server.UserIdentity;
+import org.eclipse.jetty.server.Authentication;
+import org.eclipse.jetty.security.LoginService;
+import org.eclipse.jetty.security.ServerAuthException;
+import org.eclipse.jetty.security.Authenticator;
+import org.eclipse.jetty.security.IdentityService;
+import org.eclipse.jetty.security.UserAuthentication;
+import org.eclipse.jetty.security.authentication.FormAuthenticator;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractWebModuleTest extends TestSupport {
+    protected ClassLoader cl;
+    protected final static String securityRealmName = "demo-properties-realm";
+    protected HTTPSocketConnector connector;
+    protected JettyContainerImpl container;
+    private TransactionManager transactionManager;
+    private ConnectionTrackingCoordinator connectionTrackingCoordinator;
+    private URL configurationBaseURL;
+    protected PreHandlerFactory preHandlerFactory = null;
+    protected SessionHandlerFactory sessionHandlerFactory = null;
+
+    protected void setUpStaticContentServlet(JettyServletRegistration webModule) throws Exception {
+        Map<String, String> staticContentServletInitParams = new HashMap<String, String>();
+        staticContentServletInitParams.put("acceptRanges", "true");
+        staticContentServletInitParams.put("dirAllowed", "true");
+        staticContentServletInitParams.put("putAllowed", "false");
+        staticContentServletInitParams.put("delAllowed", "false");
+        staticContentServletInitParams.put("redirectWelcome", "false");
+        staticContentServletInitParams.put("minGzipLength", "8192");
+
+        new ServletHolderWrapper("test:name=staticservlet",
+                "default",
+                "org.eclipse.jetty.servlet.DefaultServlet",
+                null,
+                staticContentServletInitParams,
+                null,
+                Collections.singleton("/"),
+                null,
+                webModule);
+
+    }
+
+    protected WebAppContextWrapper setUpAppContext(String securityRealmName, SecurityHandlerFactory securityHandlerFactory, String policyContextId, RunAsSource runAsSource, String uriString) throws Exception {
+
+        if (securityHandlerFactory == null) {
+            Permissions unchecked = new Permissions();
+            unchecked.add(new WebUserDataPermission("/", null));
+            unchecked.add(new WebResourcePermission("/", ""));
+            ComponentPermissions componentPermissions = new ComponentPermissions(new Permissions(), unchecked, Collections.<String, PermissionCollection>emptyMap());
+            setUpJACC(Collections.<String, SubjectInfo>emptyMap(), Collections.<Principal, Set<String>>emptyMap(), componentPermissions, policyContextId);
+            LoginService loginService = newLoginService();
+//            final ServletCallbackHandler callbackHandler = new ServletCallbackHandler(loginService);
+            final Subject subject = new Subject();
+            final AccessControlContext acc = ContextManager.registerSubjectShort(subject, null, null);
+            securityHandlerFactory = new ServerAuthenticationGBean(new Authenticator() {
+                public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory) throws ServerAuthException {
+                    return new UserAuthentication(this, new GeronimoUserIdentity(subject, new GeronimoUserPrincipal("foo"), acc));
+                }// most likely validatedUser is not needed here.
+
+                public boolean secureResponse(ServletRequest request, ServletResponse response, boolean mandatory, Authentication.User validatedUser) throws ServerAuthException {
+                    return true;
+                }
+
+                public void setConfiguration(Configuration configuration) {
+                }
+
+                public String getAuthMethod() {
+                    return null;
+                }
+
+            }, loginService);
+        }
+        String contextPath = "/test";
+        WebAppContextWrapper app = new WebAppContextWrapper(null,
+                contextPath,
+                null,
+                Collections.<String, Object>emptyMap(),
+                cl,
+                new URL(configurationBaseURL, uriString),
+                null, null,
+                null,
+                "context",
+                null,
+                null,
+                false,
+                null,
+                null,
+                null,
+                null,
+                null,
+                false,
+                0,
+                sessionHandlerFactory,
+                preHandlerFactory,
+                policyContextId,
+                securityHandlerFactory,
+                runAsSource,
+                null,
+                null,
+                transactionManager,
+                connectionTrackingCoordinator,
+                container,
+                null,
+                null,
+                null,
+                null);
+        app.doStart();
+        return app;
+    }
+
+    protected WebAppContextWrapper setUpSecureAppContext(String securityRealmName, Map<String, SubjectInfo> roleDesignates, Map<Principal, Set<String>> principalRoleMap, ComponentPermissions componentPermissions, SubjectInfo defaultSubjectInfo, PermissionCollection checked, Set securityRoles) throws Exception {
+        String policyContextId = "TEST";
+        ApplicationPolicyConfigurationManager jacc = setUpJACC(roleDesignates, principalRoleMap, componentPermissions, policyContextId);
+        LoginService loginService = newLoginService();
+//        Authenticator serverAuthentication = new FormAuthenticator("/auth/logon.html?param=test", "/auth/logonError.html?param=test", true);
+        Authenticator serverAuthentication = new FormAuthenticator("/auth/logon.html?param=test", "/auth/logonError.html?param=test", true);
+        SecurityHandlerFactory securityHandlerFactory = new ServerAuthenticationGBean(serverAuthentication, loginService);
+        return setUpAppContext(
+                securityRealmName,
+                securityHandlerFactory,
+                policyContextId,
+                jacc,
+                "war3/");
+
+    }
+
+    private ApplicationPolicyConfigurationManager setUpJACC(Map<String, SubjectInfo> roleDesignates, Map<Principal, Set<String>> principalRoleMap, ComponentPermissions componentPermissions, String policyContextId) throws Exception {
+        setUpSecurityService();
+        PrincipalRoleMapper roleMapper = new ApplicationPrincipalRoleConfigurationManager(principalRoleMap, null, roleDesignates, null);
+        Map<String, ComponentPermissions> contextIDToPermissionsMap = new HashMap<String, ComponentPermissions>();
+        contextIDToPermissionsMap.put(policyContextId, componentPermissions);
+        ApplicationPolicyConfigurationManager jacc = new ApplicationPolicyConfigurationManager(contextIDToPermissionsMap, roleMapper, cl);
+        jacc.doStart();
+        return jacc;
+    }
+
+    protected LoginService newLoginService() throws Exception {
+//        String domainName = "demo-properties-realm";
+//
+        Map<String, String> users = new HashMap<String, String>();
+        users.put("alan", "starcraft");
+        users.put("izumi", "violin");
+        Map<String, List<String>> groups = new HashMap<String, List<String>>();
+        groups.put("alan", Collections.singletonList("it"));
+        return new TestLoginService(users, groups);
+
+    }
+
+    protected void setUpSecurityService() throws Exception {
+        ServerInfo serverInfo = new BasicServerInfo(".");
+
+        new SecurityServiceImpl(cl, serverInfo, GeronimoPolicyConfigurationFactory.class.getName(), GeronimoPolicy.class.getName(), null, null, null, null);
+    }
+
+    protected void tearDownSecurity() throws Exception {
+    }
+
+    protected void setUp() throws Exception {
+        cl = this.getClass().getClassLoader();
+
+        configurationBaseURL = cl.getResource("deployables/");
+
+        ServerInfo serverInfo = new BasicServerInfo(".");
+        container = new JettyContainerImpl("test:name=JettyContainer",
+            new MockBundleContext(getClass().getClassLoader(), "", new HashMap<Artifact, ConfigurationData>(), null),
+            null, new File(BASEDIR, "target/var/jetty").toString(), serverInfo);
+        container.doStart();
+        connector = new HTTPSocketConnector(container, null);
+        connector.setPort(5678);
+        connector.setHost("localhost");
+        connector.setMaxThreads(2);
+        connector.doStart();
+
+        TransactionManagerImpl transactionManager = new TransactionManagerImpl();
+        this.transactionManager = transactionManager;
+        connectionTrackingCoordinator = new ConnectionTrackingCoordinator();
+        transactionManager.addTransactionAssociationListener(new GeronimoTransactionListener(connectionTrackingCoordinator));
+    }
+
+    protected void tearDown() throws Exception {
+        connector.doStop();
+        Thread.sleep(1000);
+    }
+
+    private static class TestLoginService implements LoginService {
+
+        private final Map<String, String> users;
+        private final Map<String, List<String>> groups;
+        private IdentityService identityService;
+
+        private TestLoginService(Map<String, String> users, Map<String, List<String>> groups) {
+            this.users = users;
+            this.groups = groups;
+        }
+
+//        public void login(LoginCallback loginCallback) throws ServerAuthException {
+//            String userName = loginCallback.getUserName();
+//            String pws = users.get(userName);
+//            if (pws != null && pws.equals(new String((char[])loginCallback.getCredential()))) {
+//                final GeronimoUserPrincipal userPrincipal = new GeronimoUserPrincipal(userName);
+//                Subject subject = loginCallback.getSubject();
+//                subject.getPrincipals().add(userPrincipal);
+//                loginCallback.setUserPrincipal(userPrincipal);
+//                List<String> usersGroups = groups.get(userName);
+//                if (usersGroups != null) {
+//                    for (String group: usersGroups) {
+//                        subject.getPrincipals().add(new GeronimoGroupPrincipal(group));
+//                    }
+//                    loginCallback.setGroups(usersGroups);
+//                }
+//                loginCallback.setSuccess(true);
+//            }
+//        }
+
+        @Deprecated
+        public String getName() {
+            return null;
+        }
+
+        public UserIdentity login(String userName, Object credentials) {
+            String pws = users.get(userName);
+            if (pws != null && pws.equals(credentials)) {
+                final GeronimoUserPrincipal userPrincipal = new GeronimoUserPrincipal(userName);
+                Subject subject = new Subject();
+                subject.getPrincipals().add(userPrincipal);
+                List<String> usersGroups = groups.get(userName);
+                if (usersGroups != null) {
+                    for (String group: usersGroups) {
+                        subject.getPrincipals().add(new GeronimoGroupPrincipal(group));
+                    }
+                }
+                return identityService.newUserIdentity(subject, userPrincipal, null);
+            }
+            return null;
+        }
+
+        public boolean validate(UserIdentity user) {
+            return false;
+        }
+
+        public void logout(UserIdentity user) {
+        }
+
+        public IdentityService getIdentityService() {
+            return identityService;
+        }
+
+        public void setIdentityService(IdentityService service) {
+            this.identityService = service;
+        }
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,90 @@
+/**
+ *  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.geronimo.jetty8;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.server.session.SessionHandler;
+import org.eclipse.jetty.server.Request;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ApplicationTest extends AbstractWebModuleTest {
+
+    public void testApplication() throws Exception {
+        WebAppContextWrapper app = setUpAppContext(null, null, "policyContextID", null, "war1/");
+
+        setUpStaticContentServlet(app);
+
+        HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678/test/hello.txt").openConnection();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+        assertEquals("Hello World", reader.readLine());
+        connection.disconnect();
+    }
+
+    public void testApplicationWithSessionHandler() throws Exception {
+        preHandlerFactory = new MockPreHandlerFactory();
+        sessionHandlerFactory = new MockSessionHandlerFactory();
+        WebAppContextWrapper app = setUpAppContext(null, null, "policyContextID", null, "war1/");
+
+        setUpStaticContentServlet(app);
+
+        HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678/test/hello.txt").openConnection();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+        assertEquals("Hello World", reader.readLine());
+        connection.disconnect();
+    }
+
+    public class MockPreHandlerFactory implements PreHandlerFactory {
+        public PreHandler createHandler() {
+            return new AbstractPreHandler() {
+
+                public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
+                        throws IOException, ServletException {
+                    next.handle(target, baseRequest, request, response);
+                }
+
+                public void addLifeCycleListener(Listener listener) {
+                }
+
+                public void removeLifeCycleListener(Listener listener) {
+                }
+            };
+        }
+
+    }
+
+    public class MockSessionHandlerFactory implements SessionHandlerFactory {
+        public SessionHandler createHandler(PreHandler preHandler) {
+            return new SessionHandler();
+        }
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ApplicationTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ClassLoaderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ClassLoaderTest.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ClassLoaderTest.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ClassLoaderTest.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,244 @@
+/**
+ *  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.geronimo.jetty8;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Arrays;
+import java.util.Collections;
+
+import org.apache.geronimo.testsupport.TestSupport;
+
+// import org.apache.geronimo.kernel.config.MultiParentClassLoader;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ClassLoadingRules;
+
+/**
+ * Tests loading various classes (as classes and URL resources) with different
+ * settings for contextPriorityClassLoader to make sure the restrictions on
+ * javax.* class loading are honored.
+ *
+ * @version $Rev$ $Date$
+/**
+ * \
+ *
+ */
+public class ClassLoaderTest extends TestSupport {
+    Artifact configId = new Artifact("foo", "bar", "1", "car");
+    ClassLoader cl;
+    URL[] urls;
+    private static final Set<String> HIDDEN = new HashSet<String>(Arrays.asList("org.apache.geronimo", "org.mortbay", "org.xml", "org.w3c"));
+    private static final Set<String> NON_OVERRIDABLE = new HashSet<String>(Arrays.asList("java.", "javax."));
+    private final ClassLoadingRules clRules = new ClassLoadingRules();
+
+    public void setUp() throws Exception {
+        super.setUp();
+        URL url = new File(BASEDIR, "src/test/resources/deployables/cltest/").toURL();
+        urls = new URL[]{url};
+        clRules.setInverseClassLoading(false);
+        clRules.getHiddenRule().setClassPrefixes(HIDDEN);
+        clRules.getNonOverrideableRule().setClassPrefixes(NON_OVERRIDABLE);
+    }
+
+    //todo: try more restricted prefixed besides javax.*
+
+    /**
+     * Tries to load a javax.* class that's not available from the
+     * parent ClassLoader.  This should work.
+     */
+    public void testFalseNonexistantJavaxClass() {
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        try {
+//            cl.loadClass("javax.foo.Foo");
+//        } catch(ClassNotFoundException e) {
+//            fail("Should be able to load a javax.* class that is not defined by my parent CL");
+//        }
+    }
+
+    /**
+     * Tries to load a javax.* class that's not available from the
+     * parent ClassLoader.  This should work.
+     */
+//    public void testTrueNonexistantJavaxClass() {
+//        clRules.setInverseClassLoading(true);
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        try {
+//            cl.loadClass("javax.foo.Foo");
+//        } catch(ClassNotFoundException e) {
+//            fail("Should be able to load a javax.* class that is not defined by my parent CL");
+//        }
+//    }
+
+    /**
+     * Tries to load a javax.* class that is avialable from the parent ClassLoader,
+     * when there's a different definition available from this ClassLoader too.
+     * This should always load the parent's copy.
+     */
+//    public void testFalseExistantJavaxClass() {
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        try {
+//            Class cls = cl.loadClass("javax.servlet.Servlet");
+//            assertTrue("Loaded wrong class first; expected to find parent CL's copy of javax.servlet.Servlet",cls.getDeclaredMethods().length > 0);
+//        } catch(ClassNotFoundException e) {
+//            fail("Problem with test; expecting to have javax.servlet.* on the ClassPath");
+//        }
+//    }
+
+    /**
+     * Tries to load a javax.* class that is avialable from the parent ClassLoader,
+     * when there's a different definition available from this ClassLoader too.
+     * This should always load the parent's copy.
+     */
+//    public void testTrueExistantJavaxClass() {
+//        clRules.setInverseClassLoading(true);
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        try {
+//            Class cls = cl.loadClass("javax.servlet.Servlet");
+//            assertTrue("Loaded wrong class first; expected to find parent CL's copy of javax.servlet.Servlet",cls.getDeclaredMethods().length > 0);
+//        } catch(ClassNotFoundException e) {
+//            fail("Problem with test; expecting to have javax.servlet.* on the ClassPath");
+//        }
+//    }
+
+    /**
+     * Tries to load a non-javax.* class that is aailable form the parent
+     * ClassLoader, when there's a different definition available from this
+     * ClassLoader.  This should load the parent's copy when
+     * contextPriorityClassLoader is set to false (as here) and the child's
+     * copy when the contextPriorityClassLoader is set to true.
+     */
+//    public void xtestFalseExistantNonJavaxClass() {
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        try {
+//            Class cls = cl.loadClass("mx4j.MBeanDescription");
+//            assertTrue("Should not have overriden parent CL definition of class mx4j.MBeanDescription", cls.getDeclaredMethods().length > 0);
+//        } catch(ClassNotFoundException e) {
+//            fail("Problem with test; expecting to have mx4j.* on the ClassPath");
+//        }
+//    }
+
+    /**
+     * Tries to load a non-javax.* class that is aailable form the parent
+     * ClassLoader, when there's a different definition available from this
+     * ClassLoader.  This should load the parent's copy when
+     * contextPriorityClassLoader is set to false and the child's copy when
+     * the contextPriorityClassLoader is set to true (as here).
+     */
+//    public void xtestTrueExistantNonJavaxClass() {
+//        clRules.setInverseClassLoading(true);
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        try {
+//            Class cls = cl.loadClass("mx4j.MBeanDescription");
+//            assertTrue("Should be able to override a class that is not in java.*, javax.*, etc.", cls.getDeclaredMethods().length == 0);
+//        } catch(ClassNotFoundException e) {
+//            fail("Problem with test; expecting to have mx4j.* on the ClassPath");
+//        }
+//    }
+
+    /**
+     * Tries to load a javax.* class that's not available from the
+     * parent ClassLoader.  This should work.
+     */
+//    public void testFalseNonexistantJavaxResource() {
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        URL url = cl.getResource("javax/foo/Foo.class");
+//        if(url == null) {
+//            fail("Should be able to load a javax.* class that is not defined by my parent CL");
+//        }
+//        assertEquals(url.getProtocol(), "file");
+//    }
+
+    /**
+     * Tries to load a javax.* class that's not available from the
+     * parent ClassLoader.  This should work.
+     */
+//    public void testTrueNonexistantJavaxResource() {
+//        clRules.setInverseClassLoading(true);
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        URL url = cl.getResource("javax/foo/Foo.class");
+//        if(url == null) {
+//            fail("Should be able to load a javax.* class that is not defined by my parent CL");
+//        }
+//        assertEquals(url.getProtocol(), "file");
+//    }
+
+    /**
+     * Tries to load a javax.* class that is avialable from the parent ClassLoader,
+     * when there's a different definition available from this ClassLoader too.
+     * This should always load the parent's copy.
+     */
+//    public void testFalseExistantJavaxResource() {
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        URL url = cl.getResource("javax/servlet/Servlet.class");
+//        if(url == null) {
+//            fail("Problem with test; expecting to have javax.servlet.* on the ClassPath");
+//        }
+//        assertEquals("Loaded wrong class first; expected to find parent CL's copy of javax.servlet.Servlet", url.getProtocol(), "jar");
+//    }
+
+    /**
+     * Tries to load a javax.* class that is avialable from the parent ClassLoader,
+     * when there's a different definition available from this ClassLoader too.
+     * This should always load the parent's copy.
+     */
+//    public void testTrueExistantJavaxResource() {
+//        clRules.setInverseClassLoading(true);
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        URL url = cl.getResource("javax/servlet/Servlet.class");
+//        if(url == null) {
+//            fail("Problem with test; expecting to have javax.servlet.* on the ClassPath");
+//        }
+//        assertEquals("Loaded wrong class first; expected to find parent CL's copy of javax.servlet.Servlet",url.getProtocol(),"jar");
+//    }
+
+    /**
+     * Tries to load a non-javax.* class that is aailable form the parent
+     * ClassLoader, when there's a different definition available from this
+     * ClassLoader.  This should load the parent's copy when
+     * contextPriorityClassLoader is set to false (as here) and the child's
+     * copy when the contextPriorityClassLoader is set to true.
+     */
+//    public void xtestFalseExistantNonJavaxResource() {
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        URL url = cl.getResource("mx4j/MBeanDescription.class");
+//        if(url == null) {
+//            fail("Problem with test; expecting to have mx4j.* on the ClassPath");
+//        }
+//        assertEquals("Should not have overriden parent CL definition of class mx4j.MBeanDescription", url.getProtocol(), "jar");
+//    }
+
+    /**
+     * Tries to load a non-javax.* class that is aailable form the parent
+     * ClassLoader, when there's a different definition available from this
+     * ClassLoader.  This should load the parent's copy when
+     * contextPriorityClassLoader is set to false and the child's copy when
+     * the contextPriorityClassLoader is set to true (as here).
+     */
+//    public void testTrueExistantNonJavaxResource() {
+//        clRules.setInverseClassLoading(true);
+//        clRules.getHiddenRule().setClassPrefixes(Collections.<String>emptySet());
+//        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
+//        URL url = cl.getResource("mx4j/MBeanDescription.class");
+//        if(url == null) {
+//            fail("Problem with test; expecting to have mx4j.* on the ClassPath");
+//        }
+//        assertEquals("Should be able to override a class that is not in java.*, javax.*, etc.", url.getProtocol(), "file");
+//    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ClassLoaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ClassLoaderTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ClassLoaderTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ContainerTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ContainerTest.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ContainerTest.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ContainerTest.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,100 @@
+/**
+ *  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.geronimo.jetty8;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.apache.geronimo.jetty8.app.MockWebServiceContainer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ContainerTest extends AbstractWebModuleTest {
+
+    public void testHTTPConnector() throws Exception {
+
+        HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678").openConnection();
+        try {
+            connection.getInputStream();
+            fail();
+        } catch (Exception e) {
+            // 404 proves we spoke to the server even if we didn't get anything
+            assertEquals(HttpURLConnection.HTTP_NOT_FOUND, connection.getResponseCode());
+            connection.disconnect();
+        }
+    }
+
+    public void testWebServiceHandler() throws Exception {
+
+        String contextPath = "/foo/webservice.ws";
+        MockWebServiceContainer webServiceInvoker = new MockWebServiceContainer();
+        container.addWebService(contextPath, null, webServiceInvoker, null, null, null, null, null, cl);
+
+        HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678" + contextPath).openConnection();
+        try {
+            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+            assertEquals("Hello World", reader.readLine());
+        } finally {
+            connection.disconnect();
+        }
+        container.removeWebService(contextPath);
+        connection = (HttpURLConnection) new URL("http://localhost:5678" + contextPath).openConnection();
+        try {
+            connection.getInputStream();
+            fail();
+        } catch (Exception e) {
+            // see if we removed the ws.
+            assertEquals(HttpURLConnection.HTTP_NOT_FOUND, connection.getResponseCode());
+            connection.disconnect();
+        }
+    }
+    public void test2WebServiceHandlers() throws Exception {
+
+        String contextPath = "/foo/webservice.ws";
+        MockWebServiceContainer webServiceInvoker = new MockWebServiceContainer();
+        container.addWebService(contextPath, null, webServiceInvoker, null, null, null, null, null, cl);
+
+        String contextPath2 = "/bar/webservice.ws";
+        MockWebServiceContainer webServiceInvoker2 = new MockWebServiceContainer();
+        container.addWebService(contextPath2, null, webServiceInvoker2, null, null, null, null, null, cl);
+
+        HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678" + contextPath).openConnection();
+        try {
+            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+            assertEquals("Hello World", reader.readLine());
+        } finally {
+            connection.disconnect();
+        }
+        container.removeWebService(contextPath);
+        connection = (HttpURLConnection) new URL("http://localhost:5678" + contextPath).openConnection();
+        try {
+            connection.getInputStream();
+            fail();
+        } catch (Exception e) {
+            // see if we removed the ws.
+            assertEquals(HttpURLConnection.HTTP_NOT_FOUND, connection.getResponseCode());
+            connection.disconnect();
+        }
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ContainerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ContainerTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/ContainerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/GBeanInfoTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/GBeanInfoTest.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/GBeanInfoTest.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/GBeanInfoTest.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,41 @@
+/**
+ *  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.geronimo.jetty8;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.gbean.annotation.AnnotationGBeanInfoFactory;
+import org.apache.geronimo.system.serverinfo.BasicServerInfo;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GBeanInfoTest extends TestCase {
+
+    public void testJettyPOJOWebServiceHolder() throws Exception {
+        new AnnotationGBeanInfoFactory().getGBeanInfo(POJOWebServiceHolderWrapper.class);
+//        new POJOWebServiceHolderWrapper();
+    }
+
+    public void testJettyContainerImpl() throws Exception {
+        new AnnotationGBeanInfoFactory().getGBeanInfo(JettyContainerImpl.class);
+        ServerInfo serverInfo = new BasicServerInfo(".");
+        new JettyContainerImpl(null, null, null, null, serverInfo);
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/GBeanInfoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/GBeanInfoTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/GBeanInfoTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/SecurityTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/SecurityTest.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/SecurityTest.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/SecurityTest.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,174 @@
+/**
+ *  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.geronimo.jetty8;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Principal;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.security.jacc.WebResourcePermission;
+import javax.security.jacc.WebUserDataPermission;
+
+import org.apache.geronimo.security.deploy.SubjectInfo;
+import org.apache.geronimo.security.jacc.ComponentPermissions;
+import org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal;
+
+
+/**
+ * Tests the JAAC security for Jetty by using both explicit and auto role mapping
+ *
+ * @version $Rev$ $Date$
+ */
+public class SecurityTest extends AbstractWebModuleTest {
+
+    /**
+     * Test the explicit map feature.  Only Alan should be able to log in.
+     *
+     * @throws Exception thrown if an error in the test occurs
+     */
+    public void testExplicitMapping() throws Exception {
+        if (1 == 1) return;
+
+        String securityRealmName = "demo-properties-realm";
+        String defaultPrincipalId = "izumi";
+        SubjectInfo defaultSubjectInfo = new SubjectInfo(securityRealmName, defaultPrincipalId);
+
+        Map<String, SubjectInfo> roleDesignates = Collections.emptyMap();
+        Map<Principal, Set<String>> principalRoleMap = Collections.singletonMap((Principal)new GeronimoGroupPrincipal("it"), Collections.singleton("content-administrator"));
+
+        PermissionCollection uncheckedPermissions = new Permissions();
+        uncheckedPermissions.add(new WebUserDataPermission("/protected/*", ""));
+
+        PermissionCollection excludedPermissions = new Permissions();
+        uncheckedPermissions.add(new WebResourcePermission("/auth/logon.html", ""));
+        uncheckedPermissions.add(new WebUserDataPermission("/auth/logon.html", ""));
+//        uncheckedPermissions.add(new WebResourcePermission("/auth/j_security_check", ""));
+        uncheckedPermissions.add(new WebUserDataPermission("/auth/j_security_check", ""));
+
+        Map<String, PermissionCollection> rolePermissions = new HashMap<String, PermissionCollection>();
+        PermissionCollection permissions = new Permissions();
+        permissions.add(new WebResourcePermission("/protected/*", ""));
+        rolePermissions.put("content-administrator", permissions);
+        rolePermissions.put("auto-administrator", permissions);
+
+        Set<String> securityRoles = new HashSet<String>();
+        securityRoles.add("content-administrator");
+        securityRoles.add("auto-administrator");
+
+        ComponentPermissions componentPermissions = new ComponentPermissions(excludedPermissions, uncheckedPermissions, rolePermissions);
+
+        startWebApp(roleDesignates, principalRoleMap, componentPermissions, defaultSubjectInfo, permissions, securityRoles);
+
+        HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+        connection.setInstanceFollowRedirects(false);
+//        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
+
+        String cookie = connection.getHeaderField("Set-Cookie");
+        cookie = cookie == null? "": cookie.substring(0, cookie.lastIndexOf(';'));
+//        String location = connection.getHeaderField("Location");
+//
+//        connection = (HttpURLConnection) new URL(location).openConnection();
+//        connection.setInstanceFollowRedirects(false);
+//        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+
+        String location = "http://localhost:5678/test/protected/j_security_check?j_username=alan&j_password=starcraft";
+
+        connection = (HttpURLConnection) new URL(location).openConnection();
+        connection.setRequestMethod("POST");
+        connection.setRequestProperty("Cookie", cookie);
+        connection.setInstanceFollowRedirects(false);
+        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
+
+        connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+        connection.setRequestProperty("Cookie", cookie);
+        connection.setInstanceFollowRedirects(false);
+        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+
+        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+        assertEquals("Hello World", reader.readLine());
+        connection.disconnect();
+
+        //make sure that leaving out the session id makes us try to login again.
+        connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+        connection.setInstanceFollowRedirects(false);
+//        connection.setRequestProperty("Cookie", cookie);
+//        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
+
+        //new cookie for new session
+        cookie = connection.getHeaderField("Set-Cookie");
+        cookie = cookie.substring(0, cookie.lastIndexOf(';'));
+//        location = connection.getHeaderField("Location");
+
+//        connection = (HttpURLConnection) new URL(location).openConnection();
+//        connection.setInstanceFollowRedirects(false);
+//        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+
+        location = "http://localhost:5678/test/protected/j_security_check?j_username=izumi&j_password=violin";
+
+        connection = (HttpURLConnection) new URL(location).openConnection();
+        connection.setRequestMethod("POST");
+        connection.setRequestProperty("Cookie", cookie);
+        connection.setInstanceFollowRedirects(false);
+//        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
+
+        try {
+            //izumi is not authorized for /protected/*
+            connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+            connection.setRequestProperty("Cookie", cookie);
+            connection.setInstanceFollowRedirects(false);
+            reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+
+//            fail("Should throw an IOException for HTTP 403 response");
+        } catch (IOException e) {
+        }
+
+//        assertEquals(HttpURLConnection.HTTP_FORBIDDEN, connection.getResponseCode());
+        connection.disconnect();
+
+        stopWebApp();
+    }
+
+    protected void startWebApp(Map<String, SubjectInfo> roleDesignates, Map<Principal, Set<String>> principalRoleMap, ComponentPermissions componentPermissions, SubjectInfo defaultSubjectInfo, PermissionCollection checked, Set securityRoles) throws Exception {
+        WebAppContextWrapper app = setUpSecureAppContext(securityRealmName, roleDesignates, principalRoleMap, componentPermissions, defaultSubjectInfo, checked, securityRoles);
+        setUpStaticContentServlet(app);
+//        start(appName, app);
+    }
+
+    protected void stopWebApp() throws Exception {
+//        stop(appName);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        tearDownSecurity();
+        super.tearDown();
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/SecurityTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/SecurityTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/SecurityTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,90 @@
+/**
+ *  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.geronimo.jetty8;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import javax.management.ObjectName;
+import javax.management.j2ee.statistics.Statistic;
+import javax.management.j2ee.statistics.Stats;
+import org.apache.geronimo.management.LazyStatisticsProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatTest extends AbstractWebModuleTest {
+
+    private ObjectName webModuleName;
+    
+    public void testContainerStats() throws Exception {
+	statsTest(container);
+    }
+
+    public void testConnectorStats() throws Exception {
+	statsTest(connector);
+    }
+    
+    public void statsTest(LazyStatisticsProvider component) throws Exception {       
+        // start statistics collection
+        if (component instanceof LazyStatisticsProvider) {
+        assertTrue("Stats should be off initially", !component.isStatsOn());
+        component.setStatsOn(true);
+        }
+        int n = 4; // no of connections
+        for (int k = 0; k < n; k++) {
+            HttpURLConnection connection = (HttpURLConnection) new URL(connector.getConnectUrl() + "/test/hello.txt")
+                    .openConnection();
+            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+            assertEquals("Hello World", reader.readLine());
+            
+            Stats stats = component.getStats();
+            Statistic[] stts = stats.getStatistics();
+            Statistic aStts;
+            String[] sttsNames = stats.getStatisticNames();
+            for (int i = 0; i < sttsNames.length; i++) {
+                // check that the names match the getter methods
+                String sttsName = sttsNames[i];
+                assertFalse(sttsName.equals(stts[i].getName()));
+                try {
+                stats.getClass().getMethod("get" + sttsName, new Class[0]);
+                } catch (NoSuchMethodException e) {
+            	continue; // ignore this statistics for now, JSR77.6.10.1.1
+                }
+                aStts = stats.getStatistic(sttsName);
+                assertTrue("startTime was not set for " + sttsName, aStts.getStartTime() != 0);
+                assertTrue("lastSampleTime was not set for " + sttsName, aStts.getLastSampleTime() != 0);
+                /*System.out.println("              lastSampleTime = " + aStts.getLastSampleTime() + 
+            	    "  startTime = " + aStts.getStartTime());
+                System.out.println(aStts);*/
+            }
+            if (k == n-2) component.resetStats(); // test reset
+            connection.disconnect();
+            Thread.sleep(1000);  // connection interval
+        }       
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        WebAppContextWrapper app;
+        app = setUpAppContext(null, null, "policyContextID", null, "war1/");
+        setUpStaticContentServlet(app);
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/app/MockWebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/app/MockWebServiceContainer.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/app/MockWebServiceContainer.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/app/MockWebServiceContainer.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,36 @@
+/**
+ *  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.geronimo.jetty8.app;
+
+import org.apache.geronimo.webservices.WebServiceContainer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MockWebServiceContainer implements WebServiceContainer {
+    public void invoke(Request request, Response response) throws Exception {
+        response.getOutputStream().write("Hello World".getBytes());
+    }
+
+    public void getWsdl(Request req, Response res) throws Exception {
+    
+    }
+
+    public void destroy() {
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/app/MockWebServiceContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/app/MockWebServiceContainer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/app/MockWebServiceContainer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/ConnectorGBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/ConnectorGBeanTest.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/ConnectorGBeanTest.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/ConnectorGBeanTest.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,38 @@
+/*
+ * 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.geronimo.jetty8.connector;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConnectorGBeanTest extends TestCase {
+
+    public void testGBeans() throws Exception {
+        GBeanInfo gBeanInfo = HTTPBlockingConnector.getGBeanInfo();
+        gBeanInfo = HTTPSelectChannelConnector.getGBeanInfo();
+        gBeanInfo = HTTPSocketConnector.getGBeanInfo();
+        gBeanInfo = HTTPSSelectChannelConnector.getGBeanInfo();
+        gBeanInfo = HTTPSSocketConnector.getGBeanInfo();
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/ConnectorGBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/ConnectorGBeanTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/ConnectorGBeanTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/HTTPConnectorTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/HTTPConnectorTest.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/HTTPConnectorTest.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/HTTPConnectorTest.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,40 @@
+/**
+ *  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.geronimo.jetty8.connector;
+
+import java.net.UnknownHostException;
+import java.net.InetSocketAddress;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HTTPConnectorTest extends TestCase {
+    private HTTPSocketConnector connector;
+
+    public void testAddress() throws UnknownHostException {
+        connector.setHost("localhost");
+        connector.setPort(1234);
+        assertEquals(new InetSocketAddress("localhost", 1234), connector.getListenAddress());
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        connector = new HTTPSocketConnector(null, null);
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/HTTPConnectorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/HTTPConnectorTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/connector/HTTPConnectorTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message