Package org.jboss.services.binding.impl

Examples of org.jboss.services.binding.impl.PojoServiceBindingStore$ServiceBindingKey


    * @param standardBindings
    */
   public ServiceBindingManagementObject(String serverName, Set<ServiceBindingSet> bindingSets,
         Set<ServiceBindingMetadata> standardBindings)
   {
      bindingStore = new PojoServiceBindingStore(bindingSets, standardBindings);
      bindingManager = new ServiceBindingManager(serverName, bindingStore);
   }
View Full Code Here


   }
  
  
   public void testGetServiceBinding() throws Exception
   {
      PojoServiceBindingStore store = new PojoServiceBindingStore();     
      store.setServiceBindingSets(bindingSets);
      store.setStandardBindings(bindings);
      store.start();
     
      assertEquals(getServiceBinding(AA, SET_A), store.getServiceBinding(A, A, A));     
      assertEquals(getServiceBinding(AA, SET_B), store.getServiceBinding(B, A, A));    
      assertEquals(getServiceBinding(AA, SET_C), store.getServiceBinding(C, A, A));
     
      assertEquals(getServiceBinding(AB, SET_A), store.getServiceBinding(A, A, B));     
      assertEquals(getServiceBinding(AB, SET_B), store.getServiceBinding(B, A, B));    
      assertEquals(getServiceBinding(AB, SET_C), store.getServiceBinding(C, A, B));
     
      assertEquals(getServiceBinding(Anull, SET_A), store.getServiceBinding(A, A, null));     
      assertEquals(getServiceBinding(Anull, SET_B), store.getServiceBinding(B, A, null));    
      assertEquals(getServiceBinding(Anull, SET_C), store.getServiceBinding(C, A, null));
     
      try
      {
         store.getServiceBinding(D, A, A);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      try
      {
         store.getServiceBinding(A, B, A);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      try
      {
         store.getServiceBinding(A, B, null);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
   }
View Full Code Here

      catch (NoSuchBindingException e) {}
   }
  
   public void testAddServiceBinding() throws Exception
   {
      PojoServiceBindingStore store = new PojoServiceBindingStore();     
      store.setServiceBindingSets(bindingSets);
      store.setStandardBindings(bindings);
      store.start();
     
      ServiceBindingMetadata new1 = new ServiceBindingMetadata(B, A, "localhost", 1, false, false);
      store.addServiceBinding(A, new1);
      store.addServiceBinding(B, new1);
      store.addServiceBinding(C, new1);
     
      assertEquals(getServiceBinding(new1, SET_A), store.getServiceBinding(A, B, A));     
      assertEquals(getServiceBinding(new1, SET_B), store.getServiceBinding(B, B, A));     
      assertEquals(getServiceBinding(new1, SET_C), store.getServiceBinding(C, B, A));
     
      ServiceBindingMetadata new2 = new ServiceBindingMetadata(B, A, "localhost", 2, false, false);
      try
      {
         store.addServiceBinding(D, new2);     
         fail("add for unknown binding set succeeded");
      }
      catch (IllegalArgumentException good) {}
     
      try
      {
         store.addServiceBinding(A, new2);
         fail("duplicate add succeeded");
      }
      catch (DuplicateServiceException good) {}
   }
View Full Code Here

      catch (DuplicateServiceException good) {}
   }
  
   public void testRemoveServiceBinding() throws Exception
   {
      PojoServiceBindingStore store = new PojoServiceBindingStore();     
      store.setServiceBindingSets(bindingSets);
      store.setStandardBindings(bindings);
      store.start();
     
      store.removeServiceBinding(A, AA);
     
      try
      {
         store.getServiceBinding(A, A, A);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      store.removeServiceBinding(B, AA);
     
      try
      {
         store.getServiceBinding(B, A, A);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      store.removeServiceBinding(A, Anull);
     
      try
      {
         store.getServiceBinding(A, A, null);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      store.removeServiceBinding(B, Anull);
     
      try
      {
         store.getServiceBinding(B, A, null);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      ServiceBindingMetadata new1 = new ServiceBindingMetadata(B, A, "localhost", 1, false, false);
      store.removeServiceBinding(A, new1);
      store.removeServiceBinding(A, BA);
   }
View Full Code Here

      ServiceBindingSet newSetB = new ServiceBindingSet(B, "localhost", 20, set);
      ourSets.add(newSetB)
      ServiceBindingSet newSetC = new ServiceBindingSet(C, "192.168.0.10", 30, set);
      ourSets.add(newSetC);
     
      PojoServiceBindingStore store = new PojoServiceBindingStore();
      store.setServiceBindingSets(ourSets);
      store.start();
     
      ServiceBindingMetadata new1 = new ServiceBindingMetadata(B, A, "192.168.0.22", 1, false, true);
      store.addServiceBinding(new1);
     
      InetAddress address = InetAddress.getByName("192.168.0.22");
     
      ServiceBinding got = store.getServiceBinding(A, B, A);
      assertEquals(getServiceBinding(new1, newSetA), got);   
      assertEquals(11, got.getPort());
      assertEquals("192.168.0.22", got.getHostName());
      assertEquals(address, got.getBindAddress());
     
      got = store.getServiceBinding(B, B, A);
      assertEquals(getServiceBinding(new1, newSetB), got);   
      assertEquals(21, got.getPort());
      assertEquals("192.168.0.22", got.getHostName());
      assertEquals(address, got.getBindAddress());
     
      got = store.getServiceBinding(C, B, A);
      assertEquals(getServiceBinding(new1, newSetC), got);
      assertEquals(31, got.getPort());
      assertEquals("192.168.0.22", got.getHostName());
      assertEquals(address, got.getBindAddress());
     
      ServiceBindingMetadata new2 = new ServiceBindingMetadata(B, A, "localhost", 2, false, false);
      try
      {
         store.addServiceBinding(new2);
         fail("duplicate add succeeded");
      }
      catch (DuplicateServiceException good) {}
     
      ServiceBindingMetadata new3 = new ServiceBindingMetadata(C, C, null, 3, false, false);
      store.addServiceBinding(new3);
     
      got = store.getServiceBinding(A, C, C);
      assertEquals(getServiceBinding(new3, newSetA), got);   
      assertEquals(13, got.getPort());
      assertNull(got.getHostName());
      assertEquals(InetAddress.getByName(null), got.getBindAddress());
     
      got = store.getServiceBinding(B, C, C);
      assertEquals(getServiceBinding(new3, newSetB), got);   
      assertEquals(23, got.getPort());
      assertEquals("localhost", got.getHostName());
      assertEquals(InetAddress.getByName("localhost"), got.getBindAddress());
     
      got = store.getServiceBinding(C, C, C);
      assertEquals(getServiceBinding(new3, newSetC), got);   
      assertEquals(33, got.getPort());
      assertEquals("192.168.0.10", got.getHostName());
      assertEquals(InetAddress.getByName("192.168.0.10"), got.getBindAddress());
     
View Full Code Here

     
   }
  
   public void testRemoveServiceBindingFromAll() throws Exception
   {
      PojoServiceBindingStore store = new PojoServiceBindingStore();     
      store.setServiceBindingSets(bindingSets);
      store.setStandardBindings(bindings);
      store.start();
     
      store.removeServiceBinding(AA);
     
      try
      {
         store.getServiceBinding(A, A, A);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      store.removeServiceBinding(B, AA);
     
      try
      {
         store.getServiceBinding(B, A, A);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      try
      {
         store.getServiceBinding(C, A, A);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      String nullA = null;
      store.removeServiceBinding(A, nullA);
     
      try
      {
         store.getServiceBinding(A, A, null);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      try
      {
         store.getServiceBinding(B, A, null);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      try
      {
         store.getServiceBinding(C, A, null);
         fail("invalid");
      }
      catch (NoSuchBindingException e) {}
     
      ServiceBindingMetadata new1 = new ServiceBindingMetadata(B, A, "localhost", 1, false, false);
      store.removeServiceBinding(new1);
      store.removeServiceBinding(B, A);
   }
View Full Code Here

      store.removeServiceBinding(B, A);
   }
  
   public void testDefaultDefaults() throws Exception
   {
      PojoServiceBindingStore store = new PojoServiceBindingStore();     
      store.setServiceBindingSets(bindingSets);
      store.setStandardBindings(bindings);
      store.start();
     
      String[] names = {A, B, C};
     
      for (String name :names)
      {
         assertEquals("localhost", store.getDefaultHostName(name));
         assertEquals(0, store.getDefaultPortOffset(name));
      }
   }
View Full Code Here

      Set<ServiceBindingSet> sbs = new HashSet<ServiceBindingSet>();
      sbs.add(new ServiceBindingSet(A, null, 10, set));
      sbs.add(new ServiceBindingSet(B, "localhost", 20, set));     
      sbs.add(new ServiceBindingSet(C, "192.168.0.10", 30, set));
     
      PojoServiceBindingStore store = new PojoServiceBindingStore();
      store.setServiceBindingSets(sbs);
      store.start();
     
      assertNull(store.getDefaultHostName(A));
      assertEquals(10, store.getDefaultPortOffset(A));
     
      assertEquals("localhost", store.getDefaultHostName(B));
      assertEquals(20, store.getDefaultPortOffset(B));
     
      assertEquals("192.168.0.10", store.getDefaultHostName(C));
      assertEquals(30, store.getDefaultPortOffset(C));
   }
View Full Code Here

      assertEquals(30, store.getDefaultPortOffset(C));
   }
  
   public void testGetServiceBindings() throws Exception
   {
      PojoServiceBindingStore store = new PojoServiceBindingStore();     
      store.setServiceBindingSets(bindingSets);
      store.setStandardBindings(bindings);
      store.start();
     
      String[] servers = {A, B, C};
      for (String server : servers)
      {
         Set<ServiceBinding> set = store.getServiceBindings(server);
         assertEquals(bindings.size(), set.size());
         for (ServiceBinding binding : set)
         {
            ServiceBindingMetadata metadata = new ServiceBindingMetadata(binding);
            assertTrue(server + " includes " + metadata, bindings.contains(metadata));
View Full Code Here

      ServiceBindingSet setB = new ServiceBindingSet(B, "localhost", 20);     
      sbs.add(setB);    
      ServiceBindingSet setC = new ServiceBindingSet(C, "192.168.0.10", 30);
      sbs.add(setC);
     
      PojoServiceBindingStore store = new PojoServiceBindingStore(sbs, set);
      store.start();
     
      Set<ServiceBindingMetadata> updatedSet =
         new HashSet<ServiceBindingMetadata>(store.getStandardBindings());
      assertEquals(3, updatedSet.size());
      ServiceBindingMetadata updated = new ServiceBindingMetadata(AA);
      updated.setPort(9999);
      updated.setDescription("updated");
      updatedSet.remove(AA);
      updatedSet.add(updated);
      updatedSet.add(BA);
      assertEquals(4, updatedSet.size());
     
      store.setStandardBindings(updatedSet);
     
      Set<ServiceBindingMetadata> result = store.getStandardBindings();
      assertNotNull(result);
      assertTrue("has updated", result.contains(updated));
      assertTrue("has AB", result.contains(AB));
      assertTrue("has Anull", result.contains(Anull));
      assertTrue("has BA", result.contains(BA));
     
      for (ServiceBindingSet bindingSet : sbs)
      {
         String setName = bindingSet.getName();
         Set<ServiceBinding> bindings = store.getServiceBindings(setName);
         assertNotNull(bindings);
         assertEquals(4, bindings.size());
         Map<String, ServiceBinding> byFQN = new HashMap<String, ServiceBinding>();
         for (ServiceBinding binding : bindings)
         {
View Full Code Here

TOP

Related Classes of org.jboss.services.binding.impl.PojoServiceBindingStore$ServiceBindingKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.