org.jboss.forge.furnace.util.OperatingSystemUtils Java Examples
The following examples show how to use
org.jboss.forge.furnace.util.OperatingSystemUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NewComponentInstanceTest.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Test public void testSomething() throws Exception { File tempDir = OperatingSystemUtils.createTempDir(); try { Project project = projectFactory.createTempProject(); Assert.assertNotNull("Should have created a project", project); CommandController command = testHarness.createCommandController(CamelSetupCommand.class, project.getRoot()); command.initialize(); command.setValueFor("kind", "camel-spring"); Result result = command.execute(); Assert.assertFalse("Should setup Camel in the project", result instanceof Failed); command = testHarness.createCommandController(CamelGetComponentsCommand.class, project.getRoot()); command.initialize(); result = command.execute(); Assert.assertFalse("Should not fail", result instanceof Failed); String message = result.getMessage(); System.out.println(message); } finally { tempDir.delete(); } }
Example #2
Source File: IssueCategoryRegistry.java From windup with Eclipse Public License 1.0 | 6 votes |
/** * Adds a {@link IssueCategory} to the registry and throws a {@link DuplicateIssueCategoryException} if the item already exists. */ public void addCategory(IssueCategory category) throws DuplicateIssueCategoryException { IssueCategory original = this.issueCategories.get(category.getCategoryID()); // Just overwrite it if it was a placeholder if (original != null && !original.isPlaceholder()) { StringBuilder message = new StringBuilder("Issue category (ID: ").append(category.getCategoryID()) .append(") is defined at the following locations:"); message.append(OperatingSystemUtils.getLineSeparator()); message.append("\t1: " + original.getOrigin()); message.append("\t2: " + category.getOrigin()); throw new DuplicateIssueCategoryException(message.toString()); } this.issueCategories.put(category.getCategoryID(), category); }
Example #3
Source File: IterationPayloadTest.java From windup with Eclipse Public License 1.0 | 6 votes |
@Test public void testNestedIteration() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { GraphRewrite event = new GraphRewrite(context); final DefaultEvaluationContext evaluationContext = new DefaultEvaluationContext(); final DefaultParameterValueStore values = new DefaultParameterValueStore(); evaluationContext.put(ParameterValueStore.class, values); fillData(context); RuleSubset.create(nestedIterationRuleProvider.getConfiguration(null)).perform(event, evaluationContext); Assert.assertEquals(2, nestedIterationRuleProvider.outerVertices.size()); Assert.assertEquals(3, nestedIterationRuleProvider.innerVertices.size()); Assert.assertEquals(6, nestedIterationRuleProvider.iterationCount); } }
Example #4
Source File: VariablesTest.java From windup with Eclipse Public License 1.0 | 6 votes |
@Test public void testUnTypedGet() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { GraphRewrite event = new GraphRewrite(context); final DefaultEvaluationContext evaluationContext = new DefaultEvaluationContext(); final DefaultParameterValueStore values = new DefaultParameterValueStore(); evaluationContext.put(ParameterValueStore.class, values); JavaClassModel classModel1 = context.getFramed().addFramedVertex(JavaClassModel.class); classModel1.setQualifiedName("com.example.Class1NoToString"); JavaClassModel classModel2 = context.getFramed().addFramedVertex(JavaClassModel.class); classModel2.setQualifiedName("com.example.Class2HasToString"); Variables vars = Variables.instance(event); vars.push(); vars.setSingletonVariable("classModel1", classModel1); WindupVertexFrame frame = vars.findSingletonVariable("classModel1"); Assert.assertNotNull(frame); } }
Example #5
Source File: AddonRepositoryImplTest.java From furnace with Eclipse Public License 1.0 | 6 votes |
@Test public void testPluggableStateRepository() throws Exception { Furnace furnace = new FurnaceImpl(); File temp = OperatingSystemUtils.createTempDir(); MutableAddonRepositoryStorageStrategy storageRepository = new AddonRepositoryStorageStrategyImpl(furnace.getLockManager(), temp); MutableAddonRepositoryStateStrategy stateRepository = new TestInMemoryAddonRepositoryStateStrategy(); MutableAddonRepository repository = new AddonRepositoryImpl(storageRepository, stateRepository, temp); AddonId addon = TestInMemoryAddonRepositoryStateStrategy.TEST_ADDON; repository.enable(addon); Assert.assertTrue(repository.isEnabled(addon)); // Delete storage directory to demonstrate that filesystem is not used to store the state Files.delete(temp, true); // Addon still enabled state wasn't affected Assert.assertTrue(repository.isEnabled(addon)); }
Example #6
Source File: AddonRepositoryStorageStrategyImpl.java From furnace with Eclipse Public License 1.0 | 6 votes |
@Override public File getAddonBaseDir(final AddonId found) { Assert.notNull(found, "Addon must be specified."); Assert.notNull(found.getVersion(), "Addon version must be specified."); Assert.notNull(found.getName(), "Addon name must be specified."); return lock.performLocked(LockMode.READ, new Callable<File>() { @Override public File call() throws Exception { File addonDir = new File(getRootDirectory(), OperatingSystemUtils.getSafeFilename(found.toCoordinates())); return addonDir; } }); }
Example #7
Source File: IterationPayloadTest.java From windup with Eclipse Public License 1.0 | 6 votes |
@Test public void testIterationVariableResolving() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { GraphRewrite event = new GraphRewrite(context); final DefaultEvaluationContext evaluationContext = new DefaultEvaluationContext(); final DefaultParameterValueStore values = new DefaultParameterValueStore(); evaluationContext.put(ParameterValueStore.class, values); fillData(context); RuleSubset.create(provider.getConfiguration(null)).perform(event, evaluationContext); Assert.assertEquals(3, provider.getChildCount()); Assert.assertEquals(2, provider.getParentCount()); Assert.assertEquals(3, provider.getActualChildCount()); Assert.assertEquals(3, provider.getActualParentCount()); } }
Example #8
Source File: QueryConditionTest.java From windup with Eclipse Public License 1.0 | 6 votes |
@Test public void testTypeAndPropertyFilter() throws Exception { // build the initial graph final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { fillData(context); context.commit(); // setup the context for the rules GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); // build a configuration, and make sure it matches what we expect (4 items) TestXmlExampleRuleProvider3 provider = new TestXmlExampleRuleProvider3(); Configuration configuration = provider.getConfiguration(null); RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(1, provider.getTypeSearchResults().size()); TestXmlMetaFacetModel result1 = provider.getTypeSearchResults().get(0); Assert.assertEquals("xmlTag2", result1.getRootTagName()); } }
Example #9
Source File: QueryConditionTest.java From windup with Eclipse Public License 1.0 | 6 votes |
@Test public void testPropertyFilter() throws Exception { // build the initial graph final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { fillData(context); context.commit(); // setup the context for the rules GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); // build a configuration, and make sure it matches what we expect (4 items) TestXmlExampleRuleProvider2 provider = new TestXmlExampleRuleProvider2(); Configuration configuration = provider.getConfiguration(null); RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(1, provider.getTypeSearchResults().size()); Assert.assertEquals("xmlTag3", provider.getTypeSearchResults().get(0).getRootTagName()); } }
Example #10
Source File: Files.java From furnace with Eclipse Public License 1.0 | 6 votes |
public static boolean delete(File file, final boolean recursive) { Assert.notNull(file, "File to delete must not be null."); boolean result = false; if (recursive) { result = _deleteRecursive(file, true); } else { if ((file.listFiles() != null) && (file.listFiles().length != 0)) { throw new RuntimeException("directory not empty"); } if (OperatingSystemUtils.isWindows()) { System.gc(); // ensure no lingering handles that would prevent deletion } result = file.delete(); } return result; }
Example #11
Source File: CORBALookupTest.java From furnace with Eclipse Public License 1.0 | 6 votes |
@Test public void testGetJDKProvidedCORBA() { assumeTrue(OperatingSystemUtils.isJava8()); try { getClass().getClassLoader().loadClass("javax.rmi.CORBA.Tie"); getClass().getClassLoader().loadClass("javax.rmi.CORBA.ClassDesc"); getClass().getClassLoader().loadClass("javax.rmi.CORBA.PortableRemoteObjectDelegate"); getClass().getClassLoader().loadClass("org.omg.CORBA.Any"); } catch (Exception e) { Assert.fail("Could not load required CORBA class." + e.getMessage()); } }
Example #12
Source File: IterationPayLoadPassTest.java From windup with Eclipse Public License 1.0 | 6 votes |
@Test(expected = Exception.class) public void testPayloadNotPass() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { context.getFramed().addFramedVertex(TestSimple1Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); WindupConfigurationModel windupCfg = context.getFramed().addFramedVertex(WindupConfigurationModel.class); FileService fileModelService = new FileService(context); windupCfg.addInputPath(fileModelService.createByFilePath("/tmp/testpath")); TestIterationPayLoadNotPassProvider provider = new TestIterationPayLoadNotPassProvider(); Configuration configuration = provider.getConfiguration(null); // this should call perform() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(3, modelCounter); modelCounter = 0; } }
Example #13
Source File: RuleProviderDisabledTest.java From windup with Eclipse Public License 1.0 | 6 votes |
@Test public void testDisabledFeature() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); WindupConfigurationModel windupCfg = context.getFramed().addFramedVertex(WindupConfigurationModel.class); FileService fileModelService = new FileService(context); windupCfg.addInputPath(fileModelService.createByFilePath(folder.toAbsolutePath().toString())); windupCfg.setOnlineMode(false); Predicate<RuleProvider> migrationPhase = (provider) -> provider.getMetadata().getPhase() == MigrationRulesPhase.class; RuleLoaderContext ruleLoaderContext = new RuleLoaderContext(Collections.emptyList(), migrationPhase); Configuration configuration = loader.loadConfiguration(ruleLoaderContext).getConfiguration(); RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertTrue("Enabled should run", enabledProvider.executed); Assert.assertFalse("Disabled should not run", disabledProvider.executed); } }
Example #14
Source File: FurnaceDeployableContainer.java From furnace with Eclipse Public License 1.0 | 6 votes |
private MutableAddonRepository selectTargetRepository(RepositoryLocationAware<?> archive) { MutableAddonRepository target = repository; if (archive instanceof RepositoryLocationAware<?> && ((RepositoryLocationAware<?>) archive).getAddonRepository() != null) { final String repositoryName = ((RepositoryLocationAware<?>) archive).getAddonRepository(); if (deploymentRepositories.get(repositoryName) == null) { target = waitForConfigurationRescan(new Callable<MutableAddonRepository>() { @Override public MutableAddonRepository call() throws Exception { return (MutableAddonRepository) runnable.furnace.addRepository(AddonRepositoryMode.MUTABLE, new File(addonDir, OperatingSystemUtils.getSafeFilename(repositoryName))); } }); deploymentRepositories.put(repositoryName, target); } else target = deploymentRepositories.get(repositoryName); } return target; }
Example #15
Source File: ContainerLifecycleListenerTest.java From furnace with Eclipse Public License 1.0 | 6 votes |
@Test public void testContainerStartup() throws Exception { Furnace furnace = FurnaceFactory.getInstance(); TestLifecycleListener listener = new TestLifecycleListener(); ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener); File temp = OperatingSystemUtils.createTempDir(); temp.deleteOnExit(); furnace.addRepository(AddonRepositoryMode.IMMUTABLE, temp); furnace.startAsync(); waitUntilStarted(furnace); Assert.assertEquals(1, listener.beforeStartTimesCalled); Assert.assertEquals(1, listener.afterStartTimesCalled); registration.removeListener(); furnace.stop(); }
Example #16
Source File: TagsRulesTest.java From windup with Eclipse Public License 1.0 | 6 votes |
@Test public void testTagsLoading() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { GraphRewrite event = new GraphRewrite(context); final DefaultEvaluationContext evaluationContext = new DefaultEvaluationContext(); final DefaultParameterValueStore values = new DefaultParameterValueStore(); evaluationContext.put(ParameterValueStore.class, values); RuleSubset.create(getNoOpRule(context)).perform(event, evaluationContext); //Assert.assertEquals(); } }
Example #17
Source File: QueryConditionTest.java From windup with Eclipse Public License 1.0 | 6 votes |
@Test public void testTypeTransition() throws Exception { // build the initial graph final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { fillData(context); context.commit(); // setup the context for the rules GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); // build a configuration, and make sure it matches what we expect (4 items) TestMavenExampleRuleProvider provider = new TestMavenExampleRuleProvider(); Configuration configuration = provider.getConfiguration(null); RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(4, provider.getSearchResults().size()); } }
Example #18
Source File: IterationPayLoadPassTest.java From windup with Eclipse Public License 1.0 | 6 votes |
@Test public void testPayloadPass() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { context.getFramed().addFramedVertex(TestPayloadModel.class); context.getFramed().addFramedVertex(TestPayloadModel.class); context.getFramed().addFramedVertex(TestPayloadModel.class); GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); WindupConfigurationModel windupCfg = context.getFramed().addFramedVertex(WindupConfigurationModel.class); FileService fileModelService = new FileService(context); windupCfg.addInputPath(fileModelService.createByFilePath("/tmp/testpath")); TestIterationPayLoadPassProvider provider = new TestIterationPayLoadPassProvider(); Configuration configuration = provider.getConfiguration(null); // this should call perform() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(3, modelCounter); modelCounter = 0; } }
Example #19
Source File: QueryConditionTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testInitialQueryAsGremlin() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); WindupConfigurationModel windupCfg = context.getFramed().addFramedVertex(WindupConfigurationModel.class); FileService fileModelService = new FileService(context); windupCfg.addInputPath(fileModelService.createByFilePath(folder.toAbsolutePath().toString())); JavaClassModel classModel1 = context.getFramed().addFramedVertex(JavaClassModel.class); classModel1.setQualifiedName("com.example.Class1NoToString"); JavaClassModel classModel2 = context.getFramed().addFramedVertex(JavaClassModel.class); classModel2.setQualifiedName("com.example.Class2HasToString"); JavaMethodModel methodModelSomeMethod = context.getFramed().addFramedVertex(JavaMethodModel.class); methodModelSomeMethod.setJavaClass(classModel2); methodModelSomeMethod.setMethodName("foo"); JavaMethodModel methodModelToString = context.getFramed().addFramedVertex(JavaMethodModel.class); methodModelToString.setJavaClass(classModel2); methodModelToString.setMethodName("toString"); TestGremlinQueryOnlyRuleProvider provider = new TestGremlinQueryOnlyRuleProvider(); Configuration configuration = provider.getConfiguration(null); RuleSubset.create(configuration).perform(event, evaluationContext); List<JavaMethodModel> methodModelList = provider.getResults(); Assert.assertTrue(methodModelList.size() == 2); Assert.assertTrue(methodModelList.get(0) instanceof JavaMethodModel); Assert.assertTrue(methodModelList.get(1) instanceof JavaMethodModel); } }
Example #20
Source File: QueryConditionTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testJavaMethodModel() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); JavaClassModel classModel1 = context.getFramed().addFramedVertex(JavaClassModel.class); classModel1.setQualifiedName("com.example.Class1NoToString"); JavaClassModel classModel2 = context.getFramed().addFramedVertex(JavaClassModel.class); classModel2.setQualifiedName("com.example.Class2HasToString"); JavaMethodModel methodModelSomeMethod = context.getFramed().addFramedVertex(JavaMethodModel.class); methodModelSomeMethod.setJavaClass(classModel2); methodModelSomeMethod.setMethodName("foo"); JavaMethodModel methodModelToString = context.getFramed().addFramedVertex(JavaMethodModel.class); methodModelToString.setJavaClass(classModel2); methodModelToString.setMethodName("toString"); TestJavaExampleRuleProvider provider = new TestJavaExampleRuleProvider(); Configuration configuration = provider.getConfiguration(null); RuleSubset.create(configuration).perform(event, evaluationContext); List<JavaMethodModel> methodModelList = provider.getResults(); Assert.assertTrue(methodModelList.size() == 1); Assert.assertNotNull(methodModelList.get(0)); Assert.assertNotNull(methodModelList.get(0).getJavaClass()); Assert.assertEquals("toString", methodModelList.get(0).getMethodName()); Assert.assertEquals(classModel2.getQualifiedName(), methodModelList.get(0).getJavaClass() .getQualifiedName()); } }
Example #21
Source File: QueryConditionTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testTypeFilter() throws Exception { // build the initial graph final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { fillData(context); context.commit(); // setup the context for the rules GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); // build a configuration, and make sure it matches what we expect (4 items) TestXmlExampleRuleProvider1 provider = new TestXmlExampleRuleProvider1(); Configuration configuration = provider.getConfiguration(null); RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(4, provider.getTypeSearchResults().size()); Assert.assertEquals(3, provider.getXmlRootNames().size()); Assert.assertTrue(provider.getXmlRootNames().contains("xmlTag1")); Assert.assertTrue(provider.getXmlRootNames().contains("xmlTag2")); Assert.assertFalse(provider.getXmlRootNames().contains("xmlTag3")); Assert.assertTrue(provider.getXmlRootNames().contains("xmlTag4")); Assert.assertFalse(provider.getXmlRootNames().contains("xmlTag5")); Assert.assertEquals(1, provider.getExcludedXmlRootNames().size()); Assert.assertTrue(provider.getExcludedXmlRootNames().contains("xmlTag3")); } }
Example #22
Source File: AddonManagerRealTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Before public void setUp() throws IOException { furnace = ServiceLoader.load(Furnace.class).iterator().next(); resolver = new MavenAddonDependencyResolver(); repository = OperatingSystemUtils.createTempDir(); furnace.addRepository(AddonRepositoryMode.MUTABLE, repository); addonManager = new AddonManagerImpl(furnace, resolver); }
Example #23
Source File: ParameterWiringTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testIterationVariableResolving4() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { GraphRewrite event = new GraphRewrite(context); final DefaultEvaluationContext evaluationContext = new DefaultEvaluationContext(); final DefaultParameterValueStore values = new DefaultParameterValueStore(); evaluationContext.put(ParameterValueStore.class, values); GraphService<ParameterWiringTestModel> service = new GraphService<>(context, ParameterWiringTestModel.class); ParameterWiringTestModel model1 = service.create(); model1.setValue("The quick brown fox jumped over the lazy dog."); ParameterWiringTestModel model2 = service.create(); model2.setValue("The lazy dog slept under the quick brown fox."); ParameterWiringTestModel model3 = service.create(); model3.setValue("The lazy fox jumped over the quick brown dog."); ParameterWiringTestModel model4 = service.create(); model4.setValue("The lazy fox slept under the quick brown dog."); ParameterWiringTestModel model5 = service.create(); model5.setValue("The quick brown fox jumped over the lazy fox."); ParameterWiringTestRuleProvider4 provider = new ParameterWiringTestRuleProvider4(); RuleSubset.create(provider.getConfiguration(null)).perform(event, evaluationContext); Assert.assertEquals(4, provider.getMatchCount()); Assert.assertTrue(provider.getResults().contains(model1)); Assert.assertTrue(provider.getResults().contains(model3)); Assert.assertTrue(provider.getResults().contains(model4)); Assert.assertTrue(provider.getResults().contains(model5)); } }
Example #24
Source File: RuleIterationOverDefaultListVariableTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testTypeSelection() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { TestSimple1Model vertex = context.getFramed().addFramedVertex(TestSimple1Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); WindupConfigurationModel windupCfg = context.getFramed().addFramedVertex(WindupConfigurationModel.class); FileService fileModelService = new FileService(context); windupCfg.addInputPath(fileModelService.createByFilePath(OperatingSystemUtils.createTempDir() .getAbsolutePath())); TestRuleIterationOverDefaultListVariableProvider provider = new TestRuleIterationOverDefaultListVariableProvider(); Configuration configuration = provider.getConfiguration(null); // this should call perform() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(TestSimple1ModelCounter, 1); Assert.assertEquals(TestSimple2ModelCounter, 2); vertex.remove(); // this should call otherwise() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(TestSimple1ModelCounter, 1); Assert.assertEquals(TestSimple2ModelCounter, 4); } }
Example #25
Source File: RuleIterationOverDefaultSingleVariableTest.java From windup with Eclipse Public License 1.0 | 5 votes |
/** * @throws Exception because the provider tries to use a non-existent variable. */ @Test(expected = Exception.class) public void testTypeSelectionWithException() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { TestSimple1Model vertex = context.getFramed().addFramedVertex(TestSimple1Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); WindupConfigurationModel windupCfg = context.getFramed().addFramedVertex(WindupConfigurationModel.class); FileService fileModelService = new FileService(context); windupCfg.addInputPath(fileModelService .createByFilePath(OperatingSystemUtils.createTempDir().getAbsolutePath())); TestRuleIterationOverDefaultSingleVariableWithExceptionProvider provider = new TestRuleIterationOverDefaultSingleVariableWithExceptionProvider(); Configuration configuration = provider.getConfiguration(null); // this should call perform() RuleSubset.create(configuration).perform(event, evaluationContext); } }
Example #26
Source File: RuleIterationOverDefaultSingleVariableTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testTypeSelection() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { TestSimple1Model vertex = context.getFramed().addFramedVertex(TestSimple1Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); WindupConfigurationModel windupCfg = context.getFramed().addFramedVertex(WindupConfigurationModel.class); FileService fileModelService = new FileService(context); windupCfg.addInputPath(fileModelService.createByFilePath(OperatingSystemUtils.createTempDir() .getAbsolutePath())); TestRuleIterationOverDefaultSingleVariableProvider provider = new TestRuleIterationOverDefaultSingleVariableProvider(); Configuration configuration = provider.getConfiguration(null); // this should call perform() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(1, TestSimple1ModelCounter); Assert.assertEquals(2, TestSimple2ModelCounter); vertex.remove(); // this should call otherwise() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(1, TestSimple1ModelCounter); Assert.assertEquals(4, TestSimple2ModelCounter); } }
Example #27
Source File: IterationAutomicCommitTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testAutomaticPeriodicCommit() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext baseContext = factory.create(folder, true)) { CommitInterceptingGraphContext context = new CommitInterceptingGraphContext(baseContext); GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); WindupConfigurationModel windupCfg = context.getFramed().addFramedVertex(WindupConfigurationModel.class); FileService fileModelService = new FileService(context); windupCfg.addInputPath(fileModelService.createByFilePath(OperatingSystemUtils.createTempDir() .getAbsolutePath())); TestRuleProvider provider = new TestRuleProvider(); Configuration configuration = provider.getConfiguration(null); RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(1, context.commitCount); // Now create a few hundred FileModels to see if autocommit happens periodically for (int i = 0; i < 1200; i++) { fileModelService.create().setFilePath("foo." + i); } context.commitCount = 0; RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(2, context.commitCount); } }
Example #28
Source File: RuleIterationOverTypesTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test(expected = Exception.class) public void testTypeSelectionWithException() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { TestSimple1Model vertex = context.getFramed().addFramedVertex(TestSimple1Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); WindupConfigurationModel windupCfg = context.getFramed().addFramedVertex(WindupConfigurationModel.class); FileService fileModelService = new FileService(context); windupCfg.addInputPath(fileModelService .createByFilePath(OperatingSystemUtils.createTempDir().getAbsolutePath())); TestRuleIterationOverTypesWithExceptionProvider provider = new TestRuleIterationOverTypesWithExceptionProvider(); Configuration configuration = provider.getConfiguration(null); // this should call perform() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(TestSimple1ModelCounter, 1); Assert.assertEquals(TestSimple2ModelCounter, 2); vertex.remove(); // this should call otherwise() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(TestSimple1ModelCounter, 1); Assert.assertEquals(TestSimple2ModelCounter, 4); } }
Example #29
Source File: RuleIterationOverTypesTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testTypeSelection() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { TestSimple1Model vertex = context.getFramed().addFramedVertex(TestSimple1Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); WindupConfigurationModel windupCfg = context.getFramed().addFramedVertex(WindupConfigurationModel.class); FileService fileModelService = new FileService(context); windupCfg.addInputPath(fileModelService.createByFilePath(OperatingSystemUtils.createTempDir() .getAbsolutePath())); TestRuleIterationOverTypesProvider provider = new TestRuleIterationOverTypesProvider(); Configuration configuration = provider.getConfiguration(null); // this should call perform() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(TestSimple1ModelCounter, 1); Assert.assertEquals(TestSimple2ModelCounter, 2); vertex.remove(); // this should call otherwise() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(TestSimple1ModelCounter, 1); Assert.assertEquals(TestSimple2ModelCounter, 4); } }
Example #30
Source File: RuleIterationOverAllSpecifiedTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testTypeSelection() throws Exception { final Path folder = OperatingSystemUtils.createTempDir().toPath(); try (final GraphContext context = factory.create(folder, true)) { TestSimple1Model vertex = context.getFramed().addFramedVertex(TestSimple1Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); context.getFramed().addFramedVertex(TestSimple2Model.class); GraphRewrite event = new GraphRewrite(context); DefaultEvaluationContext evaluationContext = createEvalContext(event); WindupConfigurationModel windupCfg = context.getFramed().addFramedVertex(WindupConfigurationModel.class); FileService fileModelService = new FileService(context); windupCfg.addInputPath(fileModelService.createByFilePath(OperatingSystemUtils.createTempDir() .getAbsolutePath())); TestRuleIterationOverAllSpecifiedProvider provider = new TestRuleIterationOverAllSpecifiedProvider(); Configuration configuration = provider.getConfiguration(null); // this should call perform() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(1, TestSimple1ModelCounter); Assert.assertEquals(2, TestSimple2ModelCounter); vertex.remove(); // this should call otherwise() RuleSubset.create(configuration).perform(event, evaluationContext); Assert.assertEquals(1, TestSimple1ModelCounter); Assert.assertEquals(4, TestSimple2ModelCounter); } }