You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SanityTestsJava11.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*******************************************************************************
  2. * Copyright (c) 2006, 2018 Contributors
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *******************************************************************************/
  8. package org.aspectj.systemtest.ajc192;
  9. import org.aspectj.apache.bcel.classfile.JavaClass;
  10. import org.aspectj.testing.XMLBasedAjcTestCase;
  11. import org.aspectj.testing.XMLBasedAjcTestCaseForJava11OrLater;
  12. import junit.framework.Test;
  13. /*
  14. * Some very trivial tests that help verify things are OK.
  15. * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -10 option
  16. * to check code generation and modification with that version specified.
  17. *
  18. * @author Andy Clement
  19. */
  20. public class SanityTestsJava11 extends XMLBasedAjcTestCaseForJava11OrLater {
  21. // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
  22. public void testSimpleJava_A() {
  23. runTest("simple - a");
  24. }
  25. public void testSimpleJava_B() {
  26. runTest("simple - b");
  27. }
  28. public void testSimpleCode_C() {
  29. runTest("simple - c");
  30. }
  31. public void testSimpleCode_D() {
  32. runTest("simple - d");
  33. }
  34. public void testSimpleCode_E() {
  35. runTest("simple - e");
  36. }
  37. public void testSimpleCode_F() {
  38. runTest("simple - f");
  39. }
  40. public void testSimpleCode_G() {
  41. runTest("simple - g");
  42. }
  43. public void testSimpleCode_H() {
  44. runTest("simple - h", true);
  45. }
  46. public void testSimpleCode_I() {
  47. runTest("simple - i");
  48. }
  49. public void testVersionCorrect1() throws ClassNotFoundException {
  50. runTest("simple - j");
  51. checkVersion("A", 55, 0);
  52. }
  53. public void testVersionCorrect2() throws ClassNotFoundException {
  54. runTest("simple - k");
  55. checkVersion("A", 55, 0);
  56. }
  57. public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified
  58. runTest("simple - m");
  59. checkVersion("A", 49, 0);
  60. }
  61. private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
  62. JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
  63. if (jc.getMajor() != major) {
  64. fail("Expected major version to be " + major + " but was " + jc.getMajor());
  65. }
  66. if (jc.getMinor() != minor) {
  67. fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
  68. }
  69. }
  70. // ///////////////////////////////////////
  71. public static Test suite() {
  72. return XMLBasedAjcTestCase.loadSuite(SanityTestsJava11.class);
  73. }
  74. @Override
  75. protected java.net.URL getSpecFile() {
  76. return getClassResource("sanity-tests-11.xml");
  77. }
  78. }