You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2015/07/17 18:18:23 UTC
[03/25] mina-sshd git commit: [SSHD-542] Checkstyle validation
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
index 41b4296..dcec671 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
@@ -60,60 +60,60 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
@Test
public void testReadFromURL() throws IOException {
- URL url=getClass().getResource("sshd_config");
+ URL url = getClass().getResource("sshd_config");
assertNotNull("Cannot locate test file", url);
-
- Properties props=SshConfigFileReader.readConfigFile(url);
+
+ Properties props = SshConfigFileReader.readConfigFile(url);
assertFalse("No properties read", props.isEmpty());
assertTrue("Unexpected commented property data", GenericUtils.isEmpty(props.getProperty("ListenAddress")));
assertTrue("Unexpected non-existing property data", GenericUtils.isEmpty(props.getProperty(getCurrentTestName())));
- String keysList=props.getProperty("HostKey");
+ String keysList = props.getProperty("HostKey");
assertFalse("No host keys", GenericUtils.isEmpty(keysList));
- String[] keys=GenericUtils.split(keysList, ',');
+ String[] keys = GenericUtils.split(keysList, ',');
assertTrue("No multiple keys", GenericUtils.length((Object[]) keys) > 1);
}
@Test
public void testParseCiphersList() {
- List<? extends NamedResource> expected=BaseBuilder.DEFAULT_CIPHERS_PREFERENCE;
- Properties props=initNamedResourceProperties(SshConfigFileReader.CIPHERS_CONFIG_PROP, expected);
- BuiltinCiphers.ParseResult result=SshConfigFileReader.getCiphers(props);
+ List<? extends NamedResource> expected = BaseBuilder.DEFAULT_CIPHERS_PREFERENCE;
+ Properties props = initNamedResourceProperties(SshConfigFileReader.CIPHERS_CONFIG_PROP, expected);
+ BuiltinCiphers.ParseResult result = SshConfigFileReader.getCiphers(props);
testParsedFactoriesList(expected, result.getParsedFactories(), result.getUnsupportedFactories());
}
@Test
public void testParseMacsList() {
- List<? extends NamedResource> expected=BaseBuilder.DEFAULT_MAC_PREFERENCE;
- Properties props=initNamedResourceProperties(SshConfigFileReader.MACS_CONFIG_PROP, expected);
- BuiltinMacs.ParseResult result=SshConfigFileReader.getMacs(props);
+ List<? extends NamedResource> expected = BaseBuilder.DEFAULT_MAC_PREFERENCE;
+ Properties props = initNamedResourceProperties(SshConfigFileReader.MACS_CONFIG_PROP, expected);
+ BuiltinMacs.ParseResult result = SshConfigFileReader.getMacs(props);
testParsedFactoriesList(expected, result.getParsedFactories(), result.getUnsupportedFactories());
}
@Test
public void testParseSignaturesList() {
- List<? extends NamedResource> expected=BaseBuilder.DEFAULT_SIGNATURE_PREFERENCE;
- Properties props=initNamedResourceProperties(SshConfigFileReader.HOST_KEY_ALGORITHMS_CONFIG_PROP, expected);
- BuiltinSignatures.ParseResult result=SshConfigFileReader.getSignatures(props);
+ List<? extends NamedResource> expected = BaseBuilder.DEFAULT_SIGNATURE_PREFERENCE;
+ Properties props = initNamedResourceProperties(SshConfigFileReader.HOST_KEY_ALGORITHMS_CONFIG_PROP, expected);
+ BuiltinSignatures.ParseResult result = SshConfigFileReader.getSignatures(props);
testParsedFactoriesList(expected, result.getParsedFactories(), result.getUnsupportedFactories());
}
@Test
public void testParseKexFactoriesList() {
- List<? extends NamedResource> expected=BaseBuilder.DEFAULT_KEX_PREFERENCE;
- Properties props=initNamedResourceProperties(SshConfigFileReader.KEX_ALGORITHMS_CONFIG_PROP, expected);
- BuiltinDHFactories.ParseResult result=SshConfigFileReader.getKexFactories(props);
+ List<? extends NamedResource> expected = BaseBuilder.DEFAULT_KEX_PREFERENCE;
+ Properties props = initNamedResourceProperties(SshConfigFileReader.KEX_ALGORITHMS_CONFIG_PROP, expected);
+ BuiltinDHFactories.ParseResult result = SshConfigFileReader.getKexFactories(props);
testParsedFactoriesList(expected, result.getParsedFactories(), result.getUnsupportedFactories());
}
@Test
public void testGetCompression() {
- Properties props=new Properties();
+ Properties props = new Properties();
for (CompressionConfigValue expected : CompressionConfigValue.VALUES) {
props.setProperty(SshConfigFileReader.COMPRESSION_PROP, expected.name().toLowerCase());
-
- NamedResource actual=SshConfigFileReader.getCompression(props);
+
+ NamedResource actual = SshConfigFileReader.getCompression(props);
assertNotNull("No match for " + expected.name(), actual);
assertEquals(expected.name(), expected.getName(), actual.getName());
}
@@ -121,22 +121,22 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
@Test
public void testConfigureAbstractFactoryManagerWithDefaults() {
- Properties props=new Properties(); // empty means use defaults
- AbstractFactoryManager expected=new AbstractFactoryManager() {
- @Override
- protected Closeable getInnerCloseable() {
- return null;
- }
- };
+ Properties props = new Properties(); // empty means use defaults
+ AbstractFactoryManager expected = new AbstractFactoryManager() {
+ @Override
+ protected Closeable getInnerCloseable() {
+ return null;
+ }
+ };
// must be lenient since we do not cover the full default spectrum
- AbstractFactoryManager actual=SshConfigFileReader.configure(expected, props, true, true);
+ AbstractFactoryManager actual = SshConfigFileReader.configure(expected, props, true, true);
assertSame("Mismatched configured result", expected, actual);
validateAbstractFactoryManagerConfiguration(expected, props, true);
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testNonLenientCiphersConfiguration() {
- FactoryManager manager=SshConfigFileReader.configureCiphers(
+ FactoryManager manager = SshConfigFileReader.configureCiphers(
new AbstractFactoryManager() {
@Override
protected Closeable getInnerCloseable() {
@@ -149,9 +149,9 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
fail("Unexpected success: " + NamedResource.Utils.getNames(manager.getCipherFactories()));
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testNonLenientSignaturesConfiguration() {
- FactoryManager manager=SshConfigFileReader.configureSignatures(
+ FactoryManager manager = SshConfigFileReader.configureSignatures(
new AbstractFactoryManager() {
@Override
protected Closeable getInnerCloseable() {
@@ -164,9 +164,9 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
fail("Unexpected success: " + NamedResource.Utils.getNames(manager.getSignatureFactories()));
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testNonLenientMacsConfiguration() {
- FactoryManager manager=SshConfigFileReader.configureMacs(
+ FactoryManager manager = SshConfigFileReader.configureMacs(
new AbstractFactoryManager() {
@Override
protected Closeable getInnerCloseable() {
@@ -186,11 +186,11 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
}
private static <E extends Enum<E> & CompressionFactory> void testConfigureCompressionFromStringAcceptsCombinedValues(
- Class<E> facs, Transformer<? super E,String> configValueXformer) {
+ Class<E> facs, Transformer<? super E, String> configValueXformer) {
for (E expected : facs.getEnumConstants()) {
- String value=configValueXformer.transform(expected);
- String prefix=facs.getSimpleName() + "[" + expected.name() + "][" + value + "]";
- FactoryManager manager=SshConfigFileReader.configureCompression(
+ String value = configValueXformer.transform(expected);
+ String prefix = facs.getSimpleName() + "[" + expected.name() + "][" + value + "]";
+ FactoryManager manager = SshConfigFileReader.configureCompression(
new AbstractFactoryManager() {
@Override
protected Closeable getInnerCloseable() {
@@ -200,7 +200,7 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
value,
false,
true);
- List<NamedFactory<Compression>> compressions=manager.getCompressionFactories();
+ List<NamedFactory<Compression>> compressions = manager.getCompressionFactories();
assertEquals(prefix + "(size)", 1, GenericUtils.size(compressions));
assertSame(prefix + "[instance]", expected, compressions.get(0));
}
@@ -219,7 +219,7 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
}
private static <M extends FactoryManager> M validateFactoryManagerCiphers(M manager, String value) {
- BuiltinCiphers.ParseResult result=BuiltinCiphers.parseCiphersList(value);
+ BuiltinCiphers.ParseResult result = BuiltinCiphers.parseCiphersList(value);
validateFactoryManagerFactories(Cipher.class, result.getParsedFactories(), manager.getCipherFactories());
return manager;
}
@@ -229,7 +229,7 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
}
private static <M extends FactoryManager> M validateFactoryManagerSignatures(M manager, String value) {
- BuiltinSignatures.ParseResult result=BuiltinSignatures.parseSignatureList(value);
+ BuiltinSignatures.ParseResult result = BuiltinSignatures.parseSignatureList(value);
validateFactoryManagerFactories(Signature.class, result.getParsedFactories(), manager.getSignatureFactories());
return manager;
}
@@ -239,7 +239,7 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
}
private static <M extends FactoryManager> M validateFactoryManagerMacs(M manager, String value) {
- BuiltinMacs.ParseResult result=BuiltinMacs.parseMacsList(value);
+ BuiltinMacs.ParseResult result = BuiltinMacs.parseMacsList(value);
validateFactoryManagerFactories(Mac.class, result.getParsedFactories(), manager.getMacFactories());
return manager;
}
@@ -249,7 +249,7 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
}
private static <M extends FactoryManager> M validateFactoryManagerCompressions(M manager, String value, boolean lenient) {
- NamedFactory<Compression> factory=CompressionConfigValue.fromName(value);
+ NamedFactory<Compression> factory = CompressionConfigValue.fromName(value);
assertTrue("Unknown compression: " + value, lenient || (factory != null));
if (factory != null) {
validateFactoryManagerFactories(Compression.class, Collections.singletonList(factory), manager.getCompressionFactories());
@@ -257,7 +257,7 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
return manager;
}
- private static <T,F extends NamedFactory<T>> void validateFactoryManagerFactories(Class<T> type, List<? extends F> expected, List<? extends F> actual) {
+ private static <T, F extends NamedFactory<T>> void validateFactoryManagerFactories(Class<T> type, List<? extends F> expected, List<? extends F> actual) {
validateFactoryManagerSettings(type, expected, actual);
}
@@ -273,21 +273,21 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
List<? extends NamedResource> expected, List<T> actual, Collection<String> unsupported) {
assertTrue("Unexpected unsupported factories: " + unsupported, GenericUtils.isEmpty(unsupported));
assertEquals("Mismatched list size", expected.size(), GenericUtils.size(actual));
- for (int index=0; index < expected.size(); index++) {
- NamedResource e=expected.get(index), a=actual.get(index);
- String n1=e.getName(), n2=a.getName();
+ for (int index = 0; index < expected.size(); index++) {
+ NamedResource e = expected.get(index), a = actual.get(index);
+ String n1 = e.getName(), n2 = a.getName();
assertEquals("Mismatched name at index=" + index, n1, n2);
}
-
+
return actual;
}
-
+
private static <R extends NamedResource> Properties initNamedResourceProperties(String key, Collection<? extends R> values) {
return initProperties(key, NamedResource.Utils.getNames(values));
}
private static Properties initProperties(String key, String value) {
- Properties props=new Properties();
+ Properties props = new Properties();
props.setProperty(key, value);
return props;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/config/TimeValueConfigTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/TimeValueConfigTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/TimeValueConfigTest.java
index 795e15c..e70202c 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/TimeValueConfigTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/TimeValueConfigTest.java
@@ -37,17 +37,17 @@ public class TimeValueConfigTest extends BaseTestSupport {
@Test
public void testDurationOf() {
- Object[] values={
+ Object[] values = {
"600", Long.valueOf(TimeUnit.SECONDS.toMillis(600L)),
"10m", Long.valueOf(TimeUnit.MINUTES.toMillis(10L)),
"1h30m", Long.valueOf(TimeUnit.MINUTES.toMillis(90L)),
"2d", Long.valueOf(TimeUnit.DAYS.toMillis(2L)),
"3w", Long.valueOf(TimeUnit.DAYS.toMillis(3L * 7L))
- };
- for (int index=0; index < values.length; index += 2) {
- String s=(String) values[index];
- Number expected=(Number) values[index + 1];
- long actual=TimeValueConfig.durationOf(s);
+ };
+ for (int index = 0; index < values.length; index += 2) {
+ String s = (String) values[index];
+ Number expected = (Number) values[index + 1];
+ long actual = TimeValueConfig.durationOf(s);
assertEquals(s, expected.longValue(), actual);
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/config/keys/BuiltinIdentitiesTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/BuiltinIdentitiesTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/BuiltinIdentitiesTest.java
index c0bb996..63bc2d8 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/BuiltinIdentitiesTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/BuiltinIdentitiesTest.java
@@ -88,16 +88,16 @@ public class BuiltinIdentitiesTest extends BaseTestSupport {
if (!Modifier.isStatic(mods)) {
continue;
}
-
+
if (!Modifier.isFinal(mods)) {
continue;
}
-
+
Class<?> type = f.getType();
if (!String.class.isAssignableFrom(type)) {
continue;
}
-
+
String name = f.getName(), value = (String) f.get(null);
BuiltinIdentities id = BuiltinIdentities.fromName(value);
assertNotNull("No match found for field " + name + "=" + value, id);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
index 2f51a61..d0eaa01 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
@@ -59,11 +59,11 @@ public class KeyUtilsTest extends BaseTestSupport {
try {
KeyPair kp = generateKeyPair(KeyPairProvider.SSH_RSA, keySize);
testKeyPairCloning(KeyPairProvider.SSH_RSA, keySize, kp);
- } catch(GeneralSecurityException e) {
+ } catch (GeneralSecurityException e) {
err = GenericUtils.accumulateException(err, e);
}
}
-
+
if (err != null) {
throw err;
}
@@ -77,11 +77,11 @@ public class KeyUtilsTest extends BaseTestSupport {
try {
KeyPair kp = generateKeyPair(KeyPairProvider.SSH_DSS, keySize);
testKeyPairCloning(KeyPairProvider.SSH_DSS, keySize, kp);
- } catch(GeneralSecurityException e) {
+ } catch (GeneralSecurityException e) {
err = GenericUtils.accumulateException(err, e);
}
}
-
+
if (err != null) {
throw err;
}
@@ -98,11 +98,11 @@ public class KeyUtilsTest extends BaseTestSupport {
try {
KeyPair kp = generateKeyPair(keyType, keySize);
testKeyPairCloning(keyType, keySize, kp);
- } catch(GeneralSecurityException e) {
+ } catch (GeneralSecurityException e) {
err = GenericUtils.accumulateException(err, e);
}
}
-
+
if (err != null) {
throw err;
}
@@ -113,22 +113,22 @@ public class KeyUtilsTest extends BaseTestSupport {
for (DigestInformation info : BuiltinDigests.VALUES) {
final Exception thrown = new DigestException(info.getAlgorithm() + ":" + info.getBlockSize());
final Digest digest = new BaseDigest(info.getAlgorithm(), info.getBlockSize()) {
- @Override
- public byte[] digest() throws Exception {
- throw thrown;
- }
- };
+ @Override
+ public byte[] digest() throws Exception {
+ throw thrown;
+ }
+ };
String actual = KeyUtils.getFingerPrint(new DigestFactory() {
- @Override
- public String getName() {
- return getCurrentTestName();
- }
-
- @Override
- public Digest create() {
- return digest;
- }
- }, getCurrentTestName());
+ @Override
+ public String getName() {
+ return getCurrentTestName();
+ }
+
+ @Override
+ public Digest create() {
+ return digest;
+ }
+ }, getCurrentTestName());
String expected = thrown.getClass().getSimpleName();
assertEquals("Mismatched fingerprint for " + thrown.getMessage(), expected, actual);
}
@@ -141,7 +141,7 @@ public class KeyUtilsTest extends BaseTestSupport {
try {
for (NamedFactory<? extends Digest> f : BuiltinDigests.VALUES) {
KeyUtils.setDefaultFingerPrintFactory(f);
-
+
String data = getClass().getName() + "#" + getCurrentTestName() + "(" + f.getName() + ")";
String expected = KeyUtils.getFingerPrint(f, data);
String actual = KeyUtils.getFingerPrint(data);
@@ -156,12 +156,12 @@ public class KeyUtilsTest extends BaseTestSupport {
try {
System.out.println("generateKeyPair(" + keyType + ")[" + keySize + "]");
return KeyUtils.generateKeyPair(keyType, keySize);
- } catch(GeneralSecurityException e) {
+ } catch (GeneralSecurityException e) {
System.err.println("Failed (" + e.getClass().getSimpleName() + ") to generate key-pair for " + keyType + "/" + keySize + ": " + e.getMessage());
throw e;
}
}
-
+
private static void testKeyPairCloning(String keyType, int keySize, KeyPair kp) throws GeneralSecurityException {
String prefix = keyType + "[" + keySize + "]";
System.out.println("testKeyPairCloning(" + prefix + ")");
@@ -169,16 +169,16 @@ public class KeyUtilsTest extends BaseTestSupport {
KeyPair cloned = KeyUtils.cloneKeyPair(keyType, kp);
assertNotSame(prefix + ": Key pair not cloned", kp, cloned);
assertTrue(prefix + ": Cloned pair not equals", KeyUtils.compareKeyPairs(kp, cloned));
-
+
{
PublicKey k1 = kp.getPublic(), k2 = cloned.getPublic();
assertNotSame(prefix + ": Public key not cloned", k1, k2);
assertTrue(prefix + ": Cloned public key not equals", KeyUtils.compareKeys(k1, k2));
-
+
String f1 = KeyUtils.getFingerPrint(k1), f2 = KeyUtils.getFingerPrint(k2);
assertEquals(prefix + ": Mismatched fingerprints", f1, f2);
}
-
+
{
PrivateKey k1 = kp.getPrivate(), k2 = cloned.getPrivate();
assertNotSame(prefix + ": Private key not cloned", k1, k2);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactoriesTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactoriesTest.java b/sshd-core/src/test/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactoriesTest.java
index f715362..2051553 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactoriesTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactoriesTest.java
@@ -35,12 +35,12 @@ public class BuiltinIoServiceFactoryFactoriesTest extends BaseTestSupport {
@Test
public void testFromFactoryName() {
- for (String name : new String[] { null, "", getCurrentTestName() }) {
+ for (String name : new String[]{null, "", getCurrentTestName()}) {
assertNull("Unexpected success for name='" + name + "'", BuiltinIoServiceFactoryFactories.fromFactoryName(name));
}
for (BuiltinIoServiceFactoryFactories expected : BuiltinIoServiceFactoryFactories.VALUES) {
- String name=expected.getName();
+ String name = expected.getName();
assertSame(name, expected, BuiltinIoServiceFactoryFactories.fromFactoryName(name));
}
}
@@ -48,7 +48,7 @@ public class BuiltinIoServiceFactoryFactoriesTest extends BaseTestSupport {
@Test
public void testFromFactoryClass() {
for (BuiltinIoServiceFactoryFactories expected : BuiltinIoServiceFactoryFactories.VALUES) {
- Class<?> clazz=expected.getFactoryClass();
+ Class<?> clazz = expected.getFactoryClass();
assertSame(clazz.getSimpleName(), expected, BuiltinIoServiceFactoryFactories.fromFactoryClass(clazz));
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactoryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactoryTest.java b/sshd-core/src/test/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactoryTest.java
index d2ead6b..61e1732 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactoryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactoryTest.java
@@ -44,9 +44,9 @@ public class DefaultIoServiceFactoryFactoryTest extends BaseTestSupport {
public void testBuiltinIoServiceFactoryFactories() {
for (BuiltinIoServiceFactoryFactories f : BuiltinIoServiceFactoryFactories.VALUES) {
String name = f.getName();
- IoServiceFactoryFactory factoryInstance =
+ IoServiceFactoryFactory factoryInstance =
DefaultIoServiceFactoryFactory.newInstance(IoServiceFactoryFactory.class, name);
- Class<?> expected = f.getFactoryClass(), actual = factoryInstance.getClass();
+ Class<?> expected = f.getFactoryClass(), actual = factoryInstance.getClass();
assertSame(name, expected, actual);
}
}
@@ -60,25 +60,25 @@ public class DefaultIoServiceFactoryFactoryTest extends BaseTestSupport {
Mockito.when(service.isTerminated()).thenReturn(Boolean.TRUE);
FactoryManager manager = Mockito.mock(FactoryManager.class);
- Mockito.when(manager.getProperties()).thenReturn(Collections.<String,Object>emptyMap());
+ Mockito.when(manager.getProperties()).thenReturn(Collections.<String, Object>emptyMap());
String propName = IoServiceFactoryFactory.class.getName();
for (BuiltinIoServiceFactoryFactories f : BuiltinIoServiceFactoryFactories.VALUES) {
String name = f.getName();
try {
System.setProperty(propName, name);
- for (boolean shutdownOnExit : new boolean[] { true, false } ) {
+ for (boolean shutdownOnExit : new boolean[]{true, false}) {
DefaultIoServiceFactoryFactory defaultFactory = new DefaultIoServiceFactoryFactory(service, shutdownOnExit);
- try(IoServiceFactory factory = defaultFactory.create(manager)) {
+ try (IoServiceFactory factory = defaultFactory.create(manager)) {
assertObjectInstanceOf(name + "/" + shutdownOnExit + " no executor service configuration", ExecutorServiceCarrier.class, factory);
-
- ExecutorServiceCarrier carrier = (ExecutorServiceCarrier) factory;
+
+ ExecutorServiceCarrier carrier = (ExecutorServiceCarrier) factory;
assertSame(name + "/" + shutdownOnExit + " - mismatched executor service", service, carrier.getExecutorService());
assertEquals(name + "/" + shutdownOnExit + " - mismatched shutdown on exit", shutdownOnExit, carrier.isShutdownOnExit());
}
}
- } finally {
+ } finally {
System.clearProperty(propName);
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/kex/AbstractDHTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/kex/AbstractDHTest.java b/sshd-core/src/test/java/org/apache/sshd/common/kex/AbstractDHTest.java
index 22b61c2..63d76f7 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/kex/AbstractDHTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/kex/AbstractDHTest.java
@@ -34,34 +34,34 @@ public class AbstractDHTest extends BaseTestSupport {
@Test
public void testStripLeadingZeroes() {
- byte[] data = { 3, 7, 7, 3, 4, 7 };
+ byte[] data = {3, 7, 7, 3, 4, 7};
for (int index = 1; index <= data.length; index++) {
assertSame("Unexpected sub-array generation for " + Arrays.toString(data), data, AbstractDH.stripLeadingZeroes(data));
if (index < data.length) {
data[index] = 0;
}
}
-
+
Arrays.fill(data, (byte) 0);
try {
byte[] stripped = AbstractDH.stripLeadingZeroes(data);
fail("Unexpected success for all zeroes data: " + Arrays.toString(stripped));
- } catch(IllegalArgumentException expected) {
+ } catch (IllegalArgumentException expected) {
// ignored
}
for (int index = data.length - 1; index > 0; index--) {
data[index] = (byte) index;
-
+
byte[] stripped = AbstractDH.stripLeadingZeroes(data);
- String ds = Arrays.toString(data), ss = Arrays.toString(stripped);
+ String ds = Arrays.toString(data), ss = Arrays.toString(stripped);
assertEquals("Mismatched stripped (" + ss + ") length for " + ds, data.length - index, stripped.length);
- for (int i=index, j=0; j < stripped.length; i++, j++) {
+ for (int i = index, j = 0; j < stripped.length; i++, j++) {
if (data[i] != stripped[j]) {
fail("Mismatched values at stripped index = " + j + ": data=" + ds + ", stripped=" + ss);
}
}
}
-
+
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/kex/BuiltinDHFactoriesTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/kex/BuiltinDHFactoriesTest.java b/sshd-core/src/test/java/org/apache/sshd/common/kex/BuiltinDHFactoriesTest.java
index ba112fb..3af8bba 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/kex/BuiltinDHFactoriesTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/kex/BuiltinDHFactoriesTest.java
@@ -57,30 +57,30 @@ public class BuiltinDHFactoriesTest extends BaseTestSupport {
@Test
public void testAllConstantsCovered() throws Exception {
- Set<BuiltinDHFactories> avail=EnumSet.noneOf(BuiltinDHFactories.class);
- Field[] fields=BuiltinDHFactories.Constants.class.getFields();
+ Set<BuiltinDHFactories> avail = EnumSet.noneOf(BuiltinDHFactories.class);
+ Field[] fields = BuiltinDHFactories.Constants.class.getFields();
for (Field f : fields) {
- String name=(String) f.get(null);
- BuiltinDHFactories value=BuiltinDHFactories.fromFactoryName(name);
+ String name = (String) f.get(null);
+ BuiltinDHFactories value = BuiltinDHFactories.fromFactoryName(name);
assertNotNull("No match found for " + name, value);
assertTrue(name + " re-specified", avail.add(value));
}
-
+
assertEquals("Incomplete coverage", BuiltinDHFactories.VALUES, avail);
}
@Test
public void testParseDHFactorysList() {
- List<String> builtin=NamedResource.Utils.getNameList(BuiltinDHFactories.VALUES);
- List<String> unknown=Arrays.asList(getClass().getPackage().getName(), getClass().getSimpleName(), getCurrentTestName());
- Random rnd=new Random();
- for (int index=0; index < (builtin.size() + unknown.size()); index++) {
+ List<String> builtin = NamedResource.Utils.getNameList(BuiltinDHFactories.VALUES);
+ List<String> unknown = Arrays.asList(getClass().getPackage().getName(), getClass().getSimpleName(), getCurrentTestName());
+ Random rnd = new Random();
+ for (int index = 0; index < (builtin.size() + unknown.size()); index++) {
Collections.shuffle(builtin, rnd);
Collections.shuffle(unknown, rnd);
-
- List<String> weavedList=new ArrayList<String>(builtin.size() + unknown.size());
- for (int bIndex=0, uIndex=0; (bIndex < builtin.size()) || (uIndex < unknown.size()); ) {
- boolean useBuiltin=false;
+
+ List<String> weavedList = new ArrayList<String>(builtin.size() + unknown.size());
+ for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size()); ) {
+ boolean useBuiltin = false;
if (bIndex < builtin.size()) {
useBuiltin = (uIndex < unknown.size()) ? rnd.nextBoolean() : true;
}
@@ -88,17 +88,17 @@ public class BuiltinDHFactoriesTest extends BaseTestSupport {
if (useBuiltin) {
weavedList.add(builtin.get(bIndex));
bIndex++;
- } else if (uIndex < unknown.size()){
+ } else if (uIndex < unknown.size()) {
weavedList.add(unknown.get(uIndex));
uIndex++;
}
}
- String fullList=GenericUtils.join(weavedList, ',');
- ParseResult result=BuiltinDHFactories.parseDHFactoriesList(fullList);
- List<String> parsed=NamedResource.Utils.getNameList(result.getParsedFactories());
- List<String> missing=result.getUnsupportedFactories();
-
+ String fullList = GenericUtils.join(weavedList, ',');
+ ParseResult result = BuiltinDHFactories.parseDHFactoriesList(fullList);
+ List<String> parsed = NamedResource.Utils.getNameList(result.getParsedFactories());
+ List<String> missing = result.getUnsupportedFactories();
+
// makes sure not only that the contents are the same but also the order
assertListEquals(fullList + "[parsed]", builtin, parsed);
assertListEquals(fullList + "[unsupported]", unknown, missing);
@@ -108,8 +108,8 @@ public class BuiltinDHFactoriesTest extends BaseTestSupport {
@Test
public void testResolveFactoryOnBuiltinValues() {
for (DHFactory expected : BuiltinDHFactories.VALUES) {
- String name=expected.getName();
- DHFactory actual=BuiltinDHFactories.resolveFactory(name);
+ String name = expected.getName();
+ DHFactory actual = BuiltinDHFactories.resolveFactory(name);
assertSame(name, expected, actual);
}
}
@@ -120,20 +120,20 @@ public class BuiltinDHFactoriesTest extends BaseTestSupport {
try {
BuiltinDHFactories.registerExtension(expected);
fail("Unexpected sucess for " + expected.getName());
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// expected - ignored
}
}
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testNotAllowedToOverrideRegisteredFactories() {
- DHFactory expected=Mockito.mock(DHFactory.class);
+ DHFactory expected = Mockito.mock(DHFactory.class);
Mockito.when(expected.getName()).thenReturn(getCurrentTestName());
- String name=expected.getName();
+ String name = expected.getName();
try {
- for (int index=1; index <= Byte.SIZE; index++) {
+ for (int index = 1; index <= Byte.SIZE; index++) {
BuiltinDHFactories.registerExtension(expected);
assertEquals("Unexpected success at attempt #" + index, 1, index);
}
@@ -144,18 +144,18 @@ public class BuiltinDHFactoriesTest extends BaseTestSupport {
@Test
public void testResolveFactoryOnRegisteredExtension() {
- DHFactory expected=Mockito.mock(DHFactory.class);
+ DHFactory expected = Mockito.mock(DHFactory.class);
Mockito.when(expected.getName()).thenReturn(getCurrentTestName());
- String name=expected.getName();
+ String name = expected.getName();
try {
assertNull("Extension already registered", BuiltinDHFactories.resolveFactory(name));
BuiltinDHFactories.registerExtension(expected);
- DHFactory actual=BuiltinDHFactories.resolveFactory(name);
+ DHFactory actual = BuiltinDHFactories.resolveFactory(name);
assertSame("Mismatched resolved instance", expected, actual);
} finally {
- DHFactory actual=BuiltinDHFactories.unregisterExtension(name);
+ DHFactory actual = BuiltinDHFactories.unregisterExtension(name);
assertSame("Mismatched unregistered instance", expected, actual);
assertNull("Extension not un-registered", BuiltinDHFactories.resolveFactory(name));
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/kex/KexProposalOptionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/kex/KexProposalOptionTest.java b/sshd-core/src/test/java/org/apache/sshd/common/kex/KexProposalOptionTest.java
index 33418ca..b0b19af 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/kex/KexProposalOptionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/kex/KexProposalOptionTest.java
@@ -42,15 +42,15 @@ public class KexProposalOptionTest extends BaseTestSupport {
@Test
public void testFromName() {
- for (String n : new String[] { null, "", getCurrentTestName() }) {
+ for (String n : new String[]{null, "", getCurrentTestName()}) {
KexProposalOption o = KexProposalOption.fromName(n);
assertNull("Unexpected value for name='" + n + "'", o);
}
for (KexProposalOption expected : KexProposalOption.VALUES) {
String n = expected.name();
-
- for (int index=0; index < n.length(); index++) {
+
+ for (int index = 0; index < n.length(); index++) {
KexProposalOption actual = KexProposalOption.fromName(n);
assertSame("Mismatched option for name=" + n, expected, actual);
n = shuffleCase(n); // prepare for next iteration
@@ -60,11 +60,11 @@ public class KexProposalOptionTest extends BaseTestSupport {
@Test
public void testFromProposalIndex() {
- for (int index : new int[] { (-1), KexProposalOption.VALUES.size() }) {
+ for (int index : new int[]{(-1), KexProposalOption.VALUES.size()}) {
KexProposalOption o = KexProposalOption.fromProposalIndex(index);
assertNull("Unexpected value for index=" + index, o);
}
-
+
for (KexProposalOption expected : KexProposalOption.VALUES) {
int index = expected.getProposalIndex();
KexProposalOption actual = KexProposalOption.fromProposalIndex(index);
@@ -74,14 +74,14 @@ public class KexProposalOptionTest extends BaseTestSupport {
@Test
public void testByProposalIndexSortOrder() {
- for (int index=0; index < KexProposalOption.VALUES.size(); index++) {
+ for (int index = 0; index < KexProposalOption.VALUES.size(); index++) {
if (index < 1) {
continue;
}
-
+
KexProposalOption o1 = KexProposalOption.VALUES.get(index - 1);
KexProposalOption o2 = KexProposalOption.VALUES.get(index);
-
+
int i1 = o1.getProposalIndex(), i2 = o2.getProposalIndex();
assertTrue("Non increasing index for " + o1 + "[" + i1 + "] vs. " + o2 + "[" + i2 + "]", i1 < i2);
}
@@ -89,26 +89,26 @@ public class KexProposalOptionTest extends BaseTestSupport {
@Test
public void testAllConstantsCovered() throws Exception {
- Field[] fields=Constants.class.getFields();
+ Field[] fields = Constants.class.getFields();
- Collection<KexProposalOption> options = EnumSet.allOf(KexProposalOption.class);
+ Collection<KexProposalOption> options = EnumSet.allOf(KexProposalOption.class);
for (Field f : fields) {
int mods = f.getModifiers();
if (!Modifier.isStatic(mods)) {
continue;
}
-
+
Class<?> type = f.getType();
if (!Integer.TYPE.isAssignableFrom(type)) {
continue;
}
-
+
int index = f.getInt(null);
KexProposalOption o = KexProposalOption.fromProposalIndex(index);
assertNotNull("No matching option for index=" + index, o);
assertTrue("Option not in known options: " + o, options.remove(o));
}
-
+
assertTrue("Not all options covered: " + options, GenericUtils.isEmpty(options));
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/keyprovider/KeyPairProviderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/keyprovider/KeyPairProviderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/keyprovider/KeyPairProviderTest.java
index 01378fd..0842229 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/keyprovider/KeyPairProviderTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/keyprovider/KeyPairProviderTest.java
@@ -46,8 +46,8 @@ public class KeyPairProviderTest extends BaseTestSupport {
KeyPairProvider provider = KeyPairProvider.EMPTY_KEYPAIR_PROVIDER;
assertTrue("Non empty loaded keys", GenericUtils.isEmpty(provider.loadKeys()));
assertTrue("Non empty key type", GenericUtils.isEmpty(provider.getKeyTypes()));
-
- for (String keyType : new String[] { null, "", getCurrentTestName() }) {
+
+ for (String keyType : new String[]{null, "", getCurrentTestName()}) {
assertNull("Unexpected key-pair loaded for type='" + keyType + "'", provider.loadKey(keyType));
}
}
@@ -56,22 +56,22 @@ public class KeyPairProviderTest extends BaseTestSupport {
public void testMapToKeyPairProvider() {
final PublicKey pubKey = Mockito.mock(PublicKey.class);
final PrivateKey prvKey = Mockito.mock(PrivateKey.class);
- final String[] testKeys = { getCurrentTestName(), getClass().getSimpleName() };
- Map<String,KeyPair> pairsMap=new TreeMap<String,KeyPair>(String.CASE_INSENSITIVE_ORDER) {
- private static final long serialVersionUID = 1L; // we're not serializing it
-
- {
- for (String keyType : testKeys) {
- put(keyType, new KeyPair(pubKey, prvKey));
- }
+ final String[] testKeys = {getCurrentTestName(), getClass().getSimpleName()};
+ Map<String, KeyPair> pairsMap = new TreeMap<String, KeyPair>(String.CASE_INSENSITIVE_ORDER) {
+ private static final long serialVersionUID = 1L; // we're not serializing it
+
+ {
+ for (String keyType : testKeys) {
+ put(keyType, new KeyPair(pubKey, prvKey));
}
- };
+ }
+ };
KeyPairProvider provider = MappedKeyPairProvider.MAP_TO_KEY_PAIR_PROVIDER.transform(pairsMap);
assertEquals("Key types", pairsMap.keySet(), provider.getKeyTypes());
assertEquals("Key pairs", pairsMap.values(), provider.loadKeys());
-
- for (Map.Entry<String,KeyPair> pairEntry : pairsMap.entrySet()) {
- String keyType = pairEntry.getKey();
+
+ for (Map.Entry<String, KeyPair> pairEntry : pairsMap.entrySet()) {
+ String keyType = pairEntry.getKey();
KeyPair expected = pairEntry.getValue(), actual = provider.loadKey(keyType);
assertSame(keyType, expected, actual);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/mac/BuiltinMacsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/mac/BuiltinMacsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/mac/BuiltinMacsTest.java
index d75e29b..b2933e9 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/mac/BuiltinMacsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/mac/BuiltinMacsTest.java
@@ -58,30 +58,30 @@ public class BuiltinMacsTest extends BaseTestSupport {
@Test
public void testAllConstantsCovered() throws Exception {
- Set<BuiltinMacs> avail=EnumSet.noneOf(BuiltinMacs.class);
- Field[] fields=BuiltinMacs.Constants.class.getFields();
+ Set<BuiltinMacs> avail = EnumSet.noneOf(BuiltinMacs.class);
+ Field[] fields = BuiltinMacs.Constants.class.getFields();
for (Field f : fields) {
- String name=(String) f.get(null);
- BuiltinMacs value=BuiltinMacs.fromFactoryName(name);
+ String name = (String) f.get(null);
+ BuiltinMacs value = BuiltinMacs.fromFactoryName(name);
assertNotNull("No match found for " + name, value);
assertTrue(name + " re-specified", avail.add(value));
}
-
+
assertEquals("Incomplete coverage", BuiltinMacs.VALUES, avail);
}
@Test
public void testParseMacsList() {
- List<String> builtin=NamedResource.Utils.getNameList(BuiltinMacs.VALUES);
- List<String> unknown=Arrays.asList(getClass().getPackage().getName(), getClass().getSimpleName(), getCurrentTestName());
- Random rnd=new Random();
- for (int index=0; index < (builtin.size() + unknown.size()); index++) {
+ List<String> builtin = NamedResource.Utils.getNameList(BuiltinMacs.VALUES);
+ List<String> unknown = Arrays.asList(getClass().getPackage().getName(), getClass().getSimpleName(), getCurrentTestName());
+ Random rnd = new Random();
+ for (int index = 0; index < (builtin.size() + unknown.size()); index++) {
Collections.shuffle(builtin, rnd);
Collections.shuffle(unknown, rnd);
-
- List<String> weavedList=new ArrayList<String>(builtin.size() + unknown.size());
- for (int bIndex=0, uIndex=0; (bIndex < builtin.size()) || (uIndex < unknown.size()); ) {
- boolean useBuiltin=false;
+
+ List<String> weavedList = new ArrayList<String>(builtin.size() + unknown.size());
+ for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size()); ) {
+ boolean useBuiltin = false;
if (bIndex < builtin.size()) {
useBuiltin = (uIndex < unknown.size()) ? rnd.nextBoolean() : true;
}
@@ -89,17 +89,17 @@ public class BuiltinMacsTest extends BaseTestSupport {
if (useBuiltin) {
weavedList.add(builtin.get(bIndex));
bIndex++;
- } else if (uIndex < unknown.size()){
+ } else if (uIndex < unknown.size()) {
weavedList.add(unknown.get(uIndex));
uIndex++;
}
}
- String fullList=GenericUtils.join(weavedList, ',');
- ParseResult result=BuiltinMacs.parseMacsList(fullList);
- List<String> parsed=NamedResource.Utils.getNameList(result.getParsedFactories());
- List<String> missing=result.getUnsupportedFactories();
-
+ String fullList = GenericUtils.join(weavedList, ',');
+ ParseResult result = BuiltinMacs.parseMacsList(fullList);
+ List<String> parsed = NamedResource.Utils.getNameList(result.getParsedFactories());
+ List<String> missing = result.getUnsupportedFactories();
+
// makes sure not only that the contents are the same but also the order
assertListEquals(fullList + "[parsed]", builtin, parsed);
assertListEquals(fullList + "[unsupported]", unknown, missing);
@@ -109,8 +109,8 @@ public class BuiltinMacsTest extends BaseTestSupport {
@Test
public void testResolveFactoryOnBuiltinValues() {
for (MacFactory expected : BuiltinMacs.VALUES) {
- String name=expected.getName();
- MacFactory actual=BuiltinMacs.resolveFactory(name);
+ String name = expected.getName();
+ MacFactory actual = BuiltinMacs.resolveFactory(name);
assertSame(name, expected, actual);
}
}
@@ -121,20 +121,20 @@ public class BuiltinMacsTest extends BaseTestSupport {
try {
BuiltinMacs.registerExtension(expected);
fail("Unexpected sucess for " + expected.getName());
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// expected - ignored
}
}
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testNotAllowedToOverrideRegisteredFactories() {
- MacFactory expected=Mockito.mock(MacFactory.class);
+ MacFactory expected = Mockito.mock(MacFactory.class);
Mockito.when(expected.getName()).thenReturn(getCurrentTestName());
- String name=expected.getName();
+ String name = expected.getName();
try {
- for (int index=1; index <= Byte.SIZE; index++) {
+ for (int index = 1; index <= Byte.SIZE; index++) {
BuiltinMacs.registerExtension(expected);
assertEquals("Unexpected success at attempt #" + index, 1, index);
}
@@ -145,32 +145,21 @@ public class BuiltinMacsTest extends BaseTestSupport {
@Test
public void testResolveFactoryOnRegisteredExtension() {
- MacFactory expected=Mockito.mock(MacFactory.class);
+ MacFactory expected = Mockito.mock(MacFactory.class);
Mockito.when(expected.getName()).thenReturn(getCurrentTestName());
- String name=expected.getName();
+ String name = expected.getName();
try {
assertNull("Extension already registered", BuiltinMacs.resolveFactory(name));
BuiltinMacs.registerExtension(expected);
- MacFactory actual=BuiltinMacs.resolveFactory(name);
+ MacFactory actual = BuiltinMacs.resolveFactory(name);
assertSame("Mismatched resolved instance", expected, actual);
} finally {
- MacFactory actual=BuiltinMacs.unregisterExtension(name);
+ MacFactory actual = BuiltinMacs.unregisterExtension(name);
assertSame("Mismatched unregistered instance", expected, actual);
assertNull("Extension not un-registered", BuiltinMacs.resolveFactory(name));
}
}
- @Test
- public void testFac2NamedTransformer() {
- assertNull("Invalid null transformation", MacFactory.FAC2NAMED.transform(null));
- for (MacFactory expected : BuiltinMacs.VALUES) {
- NamedFactory<Mac> actual=MacFactory.FAC2NAMED.transform(expected);
- assertSame("Mismatched transformed instance for " + expected.getName(), expected, actual);
- }
-
- MacFactory mock=Mockito.mock(MacFactory.class);
- assertSame("Mismatched transformed mocked instance", mock, MacFactory.FAC2NAMED.transform(mock));
- }
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java b/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
index d7364f1..bcd06d3 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
@@ -23,6 +23,7 @@ import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
+import com.jcraft.jsch.JSch;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.cipher.Cipher;
@@ -40,8 +41,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runners.MethodSorters;
-import com.jcraft.jsch.JSch;
-
/**
* Test Cipher algorithms.
*
@@ -124,7 +123,7 @@ public class MacTest extends BaseTestSupport {
sshd.setShellFactory(new EchoShellFactory());
sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
sshd.start();
- port = sshd.getPort();
+ port = sshd.getPort();
}
@After
@@ -141,7 +140,7 @@ public class MacTest extends BaseTestSupport {
JSch.setConfig("cipher.c2s", "aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,none");
JSch.setConfig("mac.s2c", "hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96,hmac-sha2-512");
JSch.setConfig("mac.c2s", "hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96,hmac-sha2-512");
- JSch.setConfig("hmac-sha2-512", "com.jcraft.jsch.jce.HMACSHA512");
+ JSch.setConfig("hmac-sha2-512", "com.jcraft.jsch.jce.HMACSHA512");
com.jcraft.jsch.Session s = sch.getSession(getCurrentTestName(), "localhost", port);
try {
s.setUserInfo(new SimpleUserInfo(getCurrentTestName()));
@@ -149,10 +148,10 @@ public class MacTest extends BaseTestSupport {
com.jcraft.jsch.Channel c = s.openChannel("shell");
c.connect();
- try(OutputStream os = c.getOutputStream();
- InputStream is = c.getInputStream()) {
+ try (OutputStream os = c.getOutputStream();
+ InputStream is = c.getInputStream()) {
- String expected = "this is my command\n";
+ String expected = "this is my command\n";
byte[] bytes = expected.getBytes(StandardCharsets.UTF_8);
byte[] data = new byte[bytes.length + Long.SIZE];
for (int i = 0; i < 10; i++) {
@@ -170,16 +169,15 @@ public class MacTest extends BaseTestSupport {
}
}
- static boolean checkCipher(String cipher){
- try{
- Class<?> c=Class.forName(cipher);
- com.jcraft.jsch.Cipher _c = (com.jcraft.jsch.Cipher)(c.newInstance());
+ static boolean checkCipher(String cipher) {
+ try {
+ Class<?> c = Class.forName(cipher);
+ com.jcraft.jsch.Cipher _c = (com.jcraft.jsch.Cipher) (c.newInstance());
_c.init(com.jcraft.jsch.Cipher.ENCRYPT_MODE,
new byte[_c.getBlockSize()],
new byte[_c.getIVSize()]);
return true;
- }
- catch(Exception e){
+ } catch (Exception e) {
return false;
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/session/AbstractSessionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/session/AbstractSessionTest.java b/sshd-core/src/test/java/org/apache/sshd/common/session/AbstractSessionTest.java
index ae5c805..adc34de 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/session/AbstractSessionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/session/AbstractSessionTest.java
@@ -116,41 +116,51 @@ public class AbstractSessionTest extends BaseTestSupport {
public MySession() {
super(true, SshServer.setUpDefaultServer(), null);
}
+
@Override
protected void handleMessage(Buffer buffer) throws Exception {
// ignored
}
+
@Override
protected boolean readIdentification(Buffer buffer) {
return false;
}
+
public String doReadIdentification(Buffer buffer) {
return super.doReadIdentification(buffer, false);
}
+
@Override
protected byte[] sendKexInit() throws IOException {
return GenericUtils.EMPTY_BYTE_ARRAY;
}
+
@Override
protected void receiveKexInit(Map<KexProposalOption, String> proposal, byte[] seed) throws IOException {
// ignored
}
+
@Override
protected void setKexSeed(byte... seed) {
// ignored
}
+
@Override
protected String resolveAvailableSignaturesProposal(FactoryManager manager) {
return null;
}
+
@Override
protected void checkKeys() {
// ignored
}
+
@Override
public void startService(String name) throws Exception {
// ignored
}
+
@Override
public void resetIdleTimeout() {
// ignored
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/signature/AbstractSignatureFactoryTestSupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/signature/AbstractSignatureFactoryTestSupport.java b/sshd-core/src/test/java/org/apache/sshd/common/signature/AbstractSignatureFactoryTestSupport.java
index 6376ccb..48fb637 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/signature/AbstractSignatureFactoryTestSupport.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/signature/AbstractSignatureFactoryTestSupport.java
@@ -32,7 +32,6 @@ import org.apache.sshd.common.RuntimeSshException;
import org.apache.sshd.common.config.keys.PublicKeyEntryDecoder;
import org.apache.sshd.common.keyprovider.AbstractKeyPairProvider;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
-import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.util.BaseTestSupport;
@@ -82,13 +81,13 @@ public abstract class AbstractSignatureFactoryTestSupport extends BaseTestSuppor
}
}
- protected void testKeyPairProvider(PublicKeyEntryDecoder<?,?> decoder, List<NamedFactory<Signature>> signatures) throws Exception {
+ protected void testKeyPairProvider(PublicKeyEntryDecoder<?, ?> decoder, List<NamedFactory<Signature>> signatures) throws Exception {
testKeyPairProvider(getKeyType(), getKeySize(), decoder, signatures);
}
protected void testKeyPairProvider(
- final String keyName, final int keySize, final PublicKeyEntryDecoder<?,?> decoder, List<NamedFactory<Signature>> signatures)
- throws Exception {
+ final String keyName, final int keySize, final PublicKeyEntryDecoder<?, ?> decoder, List<NamedFactory<Signature>> signatures)
+ throws Exception {
testKeyPairProvider(keyName, new Factory<Iterable<KeyPair>>() {
@Override
public Iterable<KeyPair> create() {
@@ -105,7 +104,7 @@ public abstract class AbstractSignatureFactoryTestSupport extends BaseTestSuppor
protected void testKeyPairProvider(
final String keyName, final Factory<Iterable<KeyPair>> factory, List<NamedFactory<Signature>> signatures)
- throws Exception {
+ throws Exception {
final Iterable<KeyPair> iter = factory.create();
testKeyPairProvider(new AbstractKeyPairProvider() {
@Override
@@ -123,7 +122,7 @@ public abstract class AbstractSignatureFactoryTestSupport extends BaseTestSuppor
client = SshClient.setUpDefaultClient();
client.setSignatureFactories(signatures);
client.start();
- try(ClientSession s = client.connect(getCurrentTestName(), "localhost", port).verify(7L, TimeUnit.SECONDS).getSession()) {
+ try (ClientSession s = client.connect(getCurrentTestName(), "localhost", port).verify(7L, TimeUnit.SECONDS).getSession()) {
s.addPasswordIdentity(getCurrentTestName());
// allow a rather long timeout since generating some keys may take some time
s.auth().verify(30L, TimeUnit.SECONDS);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/signature/BuiltinSignaturesTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/signature/BuiltinSignaturesTest.java b/sshd-core/src/test/java/org/apache/sshd/common/signature/BuiltinSignaturesTest.java
index f7aa56b..7592b93 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/signature/BuiltinSignaturesTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/signature/BuiltinSignaturesTest.java
@@ -55,16 +55,16 @@ public class BuiltinSignaturesTest extends BaseTestSupport {
@Test
public void testParseSignaturesList() {
- List<String> builtin=NamedResource.Utils.getNameList(BuiltinSignatures.VALUES);
- List<String> unknown=Arrays.asList(getClass().getPackage().getName(), getClass().getSimpleName(), getCurrentTestName());
- Random rnd=new Random();
- for (int index=0; index < (builtin.size() + unknown.size()); index++) {
+ List<String> builtin = NamedResource.Utils.getNameList(BuiltinSignatures.VALUES);
+ List<String> unknown = Arrays.asList(getClass().getPackage().getName(), getClass().getSimpleName(), getCurrentTestName());
+ Random rnd = new Random();
+ for (int index = 0; index < (builtin.size() + unknown.size()); index++) {
Collections.shuffle(builtin, rnd);
Collections.shuffle(unknown, rnd);
-
- List<String> weavedList=new ArrayList<String>(builtin.size() + unknown.size());
- for (int bIndex=0, uIndex=0; (bIndex < builtin.size()) || (uIndex < unknown.size()); ) {
- boolean useBuiltin=false;
+
+ List<String> weavedList = new ArrayList<String>(builtin.size() + unknown.size());
+ for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size()); ) {
+ boolean useBuiltin = false;
if (bIndex < builtin.size()) {
useBuiltin = (uIndex < unknown.size()) ? rnd.nextBoolean() : true;
}
@@ -72,17 +72,17 @@ public class BuiltinSignaturesTest extends BaseTestSupport {
if (useBuiltin) {
weavedList.add(builtin.get(bIndex));
bIndex++;
- } else if (uIndex < unknown.size()){
+ } else if (uIndex < unknown.size()) {
weavedList.add(unknown.get(uIndex));
uIndex++;
}
}
- String fullList=GenericUtils.join(weavedList, ',');
- ParseResult result=BuiltinSignatures.parseSignatureList(fullList);
- List<String> parsed=NamedResource.Utils.getNameList(result.getParsedFactories());
- List<String> missing=result.getUnsupportedFactories();
-
+ String fullList = GenericUtils.join(weavedList, ',');
+ ParseResult result = BuiltinSignatures.parseSignatureList(fullList);
+ List<String> parsed = NamedResource.Utils.getNameList(result.getParsedFactories());
+ List<String> missing = result.getUnsupportedFactories();
+
// makes sure not only that the contents are the same but also the order
assertListEquals(fullList + "[parsed]", builtin, parsed);
assertListEquals(fullList + "[unsupported]", unknown, missing);
@@ -92,8 +92,8 @@ public class BuiltinSignaturesTest extends BaseTestSupport {
@Test
public void testResolveFactoryOnBuiltinValues() {
for (SignatureFactory expected : BuiltinSignatures.VALUES) {
- String name=expected.getName();
- SignatureFactory actual=BuiltinSignatures.resolveFactory(name);
+ String name = expected.getName();
+ SignatureFactory actual = BuiltinSignatures.resolveFactory(name);
assertSame(name, expected, actual);
}
}
@@ -104,20 +104,20 @@ public class BuiltinSignaturesTest extends BaseTestSupport {
try {
BuiltinSignatures.registerExtension(expected);
fail("Unexpected sucess for " + expected.getName());
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// expected - ignored
}
}
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testNotAllowedToOverrideRegisteredFactories() {
- SignatureFactory expected=Mockito.mock(SignatureFactory.class);
+ SignatureFactory expected = Mockito.mock(SignatureFactory.class);
Mockito.when(expected.getName()).thenReturn(getCurrentTestName());
- String name=expected.getName();
+ String name = expected.getName();
try {
- for (int index=1; index <= Byte.SIZE; index++) {
+ for (int index = 1; index <= Byte.SIZE; index++) {
BuiltinSignatures.registerExtension(expected);
assertEquals("Unexpected success at attempt #" + index, 1, index);
}
@@ -128,32 +128,21 @@ public class BuiltinSignaturesTest extends BaseTestSupport {
@Test
public void testResolveFactoryOnRegisteredExtension() {
- SignatureFactory expected=Mockito.mock(SignatureFactory.class);
+ SignatureFactory expected = Mockito.mock(SignatureFactory.class);
Mockito.when(expected.getName()).thenReturn(getCurrentTestName());
- String name=expected.getName();
+ String name = expected.getName();
try {
assertNull("Extension already registered", BuiltinSignatures.resolveFactory(name));
BuiltinSignatures.registerExtension(expected);
- SignatureFactory actual=BuiltinSignatures.resolveFactory(name);
+ SignatureFactory actual = BuiltinSignatures.resolveFactory(name);
assertSame("Mismatched resolved instance", expected, actual);
} finally {
- SignatureFactory actual=BuiltinSignatures.unregisterExtension(name);
+ SignatureFactory actual = BuiltinSignatures.unregisterExtension(name);
assertSame("Mismatched unregistered instance", expected, actual);
assertNull("Extension not un-registered", BuiltinSignatures.resolveFactory(name));
}
}
- @Test
- public void testFac2NamedTransformer() {
- assertNull("Invalid null transformation", SignatureFactory.FAC2NAMED.transform(null));
- for (SignatureFactory expected : BuiltinSignatures.VALUES) {
- NamedFactory<Signature> actual=SignatureFactory.FAC2NAMED.transform(expected);
- assertSame("Mismatched transformed instance for " + expected.getName(), expected, actual);
- }
-
- SignatureFactory mock=Mockito.mock(SignatureFactory.class);
- assertSame("Mismatched transformed mocked instance", mock, SignatureFactory.FAC2NAMED.transform(mock));
- }
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureDSSFactoryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureDSSFactoryTest.java b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureDSSFactoryTest.java
index 0e434e9..4b9fe68 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureDSSFactoryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureDSSFactoryTest.java
@@ -50,7 +50,7 @@ public class SignatureDSSFactoryTest extends AbstractSignatureFactoryTestSupport
public SignatureDSSFactoryTest(int keySize) {
super(KeyPairProvider.SSH_DSS, keySize);
}
-
+
@Test
public void testDSSPublicKeyAuth() throws Exception {
testKeyPairProvider(DSSPublicKeyEntryDecoder.INSTANCE, FACTORIES);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureECDSAFactoryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureECDSAFactoryTest.java b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureECDSAFactoryTest.java
index 3c004df..fb32b21 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureECDSAFactoryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureECDSAFactoryTest.java
@@ -37,6 +37,7 @@ import org.junit.runners.Parameterized.Parameters;
/**
* Makes sure that all the available {@link Signature} implementations are tested
+ *
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -48,13 +49,13 @@ public class SignatureECDSAFactoryTest extends AbstractSignatureFactoryTestSuppo
BuiltinSignatures.nistp256,
BuiltinSignatures.nistp384,
BuiltinSignatures.nistp521
- ));
+ ));
@Parameters(name = "keySize={0}")
public static Collection<Object[]> parameters() {
return parameterize(ECCurves.VALUES);
}
-
+
public SignatureECDSAFactoryTest(ECCurves curve) {
super(curve.getName(), curve.getKeySize());
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSAFactoryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSAFactoryTest.java b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSAFactoryTest.java
index 573f0ce..49cf8ea 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSAFactoryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSAFactoryTest.java
@@ -50,7 +50,7 @@ public class SignatureRSAFactoryTest extends AbstractSignatureFactoryTestSupport
public SignatureRSAFactoryTest(int keySize) {
super(KeyPairProvider.SSH_RSA, keySize);
}
-
+
@Test
public void testRSAPublicKeyAuth() throws Exception {
testKeyPairProvider(RSAPublicKeyDecoder.INSTANCE, FACTORIES);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java
index 4e1bb9a..1621b84 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java
@@ -45,87 +45,87 @@ public class CloseableUtilsTest extends BaseTestSupport {
@Test
public void testCloseImmediateNotCalledIfAlreadyClosed() throws IOException {
- Closeable closeable=new CloseableUtils.IoBaseCloseable() {
- @Override
- public CloseFuture close(boolean immediately) {
- fail("Unexpected call to close(" + immediately + ")");
- return null;
- }
-
- @Override
- public boolean isClosed() {
- return true;
- }
-
- @Override
- public boolean isClosing() {
- return false;
- }
- };
- closeable.close();
+ Closeable closeable = new CloseableUtils.IoBaseCloseable() {
+ @Override
+ public CloseFuture close(boolean immediately) {
+ fail("Unexpected call to close(" + immediately + ")");
+ return null;
+ }
+
+ @Override
+ public boolean isClosed() {
+ return true;
+ }
+
+ @Override
+ public boolean isClosing() {
+ return false;
+ }
+ };
+ closeable.close();
}
@Test
public void testCloseImmediateNotCalledIfIsClosing() throws IOException {
- Closeable closeable=new CloseableUtils.IoBaseCloseable() {
- @Override
- public CloseFuture close(boolean immediately) {
- fail("Unexpected call to close(" + immediately + ")");
- return null;
- }
-
- @Override
- public boolean isClosed() {
- return false;
- }
-
- @Override
- public boolean isClosing() {
- return true;
- }
- };
- closeable.close();
+ Closeable closeable = new CloseableUtils.IoBaseCloseable() {
+ @Override
+ public CloseFuture close(boolean immediately) {
+ fail("Unexpected call to close(" + immediately + ")");
+ return null;
+ }
+
+ @Override
+ public boolean isClosed() {
+ return false;
+ }
+
+ @Override
+ public boolean isClosing() {
+ return true;
+ }
+ };
+ closeable.close();
}
-
+
@Test
public void testCloseImmediateCalledAndWait() throws Exception {
- final DefaultCloseFuture future=new DefaultCloseFuture(this);
- final AtomicInteger callsCount=new AtomicInteger(0);
- final Closeable closeable=new CloseableUtils.IoBaseCloseable() {
- @Override
- public CloseFuture close(boolean immediately) {
- assertTrue("Closure is not immediate", immediately);
- assertEquals("Multiple close immediate calls", 1, callsCount.incrementAndGet());
- return future;
- }
-
- @Override
- public boolean isClosed() {
- return false;
- }
-
+ final DefaultCloseFuture future = new DefaultCloseFuture(this);
+ final AtomicInteger callsCount = new AtomicInteger(0);
+ final Closeable closeable = new CloseableUtils.IoBaseCloseable() {
+ @Override
+ public CloseFuture close(boolean immediately) {
+ assertTrue("Closure is not immediate", immediately);
+ assertEquals("Multiple close immediate calls", 1, callsCount.incrementAndGet());
+ return future;
+ }
+
+ @Override
+ public boolean isClosed() {
+ return false;
+ }
+
+ @Override
+ public boolean isClosing() {
+ return false;
+ }
+ };
+ ExecutorService service = ThreadUtils.newSingleThreadExecutor(getCurrentTestName());
+ try {
+ Future<?> task = service.submit(new Runnable() {
@Override
- public boolean isClosing() {
- return false;
- }
- };
- ExecutorService service=ThreadUtils.newSingleThreadExecutor(getCurrentTestName());
- try {
- Future<?> task=service.submit(new Runnable() {
- @Override
- public void run() {
- try {
- closeable.close();
- } catch(IOException e) {
- throw new RuntimeException(e);
- }
+ public void run() {
+ try {
+ closeable.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
- });
- future.setClosed(); // signal close complete
- task.get(5L, TimeUnit.SECONDS); // make sure #await call terminated
- assertEquals("Close immediate not called", 1, callsCount.get());
- } finally {
- service.shutdownNow();
- }
+ }
+ });
+ future.setClosed(); // signal close complete
+ task.get(5L, TimeUnit.SECONDS); // make sure #await call terminated
+ assertEquals("Close immediate not called", 1, callsCount.get());
+ } finally {
+ service.shutdownNow();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
index 5504365..5ef1c63 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
@@ -40,18 +40,18 @@ public class GenericUtilsTest extends BaseTestSupport {
@Test
public void testSplitAndJoin() {
- List<String> expected=Collections.unmodifiableList(
+ List<String> expected = Collections.unmodifiableList(
Arrays.asList(getClass().getPackage().getName().replace('.', '/'), getClass().getSimpleName(), getCurrentTestName()));
// NOTE: we also test characters that have meaning in String.split(...) as regex ones
- for (char ch : new char[] { ',', '.', '*', '?' }) {
- String sep=String.valueOf(ch);
- String s=GenericUtils.join(expected, sep);
- String[] actual=GenericUtils.split(s, ch);
+ for (char ch : new char[]{',', '.', '*', '?'}) {
+ String sep = String.valueOf(ch);
+ String s = GenericUtils.join(expected, sep);
+ String[] actual = GenericUtils.split(s, ch);
assertEquals("Mismatched split length for separator=" + sep, expected.size(), GenericUtils.length((Object[]) actual));
-
- for (int index=0; index < actual.length; index++) {
- String e=expected.get(index), a=actual[index];
+
+ for (int index = 0; index < actual.length; index++) {
+ String e = expected.get(index), a = actual[index];
if (!e.endsWith(a)) {
fail("Mismatched value at index=" + index + " for separator=" + sep + ": expected=" + e + ", actual=" + a);
}
@@ -65,27 +65,27 @@ public class GenericUtilsTest extends BaseTestSupport {
assertSame("Unexpected un-quoted stripping", expected, GenericUtils.stripQuotes(expected));
StringBuilder sb = new StringBuilder(2 + expected.length()).append('|').append(expected).append('|');
- for (int index=0; index < GenericUtils.QUOTES.length(); index++) {
+ for (int index = 0; index < GenericUtils.QUOTES.length(); index++) {
char delim = GenericUtils.QUOTES.charAt(index);
sb.setCharAt(0, delim);
sb.setCharAt(sb.length() - 1, delim);
-
+
CharSequence actual = GenericUtils.stripQuotes(sb);
assertEquals("Mismatched result for delim (" + delim + ")", expected, actual.toString());
}
}
-
+
@Test
public void testStripOnlyFirstLayerQuotes() {
StringBuilder sb = new StringBuilder().append("||").append(getCurrentTestName()).append("||");
- char[] delims = { '\'', '"', '"', '\'' };
- for (int index=0; index < delims.length; index += 2) {
+ char[] delims = {'\'', '"', '"', '\''};
+ for (int index = 0; index < delims.length; index += 2) {
char topDelim = delims[index], innerDelim = delims[index + 1];
sb.setCharAt(0, topDelim);
sb.setCharAt(1, innerDelim);
sb.setCharAt(sb.length() - 2, innerDelim);
sb.setCharAt(sb.length() - 1, topDelim);
-
+
CharSequence expected = sb.subSequence(1, sb.length() - 1);
CharSequence actual = GenericUtils.stripQuotes(sb);
assertEquals("Mismatched result for delim (" + topDelim + "/" + innerDelim + ")", expected.toString(), actual.toString());
@@ -97,50 +97,50 @@ public class GenericUtilsTest extends BaseTestSupport {
String expected = getCurrentTestName();
final char delim = '|';
assertSame("Unexpected un-delimited stripping", expected, GenericUtils.stripDelimiters(expected, delim));
-
+
CharSequence actual = GenericUtils.stripDelimiters(
new StringBuilder(2 + expected.length()).append(delim).append(expected).append(delim), delim);
assertEquals("Mismatched stripped values", expected, actual.toString());
}
-
+
@Test
public void testStripDelimitersOnlyIfOnBothEnds() {
final char delim = '$';
- StringBuilder expected=new StringBuilder().append(delim).append(getCurrentTestName()).append(delim);
- for (int index : new int[] { 0, expected.length() - 1 }) {
+ StringBuilder expected = new StringBuilder().append(delim).append(getCurrentTestName()).append(delim);
+ for (int index : new int[]{0, expected.length() - 1}) {
// restore original delimiters
expected.setCharAt(0, delim);
expected.setCharAt(expected.length() - 1, delim);
// trash one end
expected.setCharAt(index, (char) (delim + 1));
-
+
assertSame("Mismatched result for delim at index=" + index, expected, GenericUtils.stripDelimiters(expected, delim));
- }
+ }
}
@Test
public void testAccumulateExceptionOnNullValues() {
assertNull("Unexpected null/null result", GenericUtils.accumulateException(null, null));
-
- Throwable expected=new NoSuchMethodException(getClass().getName() + "#" + getCurrentTestName());
+
+ Throwable expected = new NoSuchMethodException(getClass().getName() + "#" + getCurrentTestName());
assertSame("Mismatched null/extra result", expected, GenericUtils.accumulateException(null, expected));
assertSame("Mismatched current/null result", expected, GenericUtils.accumulateException(expected, null));
}
@Test
public void testAccumulateExceptionOnExistingCurrent() {
- RuntimeException[] expected=new RuntimeException[] {
+ RuntimeException[] expected = new RuntimeException[]{
new IllegalArgumentException(getCurrentTestName()),
new ClassCastException(getClass().getName()),
new NoSuchElementException(getClass().getPackage().getName())
- };
- RuntimeException current=new UnsupportedOperationException("top");
+ };
+ RuntimeException current = new UnsupportedOperationException("top");
for (RuntimeException extra : expected) {
- RuntimeException actual=GenericUtils.accumulateException(current, extra);
+ RuntimeException actual = GenericUtils.accumulateException(current, extra);
assertSame("Mismatched returned actual exception", current, actual);
}
-
- Throwable[] actual=current.getSuppressed();
+
+ Throwable[] actual = current.getSuppressed();
assertArrayEquals("Suppressed", expected, actual);
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java
index 7184c0e..2597a41 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java
@@ -52,13 +52,13 @@ import org.junit.runners.MethodSorters;
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SecurityUtilsTest extends BaseTestSupport {
- private static final String DEFAULT_PASSWORD="super secret passphrase";
+ private static final String DEFAULT_PASSWORD = "super secret passphrase";
private static final FilePasswordProvider passwordProvider = new FilePasswordProvider() {
- @Override
- public String getPassword(String file) throws IOException {
- return DEFAULT_PASSWORD;
- }
- };
+ @Override
+ public String getPassword(String file) throws IOException {
+ return DEFAULT_PASSWORD;
+ }
+ };
public SecurityUtilsTest() {
super();
@@ -73,13 +73,13 @@ public class SecurityUtilsTest extends BaseTestSupport {
@Test
public void testLoadEncryptedAESPrivateKey() {
Assume.assumeTrue("Bouncycastle not registered", SecurityUtils.isBouncyCastleRegistered());
- for (BuiltinCiphers c : new BuiltinCiphers[] {
- BuiltinCiphers.aes128cbc, BuiltinCiphers.aes192cbc, BuiltinCiphers.aes256cbc }) {
+ for (BuiltinCiphers c : new BuiltinCiphers[]{
+ BuiltinCiphers.aes128cbc, BuiltinCiphers.aes192cbc, BuiltinCiphers.aes256cbc}) {
if (!c.isSupported()) {
System.out.println("Skip unsupported encryption scheme: " + c.getName());
continue;
}
-
+
testLoadEncryptedRSAPrivateKey("AES-" + c.getKeySize());
}
}
@@ -113,7 +113,7 @@ public class SecurityUtilsTest extends BaseTestSupport {
System.out.println("Skip unsupported curve: " + c.getName());
continue;
}
-
+
testLoadECPrivateKey(getClass().getSimpleName() + "-EC-" + c.getKeySize() + "-KeyPair");
}
}
@@ -138,7 +138,7 @@ public class SecurityUtilsTest extends BaseTestSupport {
}
private static KeyPair testLoadPrivateKeyResource(String name, Class<? extends PublicKey> pubType, Class<? extends PrivateKey> prvType) {
- AbstractClassLoadableResourceKeyPairProvider provider = SecurityUtils.createClassLoadableResourceKeyPairProvider();
+ AbstractClassLoadableResourceKeyPairProvider provider = SecurityUtils.createClassLoadableResourceKeyPairProvider();
provider.setResources(Collections.singletonList(name));
return testLoadPrivateKey(name, provider, pubType, prvType);
}
@@ -148,7 +148,7 @@ public class SecurityUtilsTest extends BaseTestSupport {
provider.setFiles(Collections.singletonList(file));
return testLoadPrivateKey(file.getAbsolutePath(), provider, pubType, prvType);
}
-
+
private static KeyPair testLoadPrivateKey(String resourceKey, AbstractResourceKeyPairProvider<?> provider, Class<? extends PublicKey> pubType, Class<? extends PrivateKey> prvType) {
provider.setPasswordFinder(passwordProvider);
Iterable<KeyPair> iterator = provider.loadKeys();
@@ -156,7 +156,7 @@ public class SecurityUtilsTest extends BaseTestSupport {
for (KeyPair kp : iterator) {
pairs.add(kp);
}
-
+
assertEquals("Mismatched loaded pairs count for " + resourceKey, 1, pairs.size());
KeyPair kp = pairs.get(0);