State Machine Compiler

Oct 19, 2014

I am working in software testing, specifically automatic test cases generation. Among the existing forms of test cases, my focus is on the test cases that are composed of sequences of events such as _.event1.event2 eventx()

However, the events can be classified into: sensitive and insensitive. The latter does not affect the system's states, and hence, it can be ignored; while the former affects the states. Anyhow, the sensitive events in the test cases may lead to states explosion and there is a need to prevent that. Therefore, some techniques suggest using one variable to present states and group all similar states together such as using len variable in circular queue. Relatively, the states can be represented by using specific drawings such FSM.

For example, the test cases for circular queue may look like:

add(0).remove().add(1).Front()
add(0).add(1).remove().Front()

which produce the following states:

len=1, rear=0, front=0 and dataQ[0]=0
len=0, rear=0, front=1 and dataQ={0}
len=1, rear=1, front=1 and dataQ[1]=1

len=1, rear=0, front=0 and dataQ[0]=0
len=2, rear=1, front=0 and dataQ[1]=1
len=1, rear=1, front=1 and dataQ={1,0}

As can be seen, every addition/deletion produces a new state. A state is composed of 4 variables: len, rear, front and dataQ. The 1st three variables are integers while the dataQ is an integer array. Nonetheless, the states produced by different test cases can be identical which wastes effort and time. So, there is a need to optimize these states. The search techniques were suggested where the problem can be represented as a search problem and the technique is applied. If we consider Len as a state, then we will have: len=0; 0QSize. However, this does not represent the state but it suits for classifying the states into groups.

In terms of states representation, State Machine/Map Compiler (SMC) was suggested as a modeling mechanism that takes the state machines (i.e. FSM) drawing and generates the code in any preferred language. In SMC, the FSM is represented in a specific syntax (state---transition----next state) and saved in a file (.sm). This file will be compiled by SMC to generate a context class which includes definitions of states, transitions and actions in FSM but still need to be triggered by another class. This class has to call the transitions that modifies the state.

We had created that class and implemented all the methods with their transitions. However, the FSM used was based on 1 variable only (i.e. len). Besides, we are still looking for the SMC results as they will be the input for any search technique to be applied. Supposedly, the states generated by SMC can be used directly in the search technique but this is still questionable.

View Replies


ADVERTISEMENT

Networking :: Connecting To Remote Windows Machine From Local Machine Using SSH2

Apr 11, 2014

I have developed a code to connecting remote windows M/C from local M/C by using SSH2 (ganymed-ssh2-build209.jar) API. when I run the code its giving below error. Is there any other way to connect remote windows system using java code.
 
Exception.
 
java.io.IOException: There was a problem while talking to <host name>:22
  at ch.ethz.ssh2.Connection.connect(Connection.java:642)
  at ch.ethz.ssh2.Connection.connect(Connection.java:460)
  at Connect.RemoteServer.ConnectWindowsServer.runCommand(ConnectWindowsServer.java:55)
  at Connect.RemoteServer.ConnectWindowsServer.main(ConnectWindowsServer.java:27)
Caused by: java.net.ConnectException: Connection refused: connect

[Code] ....
 
JAVA Code

import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.Session;
 public void setAuthenticationInfo(String hostname, String username,String password) {
       this.host = hostname;
       this.userid = username;
       this.password = password;      
       this.recentCommand = "";     
       System.out.println("setting authentication info completed for host=" + host );
 
[Code] .....

View Replies View Related

Java Code To Access Windows Machine From Unix Machine

Feb 28, 2014

I have a requirement where I have to send a file from a local system to unix box(present on client side) using java code.I have developed a code that is successfully sending the file from local system to client side unix box (I am connecting to client side unix box using VPN) provided I run the code in my eclipse IDE present in local system. But when I am running the same code in the unix box it is throwing null pointer exception.Might be the unix system is not recognising the local system. Please find the code.
 
package abc;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Properties;
import com.jcraft.jsch.Channel;

[Code] ....

Error on unix box which I am getting is :-
 
Inside sftpConnection method
llllllll
fffffffffffff
Connection Successfull
Channel Connection Succesfull
aaaaa
Inside findFile method
Exception in thread "main" java.lang.NullPointerException
        at abc.TranferFile.sftpConnection(TranferFile.java:58)
        at abc.TranferFile.main(TranferFile.java:21)

View Replies View Related

Store A State Of A Project

Sep 23, 2014

Hello World program. We had to build it. Write a basic Java program that will implement one class to store a state of a project. The class should have one property to store a textual name of the state. When a object of this class is created the initial state should be "Open".

1) Class should have one method next() which will move the project to the next step in the sequence: Open - In progress - Closed.If next method is called for a project in the Closed state it should do nothing.

