Strange Null Pointer Exception in my tests passes one but fails other - java

Trying to use test driven development and ran into a NPE that I can't resolve and obviously because of that one of my tests fail.
In a method to fetch items I pass in a limit int and then instantiate a callback.
this is exactly where it falis the listener returns null I think.
[![enter image description here][1]][1]
Test class
package com.techyourchance.testdrivendevelopment.example11;
#RunWith(MockitoJUnitRunner.class)
public class FetchCartItemsUseCaseTest {
public static final int LIMIT = 10;
public static final int PRICE = 5;
public static final String ID = "id";
public static final String TITLE = "title";
public static final String DESCRIPTION = "description";
FetchCartItemsUseCase SUT;
#Mock
FetchCartItemsUseCase.Listener mListnerMock1;
FetchCartItemsUseCase.Listener mListnerMock2;
#Mock
GetCartItemsHttpEndpoint mGetCartItemsHttpEndpointMock;
#Captor
ArgumentCaptor<List<CartItem>> mAcListCartItem;
#Before
public void setup() throws Exception {
SUT = new FetchCartItemsUseCase(mGetCartItemsHttpEndpointMock);
success();
}
private void success() {
doAnswer(new Answer() {
#Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
Callback callback = (Callback) args[1];
callback.onGetCartItemsSucceeded(getCartItemSchemes());
return null;
}
}).when(mGetCartItemsHttpEndpointMock).getCartItems(anyInt(), any(Callback.class));
}
private List<CartItemSchema> getCartItemSchemes() {
List<CartItemSchema> schemas = new ArrayList<>();
schemas.add(new CartItemSchema(ID, TITLE, DESCRIPTION, PRICE));
return schemas;
}
#Test
public void fetchCartItems_correctLimitPassedToEndPoint() throws Exception {
ArgumentCaptor<Integer> acInt = ArgumentCaptor.forClass(Integer.class);
SUT.fetchCartItemsAndNotify(LIMIT);
verify(mGetCartItemsHttpEndpointMock).getCartItems(acInt.capture(), any(GetCartItemsHttpEndpoint.Callback.class));
assertThat(acInt.getValue(), is(LIMIT));
}
#Test
public void fetchCartItems_success_observersNotifiedWithCorrectData() throws Exception {
SUT.registerListener(mListnerMock1);
SUT.registerListener(mListnerMock2);
SUT.fetchCartItemsAndNotify(LIMIT);
verify(mListnerMock1).onCartItemsFetched(mAcListCartItem.capture());
verify(mListnerMock2).onCartItemsFetched(mAcListCartItem.capture());
List<List<CartItem>> captures = mAcListCartItem.getAllValues();
List<CartItem> capture1 = captures.get(0);
List<CartItem> capture2 = captures.get(1);
assertThat(capture1, is(getCartItems()));
assertThat(capture2, is(getCartItems()));
}
private List<CartItem> getCartItems() {
List<CartItem> cartItems = new ArrayList<>();
cartItems.add(new CartItem(ID, TITLE, DESCRIPTION, PRICE));
return cartItems;
}
//correct limit passed to the endpoint
//success - all observers notified with correct data
//success - unsubscribed observers not notified
//general error - observers notified of failure
//network error - observers notified of failure
}
public class FetchCartItemsUseCase {
private final List<Listener> mListeners = new ArrayList<>();
private final GetCartItemsHttpEndpoint mGetCartItemsHttpEndpoint;
public FetchCartItemsUseCase(GetCartItemsHttpEndpoint mGetCartItemsHttpEndpoint) {
this.mGetCartItemsHttpEndpoint = mGetCartItemsHttpEndpoint;
}
public void fetchCartItemsAndNotify(int limit) {
mGetCartItemsHttpEndpoint.getCartItems(limit, new GetCartItemsHttpEndpoint.Callback() {
#Override
public void onGetCartItemsSucceeded(List<CartItemSchema> cartItems) {
for(Listener listener : mListeners) {
listener.onCartItemsFetched(cartItemsFromSchemas(cartItems));
}
}
#Override
public void onGetCartItemsFailed(GetCartItemsHttpEndpoint.FailReason failReason) {
}
}) ;
}
private List<CartItem> cartItemsFromSchemas(List<CartItemSchema> cartItemSchemas) {
List<CartItem> cartItems = new ArrayList<>();
for(CartItemSchema schema : cartItemSchemas) {
cartItems.add(new CartItem(schema.getId(), schema.getTitle(),
schema.getDescription(), schema.getPrice()));
}
return cartItems;
}
public void registerListener(Listener listener) {
mListeners.add(listener);
}
public interface Listener {
Void onCartItemsFetched(List<CartItem> capture);
}
}
[1]: https://i.stack.imgur.com/r6Sea.png
really lost would appreciate any help
public class FetchReputationUseCaseSync {
private GetReputationHttpEndpointSync mGetReputationHttpEndpointSync;
public FetchReputationUseCaseSync(GetReputationHttpEndpointSync getReputationHttpEndpointSync) {
this.mGetReputationHttpEndpointSync = getReputationHttpEndpointSync;
}
public UseCaseResult fetchReputation() {
GetReputationHttpEndpointSync.EndpointResult result;
try{
result = mGetReputationHttpEndpointSync.getReputationSync();
}catch (NetworkErrorException e) {
e.printStackTrace();
return UseCaseResult.FAILURE;
}
switch(result.getStatus()) {
case SUCCESS:
return UseCaseResult.SUCCESS;
case GENERAL_ERROR:
return UseCaseResult.FAILURE;
default:
throw new RuntimeException("invalid status: " + result);
}
}
public enum UseCaseResult{
SUCCESS, FAILURE
}
}

