コード例 #1
0
func TestDispatcher(t *testing.T) {

	var registryProxy *registry.RegistryProxy
	var dispatcherHost string
	var dispatcherProxy *DispatcherProxy
	var err error

	// start up the registry
	{
		host := piazza.GetRandomHost()
		go registry.NewRegistryService(host, "my registry")
		time.Sleep(1 * time.Second)

		registryProxy, err = registry.NewRegistryProxy(host)
		if err != nil {
			t.Error(err)
		}
	}

	// start the dispatcher
	{
		dispatcherHost = piazza.GetRandomHost()
		go NewDispatcherService(dispatcherHost, registryProxy)
		time.Sleep(1 * time.Second)
	}

	// start the dispatcher proxy
	{
		dispatcherProxy, err = NewDispatcherProxy(dispatcherHost)
		if err != nil {
			t.Error(err)
		}
		log.Printf("%v", dispatcherProxy)
	}
}
コード例 #2
0
ファイル: gateway_test.go プロジェクト: venicegeo/mpg-sandbox
func setup(t *testing.T) *GatewayProxy {
	var err error

	var registryHost = piazza.GetRandomHost()
	var registryProxy *registry.RegistryProxy

	var dispatcherHost = piazza.GetRandomHost()
	var dispatcherProxy *dispatcher.DispatcherProxy

	var gatewayHost = piazza.GetRandomHost()
	var gatewayProxy *GatewayProxy

	{
		go registry.NewRegistryService(registryHost, "my registry")
		time.Sleep(250 * time.Millisecond)

		registryProxy, err = registry.NewRegistryProxy(registryHost)
		if err != nil {
			t.Error(err)
		}
	}
	{
		go dispatcher.NewDispatcherService(dispatcherHost, registryProxy)
		time.Sleep(250 * time.Millisecond)

		dispatcherProxy, err = dispatcher.NewDispatcherProxy(dispatcherHost)
		if err != nil {
			t.Error(err)
		}
	}
	{
		go NewGatewayService(gatewayHost, registryProxy)
		time.Sleep(250 * time.Millisecond)

		gatewayProxy, err = NewGatewayProxy(gatewayHost, dispatcherProxy)
		if err != nil {
			t.Error(err)
		}
	}

	return gatewayProxy
}