incubator-wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngalla...@apache.org
Subject svn commit: r787553 [25/34] - in /incubator/wink/contrib/ibm-jaxrs/tests: ./ fvt/ fvt/demo/ fvt/demo/jaxrs/ fvt/demo/jaxrs/cache/ fvt/demo/jaxrs/cache/server/ fvt/demo/jaxrs/cache/test/ fvt/demo/jaxrs/datasource/ fvt/demo/jaxrs/datasource/server/ fvt/d...
Date Tue, 23 Jun 2009 05:38:19 GMT
Added: incubator/wink/contrib/ibm-jaxrs/tests/fvt/template/test/SampleTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/fvt/template/test/SampleTest.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/fvt/template/test/SampleTest.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/fvt/template/test/SampleTest.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,34 @@
+/*
+ * 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 template.test;
+
+import framework.defaults.test.FVTTestCase;
+
+public class SampleTest extends FVTTestCase {
+
+    public static junit.framework.Test suite() {
+        return FVTTestCase.getTestSuite(SampleTest.class,
+                "template.server.Application");
+    }
+
+    public void testSomething() {
+
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/test-resources/1040_2007.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/test-resources/1040_2007.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/test-resources/1040_2007.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/test-resources/1040_2007.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,26 @@
+<taxform name="1040" version="2007">
+
+<!--
+  ~ 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.
+  -->
+
+<name></name>
+<address></address>
+<income></income>
+<deductions></deductions>
+</taxform>
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/test-resources/1040_2008.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/test-resources/1040_2008.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/test-resources/1040_2008.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/test-resources/1040_2008.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,25 @@
+<taxform name="1040" version="2007">
+
+<!--
+  ~ 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.
+  -->
+
+<name></name>
+<address></address>
+<income></income>
+</taxform>
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests/league/ibm-jaxrs.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests/league/ibm-jaxrs.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests/league/ibm-jaxrs.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests/league/ibm-jaxrs.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,103 @@
+<jaxrs:resources xmlns:jaxrs="http://www.ibm.com/xml/ns/jaxrs">
+
+<!--
+  ~ 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.
+  -->
+
+
+	<jaxrs:resource>
+		<jaxrs:class-name>com.ibm.ws.jaxrs.model.dd.League</jaxrs:class-name>
+		<jaxrs:path>/league/{id}</jaxrs:path>
+		<jaxrs:methods>
+			<jaxrs:method>
+				<jaxrs:method-name>getName</jaxrs:method-name>
+				<jaxrs:method-type>GET</jaxrs:method-type>
+				<jaxrs:path>/name</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:produces>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+			</jaxrs:method>
+			<jaxrs:method>
+				<jaxrs:method-name>getTeams</jaxrs:method-name>
+				<jaxrs:method-type>GET</jaxrs:method-type>
+				<jaxrs:path>/teams</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:produces>
+					<jaxrs:mimeType>application/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+			</jaxrs:method>
+			<jaxrs:method>
+				<jaxrs:method-name>getTeam</jaxrs:method-name>
+				<jaxrs:path>/team/{id}</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:produces>
+					<jaxrs:mimeType>application/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+				<jaxrs:parameter>
+					<jaxrs:type>java.lang.String</jaxrs:type>
+				</jaxrs:parameter>
+			</jaxrs:method>
+			<jaxrs:method>
+				<jaxrs:method-name>createTeam</jaxrs:method-name>
+				<jaxrs:method-type>POST</jaxrs:method-type>
+				<jaxrs:path>/team</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>application/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:parameter>
+					<jaxrs:type>com.ibm.ws.jaxrs.model.dd.Team</jaxrs:type>
+				</jaxrs:parameter>
+			</jaxrs:method>
+		</jaxrs:methods>
+	</jaxrs:resource>
+	
+	<jaxrs:resource>
+		<jaxrs:class-name>com.ibm.ws.jaxrs.model.dd.Team</jaxrs:class-name>
+		<jaxrs:methods>
+			<jaxrs:method>
+				<jaxrs:method-name>getName</jaxrs:method-name>
+				<jaxrs:method-type>GET</jaxrs:method-type>
+				<jaxrs:path>/</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:produces>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+			</jaxrs:method>
+		</jaxrs:methods>
+	</jaxrs:resource>
+	
+	<jaxrs:provider>
+		<jaxrs:class-name>com.ibm.ws.jaxrs.model.dd.CustomProvider</jaxrs:class-name>
+		<jaxrs:consumes>
+				<jaxrs:mimeType>application/custom</jaxrs:mimeType>
+		</jaxrs:consumes>
+		<jaxrs:produces>
+				<jaxrs:mimeType>application/custom</jaxrs:mimeType>
+		</jaxrs:produces>
+	</jaxrs:provider>
+	
+</jaxrs:resources>
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests/newsstory/ibm-jaxrs.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests/newsstory/ibm-jaxrs.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests/newsstory/ibm-jaxrs.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests/newsstory/ibm-jaxrs.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,41 @@
+<jaxrs:resources xmlns:jaxrs="http://www.ibm.com/xml/ns/jaxrs">
+
+<!--
+  ~ 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.
+  -->
+
+	<jaxrs:resource>
+		<jaxrs:class-name>com.ibm.ws.jaxrs.model.dd.NewsStory</jaxrs:class-name>
+		<jaxrs:path>/newsstory/{id}</jaxrs:path>
+		<jaxrs:methods>
+			<jaxrs:method>
+				<jaxrs:method-name>getTitle</jaxrs:method-name>
+				<jaxrs:method-type>GET</jaxrs:method-type>
+				<jaxrs:path>/title</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:produces>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+				<jaxrs:encoded>true</jaxrs:encoded>
+				<jaxrs:defaultValue>someDefaultValue</jaxrs:defaultValue>
+			</jaxrs:method>
+		</jaxrs:methods>
+	</jaxrs:resource>
+</jaxrs:resources>
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests_merge/league/ibm-jaxrs.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests_merge/league/ibm-jaxrs.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests_merge/league/ibm-jaxrs.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests_merge/league/ibm-jaxrs.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,95 @@
+<jaxrs:resources xmlns:jaxrs="http://www.ibm.com/xml/ns/jaxrs">
+
+<!--
+  ~ 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.
+  -->
+
+
+	<jaxrs:resource>
+		<jaxrs:class-name>com.ibm.ws.jaxrs.model.dd.merge.League</jaxrs:class-name>
+		<jaxrs:path>/league/{id}</jaxrs:path>
+		<jaxrs:methods>
+			<jaxrs:method>
+				<jaxrs:method-name>getName</jaxrs:method-name>
+				<jaxrs:method-type>GET</jaxrs:method-type>
+				<jaxrs:path>/name</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:produces>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+			</jaxrs:method>
+			<jaxrs:method>
+				<jaxrs:method-name>getTeams</jaxrs:method-name>
+				<jaxrs:path>/teams</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:produces>
+					<jaxrs:mimeType>application/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+			</jaxrs:method>
+			<jaxrs:method>
+				<jaxrs:method-name>getTeam</jaxrs:method-name>
+				<jaxrs:path>/team/{id}</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:produces>
+					<jaxrs:mimeType>application/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+				<jaxrs:parameter>
+					<jaxrs:type>java.lang.String</jaxrs:type>
+				</jaxrs:parameter>
+			</jaxrs:method>
+			<jaxrs:method>
+				<jaxrs:method-name>createTeam</jaxrs:method-name>
+				<jaxrs:method-type>POST</jaxrs:method-type>
+				<jaxrs:path>/team</jaxrs:path>
+				<jaxrs:parameter>
+					<jaxrs:type>com.ibm.ws.jaxrs.model.dd.merge.Team</jaxrs:type>
+				</jaxrs:parameter>
+			</jaxrs:method>
+		</jaxrs:methods>
+	</jaxrs:resource>
+	
+	<jaxrs:resource>
+		<jaxrs:class-name>com.ibm.ws.jaxrs.model.dd.merge.Team</jaxrs:class-name>
+		<jaxrs:methods>
+			<jaxrs:method>
+				<jaxrs:method-name>getName</jaxrs:method-name>
+				<jaxrs:path>/</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:produces>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+			</jaxrs:method>
+		</jaxrs:methods>
+	</jaxrs:resource>
+	
+	<jaxrs:provider>
+		<jaxrs:class-name>com.ibm.ws.jaxrs.model.dd.merge.CustomProvider</jaxrs:class-name>
+		<jaxrs:consumes>
+				<jaxrs:mimeType>application/custom</jaxrs:mimeType>
+		</jaxrs:consumes>
+	</jaxrs:provider>
+	
+</jaxrs:resources>
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests_merge/newsstory/ibm-jaxrs.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests_merge/newsstory/ibm-jaxrs.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests_merge/newsstory/ibm-jaxrs.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/test-resources/modelddtests_merge/newsstory/ibm-jaxrs.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,41 @@
+<jaxrs:resources xmlns:jaxrs="http://www.ibm.com/xml/ns/jaxrs">
+
+<!--
+  ~ 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.
+  -->
+
+	<jaxrs:resource>
+		<jaxrs:class-name>com.ibm.ws.jaxrs.model.dd.merge.NewsStory</jaxrs:class-name>
+		<jaxrs:path>/story/{id}</jaxrs:path>
+		<jaxrs:methods>
+			<jaxrs:method>
+				<jaxrs:method-name>getTitle</jaxrs:method-name>
+				<jaxrs:method-type>GET</jaxrs:method-type>
+				<jaxrs:path>/title</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:produces>
+					<jaxrs:mimeType>text/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+				<jaxrs:encoded>true</jaxrs:encoded>
+				<jaxrs:defaultValue>someDefaultValue</jaxrs:defaultValue>
+			</jaxrs:method>
+		</jaxrs:methods>
+	</jaxrs:resource>
+</jaxrs:resources>
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/test-resources/phonebook/ibm-jaxrs.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/test-resources/phonebook/ibm-jaxrs.xml?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/test-resources/phonebook/ibm-jaxrs.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/test-resources/phonebook/ibm-jaxrs.xml Tue Jun 23 05:37:57 2009
@@ -0,0 +1,91 @@
+<jaxrs:resources xmlns:jaxrs="http://www.ibm.com/xml/ns/jaxrs">
+
+<!--
+  ~ 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.
+  -->
+
+
+	<jaxrs:resource>
+		<jaxrs:class-name>com.ibm.ws.jaxrs.sample.dd.PhoneBook</jaxrs:class-name>
+		<jaxrs:path>/phonebook</jaxrs:path>
+		<jaxrs:methods>
+			<jaxrs:method>
+				<jaxrs:method-name>getEntries</jaxrs:method-name>
+				<jaxrs:method-type>GET</jaxrs:method-type>
+				<jaxrs:path>/</jaxrs:path>
+				<jaxrs:produces>
+					<jaxrs:mimeType>application/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+			</jaxrs:method>
+			<jaxrs:method>
+				<jaxrs:method-name>getEntry</jaxrs:method-name>
+				<jaxrs:path>/phoneNumber/{phoneNumber}</jaxrs:path>
+				<jaxrs:produces>
+					<jaxrs:mimeType>application/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+				<jaxrs:parameter>
+					<jaxrs:type>java.lang.String</jaxrs:type>
+				</jaxrs:parameter>
+			</jaxrs:method>
+			<jaxrs:method>
+				<jaxrs:method-name>deleteEntry</jaxrs:method-name>
+				<jaxrs:method-type>DELETE</jaxrs:method-type>
+				<jaxrs:path>/phoneNumber/{phoneNumber}</jaxrs:path>
+				<jaxrs:parameter>
+					<jaxrs:type>java.lang.String</jaxrs:type>
+				</jaxrs:parameter>
+			</jaxrs:method>
+			<jaxrs:method>
+				<jaxrs:method-name>createEntry</jaxrs:method-name>
+				<jaxrs:method-type>POST</jaxrs:method-type>
+				<jaxrs:path>/</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>application/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:parameter>
+					<jaxrs:type>com.ibm.ws.jaxrs.sample.dd.PhoneBookEntryBean</jaxrs:type>
+				</jaxrs:parameter>
+			</jaxrs:method>
+			<jaxrs:method>
+				<jaxrs:method-name>updateEntry</jaxrs:method-name>
+				<jaxrs:method-type>PUT</jaxrs:method-type>
+				<jaxrs:path>/</jaxrs:path>
+				<jaxrs:consumes>
+					<jaxrs:mimeType>application/xml</jaxrs:mimeType>
+				</jaxrs:consumes>
+				<jaxrs:parameter>
+					<jaxrs:type>com.ibm.ws.jaxrs.sample.dd.PhoneBookEntryBean</jaxrs:type>
+				</jaxrs:parameter>
+			</jaxrs:method>
+		</jaxrs:methods>
+	</jaxrs:resource>
+	
+	<jaxrs:resource>
+		<jaxrs:class-name>com.ibm.ws.jaxrs.sample.dd.PhoneBookEntry</jaxrs:class-name>
+		<jaxrs:methods>
+			<jaxrs:method>
+				<jaxrs:method-name>get</jaxrs:method-name>
+				<jaxrs:method-type>GET</jaxrs:method-type>
+				<jaxrs:produces>
+					<jaxrs:mimeType>application/xml</jaxrs:mimeType>
+				</jaxrs:produces>
+			</jaxrs:method>
+		</jaxrs:methods>
+	</jaxrs:resource>
+	
+</jaxrs:resources>
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/rest/test/utils/TestUtils.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/rest/test/utils/TestUtils.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/rest/test/utils/TestUtils.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/rest/test/utils/TestUtils.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,179 @@
+/*
+ * 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 com.ibm.rest.test.utils;
+
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.jaxrs.model.ProviderInfo;
+
+import com.ibm.ws.jaxrs.metadata.MetadataRegistry;
+import com.ibm.ws.jaxrs.model.JAXRSInfoBuilder;
+import com.ibm.ws.jaxrs.model.JAXRSInfoBuilderFactory;
+import com.ibm.ws.jaxrs.model.JAXRSInfoInput;
+import com.ibm.ws.jaxrs.model.JAXRSInfoOutput;
+
+/**
+ * This class will provide utility functions to unit tests.
+ *
+ */
+public class TestUtils {
+
+    private static File baseDirectory = null;
+    private static File testResourcesDirectory = null;
+
+    // Helper method to return a ClassResourceInfo for the class name supplied
+    public static ClassResourceInfo getClassResourceInfo(List<ClassResourceInfo> classInfoList, String className) {
+        ClassResourceInfo targetInfo = null;
+        for (ClassResourceInfo classInfo : classInfoList) {
+            if (classInfo.getServiceClass().getName().equals(className)) {
+                targetInfo = classInfo;
+                break;
+            }
+        }
+        return targetInfo;
+    }
+
+    // Helper method to return a ProviderInfo for the class name supplied
+    public static ProviderInfo getProviderInfo(List<ProviderInfo> providerInfoList, String className) {
+        ProviderInfo targetInfo = null;
+        for (ProviderInfo providerInfo : providerInfoList) {
+            if (providerInfo.getProviderClass().getName().equals(className)) {
+                targetInfo = providerInfo;
+                break;
+            }
+        }
+        return targetInfo;
+    }
+
+    // Helper method to return a list of ClassResourceInfo objects based on
+    // an input Class objects
+    public static List<ClassResourceInfo> getClassInfoList(Class[] classes, Object[] singletons)
+            throws Exception {
+        JAXRSInfoInput input = new JAXRSInfoInput(
+                JAXRSInfoInput.Type.REFLECTION);
+        if (classes != null) {
+            for (Class clazz : classes) {
+                input.addInfo(clazz.getName(), clazz, null);
+            }
+        }
+        if (singletons != null) {
+            for (Object singleton : singletons) {
+                input.addInfo(singleton.getClass().getName(), singleton
+                        .getClass(), singleton);
+            }
+        }
+        JAXRSInfoBuilderFactory factory = (JAXRSInfoBuilderFactory) MetadataRegistry
+                .getImplementation(JAXRSInfoBuilderFactory.class);
+        JAXRSInfoBuilder builder = factory.getInfoBuilder(input.getInputType());
+        JAXRSInfoOutput output = builder.buildRESTInfo(input);
+        return output != null ? output.getClassInfoList() : null;
+    }
+
+    // Helper method to retrieve the OperationResourceInfos for a particular
+    // class. This method will only return the OperationResourceInfos for
+    // a single class, so both a Class and Object instance should not be passed
+    public static List<OperationResourceInfo> getOperationInfoList(Class clazz, Object singleton)
+            throws Exception {
+        List<OperationResourceInfo> infos = null;
+        List<ClassResourceInfo> classInfoList = null;
+        if (clazz != null) {
+            classInfoList = getClassInfoList(new Class[] { clazz }, null);
+        } else if (singleton != null) {
+            classInfoList = getClassInfoList(null, new Object[] { singleton });
+        }
+        if (classInfoList != null && !classInfoList.isEmpty()) {
+            ClassResourceInfo info = classInfoList.get(0);
+            infos = new LinkedList<OperationResourceInfo>(info
+                    .getMethodDispatcher().getOperationResourceInfos());
+        }
+        return infos;
+    }
+
+    public static File getBaseDirectory() throws Exception {
+        if (baseDirectory != null)
+            return baseDirectory;
+
+        File base = new File(System.getProperty("basedir", "."));
+        if (isCurrentBaseDirectory(base))
+            return base;
+
+        String baseDir = base.getCanonicalPath();
+        if (!baseDir.contains("branches") && !baseDir.endsWith("trunk")
+                && !baseDir.endsWith("autoFVT")) {
+            if (!baseDir.endsWith(java.io.File.separator)) {
+                baseDir = baseDir + java.io.File.separator;
+            }
+            baseDir = baseDir + "trunk";
+        }
+
+        baseDirectory = base;
+        return baseDirectory;
+    }
+
+    public static boolean isCurrentBaseDirectory(File dir) {
+        if (dir == null && !dir.isDirectory())
+            return false;
+
+        File[] files = dir.listFiles();
+        if (files.length == 0)
+            return false;
+
+        for (File f : files) {
+            if (f.getName().equals("build.xml"))
+                return true;
+        }
+
+        return false;
+    }
+
+    public static String getTestResourceDirPath() throws Exception {
+        File baseDir = getBaseDirectory();
+        File file = getTestResourceDir(baseDir);
+        return file != null ? file.getAbsolutePath() : null;
+    }
+
+    static File getTestResourceDir(File input) {
+        if (testResourcesDirectory != null)
+            return testResourcesDirectory;
+
+        File[] files = input.listFiles();
+        if (files != null) {
+            for (File file : files) {
+                if (file.isDirectory()) {
+                    if (file.getName().equalsIgnoreCase("test-resources")) {
+                        testResourcesDirectory = file;
+                        return file;
+                    }
+                    File targetFile = getTestResourceDir(file);
+                    if (targetFile != null) {
+                        testResourcesDirectory = targetFile;
+                        return targetFile;
+                    }
+                }
+            }
+        }
+
+        return null;
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/annotations/AnnotationTests.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/annotations/AnnotationTests.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/annotations/AnnotationTests.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/annotations/AnnotationTests.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,230 @@
+/*
+ * 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 com.ibm.ws.jaxrs.annotations;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+
+import com.ibm.ws.jaxrs.web.RESTServlet;
+import com.ibm.ws.jaxrs.web.ServletTestFramework;
+import com.ibm.ws.jaxrs.web.mock.ServletRequest;
+import com.ibm.ws.jaxrs.web.mock.ServletResponse;
+
+public class AnnotationTests extends ServletTestFramework {
+
+    public void testAlias() throws Exception {
+        RESTServlet servlet = createServlet("com.ibm.ws.jaxrs.annotations.LaborApplication");
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/workers", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+
+            assertEquals("You made it!", responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testAliases() throws Exception {
+        RESTServlet servlet = createServlet("com.ibm.ws.jaxrs.annotations.LaborApplication");
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/towns", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+
+            assertEquals("You made it!", responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+
+        request = ServletTestFramework.createServletRequest("/townships",
+                HttpMethod.GET);
+        response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+
+            assertEquals("You made it!", responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testAliasesSubResource() throws Exception {
+        RESTServlet servlet = createServlet("com.ibm.ws.jaxrs.annotations.LaborApplication");
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/towns/Austin", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+
+            assertEquals("Austin", responseContent);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    public void testAliasMatchedPaths() throws Exception {
+        RESTServlet servlet = createServlet("com.ibm.ws.jaxrs.annotations.LaborApplication");
+
+        ServletRequest request = ServletTestFramework.createServletRequest(
+                "/towns/matched/paths", HttpMethod.GET);
+        ServletResponse response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertNotNull(responseContent);
+            String[] contentParts = responseContent.split(";");
+            assertEquals(2, contentParts.length);
+            assertEquals("towns/matched/paths", contentParts[0]);
+            assertEquals("towns", contentParts[1]);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+
+        request = ServletTestFramework.createServletRequest(
+                "/cities/matched/paths", HttpMethod.GET);
+        response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertNotNull(responseContent);
+            String[] contentParts = responseContent.split(";");
+            assertEquals(2, contentParts.length);
+            assertEquals("cities/matched/paths", contentParts[0]);
+            assertEquals("cities", contentParts[1]);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+
+        request = ServletTestFramework.createServletRequest(
+                "/townships/matched/paths", HttpMethod.GET);
+        response = ServletTestFramework.createServletResponse();
+
+        try {
+            servlet.doGet(request, response);
+
+            // make sure we have our default entry at the least
+            String responseContent = ServletTestFramework.getContent(response);
+            assertNotNull(responseContent);
+            String[] contentParts = responseContent.split(";");
+            assertEquals(2, contentParts.length);
+            assertEquals("townships/matched/paths", contentParts[0]);
+            assertEquals("townships", contentParts[1]);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("The servlet invocation failed: " + e.toString());
+        }
+    }
+
+    @Path(value = "/employees")
+    @Alias(value = "/workers")
+    public static class LaborResource {
+
+        @GET
+        public String get() {
+            return "You made it!";
+        }
+
+    }
+
+    @Path(value = "/cities")
+    @Aliases(value = { @Alias(value = "/towns"), @Alias(value = "/townships") })
+    public static class CityResource {
+
+        @Context
+        private UriInfo uriInfo;
+
+        @GET
+        public String get() {
+            return "You made it!";
+        }
+
+        @Path(value = "/{cityName}")
+        public City getCity(@PathParam(value = "cityName") String cityName) {
+            return new City(cityName);
+        }
+
+        @GET
+        @Path(value = "/matched/paths")
+        public String getMatchedPaths() {
+            StringBuffer sb = new StringBuffer();
+            for (String uri : uriInfo.getMatchedURIs()) {
+                sb.append(uri + ";");
+            }
+            return sb.toString();
+        }
+
+    }
+
+    public static class City {
+
+        private String cityName;
+
+        public City(String cityName) {
+            this.cityName = cityName;
+        }
+
+        @GET
+        @Produces(value = "text/xml")
+        public String getName() {
+            return cityName;
+        }
+
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/annotations/LaborApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/annotations/LaborApplication.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/annotations/LaborApplication.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/annotations/LaborApplication.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,39 @@
+/*
+ * 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 com.ibm.ws.jaxrs.annotations;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+import com.ibm.ws.jaxrs.annotations.AnnotationTests.CityResource;
+import com.ibm.ws.jaxrs.annotations.AnnotationTests.LaborResource;
+
+public class LaborApplication extends Application {
+
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(LaborResource.class);
+        classes.add(CityResource.class);
+        return classes;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/context/RESTContextFactoryTests.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/context/RESTContextFactoryTests.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/context/RESTContextFactoryTests.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/context/RESTContextFactoryTests.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,50 @@
+/*
+ * 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 com.ibm.ws.jaxrs.context;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Response.Status;
+
+import junit.framework.TestCase;
+
+public class RESTContextFactoryTests extends TestCase {
+
+    public void testfaultResponseContextFromException() {
+        ResponseBuilder builder = Response.status(Status.NOT_FOUND);
+        WebApplicationException wae = new WebApplicationException(builder
+                .build());
+
+        RESTContext noRequestCtx = RESTContextFactory
+                .createFaultResponseContext(wae, null);
+
+        assertTrue(noRequestCtx != null);
+        assertTrue(noRequestCtx.getProperty(ContextConstants.RESPONSE) != null);
+
+        RESTContext emptyRequestCtx = RESTContextFactory
+                .createFaultResponseContext(wae, RESTContextFactory
+                        .createRequestContext());
+
+        assertTrue(emptyRequestCtx != null);
+        assertTrue(emptyRequestCtx.getProperty(ContextConstants.RESPONSE) != null);
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/HttpHeadersTests.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/HttpHeadersTests.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/HttpHeadersTests.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/HttpHeadersTests.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,341 @@
+/*
+ * 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 com.ibm.ws.jaxrs.core;
+
+import java.io.StringWriter;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.jaxrs.impl.MetadataMap;
+
+import com.ibm.ws.jaxrs.context.ContextConstants;
+import com.ibm.ws.jaxrs.context.RESTContext;
+import com.ibm.ws.jaxrs.web.ServletTestFramework;
+import com.ibm.ws.jaxrs.web.mock.LocaleEnumeration;
+import com.ibm.ws.jaxrs.web.mock.ServletRequest;
+import com.ibm.ws.jaxrs.web.mock.ServletResponse;
+
+/**
+ * Verify the functionality of our HttpHeaders implemnetation
+ *
+ */
+public class HttpHeadersTests extends TestCase {
+
+    public void testGetAcceptableLanguages() throws Exception {
+        String url = "http://localhost:7070/resources/someresource";
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        RESTContext context = new RESTContext();
+        Enumeration localeEnumeration = getLocaleEnumeration("da", "en",
+                "en-gb");
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put(ServletRequest.LOCALES, localeEnumeration);
+        ServletRequest request = new ServletRequest(url, null, props);
+        ServletResponse response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(request, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        HttpHeaders httpHeaders = new HttpHeadersImpl(context);
+        List<Locale> acceptableLanguages = httpHeaders.getAcceptableLanguages();
+
+        // make sure we got the languages
+        assertNotNull(acceptableLanguages);
+        assertEquals(3, acceptableLanguages.size());
+
+        // now verify that the languages are sorted according to the q-value
+        String lang = acceptableLanguages.get(0).getLanguage();
+        assertEquals("da", lang);
+        lang = acceptableLanguages.get(1).getLanguage();
+        assertEquals("en", lang);
+        lang = acceptableLanguages.get(2).getLanguage();
+        assertEquals("en-gb", lang);
+
+        // try slightly different ordering
+        headers = new MetadataMap<String, String>();
+        context = new RESTContext();
+        localeEnumeration = getLocaleEnumeration("en-gb", "da", "en");
+        props = new HashMap<String, Object>();
+        props.put(ServletRequest.LOCALES, localeEnumeration);
+        request = new ServletRequest(url, null, props);
+        response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(request, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        httpHeaders = new HttpHeadersImpl(context);
+        acceptableLanguages = httpHeaders.getAcceptableLanguages();
+
+        // make sure we got the languages
+        assertNotNull(acceptableLanguages);
+        assertEquals(3, acceptableLanguages.size());
+
+        // now verify that the languages are sorted according to the q-value
+        lang = acceptableLanguages.get(0).getLanguage();
+        assertEquals("en-gb", lang);
+        lang = acceptableLanguages.get(1).getLanguage();
+        assertEquals("da", lang);
+        lang = acceptableLanguages.get(2).getLanguage();
+        assertEquals("en", lang);
+    }
+
+    public void testGetAcceptableLanguagesWithLocale() throws Exception {
+        String url = "http://localhost:7070/resources/someresource";
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        RESTContext context = new RESTContext();
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put(ServletRequest.LOCALE, new Locale("en-us"));
+        ServletRequest request = new ServletRequest(url, null, props);
+        ServletResponse response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(request, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        HttpHeaders httpHeaders = new HttpHeadersImpl(context);
+        List<Locale> acceptableLanguages = httpHeaders.getAcceptableLanguages();
+        assertNotNull(acceptableLanguages);
+        assertEquals(1, acceptableLanguages.size());
+        assertEquals("en-us", acceptableLanguages.get(0).getLanguage());
+    }
+
+    public void testGetAcceptableMediaTypes() throws Exception {
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        RESTContext context = new RESTContext();
+        Map<String, Object> props = new HashMap<String, Object>();
+        ServletRequest request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        context.setProperty(ContextConstants.HTTP_ACCEPT_HEADER,
+                "text/plain; q=0.5, text/html, text/xml; q=0.9");
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        HttpHeaders httpHeaders = new HttpHeadersImpl(context);
+        List<MediaType> mediaTypes = httpHeaders.getAcceptableMediaTypes();
+        assertNotNull(mediaTypes);
+        assertEquals(3, mediaTypes.size());
+
+        // make sure the last MediaType is text/plain according to the q-value
+        MediaType type = mediaTypes.get(2);
+        assertEquals("text", type.getType());
+        assertEquals("plain", type.getSubtype());
+
+        // now let's try with some wildcards
+        headers = new MetadataMap<String, String>();
+        context = new RESTContext();
+        props = new HashMap<String, Object>();
+        request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        context.setProperty(ContextConstants.HTTP_ACCEPT_HEADER,
+                "text/*;q=.7, text/html;q=.9, text/plain;q=1");
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        httpHeaders = new HttpHeadersImpl(context);
+        mediaTypes = httpHeaders.getAcceptableMediaTypes();
+        assertNotNull(mediaTypes);
+        assertEquals(3, mediaTypes.size());
+
+        // make sure the last MediaType is text/*
+        type = mediaTypes.get(2);
+        assertEquals("text", type.getType());
+        assertEquals("*", type.getSubtype());
+
+        // another wildcard test
+        headers = new MetadataMap<String, String>();
+        context = new RESTContext();
+        props = new HashMap<String, Object>();
+        request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        context.setProperty(ContextConstants.HTTP_ACCEPT_HEADER,
+                "text/*;q=.7, text/html;q=.9, text/plain;q=1, */*;q=.1");
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        httpHeaders = new HttpHeadersImpl(context);
+        mediaTypes = httpHeaders.getAcceptableMediaTypes();
+        assertNotNull(mediaTypes);
+        assertEquals(4, mediaTypes.size());
+
+        // make sure the last MediaType is */*
+        type = mediaTypes.get(3);
+        assertEquals("*", type.getType());
+        assertEquals("*", type.getSubtype());
+    }
+
+    public void testGetAcceptableMediaTypesWithAccept() throws Exception {
+        String url = "http://localhost:7070/resources/someresource";
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        RESTContext context = new RESTContext();
+        Map<String, Object> props = new HashMap<String, Object>();
+        props.put(ServletRequest.CONTENT_TYPE, "text/html");
+        ServletRequest request = new ServletRequest(url, null, props);
+        ServletResponse response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(request, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        HttpHeaders httpHeaders = new HttpHeadersImpl(context);
+        List<MediaType> mediaTypes = httpHeaders.getAcceptableMediaTypes();
+        assertNotNull(mediaTypes);
+        assertEquals(1, mediaTypes.size());
+    }
+
+    public void testGetCookies() throws Exception {
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        RESTContext context = new RESTContext();
+        javax.ws.rs.core.Cookie cookie1 = new javax.ws.rs.core.Cookie(
+                "myCookie1", "myCookieValue1");
+        javax.ws.rs.core.Cookie cookie2 = new javax.ws.rs.core.Cookie(
+                "myCookie2", "myCookieValue2");
+        Map<String, javax.ws.rs.core.Cookie> cookies = new HashMap<String, javax.ws.rs.core.Cookie>();
+        cookies.put(cookie1.getName(), cookie1);
+        cookies.put(cookie2.getName(), cookie2);
+        Map<String, Object> props = new HashMap<String, Object>();
+        ServletRequest request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        context.setProperty(ContextConstants.HTTP_COOKIES, cookies);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        HttpHeaders httpHeaders = new HttpHeadersImpl(context);
+        Map<String, javax.ws.rs.core.Cookie> cookieMap = httpHeaders
+                .getCookies();
+        assertNotNull(cookieMap);
+        assertEquals(2, cookieMap.size());
+        javax.ws.rs.core.Cookie rsCookie = cookieMap.get("myCookie1");
+        assertNotNull(rsCookie);
+        assertEquals("myCookieValue1", rsCookie.getValue());
+        rsCookie = cookieMap.get("myCookie2");
+        assertNotNull(rsCookie);
+        assertEquals("myCookieValue2", rsCookie.getValue());
+    }
+
+    public void testGetLanguage() throws Exception {
+        String url = "http://localhost:7070/resources/someresource";
+        RESTContext context = new RESTContext();
+        Map<String, Object> props = new HashMap<String, Object>();
+        ServletRequest request = new ServletRequest(url, null, props);
+        ServletResponse response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(request, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        context.setProperty(ContextConstants.CONTENT_LANGUAGE, "en");
+        HttpHeaders httpHeaders = new HttpHeadersImpl(context);
+        Locale lang = httpHeaders.getLanguage();
+        assertNotNull(lang);
+        assertEquals("en", lang.getLanguage());
+
+        props.put(ServletRequest.LOCALE, null);
+        request = new ServletRequest(url, null, props);
+        response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(request, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        httpHeaders = new HttpHeadersImpl(context);
+        lang = httpHeaders.getLanguage();
+        assertNull(lang);
+    }
+
+    public void testGetMediaType() {
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        RESTContext context = new RESTContext();
+        Map<String, Object> props = new HashMap<String, Object>();
+        ServletRequest request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        context.setProperty(ContextConstants.CONTENT_TYPE, "text/xml");
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        HttpHeaders httpHeaders = new HttpHeadersImpl(context);
+        MediaType mType = httpHeaders.getMediaType();
+        assertNotNull(mType);
+        assertEquals("text", mType.getType());
+        assertEquals("xml", mType.getSubtype());
+
+        context.setProperty(ContextConstants.CONTENT_TYPE, "audio/basic");
+        httpHeaders = new HttpHeadersImpl(context);
+        mType = httpHeaders.getMediaType();
+        assertNotNull(mType);
+        assertEquals("audio", mType.getType());
+        assertEquals("basic", mType.getSubtype());
+    }
+
+    public void testGetRequestHeader() {
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        RESTContext context = new RESTContext();
+        Map<String, Object> props = new HashMap<String, Object>();
+        ServletRequest request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        headers.putSingle("SomeCustomHeader".toLowerCase(), "SomeCustomValue");
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        HttpHeaders httpHeaders = new HttpHeadersImpl(context);
+        List<String> values = httpHeaders.getRequestHeader("SomeCustomHeader");
+        assertNotNull(values);
+        assertEquals(1, values.size());
+        assertEquals("SomeCustomValue", values.get(0));
+    }
+
+    public void testGetRequestHeaders() {
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        RESTContext context = new RESTContext();
+        headers.add("SomeCustomHeader1", "SomeCustomValue1");
+        headers.add("SomeCustomHeader1", "SomeCustomValue1a");
+        headers.add("SomeCustomHeader1", "SomeCustomValue1b");
+        headers.add("SomeCustomHeader2", "SomeCustomValue2");
+        headers.add("SomeCustomHeader2", "SomeCustomValue2a");
+        headers.add("SomeCustomHeader3", "SomeCustomValue3");
+        headers.add("SomeCustomHeader3", "SomeCustomValue3a");
+        headers.add("SomeCustomHeader3", "SomeCustomValue3b");
+        headers.add("SomeCustomHeader3", "SomeCustomValue3c");
+        Map<String, Object> props = new HashMap<String, Object>();
+        ServletRequest request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        HttpHeaders httpHeaders = new HttpHeadersImpl(context);
+        MultivaluedMap<String, String> reqHeaders = httpHeaders
+                .getRequestHeaders();
+
+        // now let's verify the headers are returned as we expect
+        List<String> values = reqHeaders.get("SomeCustomHeader1");
+        assertNotNull(values);
+        assertEquals(3, values.size());
+
+        values = reqHeaders.get("SomeCustomHeader2");
+        assertNotNull(values);
+        assertEquals(2, values.size());
+
+        values = reqHeaders.get("SomeCustomHeader3");
+        assertNotNull(values);
+        assertEquals(4, values.size());
+    }
+
+    public void testIllegalState() {
+        HttpHeaders httpHeaders = new HttpHeadersImpl(null);
+        IllegalStateException e = null;
+        try {
+            httpHeaders.getAcceptableLanguages();
+        } catch (IllegalStateException ise) {
+            e = ise;
+        }
+        assertNotNull(e);
+    }
+
+    Enumeration getLocaleEnumeration(String... localeStrings) {
+        List<Locale> locales = new LinkedList<Locale>();
+        for (String localeString : localeStrings) {
+            locales.add(new Locale(localeString));
+        }
+        return new LocaleEnumeration(locales.iterator());
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/RequestTests.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/RequestTests.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/RequestTests.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/RequestTests.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,460 @@
+/*
+ * 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 com.ibm.ws.jaxrs.core;
+
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.ws.rs.core.EntityTag;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Variant;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Variant.VariantListBuilder;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.jaxrs.impl.MetadataMap;
+
+import com.ibm.ws.jaxrs.context.ContextConstants;
+import com.ibm.ws.jaxrs.context.RESTContext;
+import com.ibm.ws.jaxrs.web.ServletTestFramework;
+import com.ibm.ws.jaxrs.web.mock.ServletRequest;
+import com.ibm.ws.jaxrs.web.mock.ServletResponse;
+import com.ibm.wsspi.jaxrs.http.DateHandler;
+
+/**
+ * Verify the functionality of our Request implemnetation
+ *
+ */
+public class RequestTests extends TestCase {
+
+    public void testLastModifiedPreconditionDate() throws Exception {
+        RESTContext context = new RESTContext();
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        Map<String, Object> properties = new HashMap<String, Object>();
+
+        // test when everything is okay that we get null
+        Calendar calendar = Calendar.getInstance();
+        Date compareDate = DateHandler.getCurrentDate("America/Austin");
+        headers.putSingle("If-Modified-Since".toLowerCase(), DateHandler
+                .formatDateInRFC1123Format(compareDate));
+        ServletRequest servletRequest = new ServletRequest(properties);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        Request request = new RequestImpl(context);
+        ResponseBuilder rb = request.evaluatePreconditions(compareDate);
+        assertNull("Date is : " + compareDate + " ; " + " Header is: "
+                + headers.getFirst("If-Modified-Since".toLowerCase()), rb);
+
+        // test the 304 for checking before expiration
+        calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 1);
+        compareDate = calendar.getTime();
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        request = new RequestImpl(context);
+        rb = request.evaluatePreconditions(compareDate);
+        assertNotNull(rb);
+        Response response = rb.build();
+        assertNotNull(response);
+        assertEquals(304, response.getStatus());
+
+        // now null when checking past expiration
+        calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + 1);
+        compareDate = calendar.getTime();
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        request = new RequestImpl(context);
+        rb = request.evaluatePreconditions(compareDate);
+        assertNull("Date is : " + compareDate + " ; " + " Header is: "
+                + headers.getFirst("If-Modified-Since".toLowerCase()), rb);
+    }
+
+    public void testLastModifiedPreconditionETag() throws Exception {
+        RESTContext context = new RESTContext();
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        Map<String, Object> properties = new HashMap<String, Object>();
+        headers.putSingle("If-Match".toLowerCase(), "\"testerId\"");
+
+        ServletRequest servletRequest = new ServletRequest(properties);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        Request request = new RequestImpl(context);
+        EntityTag tag = new EntityTag("testerId");
+        ResponseBuilder rb = request.evaluatePreconditions(tag);
+        assertNull(rb);
+
+        // now force an error status to be returned
+        servletRequest = new ServletRequest(properties);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        request = new RequestImpl(context);
+        tag = new EntityTag("userId");
+        rb = request.evaluatePreconditions(tag);
+        assertNotNull(rb);
+        Response response = rb.build();
+        assertNotNull(response);
+        assertEquals(412, response.getStatus());
+        MultivaluedMap<String, Object> metadata = response.getMetadata();
+        assertNotNull(metadata);
+        assertNotNull(metadata.getFirst("ETag"));
+        assertEquals(metadata.getFirst("ETag"), "\"userId\"");
+    }
+
+    public void testLastModifiedPreconditionETagAndDate() throws Exception {
+        RESTContext context = new RESTContext();
+        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
+        Map<String, Object> properties = new HashMap<String, Object>();
+        headers.putSingle("If-Match".toLowerCase(), "\"testerId\"");
+
+        // test when everything is okay that we get null
+        Calendar calendar = Calendar.getInstance();
+        Date compareDate = calendar.getTime();
+        headers.putSingle("If-Modified-Since".toLowerCase(), DateHandler
+                .formatDateInRFC1123Format(compareDate));
+        EntityTag compareTag = new EntityTag("testerId");
+        ServletRequest servletRequest = new ServletRequest(properties);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        Request request = new RequestImpl(context);
+        ResponseBuilder rb = request.evaluatePreconditions(compareDate,
+                compareTag);
+        assertNull(rb);
+
+        // now let's mess up the date
+        calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 1);
+        compareDate = calendar.getTime();
+        compareTag = new EntityTag("testerId");
+        servletRequest = new ServletRequest(properties);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        request = new RequestImpl(context);
+        rb = request.evaluatePreconditions(compareDate, compareTag);
+        assertNotNull(rb);
+        Response response = rb.build();
+        assertNotNull(response);
+        assertEquals(304, response.getStatus());
+
+        // now let's mess up the EntityTag
+        compareDate = calendar.getTime();
+        headers.putSingle("If-Modified-Since".toLowerCase(), DateHandler
+                .formatDateInRFC1123Format(compareDate));
+        compareTag = new EntityTag("userId");
+        servletRequest = new ServletRequest(properties);
+        context.setProperty(ContextConstants.HTTP_HEADER_VALUES, headers);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        request = new RequestImpl(context);
+        rb = request.evaluatePreconditions(compareDate, compareTag);
+        assertNotNull(rb);
+        response = rb.build();
+        assertNotNull(response);
+        assertEquals(412, response.getStatus());
+        MultivaluedMap<String, Object> metadata = response.getMetadata();
+        assertNotNull(metadata);
+        assertNotNull(metadata.getFirst("ETag"));
+        assertEquals(metadata.getFirst("ETag"), "\"userId\"");
+    }
+
+    public void testGetMethod() throws Exception {
+        RESTContext context = new RESTContext();
+        String url = "http://localhost:7070/resource/someresource";
+        Map<String, List<String>> headers = new HashMap<String, List<String>>();
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(ServletRequest.METHOD, "PUT");
+        properties.put(ServletRequest.HTTP_HEADERS, headers);
+        ServletRequest servletRequest = new ServletRequest(url, null,
+                properties);
+        ServletResponse response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(servletRequest, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        Request request = new RequestImpl(context);
+
+        // hack until we get updated APIs
+        assertEquals("PUT", ((RequestImpl) request).getMethod());
+
+        servletRequest = new ServletRequest(properties);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        context.setProperty(ContextConstants.HTTP_METHOD, "GET");
+        request = new RequestImpl(context);
+
+        // hack until we get updated APIs
+        assertEquals("GET", ((RequestImpl) request).getMethod());
+
+        servletRequest = new ServletRequest(properties);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        context.setProperty(ContextConstants.HTTP_METHOD, "POST");
+        request = new RequestImpl(context);
+
+        // hack until we get updated APIs
+        assertEquals("POST", ((RequestImpl) request).getMethod());
+
+        servletRequest = new ServletRequest(properties);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        context.setProperty(ContextConstants.HTTP_METHOD, "DELETE");
+        request = new RequestImpl(context);
+
+        // hack until we get updated APIs
+        assertEquals("DELETE", ((RequestImpl) request).getMethod());
+
+        servletRequest = new ServletRequest(properties);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        context.setProperty(ContextConstants.HTTP_METHOD, "HEAD");
+        request = new RequestImpl(context);
+
+        // hack until we get updated APIs
+        assertEquals("HEAD", ((RequestImpl) request).getMethod());
+    }
+
+    /**
+     * Verify we can match a Variant to the request in a simple case
+     */
+    public void testSelectVariantSingle() throws Exception {
+        String url = "http://localhost:7070/resource/someresource";
+        RESTContext context = new RESTContext();
+        MultivaluedMap<String, String> mValuedHeaders = new MetadataMap<String, String>();
+        mValuedHeaders.putSingle("Accept".toLowerCase(), "text/xml");
+        mValuedHeaders.putSingle("Accept-Language".toLowerCase(), "en");
+        mValuedHeaders.putSingle("Accept-Charset".toLowerCase(), "chunked");
+        Map<String, Object> properties = new HashMap<String, Object>();
+        ServletRequest servletRequest = new ServletRequest(url, null,
+                properties);
+        ServletResponse response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(servletRequest, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        context
+                .setProperty(ContextConstants.HTTP_HEADER_VALUES,
+                        mValuedHeaders);
+        List<MediaType> acceptedContentTypes = new ArrayList<MediaType>();
+        acceptedContentTypes.add(new MediaType("text", "xml"));
+        context.setProperty(ContextConstants.ACCEPT_CONTENT_TYPES,
+                acceptedContentTypes);
+
+        // first let's build a simple list with one variant that matches
+        // the current request
+        VariantListBuilder vBuilder = Variant.VariantListBuilder.newInstance();
+        vBuilder.mediaTypes(new MediaType[] { new MediaType("text", "xml") });
+        vBuilder.languages(new Locale[] { new Locale("en") });
+        List<Variant> variants = vBuilder.add().build();
+        Request request = new RequestImpl(context);
+        Variant variant = request.selectVariant(variants);
+        assertNotNull(variant);
+        Locale locale = variant.getLanguage();
+        assertNotNull(locale);
+        assertEquals("en", locale.getLanguage());
+        assertEquals("text/xml", variant.getMediaType().toString());
+        String varyHeader = (String) context
+                .getProperty(ContextConstants.VARY_HEADER);
+        assertNotNull(varyHeader);
+        assertTrue(varyHeader.contains("Accept"));
+    }
+
+    /**
+     * Verify we can match a Variant to the request
+     */
+    public void testSelectVariantMulti() throws Exception {
+        String url = "http://localhost:7070/resource/someresource";
+        RESTContext context = new RESTContext();
+        MultivaluedMap<String, String> mValuedHeaders = new MetadataMap<String, String>();
+        Map<String, Object> properties = new HashMap<String, Object>();
+        Map<String, List<String>> headers = new HashMap<String, List<String>>();
+        List<String> acceptValues = new ArrayList<String>();
+        acceptValues.add("text/xml");
+        headers.put("Accept", acceptValues);
+        List<String> acceptEncodingValues = new ArrayList<String>();
+        acceptEncodingValues.add("custom");
+        headers.put("Accept-Encoding", acceptEncodingValues);
+        List<String> acceptLanguageValues = new ArrayList<String>();
+        acceptLanguageValues.add("en-gb");
+        headers.put("Accept-Language", acceptLanguageValues);
+        properties.put(ServletRequest.HTTP_HEADERS, headers);
+        properties.put(ServletRequest.LOCALE, new Locale("en-gb"));
+        ServletRequest servletRequest = new ServletRequest(url, null,
+                properties);
+        ServletResponse response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(servletRequest, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        List<MediaType> acceptedContentTypes = new ArrayList<MediaType>();
+        acceptedContentTypes.add(new MediaType("text", "xml"));
+        context.setProperty(ContextConstants.ACCEPT_CONTENT_TYPES,
+                acceptedContentTypes);
+
+        // try a MediaType with no wildcards
+        VariantListBuilder vBuilder = Variant.VariantListBuilder.newInstance();
+        vBuilder.mediaTypes(new MediaType[] { new MediaType("text", "xml"),
+                new MediaType("text", "*"), new MediaType("*", "xml") });
+        vBuilder.languages(new Locale[] { new Locale("en"), new Locale("da"),
+                new Locale("en-gb") });
+        vBuilder.encodings(new String[] { "UTF-8", "custom" });
+        List<Variant> variants = vBuilder.add().build();
+        Request request = new RequestImpl(context);
+        Variant variant = request.selectVariant(variants);
+        assertNotNull(variant);
+        assertEquals("text/xml", variant.getMediaType().toString());
+        assertEquals("custom", variant.getEncoding());
+        Locale locale = variant.getLanguage();
+        assertNotNull(locale);
+        assertEquals("en-gb", locale.getLanguage());
+        String varyHeader = (String) context
+                .getProperty(ContextConstants.VARY_HEADER);
+        assertNotNull(varyHeader);
+        assertTrue(varyHeader, varyHeader.contains("Accept"));
+        assertTrue(varyHeader, varyHeader.contains("Accept-Encoding"));
+        assertTrue(varyHeader, varyHeader.contains("Accept-Language"));
+
+        // try a MediaType with wildcards
+        context
+                .setProperty(ContextConstants.HTTP_HEADER_VALUES,
+                        mValuedHeaders);
+        headers = new HashMap<String, List<String>>();
+        acceptValues = new ArrayList<String>();
+        acceptValues.add("something/xml");
+        headers.put("Accept", acceptValues);
+        acceptEncodingValues = new ArrayList<String>();
+        acceptEncodingValues.add("UTF-8");
+        headers.put("Accept-Encoding", acceptEncodingValues);
+        acceptLanguageValues = new ArrayList<String>();
+        acceptLanguageValues.add("en");
+        headers.put("Accept-Language", acceptLanguageValues);
+        properties.put(ServletRequest.HTTP_HEADERS, headers);
+        servletRequest = new ServletRequest(url, null, properties);
+        response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(servletRequest, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        acceptedContentTypes = new ArrayList<MediaType>();
+        acceptedContentTypes.add(new MediaType("something", "xml"));
+        context.setProperty(ContextConstants.ACCEPT_CONTENT_TYPES,
+                acceptedContentTypes);
+        vBuilder = Variant.VariantListBuilder.newInstance();
+        vBuilder.mediaTypes(new MediaType[] { new MediaType("text", "xml"),
+                new MediaType("text", "*"), new MediaType("*", "xml") });
+        vBuilder.languages(new Locale[] { new Locale("en"), new Locale("da"),
+                new Locale("en-gb") });
+        vBuilder.encodings(new String[] { "UTF-8", "custom" });
+        variants = vBuilder.add().build();
+        request = new RequestImpl(context);
+        variant = request.selectVariant(variants);
+        assertNotNull(variant);
+        assertTrue(new MediaType("*", "xml").isCompatible(variant
+                .getMediaType()));
+        assertEquals("UTF-8", variant.getEncoding());
+        locale = variant.getLanguage();
+        assertNotNull(locale);
+        assertEquals("en", locale.getLanguage());
+        varyHeader = (String) context.getProperty(ContextConstants.VARY_HEADER);
+        assertNotNull(varyHeader);
+        assertTrue(varyHeader.contains("Accept"));
+        assertTrue(varyHeader.contains("Accept-Encoding"));
+        assertTrue(varyHeader.contains("Accept-Language"));
+
+        // try another MediaType with wildcards
+        headers = new HashMap<String, List<String>>();
+        acceptValues = new ArrayList<String>();
+        acceptValues.add("text/*");
+        headers.put("Accept", acceptValues);
+        acceptEncodingValues = new ArrayList<String>();
+        acceptEncodingValues.add("UTF-8");
+        headers.put("Accept-Encoding", acceptEncodingValues);
+        acceptLanguageValues = new ArrayList<String>();
+        acceptLanguageValues.add("en");
+        headers.put("Accept-Language", acceptLanguageValues);
+        properties.put(ServletRequest.HTTP_HEADERS, headers);
+        servletRequest = new ServletRequest(url, null, properties);
+        response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(servletRequest, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        acceptedContentTypes = new ArrayList<MediaType>();
+        acceptedContentTypes.add(new MediaType("text", "*"));
+        context.setProperty(ContextConstants.ACCEPT_CONTENT_TYPES,
+                acceptedContentTypes);
+        vBuilder = Variant.VariantListBuilder.newInstance();
+        vBuilder.mediaTypes(new MediaType[] { new MediaType("text", "xml"),
+                new MediaType("text", "*"), new MediaType("*", "xml") });
+        vBuilder.languages(new Locale[] { new Locale("en"), new Locale("da"),
+                new Locale("en-gb") });
+        vBuilder.encodings(new String[] { "UTF-8", "custom" });
+        variants = vBuilder.add().build();
+        request = new RequestImpl(context);
+        variant = request.selectVariant(variants);
+        assertNotNull(variant);
+        assertTrue(new MediaType("text", "*").isCompatible(variant
+                .getMediaType()));
+        assertEquals("UTF-8", variant.getEncoding());
+        locale = variant.getLanguage();
+        assertNotNull(locale);
+        assertEquals("en", locale.getLanguage());
+        varyHeader = (String) context.getProperty(ContextConstants.VARY_HEADER);
+        assertNotNull(varyHeader);
+        assertTrue(varyHeader.contains("Accept"));
+        assertTrue(varyHeader.contains("Accept-Encoding"));
+        assertTrue(varyHeader.contains("Accept-Language"));
+    }
+
+    /**
+     * More select variant tests to confirm we can get a Variant with minimal
+     * matching information in the request.
+     */
+    public void testSelectVariantMinimal() throws Exception {
+        String url = "http://localhost:7070/resource/someresource";
+        RESTContext context = new RESTContext();
+        MultivaluedMap<String, String> mValuedHeaders = new MetadataMap<String, String>();
+        Map<String, Object> properties = new HashMap<String, Object>();
+        Map<String, List<String>> headers = new HashMap<String, List<String>>();
+        List<String> acceptValues = new ArrayList<String>();
+        acceptValues.add("text/xml");
+        headers.put("Accept", acceptValues);
+        List<String> acceptLanguageValues = new ArrayList<String>();
+        acceptLanguageValues.add("en-gb");
+        headers.put("Accept-Language", acceptLanguageValues);
+        properties.put(ServletRequest.HTTP_HEADERS, headers);
+        ServletRequest servletRequest = new ServletRequest(url, null,
+                properties);
+        ServletResponse response = new ServletResponse(new StringWriter());
+        ServletTestFramework.initContext(servletRequest, response, context);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, servletRequest);
+        List<MediaType> acceptedContentTypes = new ArrayList<MediaType>();
+        acceptedContentTypes.add(new MediaType("text", "xml"));
+        context.setProperty(ContextConstants.ACCEPT_CONTENT_TYPES,
+                acceptedContentTypes);
+
+        // first let's build a simple list with one variant that matches
+        // the current request
+        VariantListBuilder vBuilder = Variant.VariantListBuilder.newInstance();
+        vBuilder.mediaTypes(new MediaType[] { new MediaType("text", "xml") });
+        vBuilder.languages(new Locale[] { new Locale("en") });
+        List<Variant> variants = vBuilder.add().build();
+        Request request = new RequestImpl(context);
+        Variant variant = request.selectVariant(variants);
+        assertNotNull(variant);
+        assertEquals("text/xml", variant.getMediaType().toString());
+        String varyHeader = (String) context
+                .getProperty(ContextConstants.VARY_HEADER);
+        assertNotNull(varyHeader);
+        assertTrue(varyHeader.contains("Accept"));
+        assertFalse(varyHeader.contains("Accept-Language"));
+        assertFalse(varyHeader.contains("Accept-Charset"));
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/SecurityContextTests.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/SecurityContextTests.java?rev=787553&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/SecurityContextTests.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/tests/unittests/com/ibm/ws/jaxrs/core/SecurityContextTests.java Tue Jun 23 05:37:57 2009
@@ -0,0 +1,121 @@
+/*
+ * 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 com.ibm.ws.jaxrs.core;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.SecurityContext;
+
+import junit.framework.TestCase;
+
+import com.ibm.ws.jaxrs.context.ContextConstants;
+import com.ibm.ws.jaxrs.context.RESTContext;
+import com.ibm.ws.jaxrs.web.mock.Principal;
+import com.ibm.ws.jaxrs.web.mock.ServletRequest;
+
+/**
+ * Verify functionality of the SecurityContext implementation.
+ *
+ */
+public class SecurityContextTests extends TestCase {
+
+    public void testGetAuthenticationScheme() {
+        RESTContext context = new RESTContext();
+        context.setProperty(ContextConstants.AUTHENTICATION_SCHEME,
+                HttpServletRequest.BASIC_AUTH);
+        Map<String, Object> props = new HashMap<String, Object>();
+        ServletRequest request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        SecurityContext secContext = new SecurityContextImpl(context);
+        assertNotNull(secContext.getAuthenticationScheme());
+        assertEquals(HttpServletRequest.BASIC_AUTH, secContext
+                .getAuthenticationScheme());
+
+        context.setProperty(ContextConstants.AUTHENTICATION_SCHEME,
+                HttpServletRequest.CLIENT_CERT_AUTH);
+        request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        secContext = new SecurityContextImpl(context);
+        assertNotNull(secContext.getAuthenticationScheme());
+        assertEquals(HttpServletRequest.CLIENT_CERT_AUTH, secContext
+                .getAuthenticationScheme());
+    }
+
+    public void testGetUserPrincipal() {
+        RESTContext context = new RESTContext();
+        Map<String, Object> props = new HashMap<String, Object>();
+        Principal principal = new Principal("user1");
+        context.setProperty(ContextConstants.USER_PRINCIPAL, principal);
+        ServletRequest request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        SecurityContext secContext = new SecurityContextImpl(context);
+        java.security.Principal pncpal = secContext.getUserPrincipal();
+        assertNotNull(pncpal);
+        assertEquals("user1", pncpal.getName());
+    }
+
+    public void testIsUserInRole() {
+        RESTContext context = new RESTContext();
+        Map<String, Object> props = new HashMap<String, Object>();
+        List<String> roles = new LinkedList<String>();
+        roles.add("guest");
+        props.put(ServletRequest.ROLES_FOR_USER, roles);
+        ServletRequest request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        SecurityContext secContext = new SecurityContextImpl(context);
+        assertTrue(secContext.isUserInRole("guest"));
+        assertFalse(secContext.isUserInRole("administrator"));
+    }
+
+    public void testIsSecure() {
+        RESTContext context = new RESTContext();
+        Map<String, Object> props = new HashMap<String, Object>();
+        context.setProperty(ContextConstants.REQUEST_SECURE, false);
+        ServletRequest request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        SecurityContext secContext = new SecurityContextImpl(context);
+        assertFalse(secContext.isSecure());
+
+        context.setProperty(ContextConstants.REQUEST_SECURE, true);
+        ;
+        request = new ServletRequest(props);
+        context.setProperty(ContextConstants.SERVLET_REQUEST, request);
+        secContext = new SecurityContextImpl(context);
+        assertTrue(secContext.isSecure());
+    }
+
+    public void testIllegalContext() {
+
+        // first test the construction with a null reference
+        IllegalStateException e = null;
+        SecurityContext secContext = new SecurityContextImpl(null);
+        try {
+            secContext.getAuthenticationScheme();
+        } catch (IllegalStateException ise) {
+            e = ise;
+        }
+        assertNotNull(e);
+    }
+
+}



Mime
View raw message