コード例 #1
0
    @Before
    public void standUp() throws EntityNotFoundException, UnprocessableEntityException {
      lb = new LoadBalancer();
      lbRepository = mock(LoadBalancerRepository.class);
      lbService = new LoadBalancerServiceImpl();
      lbService.setLoadBalancerRepository(lbRepository);

      SslTermination sslTermination = new SslTermination();
      sslTermination.setIntermediateCertificate("iCert");
      sslTermination.setCertificate("cert");
      sslTermination.setPrivatekey("aKey");
      sslTermination.setEnabled(true);
      sslTermination.setSecurePort(445);
      sslTermination.setSecureTrafficOnly(false);

      lb.setSslTermination(sslTermination);
      lb.setStatus(LoadBalancerStatus.ACTIVE);

      defaultProtocol =
          new LoadBalancerProtocolObject(LoadBalancerProtocol.HTTP, "HTTP Protocol", 80, true);
      when(lbRepository.getByIdAndAccountId(Matchers.<Integer>any(), Matchers.<Integer>any()))
          .thenReturn(lb);
      //            when(lbRepository.testAndSetStatus(Matchers.<Integer>any(),
      // Matchers.<Integer>any(),Matchers.<LoadBalancerStatus>any(),
      // Matchers.<Boolean>any())).thenReturn(true);

    }
コード例 #2
0
    @Test(expected = BadRequestException.class)
    public void shouldRejectUpdateProtocolIfUsingSslTermination() throws Exception {
      LoadBalancer loadBalancer = new LoadBalancer();
      loadBalancer.setProtocol(LoadBalancerProtocol.HTTPS);
      loadBalancer.setStatus(LoadBalancerStatus.ACTIVE);

      lbService.prepareForUpdate(loadBalancer);
    }
コード例 #3
0
    @Test
    public void shouldSetStatusToBuildWhenStatusIsModified() {
      lb.setStatus(LoadBalancerStatus.ERROR);

      lbService.addDefaultValues(lb);

      Assert.assertEquals(LoadBalancerStatus.BUILD, lb.getStatus());
    }
コード例 #4
0
    @Test(expected = BadRequestException.class)
    public void shouldFailWhenUpdatingPortToSSLPort() throws Exception {

      LoadBalancer loadBalancer = new LoadBalancer();
      loadBalancer.setStatus(LoadBalancerStatus.ACTIVE);
      loadBalancer.setPort(445);

      lbService.prepareForUpdate(loadBalancer);
    }
コード例 #5
0
    @Before
    public void standUp()
        throws EntityNotFoundException, UnprocessableEntityException, ClusterStatusException,
            NoAvailableClusterException {
      lb = new LoadBalancer();
      lbRepository = mock(LoadBalancerRepository.class);
      lbService = new LoadBalancerServiceImpl();
      lbService.setLoadBalancerRepository(lbRepository);

      hostService = new HostServiceImpl();
      hostService.setLoadBalancerRepository(lbRepository);
      hostRepository = mock(HostRepository.class);
      hostService.setHostRepository(hostRepository);

      clusterService = new ClusterServiceImpl();
      clusterService.setLoadBalancerRepository(lbRepository);
      clusterRepository = mock(ClusterRepository.class);
      clusterService.setClusterRepository(clusterRepository);

      virtualIpRepository = mock(VirtualIpRepository.class);

      loadBalancerStatusHistoryRepository = mock(LoadBalancerStatusHistoryRepository.class);
      loadBalancerStatusHistoryService = new LoadBalancerStatusHistoryServiceImpl();
      loadBalancerStatusHistoryService.setLoadBalancerStatusHistoryRepository(
          loadBalancerStatusHistoryRepository);

      hostService.setClusterRepository(clusterRepository);
      //            lbService.setHostService(hostService);
      //            lbService.setLoadBalancerStatusHistoryService(loadBalancerStatusHistoryService);
      lbService.setVirtualIpRepository(virtualIpRepository);

      lb.setStatus(LoadBalancerStatus.ACTIVE);

      lb.setAccountId(555555);
      lb.setId(3333);
      lb.setPort(33);
      lb.setProtocol(LoadBalancerProtocol.HTTP);

      Host host = new Host();
      host.setId(2);
      host.setHostStatus(HostStatus.ACTIVE);

      Cluster cluster = new Cluster();
      cluster.setId(3);

      lb.setHost(host);

      when(hostRepository.getById(Matchers.<Integer>any())).thenReturn(host);
      when(hostRepository.getDefaultActiveHost(Matchers.<Integer>any())).thenReturn(host);
      when(clusterRepository.getActiveCluster(null, false)).thenReturn(cluster);
      when(hostService.getById(Matchers.<Integer>any())).thenReturn(host);
      when(loadBalancerStatusHistoryRepository.save(
              Matchers.<LoadBalancerStatusHistory>anyObject()))
          .thenReturn(new LoadBalancerStatusHistory());

      //            when(loadBalancerStatusHistoryService.save(lb.getAccountId(), lb.getId(),
      // status);)
      //            when(lbRepository.testAndSetStatus(Matchers.<Integer>any(),
      // Matchers.<Integer>any(),Matchers.<LoadBalancerStatus>any(),
      // Matchers.<Boolean>any())).thenReturn(true);

    }