protected FailureDetailView createFailureDetailView() {
   String className = BaseTestRunner.getPreference(FAILUREDETAILVIEW_KEY);
   if (className != null) {
     Class viewClass = null;
     try {
       viewClass = Class.forName(className);
       return (FailureDetailView) viewClass.newInstance();
     } catch (Exception e) {
       JOptionPane.showMessageDialog(
           mainPane, "Could not create Failure DetailView - using default view");
     }
   }
   return new DefaultFailureDetailView();
 }
Exemple #2
0
 /**
  * This method provides a readable classname if it's an array, i.e. either the classname of the
  * component type for arrays of java reference types or the name of the primitive type for arrays
  * of java primitive types. Otherwise, it returns null.
  */
 public static String getArrayClassName(String name) {
   String className = null;
   if (name.startsWith("[")) {
     int index = name.lastIndexOf("[");
     className = name.substring(index, name.length());
     if (className.startsWith("[L")) {
       className = className.substring(2, className.length() - 1);
     } else {
       try {
         Class<?> c = Class.forName(className);
         className = c.getComponentType().getName();
       } catch (ClassNotFoundException e) {
         // Should not happen
         throw new IllegalArgumentException("Bad class name " + name, e);
       }
     }
   }
   return className;
 }
Exemple #3
0
 /**
  * This method returns the class matching the name className. It's used to cater for the primitive
  * types.
  */
 public static Class<?> getClass(String className) throws ClassNotFoundException {
   Class<?> c;
   if ((c = primitiveMap.get(className)) != null) return c;
   return Class.forName(className);
 }
  public void actionPerformed(ActionEvent a) {

    int code = 0;
    String roomtypeCompare_arr = null;
    String roomtypeCompare_dep = null;
    if ("book".equals(a.getActionCommand())) {
      try {
        Class.forName("com.mysql.jdbc.Driver");

        // Database connection information. Please note that when porting the code, you must have
        // the jdbc Driver installed where the code is running.
        Connection con =
            DriverManager.getConnection(
                "jdbc:mysql://67.20.111.85:3306/jeehtove_caliking?relaxAutoCommit=true",
                "jeehtove_ck",
                "Z_^PBBZT+kcy");

        // The SELECT query
        String query_arr =
            "SELECT * from reservations WHERE checkin BETWEEN '"
                + checkindateField.getText()
                + "' AND '"
                + checkoutdateField.getText()
                + "'";
        String query_dep =
            "SELECT * from reservations WHERE checkout BETWEEN '"
                + checkindateField.getText()
                + "' AND '"
                + checkoutdateField.getText()
                + "'";

        Statement stmt_arr = con.createStatement();
        Statement stmt_dep = con.createStatement();
        Statement stmt_insert = con.createStatement();
        ResultSet result_arr = stmt_arr.executeQuery(query_arr);
        ResultSet result_dep = stmt_dep.executeQuery(query_dep);

        // Get room type from radio buttons
        String room_type;
        if (standardRoom.isSelected()) {
          room_type = "Standard";
          code = 1;
        } else if (familyRoom.isSelected()) {
          room_type = "Family";
          code = 2;
        } else {
          room_type = "Suite";
          code = 3;
        }

        bookRoom();
        // ResultSet rs=stmt.executeQuery("select * from emp");
        /*if (!result_arr.next() && !result_dep.next()){

        	bookRoom();

        	//Query Prep for checking for open rooms
        	/*String query_checkrooms = "SELECT * FROM makereservation_rooms WHERE type = '" + code + "' AND booked = '0';";
        	Statement stmt_checkrooms = con.createStatement();
        	ResultSet checkrooms = stmt_checkrooms.executeQuery(query_checkrooms);

        	if (checkrooms.next()){
        	String getroomnumber = checkrooms.getString("room");
        	String insert = "INSERT INTO `reservations` VALUES ('" + getroomnumber + "', '" +  checkindateField.getText() + "', '" +  checkoutdateField.getText() + "',  '" + room_type + "',  '" + nameField.getText() + "');";
        	String bookroom = "UPDATE `makereservation_rooms` SET booked = '1' WHERE room = '" + getroomnumber + "';";
        	//System.out.println(insert);
        	int rs=stmt_insert.executeUpdate(insert);
        	int cr=stmt_checkrooms.executeUpdate(bookroom);
        	con.commit();
        	System.out.println("Room Booked!");
        }

        	else System.out.println("All " + room_type + " rooms are booked for the time requested.");
        }

        else {
        	if (result_arr.next()){
        		roomtypeCompare_arr = result_arr.getString("type");
        		System.out.println("(arrival) Does " + roomtypeCompare_arr + " equal " + room_type + "?");
        		if (roomtypeCompare_arr.equals(room_type)){
        			String  checkindateDB_arr = result_arr.getString("checkin");
        			String  checkoutdateDB_arr = result_arr.getString("checkout");
        			System.out.println("There is a room booked on " +  checkindateDB_arr + " that checks out on " +  checkoutdateDB_arr + ". Please select another date.");
        		}

        		else {

        			System.out.println("Room Booked!");
        		}
        	}
        }
        	//System.out.println(query_dep);
        	if (result_dep.next()){
        		roomtypeCompare_dep = result_dep.getString("type");
        		System.out.println("(departure) Does " + roomtypeCompare_dep + " equal " + room_type + "?");
        		if (roomtypeCompare_dep.equals(room_type)){
        			String  checkindateDB_dep = result_dep.getString("checkin");
        			String  checkoutdateDB_dep = result_dep.getString("checkout");
        			System.out.println("There is a room booked on " +  checkindateDB_dep + " that checks out on " +  checkoutdateDB_dep + ". Please select another date.");
        		}

        		else {
        			System.out.println("Room Booked!");
        		}
        	}*/
        con.close();

      } catch (Exception e) {
        System.out.println(e);
      }
    }
  }