assertEquals(strFormatParam, format);
return enc;
}
};
AlgorithmParameters params = new DummyAlgorithmParameters(paramSpi, p,
"algorithm");
//
// test: IOException if not initialized
//
try {
params.getEncoded(strFormatParam);
fail("should not get encoded from un-initialized instance");
} catch (IOException e) {
// expected
}
//
// test: corresponding spi method is invoked
//
params.init(new MyAlgorithmParameterSpec());
assertSame(enc, params.getEncoded(strFormatParam));
//
// test: if format param is null
// Regression test for HARMONY-2680
//
paramSpi = new MyAlgorithmParameters() {
protected byte[] engineGetEncoded(String format) throws IOException {
assertNull(format); // null is passed to spi-provider
return enc;
}
};
params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
params.init(new MyAlgorithmParameterSpec());
assertSame(enc, params.getEncoded(null));
}