@Test( expected=InvalidConfigurationException.class ) public void testInvalidConfiguration() throws InvalidConfigurationException { Configuration configuration = new Configuration(); loader.load( new Properties(), configuration ); }
public void load( Properties props, Configuration configuration ) throws InvalidConfigurationException { String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE ); ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration(); config.setLocation( localCachePath ); config.setName( "Imported Maven-Proxy Cache" ); config.setId( "maven-proxy" ); config.setScanned( false ); config.setReleases( true ); config.setSnapshots( false ); configuration.addManagedRepository( config ); String propertyList = props.getProperty( PROXY_LIST ); if ( propertyList != null ) { StringTokenizer tok = new StringTokenizer( propertyList, "," ); while ( tok.hasMoreTokens() ) { String key = tok.nextToken(); if ( StringUtils.isNotEmpty( key ) ) { NetworkProxyConfiguration proxy = new NetworkProxyConfiguration(); proxy.setHost( getMandatoryProperty( props, "proxy." + key + ".host" ) ); proxy.setPort( Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ) ); proxy.setUsername( props.getProperty( "proxy." + key + ".username" ) ); proxy.setPassword( props.getProperty( "proxy." + key + ".password" ) ); configuration.addNetworkProxy( proxy ); } } } String repoList = getMandatoryProperty( props, REPO_LIST ); StringTokenizer tok = new StringTokenizer( repoList, "," ); while ( tok.hasMoreTokens() ) { String key = tok.nextToken(); Properties repoProps = getSubset( props, "repo." + key + "." ); String url = getMandatoryProperty( props, "repo." + key + ".url" ); String proxyKey = repoProps.getProperty( "proxy" ); RemoteRepositoryConfiguration repository = new RemoteRepositoryConfiguration(); repository.setId( key ); repository.setName( "Imported Maven-Proxy Remote Proxy" ); repository.setUrl( url ); repository.setLayout( "legacy" ); configuration.addRemoteRepository( repository ); ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration(); proxyConnector.setSourceRepoId( "maven-proxy" ); proxyConnector.setTargetRepoId( key ); proxyConnector.setProxyId( proxyKey ); proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.DAILY.getId() ); proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS.getId() ); configuration.addProxyConnector( proxyConnector ); } }
MavenProxyPropertyLoader { public void load( Properties props, Configuration configuration ) throws InvalidConfigurationException { String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE ); ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration(); config.setLocation( localCachePath ); config.setName( "Imported Maven-Proxy Cache" ); config.setId( "maven-proxy" ); config.setScanned( false ); config.setReleases( true ); config.setSnapshots( false ); configuration.addManagedRepository( config ); String propertyList = props.getProperty( PROXY_LIST ); if ( propertyList != null ) { StringTokenizer tok = new StringTokenizer( propertyList, "," ); while ( tok.hasMoreTokens() ) { String key = tok.nextToken(); if ( StringUtils.isNotEmpty( key ) ) { NetworkProxyConfiguration proxy = new NetworkProxyConfiguration(); proxy.setHost( getMandatoryProperty( props, "proxy." + key + ".host" ) ); proxy.setPort( Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ) ); proxy.setUsername( props.getProperty( "proxy." + key + ".username" ) ); proxy.setPassword( props.getProperty( "proxy." + key + ".password" ) ); configuration.addNetworkProxy( proxy ); } } } String repoList = getMandatoryProperty( props, REPO_LIST ); StringTokenizer tok = new StringTokenizer( repoList, "," ); while ( tok.hasMoreTokens() ) { String key = tok.nextToken(); Properties repoProps = getSubset( props, "repo." + key + "." ); String url = getMandatoryProperty( props, "repo." + key + ".url" ); String proxyKey = repoProps.getProperty( "proxy" ); RemoteRepositoryConfiguration repository = new RemoteRepositoryConfiguration(); repository.setId( key ); repository.setName( "Imported Maven-Proxy Remote Proxy" ); repository.setUrl( url ); repository.setLayout( "legacy" ); configuration.addRemoteRepository( repository ); ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration(); proxyConnector.setSourceRepoId( "maven-proxy" ); proxyConnector.setTargetRepoId( key ); proxyConnector.setProxyId( proxyKey ); proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.DAILY.getId() ); proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS.getId() ); configuration.addProxyConnector( proxyConnector ); } } }
MavenProxyPropertyLoader { public void load( Properties props, Configuration configuration ) throws InvalidConfigurationException { String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE ); ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration(); config.setLocation( localCachePath ); config.setName( "Imported Maven-Proxy Cache" ); config.setId( "maven-proxy" ); config.setScanned( false ); config.setReleases( true ); config.setSnapshots( false ); configuration.addManagedRepository( config ); String propertyList = props.getProperty( PROXY_LIST ); if ( propertyList != null ) { StringTokenizer tok = new StringTokenizer( propertyList, "," ); while ( tok.hasMoreTokens() ) { String key = tok.nextToken(); if ( StringUtils.isNotEmpty( key ) ) { NetworkProxyConfiguration proxy = new NetworkProxyConfiguration(); proxy.setHost( getMandatoryProperty( props, "proxy." + key + ".host" ) ); proxy.setPort( Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ) ); proxy.setUsername( props.getProperty( "proxy." + key + ".username" ) ); proxy.setPassword( props.getProperty( "proxy." + key + ".password" ) ); configuration.addNetworkProxy( proxy ); } } } String repoList = getMandatoryProperty( props, REPO_LIST ); StringTokenizer tok = new StringTokenizer( repoList, "," ); while ( tok.hasMoreTokens() ) { String key = tok.nextToken(); Properties repoProps = getSubset( props, "repo." + key + "." ); String url = getMandatoryProperty( props, "repo." + key + ".url" ); String proxyKey = repoProps.getProperty( "proxy" ); RemoteRepositoryConfiguration repository = new RemoteRepositoryConfiguration(); repository.setId( key ); repository.setName( "Imported Maven-Proxy Remote Proxy" ); repository.setUrl( url ); repository.setLayout( "legacy" ); configuration.addRemoteRepository( repository ); ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration(); proxyConnector.setSourceRepoId( "maven-proxy" ); proxyConnector.setTargetRepoId( key ); proxyConnector.setProxyId( proxyKey ); proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.DAILY.getId() ); proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS.getId() ); configuration.addProxyConnector( proxyConnector ); } }  }
MavenProxyPropertyLoader { public void load( Properties props, Configuration configuration ) throws InvalidConfigurationException { String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE ); ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration(); config.setLocation( localCachePath ); config.setName( "Imported Maven-Proxy Cache" ); config.setId( "maven-proxy" ); config.setScanned( false ); config.setReleases( true ); config.setSnapshots( false ); configuration.addManagedRepository( config ); String propertyList = props.getProperty( PROXY_LIST ); if ( propertyList != null ) { StringTokenizer tok = new StringTokenizer( propertyList, "," ); while ( tok.hasMoreTokens() ) { String key = tok.nextToken(); if ( StringUtils.isNotEmpty( key ) ) { NetworkProxyConfiguration proxy = new NetworkProxyConfiguration(); proxy.setHost( getMandatoryProperty( props, "proxy." + key + ".host" ) ); proxy.setPort( Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ) ); proxy.setUsername( props.getProperty( "proxy." + key + ".username" ) ); proxy.setPassword( props.getProperty( "proxy." + key + ".password" ) ); configuration.addNetworkProxy( proxy ); } } } String repoList = getMandatoryProperty( props, REPO_LIST ); StringTokenizer tok = new StringTokenizer( repoList, "," ); while ( tok.hasMoreTokens() ) { String key = tok.nextToken(); Properties repoProps = getSubset( props, "repo." + key + "." ); String url = getMandatoryProperty( props, "repo." + key + ".url" ); String proxyKey = repoProps.getProperty( "proxy" ); RemoteRepositoryConfiguration repository = new RemoteRepositoryConfiguration(); repository.setId( key ); repository.setName( "Imported Maven-Proxy Remote Proxy" ); repository.setUrl( url ); repository.setLayout( "legacy" ); configuration.addRemoteRepository( repository ); ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration(); proxyConnector.setSourceRepoId( "maven-proxy" ); proxyConnector.setTargetRepoId( key ); proxyConnector.setProxyId( proxyKey ); proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.DAILY.getId() ); proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS.getId() ); configuration.addProxyConnector( proxyConnector ); } }  void load( Properties props, Configuration configuration ); void load( InputStream is, Configuration configuration ); }
MavenProxyPropertyLoader { public void load( Properties props, Configuration configuration ) throws InvalidConfigurationException { String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE ); ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration(); config.setLocation( localCachePath ); config.setName( "Imported Maven-Proxy Cache" ); config.setId( "maven-proxy" ); config.setScanned( false ); config.setReleases( true ); config.setSnapshots( false ); configuration.addManagedRepository( config ); String propertyList = props.getProperty( PROXY_LIST ); if ( propertyList != null ) { StringTokenizer tok = new StringTokenizer( propertyList, "," ); while ( tok.hasMoreTokens() ) { String key = tok.nextToken(); if ( StringUtils.isNotEmpty( key ) ) { NetworkProxyConfiguration proxy = new NetworkProxyConfiguration(); proxy.setHost( getMandatoryProperty( props, "proxy." + key + ".host" ) ); proxy.setPort( Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ) ); proxy.setUsername( props.getProperty( "proxy." + key + ".username" ) ); proxy.setPassword( props.getProperty( "proxy." + key + ".password" ) ); configuration.addNetworkProxy( proxy ); } } } String repoList = getMandatoryProperty( props, REPO_LIST ); StringTokenizer tok = new StringTokenizer( repoList, "," ); while ( tok.hasMoreTokens() ) { String key = tok.nextToken(); Properties repoProps = getSubset( props, "repo." + key + "." ); String url = getMandatoryProperty( props, "repo." + key + ".url" ); String proxyKey = repoProps.getProperty( "proxy" ); RemoteRepositoryConfiguration repository = new RemoteRepositoryConfiguration(); repository.setId( key ); repository.setName( "Imported Maven-Proxy Remote Proxy" ); repository.setUrl( url ); repository.setLayout( "legacy" ); configuration.addRemoteRepository( repository ); ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration(); proxyConnector.setSourceRepoId( "maven-proxy" ); proxyConnector.setTargetRepoId( key ); proxyConnector.setProxyId( proxyKey ); proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.DAILY.getId() ); proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.ALWAYS.getId() ); configuration.addProxyConnector( proxyConnector ); } }  void load( Properties props, Configuration configuration ); void load( InputStream is, Configuration configuration );  }