KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cluster > test > ScopedSetAttributeTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.cluster.test;
23
24 import junit.framework.Test;
25 import org.apache.commons.httpclient.HttpClient;
26 import org.apache.commons.httpclient.HttpMethod;
27 import org.apache.commons.httpclient.methods.GetMethod;
28 import org.jboss.test.JBossClusteredTestCase;
29
30 /**
31  * Clustering test case of get/set under scoped class loader.
32  * Trigger type is set only, i.e., get is not dirty.
33  * And replication granularity is attribute based.
34  *
35  * @author Ben Wang
36  * @version $Revision: 1.0
37  */

38 public class ScopedSetAttributeTestCase
39       extends ScopedTestCase
40 {
41
42    public ScopedSetAttributeTestCase(String JavaDoc name)
43    {
44       super(name);
45       warName_ = "/http-scoped-set-attr/";
46       
47       concatenate();
48    }
49    
50    protected String JavaDoc getWarName()
51    {
52       return "http-scoped-set-attr";
53    }
54
55    public static Test suite() throws Exception JavaDoc
56    {
57       Test t1 = JBossClusteredTestCase.getDeploySetup(ScopedSetAttributeTestCase.class,
58             "http-scoped-set-attr.war");
59       return t1;
60    }
61
62
63    /**
64     * Test session modify with non-primitive get/modify.
65     *
66     * @throws Exception
67     */

68    public void testNonPrimitiveModify()
69          throws Exception JavaDoc
70    {
71       String JavaDoc attr = "";
72       getLog().debug("Enter testNonPrimitiveModify");
73
74       getLog().debug(setUrl + ":::::::" + getUrl);
75
76       // Create an instance of HttpClient.
77
HttpClient client = new HttpClient();
78
79       // Set the session attribute first
80
makeGet(client, baseURL0_ +setUrl);
81
82       // Get the Attribute set
83
String JavaDoc attrOld = makeGet(client, baseURL0_ +getUrl);
84
85       // Get the Attribute set
86
makeGet(client, baseURL0_ +modifyNoSetUrl);
87
88       // Get the Attribute set
89
attr = makeGet(client, baseURL0_ +getUrl);
90
91       sleepThread(DEFAULT_SLEEP);
92
93       // Make connection to server 1 and get
94
setCookieDomainToThisServer(client, servers_[1]);
95       String JavaDoc attr2 = makeGet(client, baseURL1_ +getUrl);
96
97       // Check the result
98
assertEquals("Attributes should be the same", attrOld, attr2);
99       getLog().debug("Exit testNonPrimitiveModify");
100    }
101
102
103 }
104
Popular Tags