@Test
  public void testUpdateExisting() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    VirtualHost newVirtualHost = _persistence.create(pk);

    newVirtualHost.setMvccVersion(ServiceTestUtil.nextLong());

    newVirtualHost.setCompanyId(ServiceTestUtil.nextLong());

    newVirtualHost.setLayoutSetId(ServiceTestUtil.nextLong());

    newVirtualHost.setHostname(ServiceTestUtil.randomString());

    _persistence.update(newVirtualHost);

    VirtualHost existingVirtualHost = _persistence.findByPrimaryKey(newVirtualHost.getPrimaryKey());

    Assert.assertEquals(existingVirtualHost.getMvccVersion(), newVirtualHost.getMvccVersion());
    Assert.assertEquals(existingVirtualHost.getVirtualHostId(), newVirtualHost.getVirtualHostId());
    Assert.assertEquals(existingVirtualHost.getCompanyId(), newVirtualHost.getCompanyId());
    Assert.assertEquals(existingVirtualHost.getLayoutSetId(), newVirtualHost.getLayoutSetId());
    Assert.assertEquals(existingVirtualHost.getHostname(), newVirtualHost.getHostname());
  }
Exemplo n.º 2
0
  @Override
  public String getVirtualHostname() {
    if (_virtualHostname != null) {
      return _virtualHostname;
    }

    try {
      VirtualHost virtualHost = VirtualHostLocalServiceUtil.fetchVirtualHost(getCompanyId(), 0);

      if (virtualHost == null) {
        _virtualHostname = StringPool.BLANK;
      } else {
        _virtualHostname = virtualHost.getHostname();
      }
    } catch (Exception e) {
      _virtualHostname = StringPool.BLANK;
    }

    return _virtualHostname;
  }