Related

Return to the list of a repository in Controller

I'm trying to return a list that is inside a Repository in my controller, but I'm not getting it. Could someone help me?
This is a RESTapi for an ATM project that I am doing for training my code. I'm using Spring Boot, Java, JUnit and Mockito. The dispenser starts with some values, however when calling the GET method, some notes are removed.
Repository
I created a list here, but I can't call it from the controller like a made with other repositories. The dispenser is created
#Repository
public class DispenserRepository {
private List<Cedula> notasDisponiveis;
public DispenserRepository() {
notasDisponiveis = new ArrayList<>();
notasDisponiveis.add(new Cedula(5, TipoNota.NOTAS_100));
notasDisponiveis.add(new Cedula(7, TipoNota.NOTAS_50));
notasDisponiveis.add(new Cedula(2, TipoNota.NOTAS_20));
notasDisponiveis.add(new Cedula(5, TipoNota.NOTAS_10));
}
public List<Cedula> buscarNotasDispenser() {
return notasDisponiveis;
}
}
SaqueService
#Service
public class SaqueService {
private static final Logger LOGGER = LoggerFactory.getLogger(SaqueService.class);
private final DispenserService dispenser;
public SaqueService(DispenserService dispenser) {
this.dispenser = dispenser;
}
public List<CedulaDTO> sacarCedulas(Integer valor) throws ValorIndisponivelException, NumeroDeNotasIndisponivelException {
List<CedulaDTO> cedulaDTOSList = buscarDistribuicaoDeCedulas(valor);
atualizarDispenser(cedulaDTOSList);
return cedulaDTOSList;
}
DispenserService
#Service
public class DispenserService {
private List<Cedula> notasDisponiveis;
private final DispenserRepository dispenserRepository;
public DispenserService(DispenserRepository dispenserRepository) {
this.dispenserRepository = dispenserRepository;
}
private void buscarNotasDispenser() {
notasDisponiveis = dispenserRepository.buscarNotasDispenser();
}
public Optional<Cedula> buscarCedulaDoTipo(TipoNota tipoNota) {
if (notasDisponiveis == null || notasDisponiveis.isEmpty()) {
buscarNotasDispenser();
}
return notasDisponiveis
.stream()
.filter(cedula -> cedula.getNota().equals(tipoNota))
.findFirst();
}
public void atualizarRetiraDeCedulas(TipoNota tipoNota, Integer quantidade) throws CedulaIndisponivelException, NumeroDeNotasIndisponivelException {
Optional<Cedula> cedulaOptional = buscarCedulaDoTipo(tipoNota);
if (cedulaOptional.isPresent()) {
cedulaOptional.get().retirarEstoque(quantidade);
} else {
throw new CedulaIndisponivelException("Cedula não encontrada!");
}
}
public List<Cedula> buscarNotasEmEstoque() {
if (notasDisponiveis == null || notasDisponiveis.isEmpty()) {
buscarNotasDispenser();
}
return notasDisponiveis
.stream()
.filter(cedula -> cedula.getQuantidadeDisponivel() > 0)
.collect(Collectors.toList());
}
}
Model
#Getter
#EqualsAndHashCode
public class Cedula {
private Integer quantidadeDisponivel;
private TipoNota nota;
public Cedula(Integer quantidadeDisponivel, TipoNota nota) {
this.quantidadeDisponivel = quantidadeDisponivel;
this.nota = nota;
}
public void retirarEstoque(Integer quantidade) throws NumeroDeNotasIndisponivelException {
if (quantidadeDisponivel < quantidade) {
throw new NumeroDeNotasIndisponivelException("Número de notas indisponível!");
}
quantidadeDisponivel = quantidadeDisponivel - quantidade;
}
}
Controller
#CrossOrigin
#RestController
#RequestMapping("/sacar")
public class SaqueController {
private final SaqueService saqueService;
public SaqueController(SaqueService saqueService) {
this.saqueService = saqueService;
}
#ResponseStatus(HttpStatus.OK)
#GetMapping("/{valor}")
public ResponseEntity<?> retornaQuantidadeDeNotas(#PathVariable("valor") Integer valor) throws ValorIndisponivelException, NumeroDeNotasIndisponivelException {
return new ResponseEntity<>(saqueService.sacarCedulas(valor), HttpStatus.OK);
}
}

JDK13 Garbage Collection Not Working Correctly. Some of the de-referenced objects not being garbage collected

*The implementation module is not being garbage collected after it is de-reference in UI module. I have overridden finalize method in all the classes of implementation. finalize method of none of the objects being called after dereferencing. No Thread is running in implementation module when it is de-referenced.
The below code is only to provide a perspective of project. The Set of WeakReferences in BankConfig, Main class are not part of original project.
The CoreConfig and CoreController belong to implementation module.
*
public class BankConfig {
public final String uuid = UUID.randomUUID().toString();
public final String name;
public Controller controller;
public BankConfig(String name, Controller controller) {
this.name = name;
this.controller = controller;
}
#SuppressWarnings("deprecation")
#Override
protected void finalize() throws Throwable {
System.out.println("garbage collected : "+uuid);
super.finalize();
}
#Override
public String toString() {
return "bank-"+uuid;
}
}
public interface Controller {
public abstract BankConfig getBankConfig();
}
public class CoreConfig extends BankConfig {
public CoreConfig(String name,Controller controller) {
super(name, controller);
}
public CoreConfig(BankConfig bankConfig) {
super(bankConfig.name, bankConfig.controller);
}
public CoreConfig(BankConfig bankConfig, final Controller controller) {
super(bankConfig.name, controller);
}
#Override
public String toString() {
return "core-"+uuid;
}
}
public class CoreController implements Controller {
public final CoreConfig config;
public CoreController(BankConfig config) {
this.config = new CoreConfig(config, this);
}
#Override
public BankConfig getBankConfig() {
return config;
}
}
public class Main {
private static final Set<WeakReference<BankConfig>> WEAK_REFERENCES = new HashSet<>();
public static final ObservableList<BankConfig> banks = FXCollections.observableArrayList();
static {
banks.add(readConfigFromDatabase("krishna"));
banks.add(readConfigFromDatabase("shankar"));
}
public static void main(String[] args) throws InterruptedException {
banks.add(loadController(readConfigFromDatabase("krishna")).getBankConfig());
banks.add(loadController(readConfigFromDatabase("shankar")).getBankConfig());
for (BankConfig bankConfig : banks) {
WEAK_REFERENCES.add(new WeakReference<BankConfig>(bankConfig));
}
banks.clear();
for (int i = 0; i < 5; i++) {
System.out.println("strong references : "+banks);
System.out.println("weak references : "+WEAK_REFERENCES.stream().filter(ref -> ref.get() != null).map(ref -> ref.get()).collect(Collectors.toSet()));
System.gc();
Thread.sleep(5000);
}
}
public static final Controller loadController(final BankConfig config) {
try {
final List<String> moduleNames = List.of("implementation");
final URLClassLoader loader = new URLClassLoader(new URL[0]);
final Configuration configuration = ModuleLayer.boot().configuration().resolveAndBind(ModuleFinder.of(Path.of(new URL("path to implementation jar").toURI())), ModuleFinder.of(), moduleNames);
final ModuleLayer moduleLayer = ModuleLayer.boot().defineModulesWithOneLoader(configuration, loader);
final Optional<Module> module = moduleLayer.findModule("implementation");
final Class<?> controllerClass = module.get().getClassLoader().loadClass("implementation.CoreController");
final Controller controller = (Controller) controllerClass.getConstructors()[0].newInstance(config);
return controller;
} catch (Exception e) {e.printStackTrace();}
return null;
}
public static BankConfig readConfigFromDatabase(final String name) {
if("krishna".equals(name)) return new BankConfig("krishna", null);
else if("shankar".equals(name)) return new BankConfig("shankar", null);
return null;
}
}
The issue was caused by datakernel library used in implementation module caused due to JmxModule registering jmx-compatible components to the global jmx registry.
Reference : datakernel issue #17

android testing - mockito error org.mockito.exceptions.misusing.WrongTypeOfReturnValue:

I try to create test for my presenter, but when I run it, I got this kind of error
org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
ScalarSynchronousObservable cannot be returned by getContext()
getContext() should return Context
I create my presenter test class like this
public class CreateTalkPresenterTest {
#Mock
TalkService talkService;
#Mock
CreateTalkMvpView createTalkMvpView;
CreateTalkPresenter createTalkPresenter;
#Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
talkService = ServiceFactory.createMapi(createTalkMvpView.getContext(), TalkService.class);
createTalkPresenter = new CreateTalkPresenter(Schedulers.immediate(), Schedulers.immediate());
createTalkPresenter.attachView(createTalkMvpView);
}
#Test
public void createTalkSuccessfullTest() {
TalkService.TalkResultModel talkResultModel = MockModel.newTalkResultModel();
when(talkService.createNewTalk(
FileUtil.createPartFromString("Lorem Ipsum dolor"),
FileUtil.createPartFromString("100"),
null,
FileUtil.createPartFromString("0")
)).thenReturn(Observable.just(talkResultModel));
createTalkPresenter.callCreateTalk("Lorem Ipsum dolor", "100", null);
verify(createTalkMvpView).showProgressIndeterminate();
verify(createTalkMvpView).hideProgressIndeterminate();
verify(createTalkMvpView).showTalkCreated(talkResultModel.object);
}
}
and for Mock the result I use this class
public class MockModel {
public static TalkService.TalkResultModel newTalkResultModel(){
TalkService.TalkResultModel talkResultModel = new TalkService.TalkResultModel();
talkResultModel.code = 600;
talkResultModel.message = "Successfully executed!";
talkResultModel.object = newTalkModel();
return talkResultModel;
}
public static TalkModel newTalkModel(){
Random random = new Random();
String index = String.valueOf(random.nextInt(100));
TalkModel talkModel = new TalkModel();
talkModel.id = index;
talkModel.content = "Lorem Ipsum dolor";
talkModel.categorytalk = newCategoryTalkModel("Category "+index);
talkModel.creator = newConsumerModel("User "+index);
return talkModel;
}
public static CategoryTalkModel newCategoryTalkModel(String name){
CategoryTalkModel categoryTalkModel = new CategoryTalkModel();
categoryTalkModel.id = "100";
categoryTalkModel.name = name;
return categoryTalkModel;
}
public static ConsumerModel newConsumerModel(String name){
Random random = new Random();
String index = String.valueOf(random.nextInt(100));
ConsumerModel consumerModel = new ConsumerModel();
consumerModel.id = index;
consumerModel.username = name;
consumerModel.email = name+"#domain.com";
consumerModel.fullName = "Fullname "+name;
return consumerModel;
}
}
And this is the presenter class that I want to test
public class CreateTalkPresenter implements Presenter<CreateTalkMvpView> {
private CreateTalkMvpView createTalkMvpView;
private TalkService mApiTalkService;
private TalkService.TalkResultModel talkResultModel;
private final Scheduler mainScheduler, ioScheduler;
private Subscription subscription;
public CreateTalkPresenter(Scheduler ioScheduler, Scheduler mainScheduler) {
this.ioScheduler = ioScheduler;
this.mainScheduler = mainScheduler;
}
#Override
public void attachView(CreateTalkMvpView view) {
createTalkMvpView = view;
}
#Override
public void detachView() {
createTalkMvpView = null;
unsubscribe();
}
private void unsubscribe() {
if (subscription != null) subscription.unsubscribe();
}
public void callCreateTalk(String content, String categoryId, String filePath) {
mApiTalkService = ServiceFactory.createMapi(createTalkMvpView.getContext(), TalkService.class);
unsubscribe();
createTalkMvpView.showProgressIndeterminate();
subscription = mApiTalkService.createNewTalk(
FileUtil.createPartFromString(content),
FileUtil.createPartFromString(categoryId),
filePath != null ? FileUtil.prepareFilePart("picture", new File(filePath)) : null,
FileUtil.createPartFromString("0"))
.observeOn(mainScheduler)
.subscribeOn(ioScheduler)
.subscribe(new Subscriber<TalkService.TalkResultModel>() {
#Override
public void onCompleted() {
createTalkMvpView.hideProgressIndeterminate();
createTalkMvpView.showTalkCreated(talkResultModel.object);
}
#Override
public void onError(Throwable e) {
createTalkMvpView.hideProgressIndeterminate();
WarningUtil.onApiError(createTalkMvpView.getContext(), 0, e.getMessage());
}
#Override
public void onNext(TalkService.TalkResultModel talkResultModel) {
CreateTalkPresenter.this.talkResultModel = talkResultModel;
}
});
}
}
I'm using retrofit 2.1.0 and rx android in this case.
So if someone have any idea, what I'm doing wrong in my code. Please help me
Thanks.
talkService isn't a mock. Even though you have this set:
#Mock
TalkService talkService;
You then overwrite it in your #Before method setUp:
talkService = ServiceFactory.createMapi(createTalkMvpView.getContext(), TalkService.class);
So in your test, this happens to a real TalkService implementation:
when(talkService.createNewTalk(/* ... */
)).thenReturn(Observable.just(talkResultModel));
Which then calls a real createNewTalk method, which starts with this:
mApiTalkService = ServiceFactory.createMapi(
createTalkMvpView.getContext(), TalkService.class);
The rest of the method isn't important, because Mockito's when works by mocking the last method that was called before/within the call to when, and nothing else in that method interacts with mocks. If talkService were a mock, then when(talkService.createNewTalk(/*...*/)) would stub the method createNewTalk, but instead it stubs that last mock method call getContext. This makes it look like:
when(createTalkMvpView.getContext()).thenReturn(Observable.just(talkResultModel));
...which exactly matches your error message:
org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
ScalarSynchronousObservable cannot be returned by getContext()
To fix this, just remove your talkService assignment so the when method call is actually a mock, or use a real talkService as you've initialized it and remove the #Mock annotation and when and verify statements.

