Esempio n. 1
0
  @Before
  public void setUp() throws Exception {
    super.setUp();
    ApiProxy.setEnvironmentForCurrentThread(new TestEnvironment());
    // ApiProxyLocalImpl apiProxyLocalImpl = new ApiProxyLocalImpl(new File(".")){};
    // ApiProxy.setDelegate(apiProxyLocalImpl);

    /*	ApiProxy.setEnvironmentForCurrentThread(new TestEnvironment());
    ApiProxyLocalFactory factory = new ApiProxyLocalFactory();
    LocalServerEnvironment localServerEnvironment = new LocalServerEnvironment() {
    	@Override
    	public void waitForServerToStart() throws InterruptedException {
    		// TODO Auto-generated method stub
    	}

    	@Override
    	public int getPort() {
    		return 8080;
    	}

    	@Override
    	public File getAppDir() {
    		return new File(".");
    	}

    	@Override
    	public String getAddress() {
    		return "127.0.0.1";
    	}
    };
          ApiProxy.setDelegate(factory.create(localServerEnvironment));*/
  }
 public static CapedwarfEnvironment setThreadLocalInstance(
     final CapedwarfEnvironment environment) {
   SecurityManager sm = System.getSecurityManager();
   if (sm == null) {
     CapedwarfEnvironment previous = getThreadLocalInstanceInternal();
     ApiProxy.setEnvironmentForCurrentThread(environment);
     return previous;
   } else {
     return AccessController.doPrivileged(
         new PrivilegedAction<CapedwarfEnvironment>() {
           public CapedwarfEnvironment run() {
             CapedwarfEnvironment previous = getThreadLocalInstanceInternal();
             ApiProxy.setEnvironmentForCurrentThread(environment);
             return previous;
           }
         });
   }
 }
 public static CapedwarfEnvironment createThreadLocalInstance() {
   CapedwarfEnvironment environment = new CapedwarfEnvironment();
   ApiProxy.setEnvironmentForCurrentThread(environment);
   return environment;
 }