Modified: shindig/branches/2.0.x/php/src/social/servlet/ApiServlet.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/src/social/servlet/ApiServlet.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/src/social/servlet/ApiServlet.php (original)
+++ shindig/branches/2.0.x/php/src/social/servlet/ApiServlet.php Tue Aug 24 
14:33:23 2010
@@ -18,30 +18,28 @@
  * under the License.
  */
 
-require 'src/social/service/DataRequestHandler.php';
-require 'src/common/SecurityToken.php';
-require 'src/common/BlobCrypter.php';
-require 'src/social/converters/InputConverter.php';
-require 'src/social/converters/InputJsonConverter.php';
-require 'src/social/converters/OutputConverter.php';
-require 'src/social/converters/OutputJsonConverter.php';
-require 'src/social/service/RequestItem.php';
-require 'src/social/service/RestRequestItem.php';
-require 'src/social/service/RpcRequestItem.php';
-require 'src/social/spi/GroupId.php';
-require 'src/social/spi/UserId.php';
-require 'src/social/spi/CollectionOptions.php';
-require 'src/common/Cache.php';
-require 'src/social/model/ComplexField.php';
-require 'src/social/model/Name.php';
-require 'src/social/model/Enum.php';
-require 'src/social/model/Person.php';
-require 'src/social/model/ListField.php';
-require 'src/social/model/Photo.php';
-require 'src/social/spi/RestfulCollection.php';
-require 'src/social/spi/DataCollection.php';
-require 'src/social/service/ResponseItem.php';
-require 'src/common/ShindigOAuth.php';
+require_once 'src/social/service/DataRequestHandler.php';
+require_once 'src/common/SecurityToken.php';
+require_once 'src/common/BlobCrypter.php';
+require_once 'src/social/converters/InputConverter.php';
+require_once 'src/social/converters/OutputConverter.php';
+require_once 'src/social/service/RequestItem.php';
+require_once 'src/social/service/RestRequestItem.php';
+require_once 'src/social/service/RpcRequestItem.php';
+require_once 'src/social/spi/GroupId.php';
+require_once 'src/social/spi/UserId.php';
+require_once 'src/social/spi/CollectionOptions.php';
+require_once 'src/common/Cache.php';
+require_once 'src/social/model/ComplexField.php';
+require_once 'src/social/model/Name.php';
+require_once 'src/social/model/Enum.php';
+require_once 'src/social/model/Person.php';
+require_once 'src/social/model/ListField.php';
+require_once 'src/social/model/Photo.php';
+require_once 'src/social/spi/RestfulCollection.php';
+require_once 'src/social/spi/DataCollection.php';
+require_once 'src/social/service/ResponseItem.php';
+require_once 'src/common/ShindigOAuth.php';
 
 /**
  * Common base class for API servlets.
@@ -51,17 +49,6 @@ abstract class ApiServlet extends HttpSe
 
   protected static $DEFAULT_ENCODING = "UTF-8";
 
-  public static $PEOPLE_ROUTE = "people";
-  public static $ACTIVITY_ROUTE = "activities";
-  public static $APPDATA_ROUTE = "appdata";
-  public static $GROUP_ROUTE = "groups";
-  public static $MESSAGE_ROUTE = "messages";
-  public static $INVALIDATE_ROUTE = "cache";
-  public static $SYSTEM_ROUTE = "system";
-  public static $ALBUM_ROUTE = "albums";
-  public static $MEDIA_ITEM_ROUTE = "mediaitems";
-  public static $HTTP_ROUTE = "http";
-
   public function __construct() {
     parent::__construct();
     $this->setNoCache(true);
@@ -147,62 +134,22 @@ abstract class ApiServlet extends HttpSe
    */
   protected function handleRequestItem(RequestItem $requestItem) {
     // lazy initialization of the service handlers, no need to instance them 
all for each request
-    if (! isset($this->handlers[$requestItem->getService()])) {
-      switch ($requestItem->getService()) {
-        case self::$PEOPLE_ROUTE:
-          require_once 'src/social/spi/PersonService.php';
-          require_once 'src/social/service/PersonHandler.php';
-          $this->handlers[self::$PEOPLE_ROUTE] = new PersonHandler();
-          break;
-        case self::$ACTIVITY_ROUTE:
-          require_once 'src/social/spi/ActivityService.php';
-          require_once 'src/social/service/ActivityHandler.php';
-          $this->handlers[self::$ACTIVITY_ROUTE] = new ActivityHandler();
-          break;
-        case self::$APPDATA_ROUTE:
-          require_once 'src/social/spi/AppDataService.php';
-          require_once 'src/social/service/AppDataHandler.php';
-          $this->handlers[self::$APPDATA_ROUTE] = new AppDataHandler();
-          break;
-        case self::$GROUP_ROUTE:
-          require_once 'src/social/spi/GroupService.php';
-          require_once 'src/social/service/GroupHandler.php';
-          $this->handlers[self::$GROUP_ROUTE] = new GroupHandler();
-          break;
-        case self::$MESSAGE_ROUTE:
-          require_once 'src/social/spi/MessagesService.php';
-          require_once 'src/social/service/MessagesHandler.php';
-          $this->handlers[self::$MESSAGE_ROUTE] = new MessagesHandler();
-          break;
-        case self::$INVALIDATE_ROUTE:
-          require_once 'src/social/spi/InvalidateService.php';
-          require_once 'src/social/service/InvalidateHandler.php';
-          $this->handlers[self::$INVALIDATE_ROUTE] = new InvalidateHandler();
-          break;
-        case self::$SYSTEM_ROUTE:
-          require_once 'src/social/service/SystemHandler.php';
-          $this->handlers[self::$SYSTEM_ROUTE] = new SystemHandler();
-          break;
-        case self::$ALBUM_ROUTE:
-          require_once 'src/social/spi/AlbumService.php';
-          require_once 'src/social/service/AlbumHandler.php';
-          $this->handlers[self::$ALBUM_ROUTE] = new AlbumHandler();
-          break;
-        case self::$MEDIA_ITEM_ROUTE:
-          require_once 'src/social/spi/MediaItemService.php';
-          require_once 'src/social/service/MediaItemHandler.php';
-          $this->handlers[self::$MEDIA_ITEM_ROUTE] = new MediaItemHandler();
-          break;
-        case self::$HTTP_ROUTE:
-           require_once 'src/social/service/HttpHandler.php';
-           $this->handlers[self::$HTTP_ROUTE] = new HttpHandler();
-           break;
-        default:
-          throw new SocialSpiException("The service " . 
$requestItem->getService() . " is not implemented", 
ResponseError::$NOT_IMPLEMENTED);
-          break;
+ 
+    $service = $requestItem->getService();
+ 
+    if (! isset($this->handlers[$service])) {
+ 
+      $handlerClasses = Config::get('service_handler');
+ 
+      if (isset($handlerClasses[$service])) {
+          $handlerClass = $handlerClasses[$service];
+          $this->handlers[$service] = new $handlerClass();
+      } else {
+          throw new SocialSpiException("The service " . $service . " is not 
implemented", ResponseError::$NOT_IMPLEMENTED);
       }
+ 
     }
-    $handler = $this->handlers[$requestItem->getService()];
+    $handler = $this->handlers[$service];
     return $handler->handleItem($requestItem);
   }
 

Modified: shindig/branches/2.0.x/php/src/social/servlet/DataServiceServlet.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/src/social/servlet/DataServiceServlet.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/src/social/servlet/DataServiceServlet.php 
(original)
+++ shindig/branches/2.0.x/php/src/social/servlet/DataServiceServlet.php Tue 
Aug 24 14:33:23 2010
@@ -48,9 +48,9 @@ class DataServiceServlet extends ApiServ
         $this->sendSecurityError();
         return;
       }
-      $inputConverter = $this->getInputConverterForRequest();
+      $inputConverterMethod = $this->getInputConverterMethodForRequest();
       $outputConverter = $this->getOutputConverterForRequest();
-      $this->handleSingleRequest($token, $inputConverter, $outputConverter);
+      $this->handleSingleRequest($token, $inputConverterMethod, 
$outputConverter);
     } catch (Exception $e) {
       $code = '500 Internal Server Error';
       header("HTTP/1.0 $code", true);
@@ -100,7 +100,7 @@ class DataServiceServlet extends ApiServ
   /**
    * Handler for non-batch requests (REST only has non-batch requests)
    */
-  private function handleSingleRequest(SecurityToken $token, $inputConverter, 
$outputConverter) {
+  private function handleSingleRequest(SecurityToken $token, 
$inputConverterMethod, $outputConverter) {
     //uri example: /social/rest/people/@self   
/gadgets/api/rest/cache/invalidate
     $servletRequest = array(
         'url' => substr($_SERVER["REQUEST_URI"], 
strpos($_SERVER["REQUEST_URI"], '/rest') + 5));
@@ -118,7 +118,7 @@ class DataServiceServlet extends ApiServ
       }
     }
     $servletRequest['params'] = array_merge($_GET, $_POST);
-    $requestItem = RestRequestItem::createWithRequest($servletRequest, $token, 
$inputConverter, $outputConverter);
+    $requestItem = RestRequestItem::createWithRequest($servletRequest, $token, 
$inputConverterMethod, $outputConverter);
     $responseItem = 
$this->getResponseItem($this->handleRequestItem($requestItem));
     if ($responseItem->getError() == null) {
       $response = $responseItem->getResponse();
@@ -173,19 +173,19 @@ class DataServiceServlet extends ApiServ
   }
 
   /**
-   * Returns the input converter to use
+   * Returns the input converter method to use
    *
-   * @return InputConverter
+   * @return string
    */
-  private function getInputConverterForRequest() {
+  private function getInputConverterMethodForRequest() {
     $inputFormat = $this->getInputRequestFormat();
     switch ($inputFormat) {
       case 'xml':
-        return new InputXmlConverter();
+        return 'convertXml';
       case 'atom':
-        return new InputAtomConverter();
+        return 'convertAtom';
       case 'json':
-        return new InputJsonConverter();
+        return 'convertJson';
       default:
         throw new Exception("Unknown format param: $inputFormat");
     }

Modified: shindig/branches/2.0.x/php/test/ShindigAllTests.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/ShindigAllTests.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/ShindigAllTests.php (original)
+++ shindig/branches/2.0.x/php/test/ShindigAllTests.php Tue Aug 24 14:33:23 2010
@@ -21,15 +21,15 @@
 /*
  * This file is meant to be run through a php command line or cruiscontrol 
build, and not called directly
  * through the web browser. To run these tests from the command line:
- * # cd /path/to/shindig
- * # phpunit ShindigAllTests php/test/ShindigAllTests.php   
+ * # cd /path/to/shindig/php
+ * # php/external/phpunit.php ShindigAllTests php/test/ShindigAllTests.php
  */
 
 function __autoload($className) {
-  $basePath = realpath('./php');
+  $basePath = realpath('./');
   $locations = array('src/common', 'src/common/sample', 'src/gadgets', 
'src/gadgets/http', 'src/gadgets/oauth', 
-      'src/gadgets/sample', 'src/social', 'src/social/http', 
'src/social/service', 
-      'src/social/converters', 'src/social/opensocial', 'src/social/spi', 
'src/social/model', 
+      'src/gadgets/sample', 'src/gadgets/render', 'src/gadgets/rewrite', 
'src/gadgets/templates', 'src/social', 'src/social/http', 'src/social/service',
+      'src/social/converters', 'src/social/opensocial', 'src/social/spi', 
'src/social/model', 'src/social/servlet',
       'src/social/sample', 'src/social/oauth');
   $extension_class_paths = Config::get('extension_class_paths');
   if (! empty($extension_class_paths)) {
@@ -45,11 +45,11 @@ function __autoload($className) {
   }
 }
 
-set_include_path(get_include_path() . PATH_SEPARATOR . realpath('./php') . 
PATH_SEPARATOR . realpath('./php/external'));
+set_include_path(get_include_path() . PATH_SEPARATOR . realpath('.') . 
PATH_SEPARATOR . realpath('./external'));
 error_reporting(E_ALL | E_STRICT);
 require_once 'src/common/Config.php';
+Config::loadConfig('test');
 require_once 'test/TestContext.php';
-
 if (defined('PHPUnit_MAIN_METHOD') === false) {
   define('PHPUnit_MAIN_METHOD', 'ShindigAllTests::main');
 }
@@ -63,7 +63,7 @@ class ShindigAllTests {
   public static function suite() {
     $suite = new PHPUnit_Framework_TestSuite();
     $suite->setName('Shindig');
-    $path = realpath('./php/test/');
+    $path = realpath('./test/');
     $testTypes = array('common', 'gadgets', 'social');
     foreach ($testTypes as $type) {
       foreach (glob("$path/{$type}/*Test.php") as $file) {

Modified: shindig/branches/2.0.x/php/test/common/BasicRemoteContentTest.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/common/BasicRemoteContentTest.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/common/BasicRemoteContentTest.php (original)
+++ shindig/branches/2.0.x/php/test/common/BasicRemoteContentTest.php Tue Aug 
24 14:33:23 2010
@@ -42,6 +42,7 @@ class MockSigningFetcherFactory {
    * @here will create a private key.
    */
   public function __construct() {
+    $_SERVER["HTTP_HOST"] = 'localhost';
     $privkey = openssl_pkey_new();
     $phrase = Config::get('private_key_phrase') != '' ? 
(Config::get('private_key_phrase')) : null;
     openssl_pkey_export($privkey, $rsa_private_key, $phrase);

Modified: shindig/branches/2.0.x/php/test/common/HttpServletTest.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/common/HttpServletTest.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/common/HttpServletTest.php (original)
+++ shindig/branches/2.0.x/php/test/common/HttpServletTest.php Tue Aug 24 
14:33:23 2010
@@ -46,6 +46,7 @@ class HttpServletTest extends PHPUnit_Fr
     $this->HttpServlet->setNoCache($this->noCache);
     $this->HttpServlet->setContentType($this->contentType);
     $this->HttpServlet->setCacheTime($this->cacheTime);
+    $this->HttpServlet->noHeaders = true;
   }
 
   /**
@@ -117,4 +118,4 @@ class HttpServletTest extends PHPUnit_Fr
     $this->assertNotEquals($this->noCache, $this->HttpServlet->getNoCache());
   }
 
-}
\ No newline at end of file
+}

Modified: shindig/branches/2.0.x/php/test/gadgets/ContainerConfigTest.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/gadgets/ContainerConfigTest.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/gadgets/ContainerConfigTest.php (original)
+++ shindig/branches/2.0.x/php/test/gadgets/ContainerConfigTest.php Tue Aug 24 
14:33:23 2010
@@ -69,7 +69,8 @@ class ContainerConfigTest extends PHPUni
 "gadgets.oauthGadgetCallbackTemplate" : "//%host%/gadgets/oauthcallback"
 }
 EOD;
-    $uncommented = ContainerConfig::removeComments($jsFile);
+    $containerConfig = new ContainerConfig(Config::get('container_path'));
+    $uncommented = $containerConfig->removeComments($jsFile);
     $jsonObj = json_decode($uncommented, true);
     $this->assertNotEquals($uncommented, $jsonObj);
     $this->assertEquals(array("default"), $jsonObj["gadgets.container"]);

Modified: shindig/branches/2.0.x/php/test/gadgets/GadgetHtmlRendererTest.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/gadgets/GadgetHtmlRendererTest.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/gadgets/GadgetHtmlRendererTest.php 
(original)
+++ shindig/branches/2.0.x/php/test/gadgets/GadgetHtmlRendererTest.php Tue Aug 
24 14:33:23 2010
@@ -29,6 +29,8 @@ class MockHtmlGadgetFactory extends Gadg
   <ModulePrefs title="title">
     <Require feature="opensocial-0.8" />
     <Require feature="dynamic-height" />
+    <Require feature="flash" />
+    <Require feature="minimessage" />
   </ModulePrefs>
   <Content type="html" view="home">
   <![CDATA[
@@ -86,7 +88,7 @@ class GadgetHtmlRendererTest extends PHP
     $this->gadget = $gadgetSpecFactory->createGadget();
 
     // init gadgetRenderer;
-    $this->GadgetHtmlRenderer = new GadgetHtmlRenderer($this->gadgetContext);
+    $this->gadgetHtmlRenderer = new GadgetHtmlRenderer($this->gadgetContext);
 
     // init $this->doc
     $this->domDocument = new DOMDocument(null, 'utf-8');
@@ -105,7 +107,7 @@ class GadgetHtmlRendererTest extends PHP
   protected function tearDown() {
     $this->gadget = null;
     $this->gadgetContext = null;
-    $this->GadgetHtmlRenderer = null;
+    $this->gadgetHtmlRenderer = null;
     $this->view = null;
     $this->domDocument = null;
     $this->domElement = null;
@@ -113,12 +115,64 @@ class GadgetHtmlRendererTest extends PHP
     parent::tearDown();
   }
 
+  public function testGetJavaScriptsExternal() {
+    $oldForcedJsLibs = Config::get('forcedJsLibs');
+    $oldForcedAppendJsLibs = Config::get('forcedAppendedJsLibs');
+    Config::set('forcedJsLibs', 'dynamic-height:views');
+    Config::set('forcedAppendedJsLibs', array('flash'));
+    $this->gadgetHtmlRenderer->dataContext = array(
+        'Msg' => array(
+            'message1' => 'one',
+            'message2' => 'two',
+         ),
+        'UserPrefs' => array(
+            'key1' => 'value1',
+            'key2' => 'value2',
+         ),
+    );
+    $this->gadgetHtmlRenderer->gadget = $this->gadget;
+    $javaScripts = $this->gadgetHtmlRenderer->getJavaScripts();
+    Config::set('forcedJsLibs', $oldForcedJsLibs);
+    Config::set('forcedAppendedJsLibs', $oldForcedAppendJsLibs);
+    $hasExtern = false;
+    $hasInline = false;
+    foreach ($javaScripts as $script) {
+        switch ($script['type']) {
+            case 'extern':
+                if ($hasExtern) {
+                    $this->fail('two entries with script type extern');
+                }
+                $hasExtern = true;
+                $this->assertEquals(0, strpos($script['content'], 
'/gadgets/js/dynamic-height:views.js?'));
+                break;
+            case 'inline':
+                if ($hasInline) {
+                    $this->fail('two entries with script type inline');
+                }
+                //this is from dynamic height and should not be included
+                $this->assertFalse(strpos($script['content'], 
'gadgets.window=gadgets.window||{};'));
+                //minimessage should be included
+                $miniMessagePos = strpos($script['content'], 
'gadgets.MiniMessage=function');
+                $this->assertTrue($miniMessagePos > 0);
+                //we force flash to be appended, so it should be after 
minimessage
+                $this->assertTrue(strpos($script['content'], 
'gadgets.flash=gadgets.flash||{};') > $miniMessagePos);
+                $hasInline = true;
+                break;
+            default:
+                $this->fail('invalid script type ' . $script['type']);
+        }
+    }
+    $this->assertTrue($hasExtern);
+    $this->assertTrue($hasInline);
+  }
+
   /**
    * Tests GadgetHtmlRenderer->renderGadget()
    */
   public function testRenderGadget() {
+    Config::set('P3P', ''); // prevents "modify header information" errors
     ob_start();
-    $this->GadgetHtmlRenderer->renderGadget($this->gadget, $this->view);
+    $this->gadgetHtmlRenderer->renderGadget($this->gadget, $this->view);
     ob_end_clean();
   }
 
@@ -126,7 +180,7 @@ class GadgetHtmlRendererTest extends PHP
    * Tests GadgetHtmlRenderer->addBodyTags()
    */
   public function testAddBodyTags() {
-    $this->GadgetHtmlRenderer->addBodyTags($this->domElement, 
$this->domDocument);
+    $this->gadgetHtmlRenderer->addBodyTags($this->domElement, 
$this->domDocument);
     $tmpNodeList = $this->domElement->getElementsByTagName("script");
     foreach($tmpNodeList as $tmpNode) {
       $this->assertEquals('gadgets.util.runOnLoadHandlers();', 
$tmpNode->nodeValue);
@@ -138,13 +192,13 @@ class GadgetHtmlRendererTest extends PHP
    */
   public function testAddHeadTags() {
     ob_start();
-    $this->GadgetHtmlRenderer->renderGadget($this->gadget, $this->view);
+    $this->gadgetHtmlRenderer->renderGadget($this->gadget, $this->view);
     ob_end_clean();
-    $this->GadgetHtmlRenderer->addHeadTags($this->domElement, 
$this->domDocument);
+    $this->gadgetHtmlRenderer->addHeadTags($this->domElement, 
$this->domDocument);
 
     // TODO: currently we just test the script part
     $tmpNodeList = $this->domElement->getElementsByTagName("script");
-    $scripts = $this->GadgetHtmlRenderer->getJavaScripts();
+    $scripts = $this->gadgetHtmlRenderer->getJavaScripts();
 
     $idx = 0;
     foreach($tmpNodeList as $tmpNode) {
@@ -159,4 +213,4 @@ class GadgetHtmlRendererTest extends PHP
   }
 
 }
-?>
\ No newline at end of file
+?>

Modified: shindig/branches/2.0.x/php/test/gadgets/MakeRequestTest.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/gadgets/MakeRequestTest.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/gadgets/MakeRequestTest.php (original)
+++ shindig/branches/2.0.x/php/test/gadgets/MakeRequestTest.php Tue Aug 24 
14:33:23 2010
@@ -35,6 +35,8 @@ class MockMakeRequestFetcher extends Rem
    * Constructor.
    */
   public function __construct() {
+    $_SERVER["HTTP_HOST"] = 'localhost';
+    date_default_timezone_set('GMT');
     $this->responses = array();
     $this->requests = array();
   }
@@ -161,7 +163,7 @@ class MakeRequestTest extends PHPUnit_Fr
     $params = new MakeRequestOptions('http://www.example.com');
     $params->setAuthz('SIGNED')
            ->setNoCache(true)
-           
->setSecurityTokenString(urlencode(base64_encode($token->toSerialForm())));
+           ->setSecurityTokenString(urldecode($token->toSerialForm()));
 
     $request = $this->catchRequest($params, $this->response);
 
@@ -183,7 +185,7 @@ class MakeRequestTest extends PHPUnit_Fr
     $params->setAuthz('SIGNED')
            ->setNoCache(true)
            ->setSignViewer(false)
-           
->setSecurityTokenString(urlencode(base64_encode($token->toSerialForm())));
+           ->setSecurityTokenString(urldecode($token->toSerialForm()));
 
     $request = $this->catchRequest($params, $this->response);
 

Modified: shindig/branches/2.0.x/php/test/misc/upload/upload.xml
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/misc/upload/upload.xml?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/misc/upload/upload.xml (original)
+++ shindig/branches/2.0.x/php/test/misc/upload/upload.xml Tue Aug 24 14:33:23 
2010
@@ -27,7 +27,7 @@
 
 function initData() {
   var jsonInput = document.getElementById("json-input");
-  jsonInput.value = ' [ { "method":"mediaitems.create", "params": 
{"albumId":"1", "mediaItem": { "id" : "11223344", "thumbnailUrl" : 
"http://pages.example.org/images/11223344-tn.png";, "mimeType" : "image/png", 
"type" : "image", "url" : "@field:1.jpg", "albumId" : "1" } } } ]';
+  jsonInput.value = ' [ { "method":"mediaitems.create", "params": 
{"albumId":"1", "mediaItem": { "id" : "11223344", "thumbnailUrl" : 
"http://www.libpng.org/pub/png/img_png/pngnow.png";, "mimeType" : "image/png", 
"type" : "image", "url" : "@field:1.jpg", "albumId" : "1" } } } ]';
   gadgets.window.adjustHeight();
 }
 

Modified: shindig/branches/2.0.x/php/test/social/MediaItemRestTest.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/social/MediaItemRestTest.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/social/MediaItemRestTest.php (original)
+++ shindig/branches/2.0.x/php/test/social/MediaItemRestTest.php Tue Aug 24 
14:33:23 2010
@@ -24,7 +24,7 @@ class MediaItemRestTest extends RestBase
   
   protected function setUp() {
     $postData = '{ "id" : "44332211",
-       "thumbnailUrl" : "http://pages.example.org/albums/4433221-tn.png";,
+       "thumbnailUrl" : "http://www.libpng.org/pub/png/img_png/pngnow.png";,
        "title" : "Example Album",
        "description" : "This is an example album, and this text is an example 
description",
        "location" : { "latitude": 0, "longitude": 0 },
@@ -45,16 +45,6 @@ class MediaItemRestTest extends RestBase
 //    $this->assertTrue(empty($ret), "Delete the created album failed. 
Response: $ret");
   }
   
-  private function curlGet($url) {
-    $ch = curl_init();
-    curl_setopt($ch, CURLOPT_URL, $url);
-    curl_setopt($ch, CURLOPT_HEADER, 0);
-    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-    $ret = curl_exec($ch);
-    curl_close($ch);
-    return $ret;
-  }
-  
   private function verifyLifeCycle($postData, $postDataFormat) {
     $url = '/mediaitems/1/@self/' . $this->album['id'];
     $ret = $this->curlRest($url, $postData, $postDataFormat);
@@ -65,10 +55,8 @@ class MediaItemRestTest extends RestBase
     $this->assertFalse(empty($ret));
     $fetched = json_decode($ret, true);
     $fetched = $fetched['entry'][0];
-    $data = $this->curlGet($fetched['url']);
-    $this->assertTrue(substr($data, 0, strlen('GIF')) == 'GIF');
-    $this->assertEquals('http://pages.example.org/images/11223344-tn.png', 
$fetched['thumbnailUrl'], "thumbnailUrl should be same.");
-    $this->assertEquals('image/gif', $fetched['mimeType'], "mimeType should be 
same.");
+    $this->assertEquals('http://www.libpng.org/pub/png/img_png/pngnow.png', 
$fetched['thumbnailUrl'], "thumbnailUrl should be same.");
+    $this->assertEquals('image/png', $fetched['mimeType'], "mimeType should be 
same.");
     $this->assertEquals('IMAGE', $fetched['type'], "type should be same.");
     $fetched['thumbnailUrl'] = 'http://changed.com/tn.png';
     $ret = $this->curlRest($url . '/' . urlencode($mediaItem['id']), 
json_encode($fetched), 'application/json', 'PUT');
@@ -77,7 +65,7 @@ class MediaItemRestTest extends RestBase
     $fetched = json_decode($ret, true);
     $fetched = $fetched['entry'][0];
     $this->assertEquals('http://changed.com/tn.png', $fetched['thumbnailUrl'], 
"thumbnailUrl should be same.");
-    $this->assertEquals('image/gif', $fetched['mimeType'], "mimeType should be 
same.");
+    $this->assertEquals('image/png', $fetched['mimeType'], "mimeType should be 
same.");
     $this->assertEquals('IMAGE', $fetched['type'], "type should be same.");
     
     $ret = $this->curlRest($url . '/' . urlencode($mediaItem['id']), '', 
'application/json', 'DELETE');
@@ -91,7 +79,7 @@ class MediaItemRestTest extends RestBase
   
   public function testLifeCycleInJson() {
     $postData = '{ "id" : "11223344",
-                   "thumbnailUrl" : 
"http://pages.example.org/images/11223344-tn.png";,
+                   "thumbnailUrl" : 
"http://www.libpng.org/pub/png/img_png/pngnow.png";,
                    "mimeType" : "image/png",
                    "type" : "image",
                    "url" : "http://www.google.com/intl/en_ALL/images/logo.gif";,
@@ -104,7 +92,7 @@ class MediaItemRestTest extends RestBase
     $postData = '<?xml version="1.0" encoding="UTF-8"?>
                  <mediaItem xmlns="http://ns.opensocial.org/2008/opensocial";>
                    <id>11223344</id>
-                   
<thumbnailUrl>http://pages.example.org/images/11223344-tn.png</thumbnailUrl>
+                   
<thumbnailUrl>http://www.libpng.org/pub/png/img_png/pngnow.png</thumbnailUrl>
                    <mimeType>image/png</mimeType>
                    <type>image</type>
                    <url>http://www.google.com/intl/en_ALL/images/logo.gif</url>
@@ -118,7 +106,7 @@ class MediaItemRestTest extends RestBase
                    <content type="application/xml">
                      <mediaItem 
xmlns="http://ns.opensocial.org/2008/opensocial";>
                        <id>11223344</id>
-                       
<thumbnailUrl>http://pages.example.org/images/11223344-tn.png</thumbnailUrl>
+                       
<thumbnailUrl>http://www.libpng.org/pub/png/img_png/pngnow.png</thumbnailUrl>
                        <mimeType>image/png</mimeType>
                        <type>image</type>
                        
<url>http://www.google.com/intl/en_ALL/images/logo.gif</url>
@@ -136,10 +124,10 @@ class MediaItemRestTest extends RestBase
   public function testLifeCycleWithActivity() {
     // Creates the media item.
     $postData = '{ "id" : "11223344",
-               "thumbnailUrl" : 
"http://pages.example.org/images/11223344-tn.png";,
+               "thumbnailUrl" : 
"http://www.libpng.org/pub/png/img_png/pngnow.png";,
                "mimeType" : "image/png",
                "type" : "image",
-               "url" : "http://pages.example.org/images/11223344.png";,
+               "url" : "http://www.libpng.org/pub/png/img_png/pngnow.png";,
                "albumId" : "' . $this->album['id'] . '"
              }';
     $url = '/mediaitems/1/@self/' . $this->album['id'];

Modified: shindig/branches/2.0.x/php/test/social/OutputAtomConverterTest.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/social/OutputAtomConverterTest.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/social/OutputAtomConverterTest.php 
(original)
+++ shindig/branches/2.0.x/php/test/social/OutputAtomConverterTest.php Tue Aug 
24 14:33:23 2010
@@ -32,6 +32,8 @@ class OutputAtomConverterTest extends PH
    * Prepares the environment before running a test.
    */
   protected function setUp() {
+    $_SERVER['REQUEST_METHOD'] = 'GET';
+    $_SERVER["HTTP_HOST"] = 'localhost';
     parent::setUp();
     $this->OutputAtomConverter = new OutputAtomConverter();
   }
@@ -48,11 +50,10 @@ class OutputAtomConverterTest extends PH
    * Tests OutputAtomConverter->outputResponse()
    */
   public function testOutputResponse() {
-    $inputConverter = new InputAtomConverter();
     $outputConverter = new OutputAtomConverter();
     $servletRequest = array('url' => '/people/1/@self');
     $token = BasicSecurityToken::createFromValues('owner', 'viewer', 'app', 
'domain', 'appUrl', '1', 'default');
-    $requestItem = RestRequestItem::createWithRequest($servletRequest, $token, 
$inputConverter, $outputConverter);
+    $requestItem = RestRequestItem::createWithRequest($servletRequest, $token, 
'convertAtom', $outputConverter);
     $requestItem->applyUrlTemplate("/people/{userId}/{groupId}/{personId}");
     $entry = array('isOwner' => false, 'isViewer' => false,
                    'displayName' => '1 1', 'id' => '1');

Modified: shindig/branches/2.0.x/php/test/social/OutputJsonConverterTest.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/social/OutputJsonConverterTest.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/social/OutputJsonConverterTest.php 
(original)
+++ shindig/branches/2.0.x/php/test/social/OutputJsonConverterTest.php Tue Aug 
24 14:33:23 2010
@@ -32,6 +32,7 @@ class OutputJsonConverterTest extends PH
    * Prepares the environment before running a test.
    */
   protected function setUp() {
+    $_SERVER['REQUEST_METHOD'] = 'GET';
     parent::setUp();
     $this->OutputJsonConverter = new OutputJsonConverter();
   }
@@ -48,11 +49,10 @@ class OutputJsonConverterTest extends PH
    * Tests OutputJsonConverter->outputResponse()
    */
   public function testOutputResponse() {
-    $inputConverter = new InputJsonConverter();
     $outputConverter = new OutputJsonConverter();
     $servletRequest = array('url' => '/people/1/@self');
     $token = BasicSecurityToken::createFromValues('owner', 'viewer', 'app', 
'domain', 'appUrl', '1', 'default');
-    $requestItem = RestRequestItem::createWithRequest($servletRequest, $token, 
$inputConverter, $outputConverter);
+    $requestItem = RestRequestItem::createWithRequest($servletRequest, $token, 
'convertJson', $outputConverter);
     $requestItem->applyUrlTemplate("/people/{userId}/{groupId}/{personId}");
     $response = array(
         'entry' => array('isOwner' => false, 'isViewer' => false, 
'displayName' => '1 1', 

Modified: shindig/branches/2.0.x/php/test/social/OutputXmlConverterTest.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/social/OutputXmlConverterTest.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/social/OutputXmlConverterTest.php (original)
+++ shindig/branches/2.0.x/php/test/social/OutputXmlConverterTest.php Tue Aug 
24 14:33:23 2010
@@ -32,6 +32,7 @@ class OutputXmlConverterTest extends PHP
    * Prepares the environment before running a test.
    */
   protected function setUp() {
+    $_SERVER['REQUEST_METHOD'] = 'GET';
     parent::setUp();
     $this->OutputXmlConverter = new OutputXmlConverter();
   }
@@ -48,11 +49,10 @@ class OutputXmlConverterTest extends PHP
    * Tests OutputXmlConverter->outputResponse()
    */
   public function testOutputResponse() {
-    $inputConverter = new InputXmlConverter();
     $outputConverter = new OutputXmlConverter();
     $servletRequest = array('url' => '/people/1/@self');
     $token = BasicSecurityToken::createFromValues('owner', 'viewer', 'app', 
'domain', 'appUrl', '1', 'default');
-    $requestItem = RestRequestItem::createWithRequest($servletRequest, $token, 
$inputConverter, $outputConverter);
+    $requestItem = RestRequestItem::createWithRequest($servletRequest, $token, 
'convertXml', $outputConverter);
     $requestItem->applyUrlTemplate("/people/{userId}/{groupId}/{personId}");
     $entry = array('isOwner' => false, 'isViewer' => false,
                    'displayName' => '1 1', 'id' => '1');

Modified: shindig/branches/2.0.x/php/test/social/RestBase.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/social/RestBase.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/social/RestBase.php (original)
+++ shindig/branches/2.0.x/php/test/social/RestBase.php Tue Aug 24 14:33:23 2010
@@ -24,32 +24,35 @@
  */
 class RestBase extends PHPUnit_Framework_TestCase {
   
-  /* Modify this if you want to test in a different social graph then partuza. 
The security token
-   * only works if ALLOW_PLAINTEXT_TOKEN is set to true in the file 
shindig/php/config/containerphp
-   * The format of the plain text token is 
owner:viewer:appId:domain:appUrl:moduleId:containerId
-   */
-  private $securityToken = '1:1:1:partuza:test.com:1:0';
+  private $securityToken;
   // The server to test against. You may need to add shindig to 127.0.0.1 
mapping in /etc/hosts.
   private $restUrl = '';
 
   public function __construct() {
-    $this->restUrl = 'http://' . $_SERVER["HTTP_HOST"] . 
Config::get('web_prefix') . '/social/rest';
+    $db = new JsonDbOpensocialService();
+    $db->resetDb();
+    $this->securityToken = BasicSecurityToken::createFromValues(1, 1, 1, 
'partuza', 'test.com', 1, 0)->toSerialForm();
+    $this->securityToken = urldecode($this->securityToken);
+    $this->restUrl = 'http://localhost' . Config::get('web_prefix') . 
'/social/rest';
   }
 
-  protected function curlRest($url, $postData, $contentType, $method = 'POST') 
{
-    $ch = curl_init();
-    if (substr($url, 0, 1) != '/') {
-      $url = '/' . $url;
-    }
+  protected function curlRest($url, $postData, $contentType = 
'application/json', $method = 'POST') {
+    $_SERVER['CONTENT_TYPE'] = $contentType;
     $sep = strpos($url, '?') !== false ? '&' : '?';
-    curl_setopt($ch, CURLOPT_URL, $this->restUrl . $url . $sep . 'st=' . 
$this->securityToken);
-    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: $contentType"));
-    curl_setopt($ch, CURLOPT_HEADER, 0);
-    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
-    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
-    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-    $ret = curl_exec($ch);
-    curl_close($ch);
+    $_SERVER["REQUEST_URI"] = $this->restUrl . $url . $sep . 'st=' . 
$this->securityToken;
+    $parsedUrl = parse_url($_SERVER["REQUEST_URI"]);
+    $GLOBALS['HTTP_RAW_POST_DATA'] = $postData ? $postData : null;
+    $_SERVER['REQUEST_METHOD'] = $method;
+    $_SERVER['QUERY_STRING'] = $parsedUrl['query'];
+    $_SERVER['HTTP_HOST'] = $parsedUrl['host'];
+    $_GET = array('st' => $this->securityToken);
+    $servlet = new DataServiceServlet();
+    $servletMethod = 'do' . ucfirst(strtolower($method));
+    $servlet->noHeaders = true; // prevents "modify header information" errors
+    ob_start();
+    $servlet->$servletMethod();
+    $ret = ob_get_clean();
+    //var_dump($ret);
     return $ret;
   }
 

Modified: shindig/branches/2.0.x/php/test/social/RestRequestItemTest.php
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/php/test/social/RestRequestItemTest.php?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/php/test/social/RestRequestItemTest.php (original)
+++ shindig/branches/2.0.x/php/test/social/RestRequestItemTest.php Tue Aug 24 
14:33:23 2010
@@ -27,6 +27,7 @@ class RestRequestItemTest extends PHPUni
    * Prepares the environment before running a test.
    */
   protected function setUp() {
+    $_SERVER['REQUEST_METHOD'] = 'GET';
     parent::setUp();
   }
 
@@ -52,11 +53,10 @@ class RestRequestItemTest extends PHPUni
       $urlencodedParams[] = $key . '=' . urlencode($value);
     }
     $url = '/people/1/@self?' . join('&', $urlencodedParams);
-    $inputConverter = new InputJsonConverter();
     $outputConverter = new OutputJsonConverter();
     $servletRequest = array('url' => $url);
     $token = BasicSecurityToken::createFromValues('owner', 'viewer', 'app', 
'domain', 'appUrl', '1', 'default');
-    $requestItem = RestRequestItem::createWithRequest($servletRequest, $token, 
$inputConverter, $outputConverter);
+    $requestItem = RestRequestItem::createWithRequest($servletRequest, $token, 
'convertJson', $outputConverter);
     $params = $requestItem->getParameters();
     $this->assertEquals($expectedParams, $params);
   }

Modified: shindig/branches/2.0.x/pom.xml
URL: 
http://svn.apache.org/viewvc/shindig/branches/2.0.x/pom.xml?rev=988569&r1=988568&r2=988569&view=diff
==============================================================================
--- shindig/branches/2.0.x/pom.xml (original)
+++ shindig/branches/2.0.x/pom.xml Tue Aug 24 14:33:23 2010
@@ -140,6 +140,15 @@
       </roles>
     </developer>
     <developer>
+      <id>bhofmann</id>
+      <name>Bastian Hoffman</name>
+      <email>[email protected]</email>
+      <organization>ASF</organization>
+      <roles>
+        <role>PMC Member</role>
+      </roles>
+    </developer>
+    <developer>
       <id>brianm</id>
       <name>Brian McCallister</name>
       <email>[email protected]</email>
@@ -470,6 +479,11 @@
           <version>${project.version}</version>
         </dependency>
 
+        <dependency>
+          <groupId>org.apache.shindig</groupId>
+          <artifactId>shindig-extras</artifactId>
+          <version>${project.version}</version>
+        </dependency>
         <!-- external dependencies -->
       </dependencies>
 
@@ -1280,11 +1294,6 @@
       <id>java.net</id>
       <url>http://download.java.net/maven/2/</url>
     </repository>
-    <repository>
-      <id>mortbay-release-repo</id>
-      <name>MortBay Release Repo</name>
-      <url>http://jetty.mortbay.org/maven2/release</url>
-    </repository>
   </repositories>
 
   <!-- ====================================================================== 
-->
@@ -1496,17 +1505,17 @@
       <dependency>
         <groupId>net.sourceforge.htmlunit</groupId>
         <artifactId>htmlunit</artifactId>
-        <version>2.7</version>
+        <version>2.8</version>
       </dependency>
       <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
-        <version>1.2.14</version>
+        <version>1.2.16</version>
       </dependency>
       <dependency>
         <groupId>rhino</groupId>
         <artifactId>js</artifactId>
-        <version>1.6R7</version>
+        <version>1.7R2</version>
       </dependency>
       <dependency>
         <groupId>org.apache.geronimo.specs</groupId>
@@ -1515,8 +1524,8 @@
       </dependency>
       <dependency>
         <groupId>net.sf.ehcache</groupId>
-        <artifactId>ehcache</artifactId>
-        <version>1.6.2</version>
+        <artifactId>ehcache-core</artifactId>
+        <version>2.2.0</version>
       </dependency>
       <dependency>
         <groupId>com.thoughtworks.xstream</groupId>
@@ -1531,7 +1540,7 @@
       <dependency>
         <groupId>net.sourceforge.nekohtml</groupId>
         <artifactId>nekohtml</artifactId>
-        <version>1.9.13</version>
+        <version>1.9.14</version>
       </dependency>
       <dependency>
         <groupId>xerces</groupId>
@@ -1556,7 +1565,7 @@
       <dependency>
         <groupId>org.apache.tomcat</groupId>
         <artifactId>jasper-el</artifactId>
-        <version>6.0.26</version>
+        <version>6.0.29</version>
       </dependency>
       <dependency>
         <groupId>de.odysseus.juel</groupId>


Reply via email to