Search in sources :

Example 1 with TeamCityProperties

use of jetbrains.buildServer.serverSide.TeamCityProperties in project teamcity-git by JetBrains.

the class AgentConfigPluginTest method setUp.

@BeforeMethod
public void setUp() {
    new TeamCityProperties() {

        {
            setModel(new BasePropertiesModel() {
            });
        }
    };
    myMockery = new Mockery();
    myAgentConfig = myMockery.mock(BuildAgentConfiguration.class);
    myBuild = myMockery.mock(AgentRunningBuild.class);
    myBuildSharedConfigParameters = new HashMap<String, String>();
    myMockery.checking(new Expectations() {

        {
            allowing(myBuild).getSharedConfigParameters();
            will(returnValue(myBuildSharedConfigParameters));
            allowing(myBuild).getBuildLogger();
            allowing(myAgentConfig).getCacheDirectory("git");
            will(returnValue(new File("")));
        }
    });
    myMirrorManager = new MirrorManagerImpl(new AgentMirrorConfig(myAgentConfig), new HashCalculatorImpl(), new RemoteRepositoryUrlInvestigatorImpl());
}
Also used : Expectations(org.jmock.Expectations) AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) AgentMirrorConfig(jetbrains.buildServer.buildTriggers.vcs.git.agent.AgentMirrorConfig) RemoteRepositoryUrlInvestigatorImpl(jetbrains.buildServer.buildTriggers.vcs.git.agent.RemoteRepositoryUrlInvestigatorImpl) Mockery(org.jmock.Mockery) TeamCityProperties(jetbrains.buildServer.serverSide.TeamCityProperties) BasePropertiesModel(jetbrains.buildServer.serverSide.BasePropertiesModel) BuildAgentConfiguration(jetbrains.buildServer.agent.BuildAgentConfiguration) File(java.io.File) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with TeamCityProperties

use of jetbrains.buildServer.serverSide.TeamCityProperties in project teamcity-git by JetBrains.

the class JSchClient method initInternalProperties.

private static void initInternalProperties(final Logger logger) {
    String intPropsPath = System.getenv(GitSSHHandler.TEAMCITY_INT_PROPS_PATH);
    File intPropsFile = intPropsPath == null ? null : new File(intPropsPath);
    if (intPropsFile != null && !intPropsFile.isFile()) {
        logger.log(Logger.WARN, "Could not find an internal properties file at path: " + intPropsPath);
        intPropsFile = null;
    }
    if (intPropsFile == null) {
        new TeamCityProperties() {

            {
                setBaseModel();
            }
        };
    } else {
        Map<String, String> loadedProps = new HashMap<>();
        Properties props = new Properties();
        try {
            FileReader r = new FileReader(intPropsFile);
            props.load(r);
            props.forEach((k, v) -> loadedProps.put((String) k, (String) v));
        } catch (IOException e) {
            logger.log(Logger.WARN, "Could not load internal properties from the file: " + intPropsPath + ", error: " + e.toString());
        }
        new TeamCityProperties() {

            {
                setModel(new BasePropertiesModel() {

                    @NotNull
                    @Override
                    public Map<String, String> getUserDefinedProperties() {
                        return loadedProps;
                    }
                });
            }
        };
    }
}
Also used : BasePropertiesModel(jetbrains.buildServer.serverSide.BasePropertiesModel) FileReader(java.io.FileReader) IOException(java.io.IOException) TeamCityProperties(jetbrains.buildServer.serverSide.TeamCityProperties) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull) TeamCityProperties(jetbrains.buildServer.serverSide.TeamCityProperties)

Example 3 with TeamCityProperties

use of jetbrains.buildServer.serverSide.TeamCityProperties in project teamcity-git by JetBrains.

the class ScriptGenTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    new TeamCityProperties() {

        {
            setModel(new BasePropertiesModel() {
            });
        }
    };
    myTempFiles = new TempFiles();
}
Also used : BasePropertiesModel(jetbrains.buildServer.serverSide.BasePropertiesModel) TeamCityProperties(jetbrains.buildServer.serverSide.TeamCityProperties) TempFiles(jetbrains.buildServer.TempFiles) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with TeamCityProperties

use of jetbrains.buildServer.serverSide.TeamCityProperties in project teamcity-git by JetBrains.

the class GitVcsSupportTest method setUp.

@BeforeMethod
public void setUp() throws IOException {
    myTestLogger.setLogLevel(Level.INFO);
    new TeamCityProperties() {

        {
            setModel(new BasePropertiesModel() {
            });
        }
    };
    myPropertiesToClean = new HashSet<>();
    myContext = new Mockery();
    myTempFiles = new TempFiles();
    myServerPaths = new ServerPaths(myTempFiles.createTempDir().getAbsolutePath());
    myConfigBuilder = new PluginConfigBuilder(myServerPaths);
    myTmpDir = myTempFiles.createTempDir();
    myMainRepositoryDir = new File(myTmpDir, "repo.git");
    copyRepository(dataFile("repo.git"), myMainRepositoryDir);
    copyRepository(dataFile("submodule.git"), new File(myTmpDir, "submodule"));
    copyRepository(dataFile("submodule.git"), new File(myTmpDir, "submodule.git"));
    copyRepository(dataFile("sub-submodule.git"), new File(myTmpDir, "sub-submodule.git"));
    myContext = new Mockery();
    myResetCacheManager = myContext.mock(ResetCacheRegister.class);
    myContext.checking(new Expectations() {

        {
            allowing(myResetCacheManager).registerHandler(with(any(ResetCacheHandler.class)));
        }
    });
}
Also used : Expectations(org.jmock.Expectations) BasePropertiesModel(jetbrains.buildServer.serverSide.BasePropertiesModel) ResetCacheRegister(jetbrains.buildServer.util.cache.ResetCacheRegister) Mockery(org.jmock.Mockery) ServerPaths(jetbrains.buildServer.serverSide.ServerPaths) GitTestUtil.dataFile(jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile) FileUtil.writeFile(jetbrains.buildServer.util.FileUtil.writeFile) File(java.io.File) LockFile(org.eclipse.jgit.internal.storage.file.LockFile) ResetCacheHandler(jetbrains.buildServer.util.cache.ResetCacheHandler) TeamCityProperties(jetbrains.buildServer.serverSide.TeamCityProperties) TempFiles(jetbrains.buildServer.TempFiles) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with TeamCityProperties

use of jetbrains.buildServer.serverSide.TeamCityProperties in project teamcity-git by JetBrains.

the class ServerPluginConfigTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    new TeamCityProperties() {

        {
            setModel(new BasePropertiesModel() {
            });
        }
    };
    myTempFiles = new TempFiles();
    File dotBuildServer = myTempFiles.createTempDir();
    myServerPaths = new ServerPaths(dotBuildServer.getAbsolutePath());
    myPropertiesBeforeTest = GitTestUtil.copyCurrentProperties();
}
Also used : BasePropertiesModel(jetbrains.buildServer.serverSide.BasePropertiesModel) File(java.io.File) ServerPaths(jetbrains.buildServer.serverSide.ServerPaths) TeamCityProperties(jetbrains.buildServer.serverSide.TeamCityProperties) TempFiles(jetbrains.buildServer.TempFiles) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

BasePropertiesModel (jetbrains.buildServer.serverSide.BasePropertiesModel)10 TeamCityProperties (jetbrains.buildServer.serverSide.TeamCityProperties)10 BeforeMethod (org.testng.annotations.BeforeMethod)7 TempFiles (jetbrains.buildServer.TempFiles)6 Mockery (org.jmock.Mockery)6 File (java.io.File)5 ServerPaths (jetbrains.buildServer.serverSide.ServerPaths)5 Expectations (org.jmock.Expectations)3 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)2 ResetCacheHandler (jetbrains.buildServer.util.cache.ResetCacheHandler)2 ResetCacheRegister (jetbrains.buildServer.util.cache.ResetCacheRegister)2 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 AgentRunningBuild (jetbrains.buildServer.agent.AgentRunningBuild)1 BuildAgentConfiguration (jetbrains.buildServer.agent.BuildAgentConfiguration)1 GcErrors (jetbrains.buildServer.buildTriggers.vcs.git.GcErrors)1 GitResetCacheHandler (jetbrains.buildServer.buildTriggers.vcs.git.GitResetCacheHandler)1 RepositoryManager (jetbrains.buildServer.buildTriggers.vcs.git.RepositoryManager)1 AgentMirrorConfig (jetbrains.buildServer.buildTriggers.vcs.git.agent.AgentMirrorConfig)1 RemoteRepositoryUrlInvestigatorImpl (jetbrains.buildServer.buildTriggers.vcs.git.agent.RemoteRepositoryUrlInvestigatorImpl)1