#MockClass is not working

I am new to jmockit and trying to execute the following online example.
The #MockClass is not working. My BookStore's getBookTitle() method is calling the function of orginal class instead of the mock class.
BookStore class:
public class BookStore {
public String getBookTitle(String isbn){
return BookStoreService.getBookTitle(isbn);
}
}
BookStoreService class:
public class BookStoreService {
public static String getBookTitle(String isbn){
return "Random";
}
}
Test class:
public class BookStoreTest {
private static Map<String, String> bookMap = new HashMap<String, String>(2);
#BeforeClass
public static void setup() {
System.out.println("in setup()");
bookMap.put("0553293354", "Foundation");
bookMap.put("0836220625", "The Far Side Gallery");
}
#MockClass(realClass = BookStoreService.class)
public static class MockBookstoreService {
#Mock
public static String getBookTitle(String isbn) {
System.out.println("in getBookTitle()");
if (bookMap.containsKey(isbn)) {
return bookMap.get(isbn);
} else {
return null;
}
}
}
#Test
public void testGetBookTitle() throws Exception {
System.out.println("in testGetBookTitle()");
final String isbn = "0553293354";
final String expectedTitle = "Foundation";
BookStore store = new BookStore();
String title = store.getBookTitle(isbn);
System.out.println(title); // This prints "Random" instead of "Foundation"
Assert.assertEquals(title, expectedTitle);
}
}
PS: I am using TestNG
Using the latest stable version of jmockit you could do it like this:
#BeforeClass
public static void setup() {
System.out.println("in setup()");
bookMap.put("0553293354", "Foundation");
bookMap.put("0836220625", "The Far Side Gallery");
new MockUp<BookStoreService>() {
#Mock
public String getBookTitle(String isbn) {
System.out.println("in getBookTitle()");
if (bookMap.containsKey(isbn)) {
return bookMap.get(isbn);
} else {
return null;
}
}
};
}
Remove the obsolete block:
public static class MockBookstoreService{...}

