jetbrains.buildServer.serverSide.ServerPaths Java Examples
The following examples show how to use
jetbrains.buildServer.serverSide.ServerPaths.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleRunContainerProviderTest.java From teamcity-kubernetes-plugin with Apache License 2.0 | 6 votes |
@BeforeMethod public void setUp() throws Exception { super.setUp(); myServerSettings = new ServerSettingsImpl(){ @Nullable @Override public String getServerUUID() { return "SERVER-UUID"; } }; final TempFiles tempFiles = new TempFiles(); myServerPaths = new ServerPaths(tempFiles.createTempDir()); myExecutorServices = new SimpleExecutorServices(); myEventDispatcher = EventDispatcher.create(BuildServerListener.class); myNameGenerator = new KubePodNameGeneratorImpl(myServerPaths, myExecutorServices, myEventDispatcher); myContainerProvider = new SimpleRunContainerProvider(myServerSettings); myPodTemplateProviders = new BuildAgentPodTemplateProvidersImpl(myServerSettings, (name, kubeClientParams) -> null); }
Example #2
Source File: DeploymentBuildAgentPodTemplateProviderTest.java From teamcity-kubernetes-plugin with Apache License 2.0 | 6 votes |
@BeforeMethod @Override protected void setUp() throws Exception { super.setUp(); m = new Mockery(); ServerSettings serverSettings = m.mock(ServerSettings.class); KubeAuthStrategyProvider authStrategies = m.mock(KubeAuthStrategyProvider.class); myDeploymentContentProvider = m.mock(DeploymentContentProvider.class); final ExecutorServices executorServices = m.mock(ExecutorServices.class); m.checking(new Expectations(){{ allowing(serverSettings).getServerUUID(); will(returnValue("server uuid")); allowing(authStrategies).get(with(UnauthorizedAccessStrategy.ID)); will(returnValue(myAuthStrategy)); ScheduledExecutorService ses = new ScheduledThreadPoolExecutor(1); allowing(executorServices).getNormalExecutorService(); will(returnValue(ses)); }}); TempFiles tempFiles = new TempFiles(); final ServerPaths serverPaths = new ServerPaths(tempFiles.createTempDir()); final EventDispatcher<BuildServerListener> eventDispatcher = EventDispatcher.create(BuildServerListener.class); myNameGenerator = new KubePodNameGeneratorImpl(serverPaths, executorServices, eventDispatcher); myPodTemplateProvider = new DeploymentBuildAgentPodTemplateProvider(serverSettings, myDeploymentContentProvider); }
Example #3
Source File: TelegramSettingsManager.java From teamcity-telegram-plugin with Apache License 2.0 | 6 votes |
public TelegramSettingsManager(@NotNull ServerPaths paths, @NotNull TelegramBotManager botManager) throws JDOMException, IOException { configDir = Paths.get(paths.getConfigDir()).resolve("_notifications"). resolve("telegram"); configFile = configDir.resolve(CONFIG_FILE_NAME); this.botManager = botManager; initResources(); reloadConfiguration(); changeObserver = new FileWatcher(configFile.toFile()); changeObserver.setSleepingPeriod(10000L); changeObserver.registerListener(this); changeObserver.start(); }
Example #4
Source File: KubePodNameGeneratorImpl.java From teamcity-kubernetes-plugin with Apache License 2.0 | 6 votes |
public KubePodNameGeneratorImpl(@NotNull ServerPaths serverPaths, @NotNull ExecutorServices executorServices, @NotNull EventDispatcher<BuildServerListener> eventDispatcher ){ myIdxStorage = new File(serverPaths.getPluginDataDirectory(), "kubeIdx"); if (!myIdxStorage.exists()){ myIdxStorage.mkdirs(); } if (!myIdxStorage.isDirectory()){ throw new CloudException("Unable to create a directory for kube plugin VM indexes"); } myIsAvailable = new AtomicBoolean(true); loadIdxes(myIdxStorage); eventDispatcher.addListener(new BuildServerAdapter(){ @Override public void serverShutdown() { myIsAvailable.set(false); storeIdxes(); } }); executorServices.getNormalExecutorService().scheduleWithFixedDelay(this::storeIdxes, 60, 60, TimeUnit.SECONDS); }
Example #5
Source File: SlackNotificationSettingsTest.java From tcSlackBuildNotifier with MIT License | 6 votes |
@Ignore @Test public void test_AuthFailNoCredsUsingProxyFromConfig() throws FileNotFoundException, IOException, InterruptedException { String expectedConfigDirectory = "."; ServerPaths serverPaths = mock(ServerPaths.class); when(serverPaths.getConfigDir()).thenReturn(expectedConfigDirectory); SlackNotificationTest test = new SlackNotificationTest(); SlackNotificationMainConfig mainConfig = new SlackNotificationMainConfig(serverPaths); mainConfig.setProxyHost(test.proxy); mainConfig.setProxyPort(test.proxyPort); mainConfig.setProxyShortNames(true); String url = "http://" + test.webserverHost + ":" + test.webserverPort + "/200"; SlackNotification w = new SlackNotificationImpl(url, mainConfig.getProxyConfig()); // w.setProxyUserAndPass("somethingIncorrect", "somethingIncorrect"); SlackNotificationTestServer s = test.startWebServer(); SlackNotificationTestProxyServer p = test.startProxyServerAuth("somethingCorrect", "somethingCorrect"); w.setEnabled(true); w.post(); test.stopWebServer(s); test.stopProxyServer(p); assertTrue(w.getStatus() == HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED); }
Example #6
Source File: SlackNotificationSettingsTest.java From tcSlackBuildNotifier with MIT License | 6 votes |
@Ignore @Test public void test_AuthFailWrongCredsUsingProxyFromConfig() throws FileNotFoundException, IOException, InterruptedException { String expectedConfigDirectory = "."; ServerPaths serverPaths = mock(ServerPaths.class); when(serverPaths.getConfigDir()).thenReturn(expectedConfigDirectory); SlackNotificationTest test = new SlackNotificationTest(); SlackNotificationMainConfig mainConfig = new SlackNotificationMainConfig(serverPaths); mainConfig.setProxyHost(test.proxy); mainConfig.setProxyPort(test.proxyPort); mainConfig.setProxyShortNames(true); String url = "http://" + test.webserverHost + ":" + test.webserverPort + "/200"; SlackNotification w = new SlackNotificationImpl(url, mainConfig.getProxyConfig()); // w.setProxyUserAndPass("somethingIncorrect", "somethingIncorrect"); SlackNotificationTestServer s = test.startWebServer(); SlackNotificationTestProxyServer p = test.startProxyServerAuth("somthingCorrect", "somethingCorrect"); w.setEnabled(true); w.post(); test.stopWebServer(s); test.stopProxyServer(p); assertTrue(w.getStatus() == HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED); }
Example #7
Source File: SlackNotificationMainSettingsTest.java From tcSlackBuildNotifier with MIT License | 6 votes |
@Test public void TestEmptyDefaultsConfig(){ String expectedConfigDirectory = "."; ServerPaths serverPaths = mock(ServerPaths.class); when(serverPaths.getConfigDir()).thenReturn(expectedConfigDirectory); SlackNotificationMainSettings whms = new SlackNotificationMainSettings(server, serverPaths); whms.register(); whms.readFrom(getEmptyDefaultsConfigElement()); String proxy = whms.getProxy(); SlackNotificationProxyConfig whpc = whms.getProxyConfig(); assertTrue(proxy.equals(this.proxyHost)); assertTrue(whpc.getProxyHost().equals(this.proxyHost )); assertTrue(whpc.getProxyPort().equals(this.proxyPort)); assertTrue(whms.getDefaultChannel().equals(this.defaultChannel)); assertTrue(whms.getTeamName().equals(this.teamName)); assertTrue(whms.getToken().equals(this.token)); assertTrue(whms.getIconUrl().equals(this.iconUrl)); assertTrue(whms.getBotName().equals(this.botName)); assertNull(whms.getShowBuildAgent()); assertNull(whms.getShowElapsedBuildTime()); assertTrue(whms.getShowCommits()); assertEquals(5, whms.getMaxCommitsToDisplay()); assertNull(whms.getShowFailureReason()); }
Example #8
Source File: ProjectSlackNotificationsBeanTest.java From tcSlackBuildNotifier with MIT License | 5 votes |
@Test public void JsonBuildSerialisationTest() throws JDOMException, IOException { ServerPaths serverPaths = mock(ServerPaths.class); SlackNotificationMainSettings myMainSettings = new SlackNotificationMainSettings(sBuildServer, serverPaths); framework = SlackNotificationMockingFrameworkImpl.create(BuildStateEnum.BUILD_FINISHED); framework.loadSlackNotificationProjectSettingsFromConfigXml(new File("../tcslackbuildnotifier-core/src/test/resources/project-settings-test-all-states-enabled-with-specific-builds.xml")); ProjectSlackNotificationsBean slacknotificationsConfig = ProjectSlackNotificationsBean.build(framework.getSlackNotificationProjectSettings() ,framework.getSBuildType() ,framework.getServer().getProjectManager().findProjectById("project01"), myMainSettings); System.out.println(ProjectSlackNotificationsBeanJsonSerialiser.serialise(slacknotificationsConfig)); }
Example #9
Source File: ProjectSlackNotificationsBeanTest.java From tcSlackBuildNotifier with MIT License | 5 votes |
@Test public void JsonSerialisationTest() throws JDOMException, IOException { ServerPaths serverPaths = mock(ServerPaths.class); SlackNotificationMainSettings myMainSettings = new SlackNotificationMainSettings(sBuildServer, serverPaths); framework = SlackNotificationMockingFrameworkImpl.create(BuildStateEnum.BUILD_FINISHED); framework.loadSlackNotificationProjectSettingsFromConfigXml(new File("../tcslackbuildnotifier-core/src/test/resources/project-settings-test-all-states-enabled-with-specific-builds.xml")); ProjectSlackNotificationsBean slacknotificationsConfig = ProjectSlackNotificationsBean.build(framework.getSlackNotificationProjectSettings() , framework.getServer().getProjectManager().findProjectById("project01"), myMainSettings); System.out.println(ProjectSlackNotificationsBeanJsonSerialiser.serialise(slacknotificationsConfig)); }
Example #10
Source File: SlackNotificationSettingsControllerTest.java From tcSlackBuildNotifier with MIT License | 5 votes |
@Test public void createMockNotification_constructsValidNotification(){ String expectedConfigDirectory = "."; ServerPaths serverPaths = mock(ServerPaths.class); when(serverPaths.getConfigDir()).thenReturn(expectedConfigDirectory); PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class); SlackNotificationMainConfig config = new SlackNotificationMainConfig(serverPaths); SlackNotificationPayloadManager payloadManager = new SlackNotificationPayloadManager(sBuildServer); SlackNotifierSettingsController controller = new SlackNotifierSettingsController( sBuildServer, serverPaths, webControllerManager, config, payloadManager, pluginDescriptor); SlackNotification notification = controller.createMockNotification( "the team", "#general", "The Bot", "tokenthingy", SlackNotificationMainConfig.DEFAULT_ICONURL, 5, true, true, true, true, "master", true, true, null, null, null, null); assertNotNull(notification); assertEquals("the team", notification.getTeamName()); assertEquals(SlackNotificationMainConfig.DEFAULT_ICONURL, notification.getIconUrl()); }
Example #11
Source File: SlackNotificationMainSettingsTest.java From tcSlackBuildNotifier with MIT License | 5 votes |
@Test public void TestFullConfig(){ String expectedConfigDirectory = "."; ServerPaths serverPaths = mock(ServerPaths.class); when(serverPaths.getConfigDir()).thenReturn(expectedConfigDirectory); SlackNotificationMainSettings whms = new SlackNotificationMainSettings(server, serverPaths); whms.register(); whms.readFrom(getFullConfigElement()); String proxy = whms.getProxy(); SlackNotificationProxyConfig whpc = whms.getProxyConfig(); assertTrue(proxy.equals(this.proxyHost)); assertTrue(whpc.getProxyHost().equals(this.proxyHost )); assertTrue(whpc.getProxyPort().equals(this.proxyPort)); assertTrue(whms.getDefaultChannel().equals(this.defaultChannel)); assertTrue(whms.getTeamName().equals(this.teamName)); assertTrue(whms.getToken().equals(this.token)); assertTrue(whms.getIconUrl().equals(this.iconUrl)); assertTrue(whms.getBotName().equals(this.botName)); assertTrue(whms.getShowBuildAgent()); assertTrue(whms.getShowElapsedBuildTime()); assertFalse(whms.getShowCommits()); assertEquals(15, whms.getMaxCommitsToDisplay()); assertTrue(whms.getShowFailureReason()); Credentials credentials = whpc.getCreds(); assertEquals("some-username", credentials.getUserPrincipal().getName()); assertEquals("some-password", credentials.getPassword()); }
Example #12
Source File: SlackNotificationMainConfig.java From tcSlackBuildNotifier with MIT License | 5 votes |
public SlackNotificationMainConfig(ServerPaths serverPaths) { this.content = new SlackNotificationContentConfig(); this.myConfigDir = new File(serverPaths.getConfigDir(), "slack"); this.myConfigFile = new File(this.myConfigDir, "slack-config.xml"); configFileExists = this.myConfigFile.exists(); reloadConfiguration(); this.myChangeObserver = new FileWatcher(this.myConfigFile); this.myChangeObserver.setSleepingPeriod(10000L); this.myChangeObserver.registerListener(this); this.myChangeObserver.start(); }
Example #13
Source File: SlackNotificationMainSettings.java From tcSlackBuildNotifier with MIT License | 5 votes |
public SlackNotificationMainSettings(SBuildServer server, ServerPaths serverPaths){ this.serverPaths = serverPaths; Loggers.SERVER.debug(NAME + " :: Constructor called"); this.server = server; slackNotificationMainConfig = new SlackNotificationMainConfig(serverPaths); }
Example #14
Source File: ParamUtil.java From teamcity-s3-artifact-storage-plugin with Apache License 2.0 | 5 votes |
/** * Put certificate directory path to param. * * @param serverPaths server paths * @param param param to store certificate directory * @return the new param map. */ @NotNull public static Map<String, String> putSslValues( @NotNull final ServerPaths serverPaths, @NotNull Map<String, String> param ) { final String certDirectory = TrustedCertificatesDirectory.getCertificateDirectoryForProject( serverPaths.getProjectsDir().getPath(), TrustedCertificatesDirectory.ROOT_PROJECT_ID); return SSLParamUtil.putSslDirectory(param, certDirectory); }
Example #15
Source File: S3CleanupExtension.java From teamcity-s3-artifact-storage-plugin with Apache License 2.0 | 5 votes |
public S3CleanupExtension( @NotNull final ServerArtifactHelper helper, @NotNull final ServerArtifactStorageSettingsProvider settingsProvider, @NotNull final ServerPaths serverPaths, @NotNull final ExecutorServices executorServices) { myHelper = helper; mySettingsProvider = settingsProvider; myServerPaths = serverPaths; myExecutorService = executorServices.getLowPriorityExecutorService(); }
Example #16
Source File: S3SettingsController.java From teamcity-s3-artifact-storage-plugin with Apache License 2.0 | 5 votes |
public S3SettingsController(@NotNull final WebControllerManager manager, @NotNull final PluginDescriptor descriptor, @NotNull final ServerPaths serverPaths) { myServerPaths = serverPaths; final String path = descriptor.getPluginResourcesPath(S3Constants.S3_SETTINGS_PATH + ".html"); manager.registerController(path, this); myHandlers.put("buckets", new BucketsResourceHandler()); myHandlers.put("bucketLocation", new BucketLocationHandler()); }
Example #17
Source File: S3ArtifactContentProvider.java From teamcity-s3-artifact-storage-plugin with Apache License 2.0 | 4 votes |
public S3ArtifactContentProvider(@NotNull ServerPaths serverPaths) { myServerPaths = serverPaths; }
Example #18
Source File: S3PreSignedUrlProviderImpl.java From teamcity-s3-artifact-storage-plugin with Apache License 2.0 | 4 votes |
public S3PreSignedUrlProviderImpl(@NotNull ServerPaths serverPaths) { myServerPaths = serverPaths; }