2) Class should have a method close() which will move the project into the Closed state.

3) Class should have a method print() that will output a current state of the project.

Submit a java code file as your assignment. Do not hesitate to contact me if you have any troubles with the assignment.

I have been working on this thing for almost a week, and really don't have a clue on what to do. I know I have to use a string = open, and I know I have to create an object. I don't have a clue on how to do this. I have read the chapter so many times, I almost memorized it, but what he wants is nothing like our demo in the book. the Book used set and get, and utility scanner, but he doesn't want any of that. Just a basic code that will move from Open --- in progress --- closed.

The best I can tell what he wants is when I set the object to open it will display " project is open", then when I set it to " in progress" it will read project is "in progress". I don't have a clue what close is suppose to do, or the print method.

View Replies View Related

Stale Object State Exception

Aug 17, 2014

Caused by: javax.persistence.NonUniqueResultException: result returns more than one elements
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryI mpl.java:109)

What are the common reasons for the above exception and the suitable fixes?

View Replies View Related

JSF :: Server-side State Saving

Nov 25, 2014

in my web.xml the.STATE_SAVING_METHOD setting is server

<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>

for measurement of application security isn't not allow to change this parameter to client , so the problem when I access for application and I open a new page via linker for print for example and I would access for my initial page to make change or modify my initial page it s no possible to make any modification because I have a empty bean , but if the state saving is a client I haven't a problem because a tree map is stored in client browser, so my version of JSF is 1.1.1 ,

View Replies View Related

How To Set State Of Radio Button Based On Configuration File

Apr 10, 2014

I am using Java Swing to create a GUI. I have some radio buttons on a JFrame that gets opened when the user makes a certain selection. I want to read a config file to have the radio buttons selected or deselected when the form is opened to indicate the current state of the radio button based on the saved config file.

How do I go about setting the radio button as selected (visibly selected) when I open up the JFrame?

I was trying to use RadioButton.setSelected(True); but this doesn't actually visibly select the radio button.

View Replies View Related

Illegal State Exception Thrown From RequestFocus In JavaFX

May 2, 2015

I am attempting to create a very simple game where two squares move around and each can see the other square moving. This is a multi-player game over a TCP network using JavaFX. I am getting an illegal state exception when I call requestFocus(). This is my server:

