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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 java.io.File;
  10. import org.aspectj.apache.bcel.classfile.JavaClass;
  11. import org.aspectj.testing.XMLBasedAjcTestCase;
  12. import org.aspectj.testing.XMLBasedAjcTestCaseForJava11OrLater;
  13. import junit.framework.Test;
  14. /*
  15. * Some very trivial tests that help verify things are OK.
  16. * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -10 option
  17. * to check code generation and modification with that version specified.
  18. *
  19. * @author Andy Clement
  20. */
  21. public class SanityTestsJava11 extends XMLBasedAjcTestCaseForJava11OrLater {
  22. // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
  23. public void testSimpleJava_A() {
  24. runTest("simple - a");
  25. }
  26. public void testSimpleJava_B() {
  27. runTest("simple - b");
  28. }
  29. public void testSimpleCode_C() {
  30. runTest("simple - c");
  31. }
  32. public void testSimpleCode_D() {
  33. runTest("simple - d");
  34. }
  35. public void testSimpleCode_E() {
  36. runTest("simple - e");
  37. }
  38. public void testSimpleCode_F() {
  39. runTest("simple - f");
  40. }
  41. public void testSimpleCode_G() {
  42. runTest("simple - g");
  43. }
  44. public void testSimpleCode_H() {
  45. runTest("simple - h", true);
  46. }
  47. public void testSimpleCode_I() {
  48. runTest("simple - i");
  49. }
  50. public void testVersionCorrect1() throws ClassNotFoundException {
  51. runTest("simple - j");
  52. checkVersion("A", 55, 0);
  53. }
  54. public void testVersionCorrect2() throws ClassNotFoundException {
  55. runTest("simple - k");
  56. checkVersion("A", 55, 0);
  57. }
  58. public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified
  59. runTest("simple - m");
  60. checkVersion("A", 49, 0);
  61. }
  62. private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
  63. JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
  64. if (jc.getMajor() != major) {
  65. fail("Expected major version to be " + major + " but was " + jc.getMajor());
  66. }
  67. if (jc.getMinor() != minor) {
  68. fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
  69. }
  70. }
  71. // ///////////////////////////////////////
  72. public static Test suite() {
  73. return XMLBasedAjcTestCase.loadSuite(SanityTestsJava11.class);
  74. }
  75. @Override
  76. protected File getSpecFile() {
  77. return getClassResource("sanity-tests-11.xml");
  78. }
  79. }