01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.geronimo.testsuite.jcacms;
19:
20: import org.apache.geronimo.testsupport.SeleniumTestSupport;
21: import org.testng.annotations.Test;
22:
23: /**
24: * ???
25: *
26: * @version $Rev: 581677 $ $Date: 2007-10-03 11:27:51 -0700 (Wed, 03 Oct 2007) $
27: */
28: @Test
29: public class CmsTest extends SeleniumTestSupport {
30: @Test
31: public void testPageContent1() throws Exception {
32: selenium
33: .open("http://localhost:8080/jca-cms/default-subject-servlet");
34: selenium.waitForPageToLoad("30000");
35:
36: String body = selenium.getText("xpath=/html/body");
37:
38: assertTrue(body.endsWith(
39: // "Current subject: Subject:\n" +
40: // "\tPrincipal: org.apache.geronimo.connector.outbound.security.ResourcePrincipal@cb1c722f\n" +
41: // "\tPrincipal: org.apache.geronimo.security.IdentificationPrincipal[[1186174499145:0x607c7eb7837eabcd6b759e6f9d29e7eee72622d6]]\n" +
42: // "\tPrincipal: org.apache.geronimo.security.IdentificationPrincipal[[1186174499146:0x7622e0831ed59a4cd6c277a53491de74f1489311]]\n" +
43: // "\tPrivate Credential: javax.resource.spi.security.PasswordCredential@23f33e5c\n" +
44: // "\n" +
45: // "Next subject: Subject:\n" +
46: // "\tPrincipal: org.apache.geronimo.connector.outbound.security.ResourcePrincipal@cb1c722f\n" +
47: // "\tPrincipal: org.apache.geronimo.security.IdentificationPrincipal[[1186174499145:0x607c7eb7837eabcd6b759e6f9d29e7eee72622d6]]\n" +
48: // "\tPrincipal: org.apache.geronimo.security.IdentificationPrincipal[[1186174499146:0x7622e0831ed59a4cd6c277a53491de74f1489311]]\n" +
49: // "\tPrivate Credential: javax.resource.spi.security.PasswordCredential@23f33e5c\n" +
50: // "\n" +
51: "Successfully got configured connection\n"
52: + "\n"
53: + "Successfully got container managed connection"));
54:
55: String expectedPrincipal = "Principal: george";
56: int pos1 = body.indexOf(expectedPrincipal);
57: assertTrue("Expected current subject principal", pos1 > 0);
58: int pos2 = body.indexOf(expectedPrincipal, pos1
59: + expectedPrincipal.length());
60: assertTrue("Expected next subject principal", pos2 > 0);
61: }
62:
63: @Test
64: public void testPageContent2() throws Exception {
65: selenium.open("http://localhost:8080/jca-cms/run-as-servlet");
66: selenium.waitForPageToLoad("30000");
67:
68: String body = selenium.getText("xpath=/html/body");
69:
70: assertTrue(body
71: .endsWith("Successfully got configured connection\n"
72: + "\n"
73: + "Successfully got container managed connection"));
74:
75: String expectedPrincipal = "Principal: george";
76: int pos1 = body.indexOf(expectedPrincipal);
77: assertTrue("Expected current subject principal", pos1 > 0);
78: int pos2 = body.indexOf("Principal: gracie", pos1
79: + expectedPrincipal.length());
80: assertTrue("Expected next subject principal", pos2 > 0);
81: }
82: }
|