public class GameServer extends Application {
ObjectOutputStream p1out;
ObjectOutputStream p2out;
int PLAYER1 = 1;
int PLAYER2 = 2;

[Code] .....

View Replies View Related

How Does Threads Come Back To Ready State After Executing The Task

Mar 21, 2014

When a thread completes its execution, it will be destroyed.In Java thread pool implemenation, how does threads come back to ready state after executing the task.?

View Replies View Related

Thread Java - Illegal State Monitor Exception

May 30, 2014

Class A{
Public static synchronized void main(String args[]){
Thread t= new thread();
t.start();
Sysout("hi");
t.wait(1000);
Sysout("hello");
}}

Illegal state monitor exception. Why?

View Replies View Related

Difference Between Interpreter And Compiler?

Aug 13, 2014

I am reading a java book and find a theory about Interpreter and Compiler. explain different between them?

View Replies View Related

Compiler Error Even After Downcasting

Apr 3, 2014

An example from the SCJP(OCP) book:

Java Code:

class Animal {
void makeNoise() {System.out.println("generic noise"); }
}
class Dog extends Animal {
void makeNoise() {System.out.println("bark"); }
void playDead() { System.out.println("roll over"); }

[Code] .....

The book states that the above code will compile if there is a downcast in the line 14 . But there is a compiler error saying playDead method is not defined for type animal even after downcasting.

View Replies View Related

Java Online Compiler API

Aug 20, 2014

Running a java source code through an online java compiler (in which you will just pass the the source code using a http request, then the compiler will return the output/error of the source code automatically)?.

View Replies View Related

GameLauncher Compiler Error

Apr 24, 2015

I have started to learn JAVA and was referring Head First JAVA book.
I have 3 separate .java files - GuessGame.java , Player.java, GameLauncher.java
I have successfully compiled GuessGame.java & Player.java

But I am getting an error when I am compiling GameLauncher.java.

View Replies View Related

Default Initialization To Appropriate Value By Compiler

Feb 20, 2014

I remember reading Instance variables & local variables (in methods) are initialized to appropriate value by the compiler.

Is this true for static class variables and variables in nested classes ?

View Replies View Related

How To Change State Of Object - Main Method Exception Error

Jan 8, 2015

The error I get when I execute my java file.

Exception in thread "main" java.lang.NullPointerExceptionat DogTestDrive.main(DogTestDrive.java:19)

Here is the source

class Dog {
int size;
String name;
void bark () {
if (size < 60) {
System.out.println("Woof woof");

[code]....

Some background: I'm reading "Head first Java 2nd edition" and I'm going through the examples which is showing me how to change the state of an object. The original code looks like the code below, however the previous chapter went over creating array's of an object, so I created an array of the object "Dog" and wanted to re-write it this way. To my understanding, it should work but it's giving me that error when I execute it. The error itself isn't very clear, if I could get a line number pointed to, that would work.

class Dog {
int size;
String name;
void bark() {
if (size > 60) {
System.out.println(“Wooof! Wooof!”);
} else if (size > 14) {
System.out.println(“Ruff! Ruff!”);
} else {
System.out.println(“Yip! Yip!”);

[code]....

View Replies View Related

Extracting Kerala State Vehicle Number Plate From Image

Mar 25, 2015

code for extracting kerala state vehicle number plate from an image

View Replies View Related

JavaFX 2.0 :: Stage From Iconified State To Regular Size Via Shortcut

Jan 23, 2015

I would like to ask you about possibility to restore javafx 8 app from iconified mode (setIconified(true)) to regular size via shorcut for example: Ctrl + Shift + Ins I use Windows 7 and jdk 1.8.0_40 beta.

View Replies View Related

How Compiler Picks What Method To Execute

Feb 20, 2014

public class Main {
private static void foo(Integer a) {
System.out.println("Integer");
}
private static void foo(long a) {
System.out.println("long");

[Code] ....

This code prints long. Why is that? How did compiler decided that it likes long version of foo() method the most. If I had to guess I'd pick int... or possibly Integer as they are most similiar to what was passed. But why long?

View Replies View Related

Why Does Compiler / IDE Force To Use Static In Code

Oct 24, 2014

I'm a beginner fiddling around classes in Java. I noticed on this particular code, Eclipse will give me an error and suggest I put the static keyword in front of the variable.

public class test {
//the following line is where Eclipse puts the static keyword
static FileAccess hello = new FileAccess("D:" + '\', ".mp3");
public static void main(String[] args) {
for (int i = 0; i < hello.getTotalNumberOfFiles(); i++) {

[Code] .....

The FileAccess class is just a class I made while trying to retrieve filenames from my hard drive.

As far as I can tell, it works correctly after I put the static keyword there. I just want to know why it is required in this particular code, considering it didn't need to do that when I made a simpler class while I was getting my feet wet at creating classes in Java.

View Replies View Related

Compiler Does Not Show Any Warning Or Errors

May 18, 2014

public void init(Board board) {
JPanel Panel = new JPanel();
Panel.setLayout(new GridLayout(board.getWidth(), board.getHeight()));
getContentPane().add(Panel, BorderLayout.CENTER);
Panel.setBorder(new LineBorder(Color.BLACK)); // it does not work also
 
[code]....

I have a JFrame. I added two JPanels to the JFrame. The first one is GridLayout and it should be situated at CENTER. Another one is bottomPanel, and that one should be situated at SOUTH.I would like to add two new JPanels(kit and another one) to the bottomPanel.Compiler does not show any warning or errors.The problem is, that bottomPanel situates at NORTH, not at SOUTH. kit situates at CENTER of bottomPanel, not at WEST.

View Replies View Related

Netbeans And Eclipse Compiler Output Is Different

Sep 6, 2014

I was trying to execute the following codes, but the something that I don't undestand was happen. The program was compiled differently according to ouput picture of the program in my java book. Furthermore, then I tried to compile the program in eclipse and NetBeans. I saw that all of output are different each other.

package finallyblock;
public class FinallyBlock {
public static void main(String[] args) {
try{
throwException();
}
catch(Exception exception){
System.err.println("Exception handled in main");

[code]...

View Replies View Related

Any Way To Stop Compiler From Calling A Constructor Implicitly?

Nov 13, 2014

Is there any way to compile a program without calling constructor.

View Replies View Related

Lexical Phase Of Compiler - Cannot Make Tokens

Apr 21, 2015

I am trying to make lexical phase of compiler. But when I try to add character (after validating them, whether they are character or not) to token array I cannot do it.

public class Main {
static int counter;
static char ch[];
static char c;
static char token[];
static String read;

[Code] .....

View Replies View Related

Custom Jtable Cell Editor Throwing Illegal Component State Exception

Jul 10, 2014

I've come across an interesting problem when using a Jcombobox as a custom cell editor(and renderer) in a jtable. I was hoping to add a keybinding in order to display the dropdown of the combobox instead of having to click on it however, when I make a call to showPopup() I get:

Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location Which is strange as my jtable is visible and the editor/renderer seems to be working fine.

Here's the cell editor + renderer I'm using:

class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {
public MyComboBoxRenderer(String[] items) {
super(items);
} public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());

[code]....

View Replies View Related

Allow User To Change And View State Of Credit Card With Menu Driven Program

Apr 20, 2015

I am new to OOP, i am not sure if this is the correct approach or not. Write a class named CreditCard that has (at least) the following member variables:

- name. A String that holds the card holder's name.
- cardNumber. A field that holds the credit card number.
- balance. A double that stores the current credit card balance.
- spendingLimit. A double that stores the spending limit of the card holder.
- Bonus: additional fields that you can think of.

In addition, the class should have the following member functions:

- Constructor. The constructor should accept the card holder's name and card number and assign these values to the object's corresponding member variables. The constructor should initialize the spending limit to $2,000 and the balance to $0.
- Accessors. Appropriate accessor functions should be created to allow values to be retrieved from an object's member variables.
- purchase. This function should add the amount specified as a parameter to the balance member variable each time it is called.
- increaseSpendingLimit. This function should add 500 to the spendingLimit member variable each time it is called.
- payBill. This function should reset the balance to 0.
- Input validation: Whenever a credit card number is modified, verify that it is of reasonable length.

Demonstrate the class in a program that creates a CreditCard object and allows the user to change and view the state of the credit card with a menu driven program.

View Card Information.

- Purchase an Item: ask the user the purchase amount and increase the card balance accordingly.
- Pay Bill: call payBill method to set the balance to 0.
- Increase Spending Limit: ask the user how much the spending limit should be, and call the increaseSpendingLimit function the appropriate number of times.

[CODE]

import java.io.*;
import java.util.Scanner;
public class CreditCard
{
Scanner input = new Scanner(System.in);
//data members
private String holderName;
private int cardNumber;
private int accountBalance;
private double spendingLimit;

[Code] ....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved