archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/networkproxy/NetworkProxyAdminTest.java
/**
     * ensure we cleanup remote repos linked to a network proxy
     */
ensure we cleanup remote repos linked to a network proxy
ensure we cleanup remote repos linked to a network proxy
@Test
    public void addAndDeleteWithRemoteRepoLinked()
        throws Exception
    {
        mockAuditListener.clearEvents();
        int initialSize = networkProxyAdmin.getNetworkProxies().size();
        NetworkProxy networkProxy = getNetworkProxyTest( "foo" );
        networkProxyAdmin.addNetworkProxy( networkProxy, getFakeAuditInformation() );
        assertEquals( initialSize + 1, networkProxyAdmin.getNetworkProxies().size() );
        networkProxy = networkProxyAdmin.getNetworkProxy( "foo" );
        assertNotNull( networkProxy );
        RemoteRepository remoteRepository = getRemoteRepository();
        remoteRepository.setRemoteDownloadNetworkProxyId( networkProxy.getId() );
        remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getFakeAuditInformation() );
        networkProxyAdmin.deleteNetworkProxy( "foo", getFakeAuditInformation() );
        remoteRepository = remoteRepositoryAdmin.getRemoteRepository( getRemoteRepository().getId() );
        assertTrue(StringUtils.isEmpty(remoteRepository.getRemoteDownloadNetworkProxyId()) );
        remoteRepositoryAdmin.deleteRemoteRepository( getRemoteRepository().getId(), getFakeAuditInformation() );
    }
@ Test public void addAndDeleteWithRemoteRepoLinked ( ) throws Exception { mockAuditListener . clearEvents ( ) ; int initialSize = networkProxyAdmin . getNetworkProxies ( ) . size ( ) ; NetworkProxy networkProxy = getNetworkProxyTest ( "foo" ) ; networkProxyAdmin . addNetworkProxy ( networkProxy , getFakeAuditInformation ( ) ) ; assertEquals ( initialSize + 1 , networkProxyAdmin . getNetworkProxies ( ) . size ( ) ) ; networkProxy = networkProxyAdmin . getNetworkProxy ( "foo" ) ; assertNotNull ( networkProxy ) ; RemoteRepository remoteRepository = getRemoteRepository ( ) ; remoteRepository . setRemoteDownloadNetworkProxyId ( networkProxy . getId ( ) ) ; remoteRepositoryAdmin . addRemoteRepository ( remoteRepository , getFakeAuditInformation ( ) ) ; networkProxyAdmin . deleteNetworkProxy ( "foo" , getFakeAuditInformation ( ) ) ; remoteRepository = remoteRepositoryAdmin . getRemoteRepository ( getRemoteRepository ( ) . getId ( ) ) ; assertTrue ( StringUtils . isEmpty ( remoteRepository . getRemoteDownloadNetworkProxyId ( ) ) ) ; remoteRepositoryAdmin . deleteRemoteRepository ( getRemoteRepository ( ) . getId ( ) , getFakeAuditInformation ( ) ) ; }
ensure we cleanup remote repos linked to a network proxy
ensure we cleanup remote repos linked to a network proxy