use of com.microsoft.azure.sdk.iot.provisioning.service.configs.X509Certificates in project azure-iot-sdk-java by Azure.
the class X509CertificatesTest method constructorStorePrimaryAndSecondaryCertsSucceed.
/* SRS_X509_CERTIFICATES_21_003: [If the secondary certificate is not null or empty, the constructor shall create a new instance of the X509CertificateWithInfo using the provided secondary certificate, and store it as the secondary Certificate.] */
@Test
public void constructorStorePrimaryAndSecondaryCertsSucceed(@Mocked final X509CertificateWithInfo mockedX509CertificateWithInfo) throws IllegalArgumentException {
// arrange
new NonStrictExpectations() {
{
Deencapsulation.newInstance(X509CertificateWithInfo.class, new Class[] { String.class }, PUBLIC_CERTIFICATE_STRING);
result = mockedX509CertificateWithInfo;
times = 2;
}
};
// act
X509Certificates x509Certificates = Deencapsulation.newInstance(X509Certificates.class, new Class[] { String.class, String.class }, PUBLIC_CERTIFICATE_STRING, PUBLIC_CERTIFICATE_STRING);
// assert
assertNotNull(Deencapsulation.getField(x509Certificates, "primary"));
assertNotNull(Deencapsulation.getField(x509Certificates, "secondary"));
}
use of com.microsoft.azure.sdk.iot.provisioning.service.configs.X509Certificates in project azure-iot-sdk-java by Azure.
the class X509CertificatesTest method emptyConstructorSucceed.
/* SRS_X509_CERTIFICATES_21_009: [The X509Certificates shall provide an empty constructor to make GSON happy.] */
@Test
public void emptyConstructorSucceed() {
// arrange
// act
X509Certificates x509Certificates = Deencapsulation.newInstance(X509Certificates.class);
// assert
assertNotNull(x509Certificates);
}
use of com.microsoft.azure.sdk.iot.provisioning.service.configs.X509Certificates in project azure-iot-sdk-java by Azure.
the class X509CertificatesTest method constructorStorePrimaryCertSucceed.
/* SRS_X509_CERTIFICATES_21_002: [The constructor shall create a new instance of the X509CertificateWithInfo using the provided primary certificate, and store is as the primary Certificate.] */
/* SRS_X509_CERTIFICATES_21_003: [If the secondary certificate is not null or empty, the constructor shall create a new instance of the X509CertificateWithInfo using the provided secondary certificate, and store it as the secondary Certificate.] */
@Test
public void constructorStorePrimaryCertSucceed(@Mocked final X509CertificateWithInfo mockedX509CertificateWithInfo) throws IllegalArgumentException {
// arrange
new NonStrictExpectations() {
{
Deencapsulation.newInstance(X509CertificateWithInfo.class, new Class[] { String.class }, PUBLIC_CERTIFICATE_STRING);
result = mockedX509CertificateWithInfo;
times = 1;
}
};
// act
X509Certificates x509Certificates = Deencapsulation.newInstance(X509Certificates.class, new Class[] { String.class, String.class }, PUBLIC_CERTIFICATE_STRING, null);
// assert
assertNotNull(Deencapsulation.getField(x509Certificates, "primary"));
assertNull(Deencapsulation.getField(x509Certificates, "secondary"));
}
use of com.microsoft.azure.sdk.iot.provisioning.service.configs.X509Certificates in project azure-iot-sdk-java by Azure.
the class X509CertificatesTest method constructorCopyThrowsOnPrimaryCertNull.
/* SRS_X509_CERTIFICATES_21_004: [The constructor shall throw IllegalArgumentException if the provide X509Certificates is null or if its primary certificate is null.] */
@Test(expected = IllegalArgumentException.class)
public void constructorCopyThrowsOnPrimaryCertNull() throws IllegalArgumentException {
// arrange
X509Certificates x509Certificates = Deencapsulation.newInstance(X509Certificates.class);
// act
new X509Certificates(x509Certificates);
// assert
}
use of com.microsoft.azure.sdk.iot.provisioning.service.configs.X509Certificates in project azure-iot-sdk-java by Azure.
the class X509CertificatesTest method constructorCopiesPrimaryCertSucceed.
/* SRS_X509_CERTIFICATES_21_005: [The constructor shall create a new instance of X509CertificateWithInfo using the primary certificate on the provided x509Certificates.] */
/* SRS_X509_CERTIFICATES_21_006: [If the secondary certificate is not null, the constructor shall create a new instance of the X509CertificateWithInfo using the provided secondary certificate, and store it as the secondary Certificate.] */
@Test
public void constructorCopiesPrimaryCertSucceed(@Mocked final X509CertificateWithInfo mockedX509CertificateWithInfo) throws IllegalArgumentException {
// arrange
X509Certificates x509Certificates = Deencapsulation.newInstance(X509Certificates.class, new Class[] { String.class, String.class }, PUBLIC_CERTIFICATE_STRING, null);
// act
X509Certificates x509CertificatesCopy = new X509Certificates(x509Certificates);
// assert
assertNotNull(Deencapsulation.getField(x509CertificatesCopy, "primary"));
assertNull(Deencapsulation.getField(x509CertificatesCopy, "secondary"));
new Verifications() {
{
new X509CertificateWithInfo((X509CertificateWithInfo) any);
times = 1;
}
};
}
Aggregations