diff options
author | Alexander Kurtakov | 2018-11-07 07:31:37 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2018-11-07 07:31:37 +0000 |
commit | 474e1b4f19c962025a45e436c31680bdadc1c9a0 (patch) | |
tree | 2b49c8751f4fabefd22e21ad711ab4ff361fcb90 | |
parent | 4c7aa45d7bb90b8573538e10e596cfd23645bf81 (diff) | |
download | rt.equinox.bundles-474e1b4f19c962025a45e436c31680bdadc1c9a0.tar.gz rt.equinox.bundles-474e1b4f19c962025a45e436c31680bdadc1c9a0.tar.xz rt.equinox.bundles-474e1b4f19c962025a45e436c31680bdadc1c9a0.zip |
Move away of deprecated StringBufferInputStream in ssh.tests.
Change-Id: I5c5d8fee75d070a4af81517d6580a730b926392c
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
4 files changed, 96 insertions, 33 deletions
diff --git a/bundles/archived/org.eclipse.equinox.console.ssh.tests/.settings/org.eclipse.jdt.ui.prefs b/bundles/archived/org.eclipse.equinox.console.ssh.tests/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000..3a5afc58d --- /dev/null +++ b/bundles/archived/org.eclipse.equinox.console.ssh.tests/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,61 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=true +sp_cleanup.convert_to_enhanced_for_loop=true +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=true +sp_cleanup.remove_redundant_semicolons=true +sp_cleanup.remove_redundant_type_arguments=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=true +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshCommandTests.java b/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshCommandTests.java index 00fc5e7b6..03c0c378d 100755 --- a/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshCommandTests.java +++ b/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshCommandTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 SAP AG + * Copyright (c) 2011, 2018 SAP AG and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,22 +14,23 @@ package org.eclipse.equinox.console.ssh; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.PrintStream; import java.io.PrintWriter; -import java.io.StringBufferInputStream; +import java.nio.charset.StandardCharsets; import java.util.Dictionary; import java.util.HashMap; import java.util.Map; import org.apache.felix.service.command.CommandProcessor; import org.apache.felix.service.command.CommandSession; -import org.apache.sshd.client.channel.ClientChannel; -import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.client.SshClient; +import org.apache.sshd.client.channel.ClientChannel; import org.apache.sshd.client.future.ConnectFuture; import org.apache.sshd.client.future.DefaultConnectFuture; +import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.server.Environment; import org.easymock.EasyMock; import org.eclipse.equinox.console.common.ConsoleInputStream; @@ -118,7 +119,7 @@ public class SshCommandTests { sshSession.addPasswordIdentity(PASSWORD); ClientChannel channel = sshSession.createChannel("shell"); - channel.setIn(new StringBufferInputStream(TEST_CONTENT + "\n")); + channel.setIn(new ByteArrayInputStream((TEST_CONTENT + "\n").getBytes(StandardCharsets.UTF_8))); ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); channel.setOut(byteOut); channel.setErr(byteOut); diff --git a/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshCommandWithConfigAdminTests.java b/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshCommandWithConfigAdminTests.java index 473e758d1..4e55e56e8 100755 --- a/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshCommandWithConfigAdminTests.java +++ b/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshCommandWithConfigAdminTests.java @@ -7,17 +7,18 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Lazar Kirchev, SAP AG - initial API and implementation *******************************************************************************/ package org.eclipse.equinox.console.ssh; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.PrintStream; import java.io.PrintWriter; -import java.io.StringBufferInputStream; +import java.nio.charset.StandardCharsets; import java.util.Dictionary; import java.util.HashMap; import java.util.Hashtable; @@ -73,11 +74,11 @@ public class SshCommandWithConfigAdminTests { initStore(); initJaasConfigFile(); } - + @SuppressWarnings("unchecked") @Test public void testSshCommandWithConfigAdmin() throws Exception { - + CommandSession session = EasyMock.createMock(CommandSession.class); EasyMock.makeThreadSafe(session, true); EasyMock.expect(session.put((String)EasyMock.anyObject(), EasyMock.anyObject())).andReturn(EasyMock.anyObject()).times(5); @@ -101,8 +102,8 @@ public class SshCommandWithConfigAdminTests { EasyMock.expect(context.getProperty(DEFAULT_USER_STORAGE)).andReturn(TRUE).anyTimes(); EasyMock.expect( (ServiceRegistration) context.registerService( - (String)EasyMock.anyObject(), - (ManagedService)EasyMock.anyObject(), + (String)EasyMock.anyObject(), + (ManagedService)EasyMock.anyObject(), (Dictionary<String, ?>)EasyMock.anyObject()) ).andAnswer((IAnswer<ServiceRegistration<?>>) () -> { configurator = (ManagedService) EasyMock.getCurrentArguments()[1]; @@ -110,8 +111,8 @@ public class SshCommandWithConfigAdminTests { }); EasyMock.expect( context.registerService( - (String)EasyMock.anyObject(), - (SshCommand)EasyMock.anyObject(), + (String)EasyMock.anyObject(), + (SshCommand)EasyMock.anyObject(), (Dictionary<String, ?>)EasyMock.anyObject())).andReturn(null); EasyMock.replay(context); @@ -143,7 +144,7 @@ public class SshCommandWithConfigAdminTests { sshSession.addPasswordIdentity(PASSWORD); ClientChannel channel = sshSession.createChannel("shell"); - channel.setIn(new StringBufferInputStream(TEST_CONTENT + "\n")); + channel.setIn(new ByteArrayInputStream((TEST_CONTENT + "\n").getBytes(StandardCharsets.UTF_8))); ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); channel.setOut(byteOut); channel.setErr(byteOut); @@ -163,17 +164,17 @@ public class SshCommandWithConfigAdminTests { command.ssh(new String[] {STOP_COMMAND}); return; } - + @Test public void testSshCommandWithConfigAdminDisabledSsh() throws Exception { testDisabled(false); } - + @Test public void testSshCommandWithConfigAdminDisabledSshByDefault() throws Exception { testDisabled(true); } - + @SuppressWarnings("unchecked") private void testDisabled(boolean isDefault) throws Exception { CommandSession session = EasyMock.createMock(CommandSession.class); @@ -197,8 +198,8 @@ public class SshCommandWithConfigAdminTests { EasyMock.expect(context.getProperty(DEFAULT_USER_STORAGE)).andReturn(TRUE).anyTimes(); EasyMock.expect( (ServiceRegistration) context.registerService( - (String)EasyMock.anyObject(), - (ManagedService)EasyMock.anyObject(), + (String)EasyMock.anyObject(), + (ManagedService)EasyMock.anyObject(), (Dictionary<String, ?>)EasyMock.anyObject()) ).andAnswer((IAnswer<ServiceRegistration<?>>) () -> { configurator = (ManagedService) EasyMock.getCurrentArguments()[1]; @@ -206,8 +207,8 @@ public class SshCommandWithConfigAdminTests { }); EasyMock.expect( context.registerService( - (String)EasyMock.anyObject(), - (SshCommand)EasyMock.anyObject(), + (String)EasyMock.anyObject(), + (SshCommand)EasyMock.anyObject(), (Dictionary<String, ?>)EasyMock.anyObject())).andReturn(null); EasyMock.replay(context); @@ -254,32 +255,32 @@ public class SshCommandWithConfigAdminTests { } return; } - + @After public void cleanUp() { clean(); } - + private void clean() { System.setProperty(USER_STORE_FILE_NAME, ""); File file = new File(STORE_FILE_NAME); if (file.exists()) { file.delete(); } - + System.setProperty(JAAS_CONFIG_PROPERTY_NAME, ""); File jaasConfFile = new File(JAAS_CONFIG_FILE_NAME); if (jaasConfFile.exists()) { jaasConfFile.delete(); } } - + private void initStore() throws Exception { System.setProperty(USER_STORE_FILE_NAME, STORE_FILE_NAME); SecureUserStore.initStorage(); SecureUserStore.putUser(USERNAME, DigestUtil.encrypt(PASSWORD), null); } - + private void initJaasConfigFile() throws Exception { System.setProperty(JAAS_CONFIG_PROPERTY_NAME, JAAS_CONFIG_FILE_NAME); File jaasConfFile = new File(JAAS_CONFIG_FILE_NAME); @@ -297,5 +298,5 @@ public class SshCommandWithConfigAdminTests { } } } - + } diff --git a/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshInputHandlerTests.java b/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshInputHandlerTests.java index 507b70116..98812da6a 100755 --- a/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshInputHandlerTests.java +++ b/bundles/archived/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshInputHandlerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 SAP AG + * Copyright (c) 2011, 2018 SAP AG and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -7,30 +7,30 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Lazar Kirchev, SAP AG - initial API and implementation *******************************************************************************/ package org.eclipse.equinox.console.ssh; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.StringBufferInputStream; +import java.nio.charset.StandardCharsets; import org.eclipse.equinox.console.common.ConsoleInputStream; import org.eclipse.equinox.console.common.ConsoleOutputStream; -import org.eclipse.equinox.console.ssh.SshInputHandler; import org.junit.Assert; import org.junit.Test; public class SshInputHandlerTests { - + private static final long WAIT_TIME = 10000; @Test public void testHandler() throws Exception { - StringBufferInputStream input = new StringBufferInputStream("abcde"); + ByteArrayInputStream input = new ByteArrayInputStream("abcde".getBytes(StandardCharsets.UTF_8)); ConsoleInputStream in = new ConsoleInputStream(); ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ConsoleOutputStream out = new ConsoleOutputStream(byteOut); |