How to Globally Access Java Bean Class?

I have one java bean class set values in parsing .My requirement to access this class
Globally but give null pointer exception when use its instance static and assign value in that.Code is as:-
private String Responce;
private String Error;
private String Url;
private SIPModle objsip;
private VMModle objvmmodle;
private ArrayList<CustompadModle> objcmodlelist = new ArrayList<CustompadModle>();
private SettingModle objsettingmodle;
private WifiModle objwifimodle;
public String getResponce() {
return Responce;
}
public void setResponce(String responce) {
Responce = responce;
}
public String getError() {
return Error;
}
public void setError(String error) {
Error = error;
}
public ArrayList<CustompadModle> getObjcmodlelist() {
return objcmodlelist;
}
public void setObjcmodlelist(CustompadModle objcmodlelist) {
this.objcmodlelist.add(objcmodlelist);
}
public String getUrl() {
return Url;
}
public void setUrl(String url) {
Url = url;
}
public SIPModle getObjsip() {
return objsip;
}
public void setObjsip(SIPModle objsip) {
this.objsip = objsip;
}
public VMModle getObjvmmodle() {
return objvmmodle;
}
public void setObjvmmodle(VMModle objvmmodle) {
this.objvmmodle = objvmmodle;
}
public SettingModle getObjsettingmodle() {
return objsettingmodle;
}
public void setObjsettingmodle(SettingModle objsettingmodle) {
this.objsettingmodle = objsettingmodle;
}
public WifiModle getObjwifimodle() {
return objwifimodle;
}
public void setObjwifimodle(WifiModle objwifimodle) {
this.objwifimodle = objwifimodle;
}
My requirement is that globle access this bean class globlly.Anyone suggest me
I am getting this object in doinbackground and assign in static object of that class as:
AsyncTask {
ProgressDialog objprogress = new ProgressDialog(
UserSettingConfiguration.this);
ApplicationRequestHandler objhandler = new ApplicationRequestHandler();
#Override
protected void onPreExecute() {
this.objprogress.setMessage("Please Wait While Loading...");
this.objprogress.isShowing();
}
#Override
protected ConfigurationSttingModle doInBackground(String... params) {
objconfigsetting = objhandler.getConfigurationSetting(params[0],
params[1], params[2], params[3]);
return objconfigsetting;
}
#Override
protected void onPostExecute(ConfigurationSttingModle result) {
if (this.objprogress.isShowing()) {
this.objprogress.dismiss();
}
}
}
And use in a class Advance as;-
private static HashMap<String, String> SUMMARIES = new HashMap<String, String>() {
private static final long serialVersionUID = 3055562364235868653L;
{
String server = UserSettingConfiguration.objconfigsetting.getObjsip().getServer();
String displayname1 = UserSettingConfiguration.objconfigsetting.getObjsip().getUser();
String user = UserSettingConfiguration.objconfigsetting.getObjsip().getUser();
String password= UserSettingConfiguration.objconfigsetting.getObjsip().getPassword();
put(FIELD_DISPLAY_NAME,displayname1);// "90901");
put(FIELD_CALLER_ID,displayname1); //"90901");
put(FIELD_SERVER,server);
put(FIELD_USERNAME,user);
put(FIELD_AUTH_ID, "207");
put(FIELD_PASSWORD,password);
put(FIELD_PROXY, null);
}
};
I think that a singleton pattern will match your requirements.
You must add this code:
private static MyJavaBeanClass = null;
public static MyJavaBeanClass getInstance(){
if(null == instance){
instance = new MyJavaBeanClass();
}
return instance;
}
You must change MyJavaBeanClass for the name of your class, and then you can invoke it anywhere like this:
MyJavaBeanClass.getInstance().setError("Testing");

Categories