Exemplo n.º 1
0
 protected function setUp()
 {
     $test1 = new ATest();
     $test1->setLabel(true);
     $test1->setName(10);
     $test1->setValue('MyValue1');
     $test2 = new ATest();
     $test2->setLabel('MyLabel2');
     $test2->setName('value');
     $test2->setValue($test1);
     $test3 = new ATest();
     $test3->setLabel('label');
     $test3->setName($test1);
     $test3->setValue('name');
     $netApp = \blazeServer\source\netlet\NetletApplication::getAdminApplication();
     $netlets = $netApp->getNetletContext()->getNetlets();
     \ob_start();
     // Need to do this because PHPUnit does something weird..
     set_error_handler(array('blaze\\lang\\System', 'systemErrorHandler'));
     $this->markTestIncomplete('getClass() alsways fails because of Call to a member function getClass() on a non-object');
     $app = $netlets->get('BlazeNetlet')->getClass()->getField('application')->get($netlets->get('BlazeNetlet'));
     $this->bCtx = new \blaze\web\application\BlazeContext($app, new \blazeServer\source\netlet\http\HttpNetletRequestImpl(), new \blazeServer\source\netlet\http\HttpNetletResponseImpl());
     \ob_clean();
     $this->bCtx = \blaze\web\application\BlazeContext::getCurrentInstance();
     $this->bCtx->getELContext()->setContext(ELContext::SCOPE_REQUEST, new scope\ELRequestScopeContext(new \blaze\collections\map\HashMap()));
     $this->bCtx->getELContext()->getContext(ELContext::SCOPE_REQUEST)->set($this->bCtx, 'test1', $test1);
     $this->bCtx->getELContext()->getContext(ELContext::SCOPE_REQUEST)->set($this->bCtx, 'test2', $test2);
     $this->bCtx->getELContext()->getContext(ELContext::SCOPE_REQUEST)->set($this->bCtx, 'test3', $test3);
 }
Exemplo n.º 2
0
 /**
  *
  * @param blaze\io\File $dir
  * @param boolean $running
  */
 public function __construct(\blazeServer\source\netlet\NetletApplication $netletApplication, \blaze\web\lifecycle\Lifecycle $lifeCycle)
 {
     $this->netletApplication = $netletApplication;
     $this->lifeCycle = $lifeCycle;
     $this->applicationPath = new File($netletApplication->getApplicationPath(), 'view');
     $this->navigationRules = new \blaze\collections\lists\ArrayList();
     $this->converter = new \blaze\collections\map\HashMap();
     $this->validator = new \blaze\collections\map\HashMap();
     $this->renderKitFactories = new \blaze\collections\map\HashMap();
     $this->decorators = new \blaze\collections\map\HashMap();
     $this->elContext = new \blaze\web\el\ELContext();
     $requestScope = new \blaze\collections\map\HashMap();
     $viewScope = new \blaze\collections\map\HashMap();
     $sessionScope = new \blaze\collections\map\HashMap();
     $applicationScope = new \blaze\collections\map\HashMap();
     $this->setELScopes($requestScope, $viewScope, $sessionScope, $applicationScope);
     $this->init();
 }
Exemplo n.º 3
0
 /**
  * This method wrapps the HTTP-Request and Response and executes the netlets
  * of a running web application or throws an error if the request does not
  * fit to any application.
  */
 public function process(\blaze\netlet\http\HttpNetletRequest $request, \blaze\netlet\http\HttpNetletResponse $response)
 {
     try {
         $cacheProvider = new \blaze\cache\LocalCacheProvider();
         $cache = $cacheProvider->buildCache(null);
         $cacheMgr = \blaze\cache\CacheManager::getInstance('blazeContainer', $cache);
         $appName = NetletApplication::getApplicationName($request);
         $app = null;
         if ($appName == null) {
             $response->sendError(\blaze\netlet\http\HttpNetletResponse::SC_NOT_FOUND, 'There was no application for the request found.');
             return;
         }
         $app = $cacheMgr->get($appName);
         if ($app == null) {
             $app = NetletApplication::getApplicationByName($appName);
             //$cacheMgr->put($appName, $app);
         }
         if ($app == null) {
             $response->sendError(\blaze\netlet\http\HttpNetletResponse::SC_NOT_FOUND, 'There was no application for the request found.');
             return;
         }
         $context = $app->getNetletContext();
         $chain = new FilterChainImpl($context, $this->getRequestedFilters($request, $context));
         // The netlet gets called after the last filter passed the chain.
         $chain->doFilter($request, $response);
         if (!$response->isCommited()) {
             $sess = $request->getSession();
             if ($sess != null) {
                 $cookie = null;
                 $sessHand = $request->getSessionHandler();
                 if (!$sess->isValid()) {
                     $cookie = new http\HttpCookieImpl('BLAZESESSION', '');
                     $cookie->setExpire(0);
                     $sessHand->removeSession();
                 } else {
                     $sessHand->saveSession();
                     $cookie = new http\HttpCookieImpl('BLAZESESSION', $sess->getId());
                     $cookie->setHttponly(true);
                     $cookie->setPath($app->getUrlPrefix());
                     //$cookie->setDomain($request->getServerName());
                 }
                 if ($cookie != null) {
                     $response->addCookie($cookie);
                 }
             }
         }
     } catch (Exception $e) {
         // Error in the netlet which was not caught
         $response->sendError(\blaze\netlet\http\HttpNetletResponse::SC_NOT_FOUND);
     }
 }