Best Karate code snippet using common.Main
Source:RemotingSubsystemTransformersTestCase.java
1/*2* JBoss, Home of Professional Open Source.3* Copyright 2012, Red Hat Middleware LLC, and individual contributors4* as indicated by the @author tags. See the copyright.txt file in the5* distribution for a full listing of individual contributors.6*7* This is free software; you can redistribute it and/or modify it8* under the terms of the GNU Lesser General Public License as9* published by the Free Software Foundation; either version 2.1 of10* the License, or (at your option) any later version.11*12* This software is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU15* Lesser General Public License for more details.16*17* You should have received a copy of the GNU Lesser General Public18* License along with this software; if not, write to the Free19* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA20* 02110-1301 USA, or see the FSF site: http://www.fsf.org.21*/22package org.jboss.as.remoting;23import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;24import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILED;25import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;26import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;27import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;28import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;29import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;30import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;31import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION;32import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;33import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;34import static org.jboss.as.remoting.SaslPolicyResource.FORWARD_SECRECY;35import static org.jboss.as.remoting.SaslPolicyResource.NO_ACTIVE;36import static org.jboss.as.remoting.SaslPolicyResource.NO_ANONYMOUS;37import static org.jboss.as.remoting.SaslPolicyResource.NO_DICTIONARY;38import static org.jboss.as.remoting.SaslPolicyResource.NO_PLAIN_TEXT;39import static org.jboss.as.remoting.SaslPolicyResource.PASS_CREDENTIALS;40import static org.junit.Assert.assertEquals;41import static org.junit.Assert.assertNotNull;42import static org.junit.Assert.assertTrue;43import java.util.ArrayList;44import java.util.List;45import org.jboss.as.controller.AttributeDefinition;46import org.jboss.as.controller.ModelVersion;47import org.jboss.as.controller.OperationFailedException;48import org.jboss.as.controller.PathAddress;49import org.jboss.as.controller.PathElement;50import org.jboss.as.controller.operations.common.Util;51import org.jboss.as.controller.transform.OperationTransformer;52import org.jboss.as.model.test.FailedOperationTransformationConfig;53import org.jboss.as.model.test.FailedOperationTransformationConfig.AttributesPathAddressConfig;54import org.jboss.as.model.test.ModelFixer;55import org.jboss.as.model.test.ModelTestControllerVersion;56import org.jboss.as.model.test.ModelTestUtils;57import org.jboss.as.subsystem.test.AbstractSubsystemTest;58import org.jboss.as.subsystem.test.AdditionalInitialization;59import org.jboss.as.subsystem.test.KernelServices;60import org.jboss.as.subsystem.test.KernelServicesBuilder;61import org.jboss.dmr.ModelNode;62import org.junit.Test;63/**64 * @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2012 Red Hat, inc65 */66public class RemotingSubsystemTransformersTestCase extends AbstractSubsystemTest {67 public RemotingSubsystemTransformersTestCase() {68 super(RemotingExtension.SUBSYSTEM_NAME, new RemotingExtension());69 }70 @Test71 public void testExpressionsAreRejectedAS712() throws Exception {72 testExpressionsAreRejectedByVersion_1_1(ModelTestControllerVersion.V7_1_2_FINAL);73 }74 @Test75 public void testExpressionsAreRejectedAS713() throws Exception {76 testExpressionsAreRejectedByVersion_1_1(ModelTestControllerVersion.V7_1_3_FINAL);77 }78 @Test79 public void testExpressionsAreRejectedEAP600() throws Exception {80 testExpressionsAreRejectedByVersion_1_1(ModelTestControllerVersion.EAP_6_0_0);81 }82 @Test83 public void testExpressionsAreRejectedEAP601() throws Exception {84 testExpressionsAreRejectedByVersion_1_1(ModelTestControllerVersion.EAP_6_0_1);85 }86 private void testExpressionsAreRejectedByVersion_1_1(ModelTestControllerVersion controllerVersion) throws Exception {87 String subsystemXml = readResource("remoting-with-expressions.xml");88 KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC);89 // Add legacy subsystems90 ModelVersion version_1_1 = ModelVersion.create(1, 1);91 builder.createLegacyKernelServicesBuilder(null, controllerVersion, version_1_1)92 .addMavenResourceURL("org.jboss.as:jboss-as-remoting:" + controllerVersion.getMavenGavVersion());93 KernelServices mainServices = builder.build();94 assertTrue(mainServices.isSuccessfulBoot());95 KernelServices legacyServices = mainServices.getLegacyServices(version_1_1);96 assertNotNull(legacyServices);97 assertTrue(legacyServices.isSuccessfulBoot());98 PathAddress subsystemAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME));99 ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version_1_1, parse(subsystemXml),100 new FailedOperationTransformationConfig()101 .addFailedAttribute(subsystemAddress.append(RemotingEndpointResource.ENDPOINT_PATH), FailedOperationTransformationConfig.DISCARDED_RESOURCE)102 .addFailedAttribute(subsystemAddress,103 new FailedOperationTransformationConfig.RejectExpressionsConfig(104 RemotingSubsystemRootResource.WORKER_READ_THREADS,105 RemotingSubsystemRootResource.WORKER_TASK_CORE_THREADS,106 RemotingSubsystemRootResource.WORKER_TASK_KEEPALIVE,107 RemotingSubsystemRootResource.WORKER_TASK_LIMIT,108 RemotingSubsystemRootResource.WORKER_TASK_MAX_THREADS,109 RemotingSubsystemRootResource.WORKER_WRITE_THREADS))110 .addFailedAttribute(subsystemAddress.append(PathElement.pathElement(CommonAttributes.CONNECTOR)).append(PathElement.pathElement(CommonAttributes.PROPERTY)),111 new FailedOperationTransformationConfig.RejectExpressionsConfig(VALUE))112 .addFailedAttribute(subsystemAddress.append(PathElement.pathElement(CommonAttributes.CONNECTOR)).append(PathElement.pathElement(CommonAttributes.SECURITY, CommonAttributes.SASL)),113 new FailedOperationTransformationConfig.RejectExpressionsConfig(CommonAttributes.SERVER_AUTH, CommonAttributes.REUSE_SESSION))114 .addFailedAttribute(subsystemAddress.append(PathElement.pathElement(CommonAttributes.CONNECTOR))115 .append(PathElement.pathElement(CommonAttributes.SECURITY, CommonAttributes.SASL)).append(PathElement.pathElement(CommonAttributes.SASL_POLICY)),116 new FailedOperationTransformationConfig.RejectExpressionsConfig(117 CommonAttributes.FORWARD_SECRECY,118 CommonAttributes.NO_ACTIVE,119 CommonAttributes.NO_ANONYMOUS,120 CommonAttributes.NO_DICTIONARY,121 CommonAttributes.NO_PLAIN_TEXT,122 CommonAttributes.PASS_CREDENTIALS))123 .addFailedAttribute(subsystemAddress.append(PathElement.pathElement(CommonAttributes.CONNECTOR))124 .append(PathElement.pathElement(CommonAttributes.PROPERTY)),125 new FailedOperationTransformationConfig.RejectExpressionsConfig(126 CommonAttributes.VALUE))127 .addFailedAttribute(subsystemAddress.append(128 PathElement.pathElement(CommonAttributes.CONNECTOR))129 .append(PathElement.pathElement(CommonAttributes.SECURITY, CommonAttributes.SASL))130 .append(CommonAttributes.PROPERTY),131 new FailedOperationTransformationConfig.RejectExpressionsConfig(132 CommonAttributes.VALUE))133 .addFailedAttribute(subsystemAddress.append(134 PathElement.pathElement(CommonAttributes.OUTBOUND_CONNECTION))135 .append(CommonAttributes.PROPERTY),136 new FailedOperationTransformationConfig.RejectExpressionsConfig(137 CommonAttributes.VALUE))138 .addFailedAttribute(subsystemAddress.append(PathElement.pathElement(CommonAttributes.REMOTE_OUTBOUND_CONNECTION)),139 new FailedOperationTransformationConfig.ChainedConfig(140 toList(new FailedOperationTransformationConfig.RejectExpressionsConfig(CommonAttributes.USERNAME), new FixProtocolConfig(CommonAttributes.PROTOCOL)),141 CommonAttributes.USERNAME, CommonAttributes.PROTOCOL))142 .addFailedAttribute(subsystemAddress.append(143 PathElement.pathElement(CommonAttributes.REMOTE_OUTBOUND_CONNECTION))144 .append(PathElement.pathElement(CommonAttributes.PROPERTY)),145 new FailedOperationTransformationConfig.RejectExpressionsConfig(CommonAttributes.VALUE))146 .addFailedAttribute(subsystemAddress.append(147 PathElement.pathElement(CommonAttributes.LOCAL_OUTBOUND_CONNECTION))148 .append(PathElement.pathElement(CommonAttributes.PROPERTY)),149 new FailedOperationTransformationConfig.RejectExpressionsConfig(CommonAttributes.VALUE)));150 }151 @Test152 public void testNonRemotingProtocolRejectedAS720() throws Exception {153 testNonRemotingProtocolRejectedByVersion1_2(ModelTestControllerVersion.V7_2_0_FINAL);154 }155 @Test156 public void testNonRemotingProtocolRejectedEAP610() throws Exception {157 testNonRemotingProtocolRejectedByVersion1_2(ModelTestControllerVersion.EAP_6_1_0);158 }159 @Test160 public void testNonRemotingProtocolRejectedEAP611() throws Exception {161 testNonRemotingProtocolRejectedByVersion1_2(ModelTestControllerVersion.EAP_6_1_1);162 }163 private void testNonRemotingProtocolRejectedByVersion1_2(ModelTestControllerVersion controllerVersion) throws Exception {164 String subsystemXml = readResource("remoting-with-expressions.xml");165 KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC);166 // Add legacy subsystems167 ModelVersion version_1_1 = ModelVersion.create(1, 2);168 builder.createLegacyKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC, controllerVersion, version_1_1)169 .addMavenResourceURL("org.jboss.as:jboss-as-remoting:" + controllerVersion.getMavenGavVersion());170 KernelServices mainServices = builder.build();171 assertTrue(mainServices.isSuccessfulBoot());172 KernelServices legacyServices = mainServices.getLegacyServices(version_1_1);173 assertNotNull(legacyServices);174 assertTrue(legacyServices.isSuccessfulBoot());175 PathAddress rootAddr = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME));176 ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version_1_1, parse(subsystemXml),177 new FailedOperationTransformationConfig()178 .addFailedAttribute(rootAddr.append(RemotingEndpointResource.ENDPOINT_PATH), FailedOperationTransformationConfig.DISCARDED_RESOURCE)179 .addFailedAttribute(rootAddr.append(PathElement.pathElement(CommonAttributes.REMOTE_OUTBOUND_CONNECTION)),180 new FixProtocolConfig(CommonAttributes.PROTOCOL)));181 }182 @Test183 public void testTransformersAS712() throws Exception {184 testTransformers_1_1(ModelTestControllerVersion.V7_1_2_FINAL);185 }186 @Test187 public void testTransformersAS713() throws Exception {188 testTransformers_1_1(ModelTestControllerVersion.V7_1_3_FINAL);189 }190 @Test191 public void testTransformersEAP600() throws Exception {192 testTransformers_1_1(ModelTestControllerVersion.EAP_6_0_0);193 }194 @Test195 public void testTransformersEAP601() throws Exception {196 testTransformers_1_1(ModelTestControllerVersion.EAP_6_0_1);197 }198 private void testTransformers_1_1(ModelTestControllerVersion controllerVersion) throws Exception {199 KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC)200 .setSubsystemXmlResource("remoting-without-expressions.xml");201 ModelVersion oldVersion = ModelVersion.create(1, 1);202 // Add legacy subsystems203 builder.createLegacyKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC, controllerVersion, oldVersion)204 .addMavenResourceURL("org.jboss.as:jboss-as-remoting:" + controllerVersion.getMavenGavVersion())205 .skipReverseControllerCheck();206 //.configureReverseControllerCheck(createAdditionalInitialization(), null);207 KernelServices mainServices = builder.build();208 assertTrue(mainServices.isSuccessfulBoot());209 KernelServices legacyServices = mainServices.getLegacyServices(oldVersion);210 assertNotNull(legacyServices);211 assertTrue(legacyServices.isSuccessfulBoot());212 checkSubsystemModelTransformation(mainServices, oldVersion, getAS7_6077Fixer(), false);213 checkRejectWorkerThreadAttributes(mainServices, oldVersion);214 checkRejectSASLAttribute(mainServices, oldVersion, CommonAttributes.REUSE_SESSION, "${reuse.session:true}");215 checkRejectSASLAttribute(mainServices, oldVersion, CommonAttributes.SERVER_AUTH, "${server.auth:true}");216 checkRejectSASLProperty(mainServices, oldVersion);217 checkRejectSASLPolicyAttributes(mainServices, oldVersion);218 checkRejectConnectorProperty(mainServices, oldVersion);219 checkRejectRemoteOutboundConnectionUsername(mainServices, oldVersion);220 checkRejectOutboundConnectionProperty(mainServices, oldVersion, CommonAttributes.REMOTE_OUTBOUND_CONNECTION, "remote-conn1");221 checkRejectOutboundConnectionProperty(mainServices, oldVersion, CommonAttributes.LOCAL_OUTBOUND_CONNECTION, "local-conn1");222 checkRejectOutboundConnectionProperty(mainServices, oldVersion, CommonAttributes.OUTBOUND_CONNECTION, "generic-conn1");223 checkRejectOutboundConnectionProtocolNotRemote(mainServices, oldVersion, CommonAttributes.REMOTE_OUTBOUND_CONNECTION, "remote-conn1");224 checkRejectHttpConnector(mainServices, oldVersion);225 checkRejectEndpointConfiguration(mainServices, oldVersion);226 }227 private ModelFixer getAS7_6077Fixer() {228 return new ModelFixer() {229 @Override230 public ModelNode fixModel(ModelNode modelNode) {231 for (AttributeDefinition ad : RemotingSubsystemRootResource.ATTRIBUTES) {232 if (modelNode.hasDefined(ad.getName())) {233 if (modelNode.get(ad.getName()).equals(ad.getDefaultValue())) {234 modelNode.get(ad.getName()).set(new ModelNode());235 }236 }237 }238 return modelNode;239 }240 };241 }242 @Test243 public void testTransformersAS720() throws Exception {244 testTransformers_1_2_0(ModelTestControllerVersion.V7_2_0_FINAL);245 }246 @Test247 public void testTransformersEAP610() throws Exception {248 testTransformers_1_2_0(ModelTestControllerVersion.EAP_6_1_0);249 }250 @Test251 public void testTransformersEAP611() throws Exception {252 testTransformers_1_2_0(ModelTestControllerVersion.EAP_6_1_1);253 }254 private void testTransformers_1_2_0(ModelTestControllerVersion controllerVersion) throws Exception {255 KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)256 .setSubsystemXmlResource("remoting-with-expressions-and-good-legacy-protocol.xml");257 ModelVersion oldVersion = ModelVersion.create(1, 2, 0);258 // Add legacy subsystems259 builder.createLegacyKernelServicesBuilder(null, controllerVersion, oldVersion)260 .addMavenResourceURL("org.jboss.as:jboss-as-remoting:" + controllerVersion.getMavenGavVersion())261 .skipReverseControllerCheck();262 //.configureReverseControllerCheck(createAdditionalInitialization(), null);263 KernelServices mainServices = builder.build();264 assertTrue(mainServices.isSuccessfulBoot());265 KernelServices legacyServices = mainServices.getLegacyServices(oldVersion);266 assertNotNull(legacyServices);267 assertTrue(legacyServices.isSuccessfulBoot());268 checkSubsystemModelTransformation(mainServices, oldVersion, null, false);269 checkRejectOutboundConnectionProtocolNotRemote(mainServices, oldVersion, CommonAttributes.REMOTE_OUTBOUND_CONNECTION, "remote-conn1");270 checkRejectHttpConnector(mainServices, oldVersion);271 checkRejectEndpointConfiguration(mainServices, oldVersion);272 }273 private void checkRejectOutboundConnectionProperty(KernelServices mainServices, ModelVersion version, String type, String name) throws OperationFailedException {274 ModelNode operation = new ModelNode();275 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);276 ModelNode address = new ModelNode();277 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);278 address.add(type, name);279 address.add(CommonAttributes.PROPERTY, "org.xnio.Options.SSL_ENABLED");280 operation.get(OP_ADDR).set(address);281 operation.get(NAME).set(CommonAttributes.VALUE);282 operation.get(VALUE).set("${myprop:true}");283 checkReject(operation, mainServices, version);284 }285 private void checkRejectOutboundConnectionProtocolNotRemote(KernelServices mainServices, ModelVersion version, String type, String name) throws OperationFailedException {286 ModelNode operation = new ModelNode();287 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);288 ModelNode address = new ModelNode();289 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);290 address.add(type, name);291 operation.get(OP_ADDR).set(address);292 operation.get(NAME).set(CommonAttributes.PROTOCOL);293 operation.get(VALUE).set(Protocol.HTTP_REMOTING.toString());294 checkReject(operation, mainServices, version);295 PathAddress addr = PathAddress.pathAddress(operation.get(OP_ADDR));296 PathElement element = addr.getLastElement();297 addr = addr.subAddress(0, addr.size() - 1);298 addr = addr.append(PathElement.pathElement(element.getKey(), "remoting-outbound2"));299 operation = Util.createAddOperation(addr);300 operation.get(CommonAttributes.OUTBOUND_SOCKET_BINDING_REF).set("dummy-outbound-socket");301 operation.get(CommonAttributes.USERNAME).set("myuser");302 operation.get(CommonAttributes.PROTOCOL).set(Protocol.HTTP_REMOTING.toString());303 checkReject(operation, mainServices, version);304 }305 private void checkRejectSASLAttribute(KernelServices mainServices, ModelVersion version, String name, String value) throws OperationFailedException {306 ModelNode operation = new ModelNode();307 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);308 ModelNode address = new ModelNode();309 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);310 address.add(CommonAttributes.CONNECTOR, "remoting-connector");311 address.add(CommonAttributes.SECURITY, CommonAttributes.SASL);312 operation.get(OP_ADDR).set(address);313 operation.get(NAME).set(name);314 operation.get(VALUE).set(value);315 checkReject(operation, mainServices, version);316 }317 private void checkRejectSASLProperty(KernelServices mainServices, ModelVersion version) throws OperationFailedException {318 ModelNode operation = new ModelNode();319 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);320 ModelNode address = new ModelNode();321 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);322 address.add(CommonAttributes.CONNECTOR, "remoting-connector");323 address.add(CommonAttributes.SECURITY, CommonAttributes.SASL);324 address.add(CommonAttributes.PROPERTY, "sasl1");325 operation.get(OP_ADDR).set(address);326 operation.get(NAME).set(CommonAttributes.VALUE);327 operation.get(VALUE).set("${sasl.prop:sasl one}");328 checkReject(operation, mainServices, version);329 }330 private void checkRejectSASLPolicyAttributes(KernelServices mainServices, ModelVersion version) throws OperationFailedException {331 for (AttributeDefinition attr: new AttributeDefinition[] {NO_ACTIVE, NO_ANONYMOUS, NO_DICTIONARY, FORWARD_SECRECY,332 NO_PLAIN_TEXT, PASS_CREDENTIALS}) {333 checkRejectSASLPolicyAttribute(mainServices, version, attr);334 }335 }336 private void checkRejectSASLPolicyAttribute(KernelServices mainServices, ModelVersion version, AttributeDefinition attr) throws OperationFailedException {337 ModelNode operation = new ModelNode();338 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);339 ModelNode address = new ModelNode();340 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);341 address.add(CommonAttributes.CONNECTOR, "remoting-connector");342 address.add(CommonAttributes.SECURITY, CommonAttributes.SASL);343 address.add(CommonAttributes.SASL_POLICY, CommonAttributes.POLICY);344 operation.get(OP_ADDR).set(address);345 operation.get(NAME).set(attr.getName());346 operation.get(VALUE).set("${mypolicy:false}");347 checkReject(operation, mainServices, version);348 }349 private void checkRejectConnectorProperty(KernelServices mainServices, ModelVersion version) throws OperationFailedException {350 ModelNode operation = new ModelNode();351 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);352 ModelNode address = new ModelNode();353 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);354 address.add(CommonAttributes.CONNECTOR, "remoting-connector");355 address.add(CommonAttributes.PROPERTY, "c1");356 operation.get(OP_ADDR).set(address);357 operation.get(NAME).set(CommonAttributes.VALUE);358 operation.get(VALUE).set("${connector.prop:connector one}");359 checkReject(operation, mainServices, version);360 }361 private void checkRejectRemoteOutboundConnectionUsername(KernelServices mainServices, ModelVersion version) throws OperationFailedException {362 ModelNode operation = new ModelNode();363 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);364 ModelNode address = new ModelNode();365 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);366 address.add(CommonAttributes.REMOTE_OUTBOUND_CONNECTION, "remote-conn1");367 operation.get(OP_ADDR).set(address);368 operation.get(NAME).set(CommonAttributes.USERNAME);369 operation.get(VALUE).set("${remoting.user:myuser}");370 checkReject(operation, mainServices, version);371 }372 private void checkRejectWorkerThreadAttributes(KernelServices mainServices, ModelVersion version) throws OperationFailedException {373 ModelNode operation = new ModelNode();374 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);375 ModelNode address = new ModelNode();376 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);377 operation.get(OP_ADDR).set(address);378 operation.get(NAME).set("worker-read-threads");379 operation.get(VALUE).set("${worker.read.threads:5}");380 checkReject(operation, mainServices, version);381 }382 private void checkRejectHttpConnector(KernelServices mainServices, ModelVersion version) throws OperationFailedException {383 ModelNode operation = new ModelNode();384 operation.get(OP).set(ADD);385 operation.get(CommonAttributes.CONNECTOR_REF).set("test");386 ModelNode address = new ModelNode();387 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);388 address.add(HttpConnectorResource.PATH.getKey(), "test");389 operation.get(OP_ADDR).set(address);390 checkReject(operation, mainServices, version);391 }392 private void checkRejectEndpointConfiguration(KernelServices mainServices, ModelVersion version) throws OperationFailedException {393 // First clean out any worker-thread-pool stuff from earlier testing394 ModelNode operation = new ModelNode();395 operation.get(OP).set(UNDEFINE_ATTRIBUTE_OPERATION);396 ModelNode address = operation.get(OP_ADDR);397 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);398 for (AttributeDefinition ad : RemotingSubsystemRootResource.ATTRIBUTES) {399 operation.get(NAME).set(ad.getName());400 ModelNode mainResult = mainServices.executeOperation(operation);401 assertEquals(mainResult.toJSONString(true), SUCCESS, mainResult.get(OUTCOME).asString());402 }403 operation = new ModelNode();404 operation.get(OP).set(ADD);405 address = new ModelNode();406 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);407 address.add(RemotingEndpointResource.ENDPOINT_PATH.getKey(), RemotingEndpointResource.ENDPOINT_PATH.getValue());408 operation.get(OP_ADDR).set(address);409 for (AttributeDefinition ad : RemotingEndpointResource.ATTRIBUTES) {410 ModelNode dflt = ad.getDefaultValue();411 if (dflt != null) {412 operation.get(ad.getName()).set(dflt);413 }414 }415 checkReject(operation, mainServices, version);416 }417 private void checkReject(ModelNode operation, KernelServices mainServices, ModelVersion version) throws OperationFailedException {418 ModelNode mainResult = mainServices.executeOperation(operation);419 assertEquals(mainResult.toJSONString(true), SUCCESS, mainResult.get(OUTCOME).asString());420 final OperationTransformer.TransformedOperation op = mainServices.transformOperation(version, operation);421 final ModelNode result = mainServices.executeOperation(version, op);422 assertEquals("should reject the operation", FAILED, result.get(OUTCOME).asString());423 }424 private List<AttributesPathAddressConfig<?>> toList(AttributesPathAddressConfig<?>...configs){425 List<AttributesPathAddressConfig<?>> list = new ArrayList<AttributesPathAddressConfig<?>>();426 for (AttributesPathAddressConfig<?> config : configs) {427 list.add(config);428 }429 return list;430 }431 private static class FixProtocolConfig extends AttributesPathAddressConfig<FixProtocolConfig> {432 public FixProtocolConfig(String... attributes) {433 super(attributes);434 }435 @Override436 protected boolean isAttributeWritable(String attributeName) {437 return true;438 }439 @Override440 protected boolean checkValue(String attrName, ModelNode attribute, boolean isWriteAttribute) {441 return !attribute.asString().equals(Protocol.REMOTE.toString());442 }443 @Override444 protected ModelNode correctValue(ModelNode toResolve, boolean isWriteAttribute) {445 return new ModelNode(Protocol.REMOTE.toString());446 }447 }448}...
Source:Boot.java
1package data;2//dependencies:3 import common.Common;4 import org.lwjgl.opengl.Display;5 //for opengl:6 import static org.lwjgl.opengl.GL11.*;7 //import helpers:8 import static helpers.Artist.*;9 //import texture:10 import org.newdawn.slick.Color;11 import org.newdawn.slick.TrueTypeFont;12 //keyboard control:13 import org.lwjgl.input.Keyboard;14//substitute main:15 import animals.*;16 import java.awt.*;17 import java.io.ByteArrayOutputStream;18 import java.io.PrintStream;19 import java.util.*;20/**21 * The main part of program22 */23public class Boot {24 public static ArrayList<Object> objectList = new ArrayList<Object>();25 public static TileGrid grid;26 public static Player mainPlayer = new Player(4,3);27 public static Common com;28 public static int tick;29 public static String playerPic = "playerM";30 public static String playerName = "MoonBoy";31 //STDOUT CHECK:32 private final static ByteArrayOutputStream outContent = new ByteArrayOutputStream();33// private final static ByteArrayOutputStream errContent = new ByteArrayOutputStream();34 private final static PrintStream originalOut = System.out;35// private final static PrintStream originalErr = System.err;36 public Boot() {37 tick = 0;38 //call helpers: Artist to load screen:39 beginSession();40 /**41 * Load and draw the map42 */43 //loadmap:44 grid = new TileGrid();45 //drawmap:46 grid.draw();47 //handle objects:48 grid.handleOccupiedTiles();49 //draw objects:50 for(int i =0; i<objectList.size(); ++i){51 objectList.get(i).draw();52 }53 /**54 * Initialize string writer for GUI55 */56 TrueTypeFont font = null;57 Font awtFont = new Font("Times New Roman", Font.BOLD, 20);58 Font awtFont2 = new Font("Times New Roman", Font.BOLD, 14);59 Font awtFont3 = new Font("Calibri", Font.BOLD, 34);60 font = new TrueTypeFont(awtFont, false);61 TrueTypeFont font2 = new TrueTypeFont(awtFont2, false);62 TrueTypeFont font3 = new TrueTypeFont(awtFont3, false);63 String[] inventory_content;64 int pass = 0;65 /**66 * GUI Loop67 */68 while(!Display.isCloseRequested()){ //while not prompted to close69 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);70 font3.drawString(47, 690, "CONTROLS", Color.yellow);71 font2.drawString(50, 730, "Move = w/a/s/d", Color.orange);72 font2.drawString(50, 755, "Grow = g", Color.orange );73 font2.drawString(50, 780, "Talk = t + <arrow_key>",Color.orange);74 font2.drawString(50, 805, "Kill = k + <arrow_key>",Color.orange);75 font2.drawString(50, 830, "Interact = i + <arrow_key>",Color.orange);76 font2.drawString(50, 855, "Mix = m + <arrow_key> + <recipe_code>",Color.orange);77 font2.drawString(50, 880, "Exit = ESC_KEY",Color.orange);78 font3.drawString(345, 690, "RECIPE CODE", Color.green);79 font2.drawString(350, 730, "Mixed Cheese = 0", Color.cyan);80 font2.drawString(350, 755, "(Cow Milk + Goat Milk)", Color.cyan);81 font2.drawString(350, 785, "Horse Rolade = 1", Color.cyan);82 font2.drawString(350, 810, "(Horse Meat + Duck Egg)", Color.cyan);83 font2.drawString(350, 840, "Bacon Omelette = 2", Color.cyan);84 font2.drawString(350, 865, "(Pig Meat + Chicken Egg)", Color.cyan);85 inventory_content = mainPlayer.printBackpack();86 int ystep = 25;87 font3.drawString(560, 690, "INVENTORY:");88 for(int i=0; i<6; ++i){89 font2.drawString(560, 730+(ystep*i), (i+1)+". " + inventory_content[i]);90 if(inventory_content[i] != "") {91 if (inventory_content[i] == "MixedCheese")92 drawQuadTexture(quickLoad("mixedcheese"), 700, 730+(ystep*i), 30, 25);93 else if (inventory_content[i] == "BaconOmelette")94 drawQuadTexture(quickLoad("baconomelette"), 700, 730+(ystep*i), 30, 25);95 else if (inventory_content[i] == "HorseRolade")96 drawQuadTexture(quickLoad("horserolade"), 700, 730+(ystep*i), 30, 25);97 }98 }99 /*100 if (inventory_content[0] != ""){101 drawQuadTexture(quickLoad("MixedCheese"), 600, 730, 50, 50);102 }*/103 font.drawString(900, 700, "OUTPUT:");104 if(outContent.toString().contains("Animal's killed")){105 String[] str_piece = outContent.toString().split("A", 2);106 font.drawString(900, 730, "It cries : " + str_piece[0]);107 font.drawString(900, 755, "A" + str_piece[1]);108 if(Common.animalList.size() == 0){109 font.drawString(900, 780, "---------------");110 font.drawString(900, 805, "Game Over");111 font.drawString(900, 830, "Final Score: " + mainPlayer.getScore());112 }113 } else if(Common.animalList.size() == 0){114 font.drawString(900, 730, "Game Over");115 font.drawString(900, 755, "Final Score: " + mainPlayer.getScore());116 } else{117 font.drawString(900, 730, outContent.toString());118 }119 font.drawString(1150, 700, "TICK = " + tick);120 font.drawString(1150, 730, "MONEY = " + mainPlayer.getScore(), Color.yellow);121 font.drawString(1150, 760, "WATER = " + mainPlayer.getPouch(), Color.blue);122 font.drawString(1150, 900, "");123 drawQuadTexture(quickLoad(playerPic), 1150, 790, 150, 150);124 font.drawString(1150, 900, playerName);125 if((tick % 20) > 10){126 font.drawString(1150, 760, "", Color.blue); // set to malam127 }128 if (Keyboard.next() && Keyboard.getEventKeyState()) {129 outContent.reset();130 setUpStreams();131 //CHANGE PLAYER PIC:132 if (Keyboard.isKeyDown(Keyboard.KEY_P)) {133 if (playerPic == "playerM") {134 playerPic = "playerF";135 playerName = "MoonGurl";136 }137 else{138 playerPic = "playerM";139 playerName = "MoonBoy";140 }141 }142 143 //MIX KEY:144 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_0) && Keyboard.isKeyDown(Keyboard.KEY_UP)) {145 mainPlayer.mix('w', "MixedCheese");146 updateMap();147 }148 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_1) && Keyboard.isKeyDown(Keyboard.KEY_UP)) {149 mainPlayer.mix('w', "HorseRolade");150 updateMap();151 }152 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_2) && Keyboard.isKeyDown(Keyboard.KEY_UP)) {153 mainPlayer.mix('w', "BaconOmelette");154 updateMap();155 }156 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_0) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {157 mainPlayer.mix('d', "MixedCheese");158 updateMap();159 }160 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_1) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {161 mainPlayer.mix('d', "HorseRolade");162 updateMap();163 }164 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_2) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {165 mainPlayer.mix('d', "BaconOmelette");166 updateMap();167 }168 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_0) && Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {169 mainPlayer.mix('s', "MixedCheese");170 updateMap();171 }172 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_1) && Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {173 mainPlayer.mix('s', "HorseRolade");174 updateMap();175 }176 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_2) && Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {177 mainPlayer.mix('s', "BaconOmelette");178 updateMap();179 }180 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_0) && Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {181 mainPlayer.mix('a', "MixedCheese");182 updateMap();183 }184 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_1) && Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {185 mainPlayer.mix('a', "HorseRolade");186 updateMap();187 }188 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_2) && Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {189 mainPlayer.mix('a', "BaconOmelette");190 updateMap();191 }192 //INTERACT KEY:193 if(Keyboard.isKeyDown(Keyboard.KEY_I) && Keyboard.isKeyDown(Keyboard.KEY_UP) ){194 mainPlayer.interact('w');195 updateMap();196 }197 if(Keyboard.isKeyDown(Keyboard.KEY_I) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT) ){198 mainPlayer.interact('d');199 updateMap();200 }201 if(Keyboard.isKeyDown(Keyboard.KEY_I) && Keyboard.isKeyDown(Keyboard.KEY_DOWN) ){202 mainPlayer.interact('s');203 updateMap();204 }205 if(Keyboard.isKeyDown(Keyboard.KEY_I) && Keyboard.isKeyDown(Keyboard.KEY_LEFT) ) {206 mainPlayer.interact('a');207 updateMap();208 }209 //TALK KEY:210 if (Keyboard.isKeyDown(Keyboard.KEY_T) && Keyboard.isKeyDown(Keyboard.KEY_UP)) {211 mainPlayer.talk('w');212 updateMap();213 }214 if (Keyboard.isKeyDown(Keyboard.KEY_T) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {215 mainPlayer.talk('d');216 updateMap();217 }218 if (Keyboard.isKeyDown(Keyboard.KEY_T) && Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {219 mainPlayer.talk('s');220 updateMap();221 }222 if (Keyboard.isKeyDown(Keyboard.KEY_T) && Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {223 mainPlayer.talk('a');224 updateMap();225 }226 //KILL KEY:227 if (Keyboard.isKeyDown(Keyboard.KEY_K) && Keyboard.isKeyDown(Keyboard.KEY_UP)) {228 mainPlayer.kill('w');229 updateMap();230 }231 if (Keyboard.isKeyDown(Keyboard.KEY_K) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {232 mainPlayer.kill('d');233 updateMap();234 }235 if (Keyboard.isKeyDown(Keyboard.KEY_K) && Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {236 mainPlayer.kill('s');237 updateMap();238 }239 if (Keyboard.isKeyDown(Keyboard.KEY_K) && Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {240 mainPlayer.kill('a');241 updateMap();242 }243 //GROW KEY:244 if (Keyboard.isKeyDown(Keyboard.KEY_G)) {245 mainPlayer.grow();246 updateMap();247 }248 //EXIT KEY:249 if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {250 break;251 }252 //MOVE KEY:253 if (Keyboard.isKeyDown(Keyboard.KEY_W)) {254 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).makeUnoccupied();255 mainPlayer.move('w');256 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).playerOccupy();257 updateMap();258 }259 if (Keyboard.isKeyDown(Keyboard.KEY_A)) {260 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).makeUnoccupied();261 mainPlayer.move('a');262 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).playerOccupy();263 updateMap();264 }265 if (Keyboard.isKeyDown(Keyboard.KEY_S)) {266 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).makeUnoccupied();267 mainPlayer.move('s');268 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).playerOccupy();269 updateMap();270 }271 if (Keyboard.isKeyDown(Keyboard.KEY_D)) {272 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).makeUnoccupied();273 mainPlayer.move('d');274 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).playerOccupy();275 updateMap();276 }277 restoreStreams();278 }279 //drawmap:280 grid.draw();281 //handle objects:282 grid.handleOccupiedTiles();283 //draw objects:284 for(int i =0; i<objectList.size(); ++i){285 objectList.get(i).draw();286 }287 Display.update();288 Display.sync(60);289 if(Common.animalList.size() == 0){290 pass++;291 if(pass > 5){292 try{Thread.sleep(3000);}catch(InterruptedException e){break;}293 break;294 }295 }296 }297 /**298 * Close the GUI Window after Game Over or ESC KEY pressed299 */300 Display.destroy();301 }302 public static void updateMap(){303 tick++;304 for(int i = 0; i < Common.animalList.size(); i++){305 Common.animalList.get(i).minThreshold();306 }307 //Move all animal every 2 ticks308 if(tick != 0 && tick % 2 == 0){309 com.moveAllAnimals();310 }311 //Erase dead animal and eat if hungry312 for(int i = 0; i < Common.animalList.size(); i++){313 Common.gamemap.get(Common.animalList.get(i).getX()).get(Common.animalList.get(i).getY()).makeUnoccupied();314 Common.animalList.get(i).eat();315 Common.gamemap.get(Common.animalList.get(i).getX()).get(Common.animalList.get(i).getY()).animalOccupy(Common.animalList.get(i));316 if(Common.animalList.get(i).getThreshold() <= -5){317 Common.gamemap.get(Common.animalList.get(i).getX()).get(Common.animalList.get(i).getY()).makeUnoccupied();318 //animalList.erase(animalList.begin() + i);319 Common.animalList.remove(i);320 }321 }322 //Update all facilities:323 com.updateAllFacilities();324 objectList.clear();325 //loadmap:326 grid = new TileGrid();327 }328 /**329 * Method to catch STDOUT330 */331 public static void setUpStreams() {332 System.setOut(new PrintStream(outContent));333 //System.setErr(new PrintStream(errContent));334 }335 /**336 * Method to clear the setOut337 */338 public static void restoreStreams() {339 System.setOut(originalOut);340 //System.setErr(originalErr);341 }342 /**343 * Entry point of program.344 * Initialize map reader, spawn animals, and create GUI window345 * @param args346 */347 public static void main(String[] args){348 com = new Common();349 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).playerOccupy();350 //Bagian Spawn Animal secara random351 //Spawn 3 Chickens352 Random rand = new Random();353 for(int i = 0; i < 3; i++){354 int x = 0;355 int y = 0;356 //Loop until correct position is found357 do{358 x = rand.nextInt(Common.gamemap.size());359 y = rand.nextInt(Common.getGamemap().get(0).size());360 } while(Common.gamemap.get(x).get(y).showSymbol() != 'o' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));361 FarmAnimal a = new Chicken(x, y, false);362 //add animal into list of animal363 Common.animalList.add(a);364 //update gamemap365 Common.gamemap.get(x).get(y).animalOccupy(a);366 }367 //Spawn 4 Ducks368 for(int i = 0; i < 4; i++){369 int x = 0;370 int y = 0;371 //Loop until correct position is found372 do{373 x = rand.nextInt(Common.gamemap.size());374 y = rand.nextInt(Common.getGamemap().get(0).size());375 } while(Common.gamemap.get(x).get(y).showSymbol() != 'o' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));376 FarmAnimal a = new Duck(x, y, false);377 //add animal into list of animal378 Common.animalList.add(a);379 //update gamemap380 Common.gamemap.get(x).get(y).animalOccupy(a);381 }382 //Spawn 8 Cows383 for(int i = 0; i < 8; i++){384 int x = 0;385 int y = 0;386 //Loop until correct position is found387 do{388 x = rand.nextInt(Common.gamemap.size());389 y = rand.nextInt(Common.getGamemap().get(0).size());390 } while(Common.gamemap.get(x).get(y).showSymbol() != '.' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));391 FarmAnimal a = new Cow(x, y, false);392 //add animal into list of animal393 Common.animalList.add(a);394 //update gamemap395 Common.gamemap.get(x).get(y).animalOccupy(a);396 }397 //Spawn 7 Goats398 for(int i = 0; i < 7; i++){399 int x = 0;400 int y = 0;401 //Loop until correct position is found402 do{403 x = rand.nextInt(Common.gamemap.size());404 y = rand.nextInt(Common.getGamemap().get(0).size());405 } while(Common.gamemap.get(x).get(y).showSymbol() != '.' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));406 FarmAnimal a = new Goat(x, y, false);407 //add animal into list of animal408 Common.animalList.add(a);409 //update gamemap410 Common.gamemap.get(x).get(y).animalOccupy(a);411 }412 //Spawn 5 Pigs413 for(int i = 0; i < 5; i++){414 int x = 0;415 int y = 0;416 //Loop until correct position is found417 do{418 x = rand.nextInt(Common.gamemap.size());419 y = rand.nextInt(Common.getGamemap().get(0).size());420 } while(Common.gamemap.get(x).get(y).showSymbol() != 'x' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));421 FarmAnimal a = new Pig(x, y, false);422 //add animal into list of animal423 Common.animalList.add(a);424 //update gamemap425 Common.gamemap.get(x).get(y).animalOccupy(a);426 }427 //Spawn 4 Horses428 for(int i = 0; i < 4; i++){429 int x = 0;430 int y = 0;431 //Loop until correct position is found432 do{433 x = rand.nextInt(Common.gamemap.size());434 y = rand.nextInt(Common.getGamemap().get(0).size());435 } while(Common.gamemap.get(x).get(y).showSymbol() != 'x' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));436 FarmAnimal a = new Horse(x, y, false);437 //add animal into list of animal438 Common.animalList.add(a);439 //update gamemap440 Common.gamemap.get(x).get(y).animalOccupy(a);441 }442 /*443 System.out.println(" GAME OVER");444 System.out.println("---------------------------------------------");445 System.out.println("Final score: " + mainPlayer.getScore());446 */447 //boot the GUI:448 new Boot();449 }450}...
Source:InviteNewMembers.java
...29 }30 31 public void clickAddMembers()32 {33 commonMethods.switchBackToMainFrame(driver);34 35 driver.findElement(addMembers).click();36 commonMethods.switchBackToMainFrame(driver);37 }38 39 public Boolean isAddMembersButtonDisplayed()40 {41 commonMethods.switchBackToMainFrame(driver);42 43 Boolean found = commonMethods.isElementDisplayed(addMembers, driver);44 commonMethods.switchBackToMainFrame(driver);45 return found;46 }47 48 public InviteNewMembers enterEmailAddress(String emailAddress)49 {50 commonMethods.switchBackToMainFrame(driver);51 52 driver.findElement(emailAddresses).sendKeys(emailAddress);53 commonMethods.switchBackToMainFrame(driver);54 return this;55 }56 57 public Boolean isEmailAddressesDisplayed()58 {59 commonMethods.switchBackToMainFrame(driver);60 61 Boolean found = commonMethods.isElementDisplayed(emailAddresses, driver);62 commonMethods.switchBackToMainFrame(driver);63 return found;64 }65 66 public InvitationResults clickSendInvitations()67 {68 commonMethods.switchBackToMainFrame(driver);69 70 driver.findElement(sendInvitations).click();71 commonMethods.switchBackToMainFrame(driver);72 return new InvitationResults(driver);73 }74 75 public Boolean isSendInvitationsButtonDisplayed()76 {77 commonMethods.switchBackToMainFrame(driver);78 79 Boolean found = commonMethods.isElementDisplayed(sendInvitations, driver);80 commonMethods.switchBackToMainFrame(driver);81 return found;82 }83 84 public void clickRemoveAll()85 {86 commonMethods.switchBackToMainFrame(driver);87 88 driver.findElement(removeAll).click();89 commonMethods.switchBackToMainFrame(driver);90 }91 92 public Boolean isRemoveAllButtonDisplayed()93 {94 commonMethods.switchBackToMainFrame(driver);95 96 Boolean found = commonMethods.isElementDisplayed(removeAll, driver);97 commonMethods.switchBackToMainFrame(driver);98 return found;99 }100 101 public InviteNewMembers clickNthInviteeEdit(int n)102 {103 commonMethods.switchBackToMainFrame(driver);104 105 driver.findElement(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableEdit)).click();106 commonMethods.switchBackToMainFrame(driver);107 return this;108 }109 110 public InviteNewMembers clickNthInviteeSave(int n)111 {112 commonMethods.switchBackToMainFrame(driver);113 114 driver.findElement(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableSave)).click();115 commonMethods.switchBackToMainFrame(driver);116 return this;117 }118 119 public InviteNewMembers clickNthInviteeDelete(int n)120 {121 commonMethods.switchBackToMainFrame(driver);122 123 driver.findElement(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableDelete)).click();124 commonMethods.switchBackToMainFrame(driver);125 return this;126 }127 128 public Boolean isNthInviteeEditButtonDisplayed(int n)129 {130 commonMethods.switchBackToMainFrame(driver);131 132 Boolean found = commonMethods.isElementDisplayed(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableEdit), driver);133 commonMethods.switchBackToMainFrame(driver);134 return found;135 }136 137 public Boolean isNthInviteeSaveButtonDisplayed(int n)138 {139 commonMethods.switchBackToMainFrame(driver);140 141 Boolean found = commonMethods.isElementDisplayed(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableSave), driver);142 commonMethods.switchBackToMainFrame(driver);143 return found;144 }145 146 public Boolean isNthInviteeDeleteButtonDisplayed(int n)147 {148 commonMethods.switchBackToMainFrame(driver);149 150 Boolean found = commonMethods.isElementDisplayed(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableDelete), driver);151 commonMethods.switchBackToMainFrame(driver);152 return found;153 }154 155 public Boolean isNthInviteeEmailFieldDisplayed(int n)156 {157 commonMethods.switchBackToMainFrame(driver);158 159 Boolean found = commonMethods.isElementDisplayed(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableEmail), driver);160 commonMethods.switchBackToMainFrame(driver);161 return found;162 }163 164 public Boolean isNthInviteeFirstnameFieldDisplayed(int n)165 {166 commonMethods.switchBackToMainFrame(driver);167 168 Boolean found = commonMethods.isElementDisplayed(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableFirstName), driver);169 commonMethods.switchBackToMainFrame(driver);170 return found;171 }172 173 public Boolean isNthInviteeLastNameFieldDisplayed(int n)174 {175 commonMethods.switchBackToMainFrame(driver);176 177 Boolean found = commonMethods.isElementDisplayed(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableLastName), driver);178 commonMethods.switchBackToMainFrame(driver);179 return found;180 }181 182 public InviteNewMembers enterNthEmail(int n, String email)183 {184 commonMethods.switchBackToMainFrame(driver);185 186 driver.findElement(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableEmail)).sendKeys(email);187 commonMethods.switchBackToMainFrame(driver);188 return this;189 }190 191 public InviteNewMembers enterNthFirstname(int n, String fname)192 {193 commonMethods.switchBackToMainFrame(driver);194 195 driver.findElement(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableFirstName)).sendKeys(fname);196 commonMethods.switchBackToMainFrame(driver);197 return this;198 }199 200 public InviteNewMembers enterNthLastName(int n, String lname)201 {202 commonMethods.switchBackToMainFrame(driver);203 204 driver.findElement(By.cssSelector(listOfInviteesTable+":nth-child("+n+")"+listOfInviteesTableLastName)).sendKeys(lname);205 commonMethods.switchBackToMainFrame(driver);206 return this;207 }208}...
Main
Using AI Code Generation
1import common.Main;2public class Four {3 public static void main(String[] args) {4 Main m = new Main();5 m.method();6 }7}8package common;9public class Main {10 public void method() {11 System.out.println("Hello");12 }13}14In Java, we can also import all the classes of a package by using the * wildcard. For example, we can import all the classes of java.util package by using the following statement:15import java.util.*;16We can also import classes of a package by using the static keyword. For example, we can import the java.lang.System class by using the following statement:17import static java.lang.System.*;18We can also import all the static members of a package by using the * wildcard. For example, we can import all the static members of java.lang package by using the following statement:19import static java.lang.*;20If we import a package more than once, then the compiler will not give any error. But the compiler will not import the package again. It will simply ignore the duplicate import statement. For example, consider the following code:21import java.util.*;22import java.util.*;23public class Five {24 public static void main(String[] args) {25 System.out.println("Hello");26 }27}28If we import a class or package that does not exist, then the compiler will give an error. For example, consider the following code:29import java.util1.*;30public class Six {31 public static void main(String[] args) {32 System.out.println("Hello");33 }34}35import java.util1.*;36In the above code, we have imported java.util1
Main
Using AI Code Generation
1import common.Main;2class MainClass {3 public static void main(String[] args) {4 Main obj = new Main();5 obj.display();6 }7}8package common;9public class Main {10 public void display() {11 System.out.println("Hello World!");12 }13}
Main
Using AI Code Generation
1import common.Main;2public class Main {3 public static void main(String[] args) {4 System.out.println("Hello World!");5 }6}7package common;8public class Main {9 public static void main(String[] args) {10 System.out.println("Hello World!");11 }12}13import common.Main;14 Main.main(args);15import common.Main;16 Main.main(args);17import common.Main;18 Main.main(args);19import common.Main;20 Main.main(args);21import common.Main;22 Main.main(args);23import common.Main;24 Main.main(args);
Main
Using AI Code Generation
1package com.common;2public class Main {3 public static void main(String[] args) {4 System.out.println("Hello World");5 }6}7package com.common;8public class Main {9 public static void main(String[] args) {10 System.out.println("Hello World");11 }12}13package com.common;14public class Main {15 public static void main(String[] args) {16 System.out.println("Hello World");17 }18}19package com.common;20public class Main {21 public static void main(String[] args) {22 System.out.println("Hello World");23 }24}25package com.common;26public class Main {27 public static void main(String[] args) {28 System.out.println("Hello World");29 }30}31package com.common;32public class Main {33 public static void main(String[] args) {34 System.out.println("Hello World");35 }36}37package com.common;38public class Main {39 public static void main(String[] args) {40 System.out.println("Hello World");41 }42}43package com.common;44public class Main {45 public static void main(String[] args) {46 System.out.println("Hello World");47 }48}49package com.common;50public class Main {51 public static void main(String[] args) {52 System.out.println("Hello World");53 }54}55package com.common;56public class Main {57 public static void main(String[] args) {58 System.out.println("Hello World");59 }60}61package com.common;62public class Main {63 public static void main(String[] args) {64 System.out.println("Hello World");65 }66}
Main
Using AI Code Generation
1package com.common;2public class Main {3 public static void main(String[] args) {4 System.out.println("Hello World!");5 }6}7package com.common;8public class Main {9 public static void main(String[] args) {10 System.out.println("Hello World!");11 }12}13package com.common;14public class Main {15 public static void main(String[] args) {16 System.out.println("Hello World!");17 }18}19package com.common;20public class Main {21 public static void main(String[] args) {22 System.out.println("Hello World!");23 }24}25package com.common;26public class Main {27 public static void main(String[] args) {28 System.out.println("Hello World!");29 }30}31package com.common;32public class Main {33 public static void main(String[] args) {34 System.out.println("Hello World!");35 }36}37package com.common;38public class Main {39 public static void main(String[] args) {40 System.out.println("Hello World!");41 }42}43package com.common;44public class Main {45 public static void main(String[] args) {46 System.out.println("Hello World!");47 }48}49package com.common;50public class Main {51 public static void main(String[] args) {52 System.out.println("Hello World!");53 }54}55package com.common;56public class Main {57 public static void main(String[] args) {58 System.out.println("Hello World!");59 }60}61package com.common;62public class Main {63 public static void main(String[] args) {64 System.out.println("Hello World!");65 }66}
Main
Using AI Code Generation
1import common.Main;2{3public static void main(String args[])4{5System.out.println("Hello World");6System.out.println("The value of x is " + Main.x);7}8}
Main
Using AI Code Generation
1import common.Main;2public class 4 extends Main {3 public static void main(String[] args) {4 Main main = new Main();5 main.print();6 }7}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!