Best Testng code snippet using org.testng.Assert.assertFalse
Source:MAnnotationSampleTest.java
...44 //45 ITestAnnotation test2 = (ITestAnnotation) m_finder.findAnnotation(MTest2.class, ITestAnnotation.class);46 // test default for enabled47 Assert.assertTrue(test2.getEnabled());48 Assert.assertFalse(test2.getAlwaysRun());49 Assert.assertEquals(test2.getTimeOut(), 0);50 Assert.assertEquals(test2.getInvocationCount(), 1);51 Assert.assertEquals(test2.getSuccessPercentage(), 100);52 Assert.assertEquals(test2.getDataProvider(), "");53 }54 public void verifyTestMethodLevel() throws SecurityException, NoSuchMethodException55 {56 //57 // Tests on MTest1SampleTest58 //59 Method method = MTest1.class.getMethod("f", new Class[0]);60 ITestAnnotation test1 = (ITestAnnotation) m_finder.findAnnotation(method, ITestAnnotation.class);61 Assert.assertTrue(test1.getEnabled());62 Assert.assertEqualsNoOrder(test1.getGroups(), new String[] { "group1", "group3", "group4", "group2" });63 Assert.assertTrue(test1.getAlwaysRun());64 Assert.assertEquals(test1.getParameters(), new String[] { "param3", "param4" });65 Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2", "dg3", "dg4" });66 Assert.assertEqualsNoOrder(test1.getDependsOnMethods(), new String[] { "dm1", "dm2", "dm3", "dm4" });67 Assert.assertEquals(test1.getTimeOut(), 142);68 Assert.assertEquals(test1.getInvocationCount(), 143);69 Assert.assertEquals(test1.getSuccessPercentage(), 61);70 Assert.assertEquals(test1.getDataProvider(), "dp2");71 Assert.assertEquals(test1.getDescription(), "Method description");72 Class[] exceptions = test1.getExpectedExceptions();73 Assert.assertEquals(exceptions.length, 1);74 Assert.assertEquals(exceptions[0], NullPointerException.class);75 }76 public void verifyTestConstructorLevel() throws SecurityException, NoSuchMethodException77 {78 //79 // Tests on MTest1SampleTest80 //81 Constructor constructor = MTest1.class.getConstructor(new Class[0]);82 ITestAnnotation test1 = (ITestAnnotation) m_finder.findAnnotation(constructor, ITestAnnotation.class);83 Assert.assertNotNull(test1);84 Assert.assertTrue(test1.getEnabled());85 Assert.assertEqualsNoOrder(test1.getGroups(), new String[] { "group5", "group1", "group6", "group2" });86 Assert.assertTrue(test1.getAlwaysRun());87 Assert.assertEquals(test1.getParameters(), new String[] { "param5", "param6" });88 Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2", "dg5", "dg6" });89 Assert.assertEqualsNoOrder(test1.getDependsOnMethods(), new String[] { "dm1", "dm2", "dm5", "dm6" });90 Assert.assertEquals(test1.getTimeOut(), 242);91 Assert.assertEquals(test1.getInvocationCount(), 243);92 Assert.assertEquals(test1.getSuccessPercentage(), 62);93 Assert.assertEquals(test1.getDataProvider(), "dp3");94 Assert.assertEquals(test1.getDescription(), "Constructor description");95 Class[] exceptions = test1.getExpectedExceptions();96 Assert.assertEquals(exceptions.length, 1);97 Assert.assertEquals(exceptions[0], NumberFormatException.class);98 }99 public void verifyConfigurationBefore() throws SecurityException, NoSuchMethodException100 {101 Method method = MTest1.class.getMethod("before", new Class[0]);102 IConfigurationAnnotation configuration =103 (IConfigurationAnnotation) m_finder.findAnnotation(method, IConfigurationAnnotation.class);104 Assert.assertNotNull(configuration);105 Assert.assertTrue(configuration.getBeforeSuite());106 Assert.assertTrue(configuration.getBeforeTestMethod());107 Assert.assertTrue(configuration.getBeforeTest());108 Assert.assertTrue(configuration.getBeforeTestClass());109 Assert.assertFalse(configuration.getAfterSuite());110 Assert.assertFalse(configuration.getAfterTestMethod());111 Assert.assertFalse(configuration.getAfterTest());112 Assert.assertFalse(configuration.getAfterTestClass());113 Assert.assertEquals(0, configuration.getAfterGroups().length);114 String[] bg = configuration.getBeforeGroups();115 Assert.assertEquals(bg.length, 2);116 Assert.assertEqualsNoOrder(bg, new String[] {"b1", "b2"});117 // Default values118 Assert.assertTrue(configuration.getEnabled());119 Assert.assertTrue(configuration.getInheritGroups());120 Assert.assertFalse(configuration.getAlwaysRun());121 }122 public void verifyConfigurationAfter() throws SecurityException, NoSuchMethodException123 {124 Method method = MTest1.class.getMethod("after", new Class[0]);125 IConfigurationAnnotation configuration =126 (IConfigurationAnnotation) m_finder.findAnnotation(method, IConfigurationAnnotation.class);127 Assert.assertNotNull(configuration);128 Assert.assertFalse(configuration.getBeforeSuite());129 Assert.assertFalse(configuration.getBeforeTestMethod());130 Assert.assertFalse(configuration.getBeforeTest());131 Assert.assertFalse(configuration.getBeforeTestClass());132 Assert.assertTrue(configuration.getAfterSuite());133 Assert.assertTrue(configuration.getAfterTestMethod());134 Assert.assertTrue(configuration.getAfterTest());135 Assert.assertTrue(configuration.getAfterTestClass());136 Assert.assertEquals(0, configuration.getBeforeGroups().length);137 String[] ag = configuration.getAfterGroups();138 Assert.assertEquals(ag.length, 2);139 Assert.assertEqualsNoOrder(ag, new String[] {"a1", "a2"});140 // Default values141 Assert.assertTrue(configuration.getEnabled());142 Assert.assertTrue(configuration.getInheritGroups());143 Assert.assertFalse(configuration.getAlwaysRun());144 }145 public void verifyConfigurationOthers() throws SecurityException, NoSuchMethodException146 {147 Method method = MTest1.class.getMethod("otherConfigurations", new Class[0]);148 IConfigurationAnnotation configuration =149 (IConfigurationAnnotation) m_finder.findAnnotation(method, IConfigurationAnnotation.class);150 Assert.assertNotNull(configuration);151 Assert.assertFalse(configuration.getBeforeSuite());152 Assert.assertFalse(configuration.getBeforeTestMethod());153 Assert.assertFalse(configuration.getBeforeTest());154 Assert.assertFalse(configuration.getBeforeTestClass());155 Assert.assertFalse(configuration.getAfterSuite());156 Assert.assertFalse(configuration.getAfterTestMethod());157 Assert.assertFalse(configuration.getAfterTest());158 Assert.assertFalse(configuration.getAfterTestClass());159 Assert.assertFalse(configuration.getEnabled());160 Assert.assertEquals(configuration.getParameters(), new String[] { "oparam1", "oparam2" });161 Assert.assertEqualsNoOrder(configuration.getGroups(), new String[] { "group1", "ogroup1", "ogroup2", "group2" }, "groups");162 Assert.assertEqualsNoOrder(configuration.getDependsOnGroups(), new String[] { "odg1", "odg2" }, "depends on groups");163 Assert.assertEqualsNoOrder(configuration.getDependsOnMethods(), new String[] { "odm1", "odm2" }, "depends on methods");164 Assert.assertFalse(configuration.getInheritGroups());165 Assert.assertTrue(configuration.getAlwaysRun());166 Assert.assertEquals(configuration.getDescription(), "beforeSuite description");167 }168 public void verifyDataProvider() throws SecurityException, NoSuchMethodException169 {170 Method method = MTest1.class.getMethod("otherConfigurations", new Class[0]);171 IDataProviderAnnotation dataProvider =172 (IDataProviderAnnotation) m_finder.findAnnotation(method, IDataProviderAnnotation.class);173 Assert.assertNotNull(dataProvider);174 Assert.assertEquals(dataProvider.getName(), "dp4");175 }176 public void verifyExpectedExceptions() throws SecurityException, NoSuchMethodException177 {178 Method method = MTest1.class.getMethod("otherConfigurations", new Class[0]);179 IExpectedExceptionsAnnotation exceptions=180 (IExpectedExceptionsAnnotation) m_finder.findAnnotation(method, IExpectedExceptionsAnnotation.class);181 Assert.assertNotNull(exceptions);182 Assert.assertEquals(exceptions.getValue(), new Class[] { MTest1.class, MTest2.class });183 }184 public void verifyFactory() throws SecurityException, NoSuchMethodException185 {186 Method method = MTest1.class.getMethod("factory", new Class[0]);187 IFactoryAnnotation factory=188 (IFactoryAnnotation) m_finder.findAnnotation(method, IFactoryAnnotation.class);189 Assert.assertNotNull(factory);190 Assert.assertEquals(factory.getParameters(), new String[] { "pf1", "pf2" });191 }192 public void verifyParameters() throws SecurityException, NoSuchMethodException193 {194 Method method = MTest1.class.getMethod("parameters", new Class[0]);195 IParametersAnnotation parameters =196 (IParametersAnnotation) m_finder.findAnnotation(method, IParametersAnnotation.class);197 Assert.assertNotNull(parameters);198 Assert.assertEquals(parameters.getValue(), new String[] { "pp1", "pp2", "pp3" });199 }200 public void verifyNewConfigurationBefore() throws SecurityException, NoSuchMethodException201 {202 Method method = MTest1.class.getMethod("newBefore", new Class[0]);203 IConfigurationAnnotation configuration =204 (IConfigurationAnnotation) m_finder.findAnnotation(method, IBeforeSuite.class);205 Assert.assertNotNull(configuration);206 Assert.assertTrue(configuration.getBeforeSuite());207 // Default values208 Assert.assertTrue(configuration.getEnabled());209 Assert.assertTrue(configuration.getInheritGroups());210 Assert.assertFalse(configuration.getAlwaysRun());211 }212 public void verifyNewConfigurationAfter() throws SecurityException, NoSuchMethodException213 {214 Method method = MTest1.class.getMethod("newAfter", new Class[0]);215 IConfigurationAnnotation configuration =216 (IConfigurationAnnotation) m_finder.findAnnotation(method, IAfterSuite.class);217 Assert.assertNotNull(configuration);218 Assert.assertTrue(configuration.getAfterSuite());219 // Default values220 Assert.assertTrue(configuration.getEnabled());221 Assert.assertTrue(configuration.getInheritGroups());222 Assert.assertFalse(configuration.getAlwaysRun());223 }224 private static void ppp(String s) {225 System.out.println("[MAnnotationSampleTest] " + s);226 }227}...
Source:DialogPortionTest.java
...17 * along with this program. If not, see <http://www.gnu.org/licenses/>18 */19package org.mobicents.protocols.ss7.tcap.asn;20import static org.testng.Assert.assertEquals;21import static org.testng.Assert.assertFalse;22import static org.testng.Assert.assertNotNull;23import static org.testng.Assert.assertNull;24import static org.testng.Assert.assertTrue;25import static org.testng.Assert.fail;26import java.util.Arrays;27import org.mobicents.protocols.asn.AsnInputStream;28import org.mobicents.protocols.asn.AsnOutputStream;29import org.testng.annotations.AfterClass;30import org.testng.annotations.AfterMethod;31import org.testng.annotations.BeforeClass;32import org.testng.annotations.BeforeMethod;33import org.testng.annotations.Test;34/**35 * @author baranowb36 * @author amit bhayani37 * @author sergey vetyutnev38 */39@Test(groups = { "asn" })40public class DialogPortionTest {41 @BeforeClass42 public static void setUpClass() throws Exception {43 }44 @AfterClass45 public static void tearDownClass() throws Exception {46 }47 @BeforeMethod48 public void setUp() {49 }50 @AfterMethod51 public void tearDown() {52 }53 @Test(groups = { "functional.encode", "functional.decode" })54 public void testDialogPortion_UserInformation() throws Exception {55 // Hex dump is from wireshark trace for TCAP - MAP/USSD56 byte[] b = new byte[] { 0x6b, 0x41, 0x28, 0x3f, 0x06, 0x07, 0x00, 0x11, (byte) 0x86, 0x05, 0x01, 0x01, 0x01,57 (byte) 0xa0, 0x34, 0x60, 0x32, (byte) 0xa1, 0x09, 0x06, 0x07, 0x04, 0x00, 0x00, 0x01, 0x00, 0x13, 0x02,58 (byte) 0xbe, 0x25, 0x28, 0x23, 0x06, 0x07, 0x04, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, (byte) 0xa0, 0x18,59 (byte) 0xa0, (byte) 0x80, (byte) 0x80, 0x09, (byte) 0x96, 0x02, 0x24, (byte) 0x80, 0x03, 0x00, (byte) 0x80,60 0x00, (byte) 0xf2, (byte) 0x81, 0x07, (byte) 0x91, 0x13, 0x26, (byte) 0x98, (byte) 0x86, 0x03, (byte) 0xf0,61 0x00, 0x00 };62 AsnInputStream asin = new AsnInputStream(b);63 asin.readTag();64 DialogPortionImpl dpi = new DialogPortionImpl();65 dpi.decode(asin);66 long[] oidValue = dpi.getOidValue();67 Arrays.equals(new long[] { 0, 0, 17, 773, 1, 1, 1 }, oidValue);68 DialogAPDU dialogAPDU = dpi.getDialogAPDU();69 assertNotNull(dialogAPDU);70 assertEquals(DialogAPDUType.Request, dialogAPDU.getType());71 DialogRequestAPDU dialogRequestAPDU = (DialogRequestAPDU) dialogAPDU;72 ApplicationContextName acn = dialogRequestAPDU.getApplicationContextName();73 assertNotNull(acn);74 assertTrue(Arrays.equals(new long[] { 0, 4, 0, 0, 1, 0, 19, 2 }, acn.getOid()));75 UserInformation userInfos = dialogRequestAPDU.getUserInformation();76 assertNotNull(userInfos);77 UserInformation userInformation = userInfos;78 assertTrue(userInformation.isOid());79 assertTrue(Arrays.equals(new long[] { 0, 4, 0, 0, 1, 1, 1, 1 }, userInformation.getOidValue()));80 assertFalse(userInformation.isInteger());81 assertTrue(userInformation.isAsn());82 assertTrue(Arrays.equals(new byte[] { (byte) 0xa0, (byte) 0x80, (byte) 0x80, 0x09, (byte) 0x96, 0x02, 0x24,83 (byte) 0x80, 0x03, 0x00, (byte) 0x80, 0x00, (byte) 0xf2, (byte) 0x81, 0x07, (byte) 0x91, 0x13, 0x26,84 (byte) 0x98, (byte) 0x86, 0x03, (byte) 0xf0, 0x00, 0x00 }, userInformation.getEncodeType()));85 // encoded version with definite length style86 byte[] b2 = new byte[] { 107, 69, 40, 67, 6, 7, 0, 17, -122, 5, 1, 1, 1, -96, 56, 96, 54, -128, 2, 7, -128, -95, 9, 6,87 7, 4, 0, 0, 1, 0, 19, 2, -66, 37, 40, 35, 6, 7, 4, 0, 0, 1, 1, 1, 1, -96, 24, -96, -128, -128, 9, -106, 2, 36,88 -128, 3, 0, -128, 0, -14, -127, 7, -111, 19, 38, -104, -122, 3, -16, 0, 0 };89 AsnOutputStream aso = new AsnOutputStream();90 dpi.encode(aso);91 byte[] encoded = aso.toByteArray();92 assertTrue(Arrays.equals(b2, encoded));93 }94 @Test(groups = { "functional.encode", "functional.decode" })95 public void testDialogPortion_DialogRequestAPDU() throws Exception {96 // trace97 byte[] b = new byte[] { 107, 30, 40, 28, 6, 7, 0, 17, (byte) 134, 5, 1, 1, 1, (byte) 160, 17, 0x60, 15, (byte) 128, 2,98 7, (byte) 128, (byte) 161, 9, 6, 7, 4, 0, 1, 1, 1, 3, 0 };99 // In HEX100 // 6B 1E 28 1C 06 07 00 11 86 05 01 01 01 A0 11 60 0F 80 02 07 80 A1 09101 // 06 07 04 00 01 01 01 03 00102 AsnInputStream asin = new AsnInputStream(b);103 asin.readTag();104 DialogPortionImpl dpi = new DialogPortionImpl();105 dpi.decode(asin);106 DialogAPDU d = dpi.getDialogAPDU();107 assertNotNull(d);108 assertEquals(DialogAPDUType.Request, d.getType());109 DialogRequestAPDU dr = (DialogRequestAPDU) d;110 assertTrue(Arrays.equals(new long[] { 0, 4, 0, 1, 1, 1, 3, 0 }, dr.getApplicationContextName().getOid()));111 assertNull(dr.getUserInformation());112 AsnOutputStream aso = new AsnOutputStream();113 dpi.encode(aso);114 byte[] encoded = aso.toByteArray();115 assertTrue(Arrays.equals(b, encoded));116 // try {117 // dpi.getEncodeBitStringType();118 // fail();119 // } catch (UnsupportedOperationException e) {120 //121 // }122 try {123 encoded = null;124 encoded = dpi.getEncodeType();125 assertNotNull(encoded);126 } catch (Exception e) {127 fail();128 e.printStackTrace();129 }130 assertTrue(dpi.isAsn());131 assertTrue(dpi.isOid());132 assertFalse(dpi.isUnidirectional());133 assertFalse(dpi.isArbitrary());134 assertFalse(dpi.isOctet());135 assertFalse(dpi.isObjDescriptor());136 assertFalse(dpi.isInteger());137 DialogAPDU _apid = dpi.getDialogAPDU();138 assertEquals(DialogAPDUType.Request, _apid.getType());139 assertFalse(_apid.isUniDirectional());140 DialogRequestAPDU apdu = (DialogRequestAPDU) _apid;141 // no idea how to check rest...?142 }143 @Test(groups = { "functional.encode", "functional.decode" })144 public void testDialogPortion_DialogAbortAPDU() throws Exception {145 // trace146 byte[] b = new byte[] { 0x6B, 0x12, 0x28, 0x10, 0x06, 0x07, 0x00, 0x11, (byte) 0x86, 0x05, 0x01, 0x01, 0x01,147 (byte) 0xA0, 0x05, 0x64, 0x03, (byte) 0x80, 0x01, 0x01 };148 AsnInputStream asin = new AsnInputStream(b);149 asin.readTag();150 DialogPortionImpl dpi = new DialogPortionImpl();151 dpi.decode(asin);152 AsnOutputStream aso = new AsnOutputStream();153 dpi.encode(aso);154 byte[] encoded = aso.toByteArray();155 assertTrue(Arrays.equals(b, encoded));156 // try {157 // dpi.getEncodeBitStringType();158 // fail();159 // } catch (UnsupportedOperationException e) {160 //161 // }162 try {163 encoded = null;164 encoded = dpi.getEncodeType();165 assertNotNull(encoded);166 } catch (Exception e) {167 fail();168 e.printStackTrace();169 }170 assertTrue(dpi.isAsn());171 assertTrue(dpi.isOid());172 assertFalse(dpi.isUnidirectional());173 assertFalse(dpi.isArbitrary());174 assertFalse(dpi.isOctet());175 assertFalse(dpi.isObjDescriptor());176 assertFalse(dpi.isInteger());177 DialogAPDU _apid = dpi.getDialogAPDU();178 assertEquals(DialogAPDUType.Abort, _apid.getType());179 assertFalse(_apid.isUniDirectional());180 DialogAbortAPDU apdu = (DialogAbortAPDU) _apid;181 }182 // @Test183 // public void testDialogPortion_DialogResponseAPDU() throws IOException,184 // ParseException {185 //186 //187 // byte[] b = new byte[] { 0x6B, 0x2A, /*EXT_T*/0x28, 0x28, /*OID_T*/0x06,188 // 0x07, 0x00, 0x11, (byte)0x86, 0x05, 0x01, 0x01, 0x01,189 // /*ASN_T*/(byte)0xA0, /*29*/0x1D, /*REsponse_T*/0x61, 0x1B, /*rest of190 // trace is gone... ech*/ };191 // System.err.println(b.length);192 // AsnInputStream asin = new AsnInputStream(new ByteArrayInputStream(b));193 // asin.readTag();194 // DialogPortionImpl dpi = new DialogPortionImpl();195 // dpi.decode(asin);196 // AsnOutputStream aso = new AsnOutputStream();197 // dpi.encode(aso);198 // byte[] encoded = aso.toByteArray();199 // assertTrue(Arrays.equals(b, encoded));200 //201 // try{202 // dpi.getEncodeBitStringType();203 // fail();204 // }catch(UnsupportedOperationException e)205 // {206 //207 // } catch (AsnException e) {208 // fail();209 // e.printStackTrace();210 // }211 // try{212 // encoded = null;213 // encoded = dpi.getEncodeType();214 // assertNotNull(encoded);215 //216 // }catch(UnsupportedOperationException e)217 // {218 // fail();219 // e.printStackTrace();220 // } catch (AsnException e) {221 // fail();222 // e.printStackTrace();223 // }224 // assertTrue(dpi.isAsn());225 // assertTrue(dpi.isOid());226 // assertFalse(dpi.isUnidirectional());227 //228 // assertFalse(dpi.isArbitrary());229 // assertFalse(dpi.isOctet());230 // assertFalse(dpi.isObjDescriptor());231 // assertFalse(dpi.isInteger());232 //233 //234 // // DialogAPDU _apid = dpi.getDialogAPDU();235 // // assertEquals(DialogAPDUType.Abort, _apid.getType());236 // // assertFalse(_apid.isUniDirectional());237 // // DialogAbortAPDU apdu = (DialogAbortAPDU) _apid;238 // }239}...
Source:TypeUtilsTest.java
...63 .getPropertyDescriptor(Test.class, "theFoo.name"));64 }65 @org.testng.annotations.Test66 public void testIsText() {67 assertFalse(TypeUtils.isText(Test.class, "bool"));68 assertTrue(TypeUtils.isText(Test.class, "text"));69 try {70 TypeUtils.isText(null, "test");71 assertFalse(true);72 }73 catch(CrankException ce) {74 // expected75 }76 try {77 TypeUtils.isText(Test.class, null);78 assertFalse(true);79 }80 catch(CrankException ce) {81 // expected82 }83 84 try {85 TypeUtils.isText(Test.class, "notAProperty");86 //assertFalse(true);87 }88 catch(CrankException ce) {89 // expected90 }91 }92 @org.testng.annotations.Test93 public void testIsTextCompoundProperty() {94 assertTrue(TypeUtils.isText(Employee.class, "address.line1"));95 }96 @org.testng.annotations.Test97 public void testIsDate() {98 assertFalse(TypeUtils.isDate(Test.class, "bool"));99 assertFalse(TypeUtils.isDate(Test.class, "text"));100 assertTrue(TypeUtils.isDate(Test.class, "date"));101 assertTrue(TypeUtils.isDate(Test.class, "sqlDate"));102 try {103 TypeUtils.isDate(null, "test");104 assertFalse(true);105 }106 catch(CrankException ce) {107 // expected108 }109 try {110 TypeUtils.isDate(Test.class, null);111 assertFalse(true);112 }113 catch(CrankException ce) {114 // expected115 }116 117 try {118 TypeUtils.isDate(Test.class, "notAProperty");119 //assertFalse(true);120 }121 catch(CrankException ce) {122 // expected123 }124 125 }126 127 @org.testng.annotations.Test128 public void testIsUrl() {129 130 assertFalse(TypeUtils.isUrl("nourlddotcom"));131 assertTrue(TypeUtils.isUrl("nourlddot.com"));132 }133 134 @org.testng.annotations.Test135 public void testIsInCollection() { 136 assertFalse(TypeUtils.isInCollection("one", "two,three,four,five"));137 assertTrue(TypeUtils.isInCollection("two", "two,three,four,five"));138 assertTrue(TypeUtils.isInCollection("five", "two,three,four,five"));139 assertTrue(TypeUtils.isInCollection("three", "two,three,four,five"));140 assertFalse(TypeUtils.isInCollection("three", "twothreefourfive"));141 assertFalse(TypeUtils.isInCollection("three", "two,threefourfive"));142 assertFalse(TypeUtils.isInCollection("three", "twothree,fourfive"));143 } 144 145 @org.testng.annotations.Test146 public void testIsBoolean() { 147 assertTrue(TypeUtils.isBoolean(BooleanTestSupport.class, "primitiveBoolean"));148 assertTrue(TypeUtils.isBoolean(BooleanTestSupport.class, "wrapperBoolean"));149 assertFalse(TypeUtils.isBoolean(BooleanTestSupport.class, "notABoolean"));150 assertTrue(TypeUtils.isBoolean(BooleanTestSupport.class, "testSupport.testSupport.primitiveBoolean"));151 152 try {153 TypeUtils.isBoolean(null, "test");154 //assertFalse(true);155 }156 catch(CrankException ce) {157 // expected158 }159 try {160 TypeUtils.isBoolean(BooleanTestSupport.class, null);161 assertFalse(true);162 }163 catch(CrankException ce) {164 // expected165 }166 167 try {168 TypeUtils.isBoolean(BooleanTestSupport.class, "notAProperty");169 //assertFalse(true);170 }171 catch(CrankException ce) {172 // expected173 }174 175 }176 177 @org.testng.annotations.Test178 public void testIsEnum() { 179 assertTrue(TypeUtils.isEnum(EnumTestSupport.class, "testEnum"));180 assertFalse(TypeUtils.isEnum(EnumTestSupport.class, "notAnEnum"));181 assertTrue(TypeUtils.isEnum(EnumTestSupport.class, "testSupport.testSupport.testEnum"));182 183 try {184 TypeUtils.isEnum(null, "test");185 //assertFalse(true);186 }187 catch(CrankException ce) {188 // expected189 }190 try {191 TypeUtils.isEnum(EnumTestSupport.class, null);192 assertFalse(true);193 }194 catch(CrankException ce) {195 // expected196 }197 198 try {199 TypeUtils.isEnum(BooleanTestSupport.class, "notAProperty");200 //assertFalse(true);201 }202 catch(CrankException ce) {203 // expected204 }205 206 } 207 208 static class EnumTestSupport {209 enum TestEnum { one, two, three};210 private TestEnum testEnum = TestEnum.three;211 private Object notAnEnum;212 private EnumTestSupport testSupport;213 public TestEnum getTestEnum() {214 return testEnum;...
Source:CamelInfoTest.java
...17 * along with this program. If not, see <http://www.gnu.org/licenses/>18 */19package org.mobicents.protocols.ss7.map.service.callhandling;20import static org.testng.Assert.assertEquals;21import static org.testng.Assert.assertFalse;22import static org.testng.Assert.assertNull;23import static org.testng.Assert.assertTrue;24import java.util.Arrays;25import org.apache.log4j.Logger;26import org.mobicents.protocols.asn.AsnInputStream;27import org.mobicents.protocols.asn.AsnOutputStream;28import org.mobicents.protocols.asn.Tag;29import org.mobicents.protocols.ss7.map.api.service.mobility.subscriberManagement.OfferedCamel4CSIs;30import org.mobicents.protocols.ss7.map.api.service.mobility.subscriberManagement.SupportedCamelPhases;31import org.mobicents.protocols.ss7.map.primitives.MAPExtensionContainerTest;32import org.mobicents.protocols.ss7.map.service.mobility.subscriberManagement.OfferedCamel4CSIsImpl;33import org.mobicents.protocols.ss7.map.service.mobility.subscriberManagement.SupportedCamelPhasesImpl;34import org.testng.annotations.AfterClass;35import org.testng.annotations.AfterTest;36import org.testng.annotations.BeforeClass;37import org.testng.annotations.BeforeTest;38import org.testng.annotations.Test;39/**40 *41 * @author sergey vetyutnev42 *43 */44public class CamelInfoTest {45 Logger logger = Logger.getLogger(ExtendedRoutingInfoTest.class);46 @BeforeClass47 public static void setUpClass() throws Exception {48 }49 @AfterClass50 public static void tearDownClass() throws Exception {51 }52 @BeforeTest53 public void setUp() {54 }55 @AfterTest56 public void tearDown() {57 }58 public static byte[] getData() {59 return new byte[] { (byte) 171, 4, 3, 2, 4, (byte) 224 };60 }61 public static byte[] getDataFull() {62 return new byte[] { -85, 51, 3, 2, 4, -64, 5, 0, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6,63 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -128, 2, 1, -86 };64 }65 @Test(groups = { "functional.decode", "service.callhandling" })66 public void testDecode() throws Exception {67 AsnInputStream asn = new AsnInputStream(getData());68 int tag = asn.readTag();69 assertEquals(tag, 11);70 CamelInfoImpl impl = new CamelInfoImpl();71 impl.decodeAll(asn);72 SupportedCamelPhases scf = impl.getSupportedCamelPhases();73 assertTrue(scf.getPhase1Supported());74 assertTrue(scf.getPhase2Supported());75 assertTrue(scf.getPhase3Supported());76 assertFalse(scf.getPhase4Supported());77 assertFalse(impl.getSuppressTCSI());78 assertNull(impl.getExtensionContainer());79 assertNull(impl.getOfferedCamel4CSIs());80 asn = new AsnInputStream(getDataFull());81 tag = asn.readTag();82 assertEquals(tag, 11);83 impl = new CamelInfoImpl();84 impl.decodeAll(asn);85 scf = impl.getSupportedCamelPhases();86 assertTrue(scf.getPhase1Supported());87 assertTrue(scf.getPhase2Supported());88 assertFalse(scf.getPhase3Supported());89 assertFalse(scf.getPhase4Supported());90 assertTrue(impl.getSuppressTCSI());91 assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(impl.getExtensionContainer()));92 OfferedCamel4CSIs ofc = impl.getOfferedCamel4CSIs();93 assertTrue(ofc.getOCsi());94 assertFalse(ofc.getDCsi());95 assertTrue(ofc.getVtCsi());96 assertFalse(ofc.getTCsi());97 assertTrue(ofc.getMtSmsCsi());98 assertFalse(ofc.getMgCsi());99 assertTrue(ofc.getPsiEnhancements());100 }101 @Test(groups = { "functional.encode", "service.callhandling" })102 public void testEncode() throws Exception {103 SupportedCamelPhases scf = new SupportedCamelPhasesImpl(true, true, true, false);104 CamelInfoImpl impl = new CamelInfoImpl(scf, false, null, null);105 // SupportedCamelPhases supportedCamelPhases, boolean suppressTCSI, MAPExtensionContainer extensionContainer,106 // OfferedCamel4CSIs offeredCamel4CSIs107 AsnOutputStream asnOS = new AsnOutputStream();108 impl.encodeAll(asnOS, Tag.CLASS_CONTEXT_SPECIFIC, 11);109 byte[] encodedData = asnOS.toByteArray();110 assertTrue(Arrays.equals(getData(), encodedData));111 scf = new SupportedCamelPhasesImpl(true, true, false, false);112 OfferedCamel4CSIs ofc = new OfferedCamel4CSIsImpl(true, false, true, false, true, false, true);...
Source:MethodCallOrderTest.java
1package test.configuration;2import static org.testng.Assert.assertFalse;3import static org.testng.Assert.assertTrue;4import org.testng.annotations.AfterClass;5import org.testng.annotations.AfterMethod;6import org.testng.annotations.AfterSuite;7import org.testng.annotations.BeforeClass;8import org.testng.annotations.BeforeMethod;9import org.testng.annotations.Test;10public class MethodCallOrderTest {11 public static boolean s_beforeSuite;12 public static boolean s_beforeTest;13 public static boolean s_beforeClass;14 public static boolean s_beforeMethod;15 @BeforeClass16 public void beforeClass() {17 assertTrue(s_beforeSuite);18 assertTrue(s_beforeTest);19 assertFalse(s_beforeClass);20 assertFalse(s_beforeMethod);21 s_beforeClass = true;22 }23 @AfterSuite24 public void cleanUp() {25 s_beforeSuite = false;26 s_beforeTest = false;27 s_beforeClass = false;28 s_beforeMethod = false;29 }30 @BeforeMethod31 public void beforeMethod() {32 assertTrue(s_beforeSuite);33 assertTrue(s_beforeTest);34 assertTrue(s_beforeClass);35 assertFalse(s_beforeMethod);36 s_beforeMethod = true;37 }38 @Test39 public void realTest() {40 assertTrue(s_beforeSuite);41 assertTrue(s_beforeTest);42 assertTrue(s_beforeClass);43 assertTrue(s_beforeMethod);44 }45 @AfterMethod46 public void afterMethod() {47 assertFalse(ExternalConfigurationClass.s_afterMethod, "afterTestMethod shouldn't have been run");48 assertFalse(ExternalConfigurationClass.s_afterClass, "afterTestClass shouldn't have been run");49 assertFalse(ExternalConfigurationClass.s_afterTest, "afterTest should haven't been run");50 ExternalConfigurationClass.s_afterMethod = true;51 }52 @AfterClass53 public void afterClass() {54 assertTrue(ExternalConfigurationClass.s_afterMethod, "afterTestMethod should have been run");55 assertFalse(ExternalConfigurationClass.s_afterClass, "afterTestClass shouldn't have been run");56 assertFalse(ExternalConfigurationClass.s_afterTest, "afterTest should haven't been run");57 ExternalConfigurationClass.s_afterClass = true;58 }59}...
Source:ExternalConfigurationClass.java
1package test.configuration;2import static org.testng.Assert.assertFalse;3import static org.testng.Assert.assertTrue;4import org.testng.annotations.AfterSuite;5import org.testng.annotations.AfterTest;6import org.testng.annotations.BeforeSuite;7import org.testng.annotations.BeforeTest;8public class ExternalConfigurationClass {9 public static boolean s_afterMethod;10 public static boolean s_afterClass;11 public static boolean s_afterTest;12 @BeforeSuite13 public void beforeSuite() {14 MethodCallOrderTest.s_beforeSuite = true;15 }16 @AfterSuite17 public void cleanUp() {18 s_afterMethod = false;19 s_afterClass = false;20 s_afterTest = false;21 }22 @BeforeTest23 public void beforeTest() {24 assertTrue(MethodCallOrderTest.s_beforeSuite);25 assertFalse(MethodCallOrderTest.s_beforeTest);26 assertFalse(MethodCallOrderTest.s_beforeClass);27 assertFalse(MethodCallOrderTest.s_beforeMethod);28 MethodCallOrderTest.s_beforeTest = true;29 }30 @AfterTest31 public void afterTest() {32 assertTrue(s_afterMethod, "afterTestMethod should have been run");33 assertTrue(s_afterClass, "afterTestClass should have been run");34 assertFalse(s_afterTest, "afterTest should haven't been run");35 s_afterTest = true;36 }37 @AfterSuite38 public void afterSuite() {39 assertTrue(s_afterMethod, "afterTestMethod should have been run");40 assertTrue(s_afterClass, "afterTestClass should have been run");41 assertTrue(s_afterTest, "afterTest should have been run");42 }43}...
Source:ConnectionPoolTest.java
1package by.antonov.webproject.model.connection;2import static org.testng.Assert.assertFalse;3import static org.testng.Assert.assertTrue;4import java.sql.Connection;5import java.sql.SQLException;6import org.testng.annotations.AfterClass;7import org.testng.annotations.BeforeClass;8import org.testng.annotations.DataProvider;9import org.testng.annotations.Test;10public class ConnectionPoolTest {11 @BeforeClass12 public void init() {13 ConnectionPool.getInstance();14 }15 @Test16 public void releaseConnectionNull() {17 boolean actual = ConnectionPool.getInstance().releaseConnection(null);18 assertFalse(actual);19 }20 @Test21 public void releaseConnection() {22 ConnectionPool connectionPool = ConnectionPool.getInstance();23 Connection connection = connectionPool.getConnection();24 boolean actual = connectionPool.releaseConnection(connection);25 assertTrue(actual);26 }27 @DataProvider(name = "wrongConnectionsData")28 public Object[][] wrongConnectionsData() throws SQLException {29 return new Object[][]{30 {ConnectionCreator.createConnection()},31 {new ProxyConnection(ConnectionCreator.createConnection())}32 };33 }34 @Test(dataProvider = "wrongConnectionsData")35 public void releaseWrongConnection(Connection connection) {36 boolean actual = ConnectionPool.getInstance().releaseConnection(connection);37 assertFalse(actual);38 }39 @AfterClass40 public void afterClass() {41 ConnectionPool.getInstance().destroyPool();42 }43}...
Source:RetryAnalyzerTest.java
1package test.retryAnalyzer;2import static org.testng.Assert.assertEquals;3import static org.testng.Assert.assertFalse;4import static org.testng.Assert.assertTrue;5import java.util.List;6import org.testng.ITestResult;7import org.testng.TestListenerAdapter;8import org.testng.TestNG;9import org.testng.annotations.Test;10import test.SimpleBaseTest;11public class RetryAnalyzerTest extends SimpleBaseTest {12 @Test13 public void testInvocationCounts() {14 TestNG tng = create(InvocationCountTest.class);15 TestListenerAdapter tla = new TestListenerAdapter();16 tng.addListener(tla);17 tng.run();18 assertFalse(tng.hasFailure());19 assertFalse(tng.hasSkip());20 assertTrue(tla.getFailedTests().isEmpty());21 List<ITestResult> fsp = tla.getFailedButWithinSuccessPercentageTests();22 assertEquals(fsp.size(), 1);23 assertEquals(fsp.get(0).getName(), "failAfterThreeRetries");24 List<ITestResult> skipped = tla.getSkippedTests();25 assertEquals(skipped.size(), InvocationCountTest.invocations.size() - fsp.size());26 }27}...
assertFalse
Using AI Code Generation
1public void testAssertFalse() {2 boolean condition = false;3 Assert.assertFalse(condition);4}5public void testAssertTrue() {6 boolean condition = true;7 Assert.assertTrue(condition);8}9public void testAssertEquals() {10 String expected = "test";11 String actual = "test";12 Assert.assertEquals(actual, expected);13}14public void testAssertNotEquals() {15 String expected = "test";16 String actual = "test1";17 Assert.assertNotEquals(actual, expected);18}19public void testAssertSame() {20 String expected = "test";21 String actual = "test";22 Assert.assertSame(actual, expected);23}24public void testAssertNotSame() {25 String expected = "test";26 String actual = "test1";27 Assert.assertNotSame(actual, expected);28}29public void testAssertNull() {30 String expected = null;31 Assert.assertNull(expected);32}33public void testAssertNotNull() {34 String expected = "test";35 Assert.assertNotNull(expected);36}37public void testAssertThrows() {38 Assert.assertThrows(NullPointerException.class, () -> {39 throw new NullPointerException();40 });41}42public void testAssertThrowsWithMessage() {43 Assert.assertThrows(NullPointerException.class, () -> {44 throw new NullPointerException();45 }, "assertThrows method failed");46}47public void testAssertThrowsWithNoMessage() {48 Assert.assertThrows(NullPointerException.class, () -> {49 throw new NullPointerException();50 });51}52public void testAssertThrowsWithMessageSupplier() {53 Assert.assertThrows(NullPointerException.class, () -> {54 throw new NullPointerException();55 }, () -> "assertThrows method failed");56}
assertFalse
Using AI Code Generation
1Assert.assertFalse(false, "Message to be displayed if the condition is false");2Assert.assertTrue(true, "Message to be displayed if the condition is true");3Assert.assertEquals("actual", "expected", "Message to be displayed if the condition is false");4Assert.assertNotEquals("actual", "expected", "Message to be displayed if the condition is true");5Assert.assertNull(null, "Message to be displayed if the condition is false");6Assert.assertNotNull("actual", "Message to be displayed if the condition is true");7Assert.assertSame("actual", "expected", "Message to be displayed if the condition is false");8Assert.assertNotSame("actual", "expected", "Message to be displayed if the condition is true");9Assert.assertArrayEquals(new String[] {"actual"}, new String[] {"expected"}, "Message to be displayed if the condition is false");10Assert.assertThrows(NullPointerException.class, () -> {throw new NullPointerException();}, "Message to be displayed if the condition is false");11Assert.assertDoesNotThrow(() -> {throw new NullPointerException();}, "Message to be displayed if the condition is false");12Assert.assertThat("actual", CoreMatchers.equalTo("expected"));13Assert.assertThat("actual", CoreMatchers.equalTo("expected"), "Message to be displayed if the condition is false");14Assert.assertThat("actual", CoreMatchers.equalTo("expected"), () -> "Message to be displayed if the condition is false");15Assert.assertAll(() -> {Assert.assertEquals("actual", "expected");});
assertFalse
Using AI Code Generation
1import org.testng.Assert;2import org.testng.annotations.Test;3public class TestNGAssertFalseExample {4 public void testAssertFalse() {5 Assert.assertFalse(2 > 3);6 }7}8Recommended Posts: TestNG - Assert.assertTrue() Method9TestNG - Assert.assertNotNull() Method10TestNG - Assert.assertNull() Method11TestNG - Assert.assertThrows() Method12TestNG - Assert.assertDoesNotThrow() Method13TestNG - Assert.assertArrayEquals() Method14TestNG - Assert.assertEquals() Method15TestNG - Assert.assertNotEquals() Method16TestNG - Assert.fail() Method17TestNG - Assert.assertSame() Method18TestNG - Assert.assertNotSame() Method19TestNG - Assert.assertThrows() Method20TestNG - Assert.assertThrows() Method21TestNG - Assert.assertThrows() Method22TestNG - Assert.assertThrows() Method23TestNG - Assert.assertThrows() Method24TestNG - Assert.assertThrows() Method25TestNG - Assert.assertThrows() Method26TestNG - Assert.assertThrows() Method27TestNG - Assert.assertThrows() Method
assertFalse
Using AI Code Generation
1assertFalse() method of Assert class in TestNG2public static void assertFalse(boolean condition, String message)3assertFalse() method of Assert class in TestNG4package com.javatpoint.test;5import org.testng.Assert;6import org.testng.annotations.Test;7public class TestNGDemo2 {8 public void testAssertFalse(){9 Assert.assertFalse(false);10 }11}
assertFalse
Using AI Code Generation
1assertNull() method of Assert class in TestNG2public static void assertNull(Object object, String message)3assertNull() method of Assert class in TestNG4package com.javatpoint.test;5import org.testng.Assert;6import org.testng.annotations.Test;7public class TestNGDemo3 {8 public void testAssertNull(){9 Assert.assertNull(null);10 }11}
assertFalse
Using AI Code Generation
1 [Test]: # (title=Use assertFalse method of org.testng.Assert class)2 [Test]: # (tags=java, testng, assert)3 [Test]: # (type=code)4 [Test]: # (code=src/test/java/org/jesperancinha/jeorg/testng/AssertTest.java)5 [Test]: # (code=src/test/java/org/jesperancinha/jeorg/testng/AssertTest.java)6 [Test]: # (output=src/test/resources/outputs/assertFalse.txt)7 [Test]: # (source=org.jesperancinha.jeorg.testng.AssertTest#assertFalse)8 [Test]: # (source=org.jesperancinha.jeorg.testng.AssertTest#assertFalse)9 [Test]: # (test=org.jesperancinha.jeorg.testng.AssertTest#assertFalse)10 [Test]: # (test=org.jesperancinha.jeorg.testng.AssertTest#assertFalse)11 [Test]: # (start=1)12 [Test]: # (end=1)13 [Test]: # (name=assertFalse)14 [Test]: # (name=assertFalse)15 [Test]: # (description=Use assertFalse method of org.testng.Assert class)16 [Test]: # (title=Use assertFalse method of org.testng.Assert class)17 [Test]: # (tags=java, testng, assert)18 [Test]: # (type=code)19 [Test]: # (code=src/test/java/org/jesperancinha/jeorg/testng/AssertTest.java)20 [Test]: # (code=src/test/java/org/jesperancinha/jeorg/testng/AssertTest.java)21 [Test]: # (output=src/test/resources/outputs/assertFalse.txt)22 [Test]: # (source=org.jesperancinha.jeorg.testng.AssertTest#assertFalse)23 [Test]: # (source=org.jesperancinha.jeorg.testng.AssertTest#assertFalse)24 [Test]: # (test=org.jesperancinha.jeorg.testng.AssertTest#assertFalse)25 [Test]: # (test=org.jesperancinha.jeorg.testng.AssertTest#assertFalse)26 [Test]: # (start=1)27 [Test]: # (end=1)28 [Test]: # (name=assertFalse)
assertFalse
Using AI Code Generation
1public void testListIsEmpty() {2 List<String> list = new ArrayList<>();3 Assert.assertFalse(list.isEmpty());4}5public void testListIsEmpty() {6 List<String> list = new ArrayList<>();7 Assert.assertTrue(list.isEmpty());8}9public void testListIsEmpty() {10 List<String> list = new ArrayList<>();11 Assert.assertEquals(list.isEmpty(), true);12}13public void testListIsEmpty() {14 List<String> list = new ArrayList<>();15 Assert.assertNotEquals(list.isEmpty(), false);16}17public void testListIsEmpty() {18 List<String> list = null;19 Assert.assertNull(list);20}21public void testListIsEmpty() {22 List<String> list = new ArrayList<>();23 Assert.assertNotNull(list);24}25public void testListIsEmpty() {26 List<String> list1 = new ArrayList<>();27 List<String> list2 = list1;28 Assert.assertSame(list1, list2);29}30public void testListIsEmpty() {31 List<String> list1 = new ArrayList<>();32 List<String> list2 = new ArrayList<>();33 Assert.assertNotSame(list1, list2);34}35public void testListIsEmpty() {
TestNG is a Java-based open-source framework for test automation that includes various test types, such as unit testing, functional testing, E2E testing, etc. TestNG is in many ways similar to JUnit and NUnit. But in contrast to its competitors, its extensive features make it a lot more reliable framework. One of the major reasons for its popularity is its ability to structure tests and improve the scripts' readability and maintainability. Another reason can be the important characteristics like the convenience of using multiple annotations, reliance, and priority that make this framework popular among developers and testers for test design. You can refer to the TestNG tutorial to learn why you should choose the TestNG framework.
You can push your abilities to do automated testing using TestNG and advance your career by earning a TestNG certification. Check out our TestNG certification.
Watch this complete tutorial to learn how you can leverage the capabilities of the TestNG framework for Selenium automation testing.
Get 100 minutes of automation test minutes FREE!!