public void actionPerformed(ActionEvent e) { String UCID = textField.getText(); String Password = String.valueOf(passwordField.getPassword()); if (!UCID.isEmpty() && !Password.isEmpty()) { Person p = new Person(); p.UCID = UCID; p.Password = Password; Client cl = new Client(); String Send = "start" + "|" + Person.ConvertToString(p); System.out.println(Send); String Receive = cl.login(Send); label.setText(p.UCID); System.out.println(Receive); String[] msg = Receive.split("\\|"); if (msg[0].equalsIgnoreCase("confirm")) { CardLayout cards = (CardLayout) contentPane.getLayout(); cards.show(contentPane, "student"); i = 1; String j = String.valueOf(i); Question c = new Question(); Send = "question" + "|" + i; System.out.println(Send); Receive = cl.login(Send); c = Question.ConverToObject(Receive); textPane.setText(c.Question); answerTF[i - 1] = c.Answer; } } }
@Test public void session() throws Exception { Client c = new Client(); Server<Object> s = new Server<Object>(TEST_AUTHENTICATOR, TEST_MANAGER); assertEquals(TEST_AUTHENTICATOR, s.getAuthenticator()); try { c.assertValidSession(); fail(); } catch (I18NException ex) { assertEquals(Messages.NOT_LOGGED_IN, ex.getI18NBoundMessage()); } c.login(TEST_USER, TEST_PASSWORD); SessionId id = c.getSessionId(); assertNotNull(id); assertEquals(id, c.getContext().getSessionId()); assertEquals(TEST_USER, TEST_MANAGER.get(id).getUser()); try { c.login(TEST_USER, TEST_PASSWORD); fail(); } catch (I18NException ex) { assertEquals(Messages.ALREADY_LOGGED_IN, ex.getI18NBoundMessage()); } assertEquals(id, c.getSessionId()); assertEquals(TEST_USER, TEST_MANAGER.get(id).getUser()); c.logout(); assertNull(c.getSessionId()); assertNull(c.getContext().getSessionId()); assertNull(TEST_MANAGER.get(id)); try { c.login(TEST_USER_D, TEST_PASSWORD); fail(); } catch (RemoteException ex) { assertEquals(Messages.BAD_CREDENTIALS, ((I18NException) ex.getCause()).getI18NBoundMessage()); } assertNull(c.getSessionId()); c.logout(); s.stop(); try { c.login(TEST_USER, TEST_PASSWORD); fail(); } catch (WebServiceException ex) { // Desired. } }
public void actionPerformed(ActionEvent e) { String allquestion = qField.getText(); String answer = aField.getText(); String[] q1 = allquestion.split("\\|"); if (!allquestion.isEmpty() && !answer.isEmpty()) { Question q = new Question(); q.QID = q1[0]; q.Question = q1[1]; q.Answer = answer; Client cl = new Client(); String Send = "add" + "|" + Question.ConvertToString(q); System.out.println(Send); String Receive = cl.login(Send); System.out.println(Receive); String[] msg = Receive.split("\\|"); } }
private void treeValueChanged(javax.swing.event.TreeSelectionEvent evt) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree_1.getLastSelectedPathComponent(); String option = (String) node.getUserObject(); CardLayout cards = (CardLayout) student.getLayout(); CardLayout cards1 = (CardLayout) content.getLayout(); if (option.equals("1")) { i = 1; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; System.out.println(answerTF[i - 1]); BG1.clearSelection(); } else if (option.equals("2")) { i = 2; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; BG1.clearSelection(); } else if (option.equals("3")) { i = 3; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; BG1.clearSelection(); } else if (option.equals("4")) { i = 4; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; BG1.clearSelection(); } else if (option.equals("5")) { i = 5; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; BG1.clearSelection(); } else if (option.equals("6")) { i = 6; cards1.show(content, "Question_T"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane.setText(p.Question); answerTF[i - 1] = p.Answer; BG1.clearSelection(); } else if (option.equals("7")) { i = 7; cards1.show(content, "Question_M"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane_1.setText(p.Question); answerTF[i - 1] = p.Answer; BG2.clearSelection(); } else if (option.equals("8")) { i = 8; cards1.show(content, "Question_M"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane_1.setText(p.Question); answerTF[i - 1] = p.Answer; BG2.clearSelection(); } else if (option.equals("9")) { i = 9; cards1.show(content, "Question_M"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane_1.setText(p.Question); answerTF[i - 1] = p.Answer; BG2.clearSelection(); } else if (option.equals("10")) { i = 10; cards1.show(content, "Question_M"); String j = String.valueOf(i); Question p = new Question(); Client cl = new Client(); String Send = "question" + "|" + i; System.out.println(Send); String Receive = cl.login(Send); p = Question.ConverToObject(Receive); textPane_1.setText(p.Question); answerTF[i - 1] = p.Answer; BG2.clearSelection(); } else if (option.equals("Submit")) { cards1.show(content, "Submit"); } else if (option.equals("Index")) { cards.show(student, "student"); } }