1   /**
2    * Copyright (C) 2005-2009 Alfresco Software Limited.
3    *
4    * This file is part of the Spring Surf Extension project.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *  http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.springframework.extensions.surf.integration;
20  
21  import java.util.Iterator;
22  
23  import org.json.JSONObject;
24  import org.junit.Ignore;
25  import org.junit.Test;
26  
27  
28  /**
29   * Tests the Surf Web Script API
30   * 
31   * @author muzquiano
32   */
33  @Ignore public class RemoteAPITest extends AbstractSeleniumTestCase
34  {
35  	/**
36  	 * Lookup prepackaged obejcts
37  	 */
38  	@Ignore @Test public void test1() throws Exception
39  	{
40  		selenium.open("/api/surf/objects/page");
41  		JSONObject pages = new JSONObject(selenium.getBodyText());
42  		assert("OK".equalsIgnoreCase(pages.getString("code")));
43  		
44  		JSONObject results = pages.getJSONObject("results");
45  		Iterator keys = results.keys();
46  		while (keys.hasNext())
47  		{
48  			String pageId = (String) keys.next();
49  			
50  			JSONObject page = (JSONObject) results.getJSONObject(pageId);
51  			assert(page != null);
52  			
53  			assertValidPage(page);
54  		}
55  	}
56  	
57  	@Ignore @Test public void assertValidPage(JSONObject page) throws Exception
58  	{			
59  		String id = page.getString("id");
60  		assert(id != null);
61  		
62  		String title = page.getString("title");
63  		assert(title != null);
64  		
65  		String templateInstance = page.getString("template-instance");
66  		assert(templateInstance != null);
67  		
68  		String description = page.getString("description");
69  		assert(description != null);
70  		
71  		String authentication = page.getString("authentication");
72  		assert(authentication != null);
73  		
74  		String pageTypeId = page.getString("page-type-id");
75  		assert(pageTypeId != null);
76  	}
77  }