package com.sequenceiq.it.cloudbreak.action.sdx;

import static java.lang.String.format;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sequenceiq.it.cloudbreak.SdxClient;
import com.sequenceiq.it.cloudbreak.action.Action;
import com.sequenceiq.it.cloudbreak.context.TestContext;
import com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto;
import com.sequenceiq.it.cloudbreak.log.Log;

public class SdxRepairAction implements Action<SdxTestDto, SdxClient> {

    private static final Logger LOGGER = LoggerFactory.getLogger(SdxRepairAction.class);

    @Override
    public SdxTestDto action(TestContext testContext, SdxTestDto testDto, SdxClient client) throws Exception {
        Log.when(LOGGER, format(" Starting repair on SDX: %s " + testDto.getName()));
        Log.whenJson(LOGGER, " SDX repair request: ", testDto.getSdxRepairRequest());
        client.getSdxClient()
                .sdxEndpoint()
                .repairCluster(testDto.getName(), testDto.getSdxRepairRequest());
        Log.when(LOGGER, " SDX repair have been initiated.");
        return testDto;
    }
}

package com.sequenceiq.it.cloudbreak.action.sdx;

import static java.lang.String.format;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sequenceiq.it.cloudbreak.SdxClient;
import com.sequenceiq.it.cloudbreak.action.Action;
import com.sequenceiq.it.cloudbreak.context.TestContext;
import com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto;
import com.sequenceiq.it.cloudbreak.log.Log;

public class SdxRepairAction implements Action<SdxTestDto, SdxClient> {

    private static final Logger LOGGER = LoggerFactory.getLogger(SdxRepairAction.class);

    @Override
    public SdxTestDto action(TestContext testContext, SdxTestDto testDto, SdxClient client) throws Exception {
        Log.when(LOGGER, format(" Starting repair on SDX: %s ", testDto.getName()));
        Log.whenJson(LOGGER, " SDX repair request: ", testDto.getSdxRepairRequest());
        client.getSdxClient()
                .sdxEndpoint()
                .repairCluster(testDto.getName(), testDto.getSdxRepairRequest());
        Log.when(LOGGER, " SDX repair have been initiated.");
        return testDto;
    }
}

Fix string format usage since it caused the repair test failure


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.test.blueprint;

import org.apache.camel.component.properties.PropertiesFunction;
import org.junit.Test;

public class PropertiesComponentFunctionTest extends CamelBlueprintTestSupport {

    public static final class MyFunction implements PropertiesFunction {

        @Override
        public String getName() {
            return "beer";
        }

        @Override
        public String apply(String remainder) {
            return "mock:" + remainder.toLowerCase();
        }
    }

    @Override
    protected String getBlueprintDescriptor() {
        return "org/apache/camel/test/blueprint/PropertiesComponentFunctionTest.xml";
    }

    @Test
    public void testFunction() throws Exception {
        getMockEndpoint("mock:foo").expectedMessageCount(1);
        getMockEndpoint("mock:bar").expectedMessageCount(1);

        template.sendBody("direct:start", "Hello World");

        assertMockEndpointsSatisfied();
    }

}

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.test.blueprint;

import org.apache.camel.spi.PropertiesFunction;
import org.junit.Test;

public class PropertiesComponentFunctionTest extends CamelBlueprintTestSupport {

    public static final class MyFunction implements PropertiesFunction {

        @Override
        public String getName() {
            return "beer";
        }

        @Override
        public String apply(String remainder) {
            return "mock:" + remainder.toLowerCase();
        }
    }

    @Override
    protected String getBlueprintDescriptor() {
        return "org/apache/camel/test/blueprint/PropertiesComponentFunctionTest.xml";
    }

    @Test
    public void testFunction() throws Exception {
        getMockEndpoint("mock:foo").expectedMessageCount(1);
        getMockEndpoint("mock:bar").expectedMessageCount(1);

        template.sendBody("direct:start", "Hello World");

        assertMockEndpointsSatisfied();
    }

}

CAMEL-14671: Make PropertiesFunction part of the PropertiesComponent SPI


package com.fenixinfotech.aspectj.playpen;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Created by 700608667 on 11/09/2015.
 */
public class AspectedFunctionalityTest
{

    @Test
    public void testPower() throws Exception
    {
        new AspectedFunctionality().power(2, 3);
    }
}

package com.fenixinfotech.aspectj.playpen;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Created by 700608667 on 11/09/2015.
 */
public class AspectedFunctionalityTest
{

    @Test
    public void testPower() throws Exception
    {
        assertEquals(8, new AspectedFunctionality().power(2, 3), 0);
    }
}

Check expected output of aspected operation.


package org.wso2.carbon.apimgt.core.configuration.models;

import org.wso2.carbon.apimgt.core.util.APIMgtConstants;
import org.wso2.carbon.config.annotation.Configuration;
import org.wso2.carbon.config.annotation.Element;

import java.util.Collections;
import java.util.List;

/**
 * Class to hold Environment configurations
 */
@Configuration(description = "Environment Configurations")
public class EnvironmentConfigurations {
    @Element(description = "list of web clients (eg: 127.0.0.1:9292) allowed to make requests to the current environment\n" +
            "(use '" + APIMgtConstants.CORSAllowOriginConstants.ALLOW_ALL_ORIGINS + "' to allow any web client)")
    private List<String> allowedHosts = Collections.singletonList(
            APIMgtConstants.CORSAllowOriginConstants.ALLOW_ALL_ORIGINS);

    //Unique name for environment to set cookies by backend
    @Element(description = "current environment's label from the list of environments")
    private String environmentLabel = "Default";

    public List<String> getAllowedHosts() {
        return allowedHosts;
    }

    public void setAllowedHosts(List<String> allowedHosts) {
        this.allowedHosts = allowedHosts;
    }

    public String getEnvironmentLabel() {
        return environmentLabel;
    }

    public void setEnvironmentLabel(String environmentLabel) {
        this.environmentLabel = environmentLabel;
    }
}

package org.wso2.carbon.apimgt.core.configuration.models;

import org.wso2.carbon.apimgt.core.util.APIMgtConstants;
import org.wso2.carbon.config.annotation.Configuration;
import org.wso2.carbon.config.annotation.Element;

import java.util.Collections;
import java.util.List;

/**
 * Class to hold Environment configurations
 */
@Configuration(description = "Environment Configurations")
public class EnvironmentConfigurations {
    @Element(description = "list of web clients (eg: 127.0.0.1:9292) to allow make requests"
            + "to current environment\n(use '" + APIMgtConstants.CORSAllowOriginConstants.ALLOW_ALL_ORIGINS +
            "' to allow any web client)")
    private List<String> allowedHosts = Collections.singletonList(
            APIMgtConstants.CORSAllowOriginConstants.ALLOW_ALL_ORIGINS);

    //Unique name for environment to set cookies by backend
    @Element(description = "current environment's label from the list of environments")
    private String environmentLabel = "Default";

    public List<String> getAllowedHosts() {
        return allowedHosts;
    }

    public void setAllowedHosts(List<String> allowedHosts) {
        this.allowedHosts = allowedHosts;
    }

    public String getEnvironmentLabel() {
        return environmentLabel;
    }

    public void setEnvironmentLabel(String environmentLabel) {
        this.environmentLabel = environmentLabel;
    }
}

Fix check style issue exceeding no of chars in one line


package io.pivotal.labs.cfenv;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class ResourceUtils {

    public static String loadResource(String name) throws IOException {
        try (InputStream stream = openResource(name)) {
            Scanner scanner = new Scanner(stream, StandardCharsets.UTF_8.name()).useDelimiter("\\z");
            String content = scanner.next();
            IOException exception = scanner.ioException();
            if (exception != null) throw exception;
            return content;
        }
    }

    public static InputStream openResource(String name) throws FileNotFoundException {
        InputStream stream = ResourceUtils.class.getResourceAsStream(name);
        if (stream == null) throw new FileNotFoundException(name);
        return stream;
    }

}

package io.pivotal.labs.cfenv;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class ResourceUtils {

    public static String loadResource(String name) throws IOException {
        try (InputStream stream = openResource(name)) {
            StringBuilder buffer = new StringBuilder();
            InputStreamReader reader = new InputStreamReader(stream);
            while (true) {
                int character = reader.read();
                if (character == -1) break;
                buffer.append((char) character);
            }
            return buffer.toString();
        }
    }

    public static InputStream openResource(String name) throws FileNotFoundException {
        InputStream stream = ResourceUtils.class.getResourceAsStream(name);
        if (stream == null) throw new FileNotFoundException(name);
        return stream;
    }

}

Fix resource loading to work with files bigger than a kilobyte

Signed-off-by: Ben Grohbiel <f31bec9830c462ca5208f6f388c04b025df0947c@pivotal.io>


// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.hughes.util;

import java.util.Map;

@SuppressWarnings({"WeakerAccess", "unused"})
public class MapUtil {

    public static <K,V> V safeGet(final Map<K,V> map, K key, V defaultValue) {
        if (!map.containsKey(key)) {
            return defaultValue;
        }
        return map.get(key);
    }

    public static <K,V> V safeGetOrPut(final Map<K,V> map, K key, V defaultValue) {
        if (!map.containsKey(key)) {
            map.put(key, defaultValue);
        }
        return map.get(key);
    }

    public static <K,V> V safeGet(final Map<K,V> map, K key, Class<V> valueClass) {
        if (!map.containsKey(key)) {
            try {
                map.put(key, valueClass.newInstance());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return map.get(key);
    }

    public static <K,V> V safeRemove(final Map<K,V> map, K key, V defaultValue) {
        if (!map.containsKey(key)) {
            return defaultValue;
        }
        return map.remove(key);
    }

}

// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.hughes.util;

import java.util.Map;

public class MapUtil {
    public static <K,V> V safeRemove(final Map<K,V> map, K key, V defaultValue) {
        if (!map.containsKey(key)) {
            return defaultValue;
        }
        return map.remove(key);
    }
}

Remove unused functions that cause warnings.


package uk.ac.ebi.quickgo.repo.solr;

import org.junit.ClassRule;
import org.junit.rules.ExternalResource;
import org.junit.rules.TemporaryFolder;

import java.io.IOException;

/**
 * Creates a temporary solr data store, which is deleted on exit. Use this class with
 * the annotation, @ClassRule in tests requiring a temporary solr data store.
 *
 * Created 13/11/15
 * @author Edd
 */
public class TemporarySolrDataStore extends ExternalResource {
    // the property defining the solr data store, used in solr core's solrconfig.xml files
    private static final String SOLR_DATA_DIR = "solr.data.dir";

    @ClassRule
    public static TemporaryFolder temporaryFolder = new TemporaryFolder();

    @Override
    public void before() throws IOException {
        temporaryFolder.create();
        System.setProperty(SOLR_DATA_DIR, temporaryFolder.getRoot().getAbsolutePath());
    }

    @Override
    public void after() {
        temporaryFolder.delete();
    }
}

package uk.ac.ebi.quickgo.repo.solr;

import java.io.File;
import org.junit.ClassRule;
import org.junit.rules.ExternalResource;
import org.junit.rules.TemporaryFolder;

import java.io.IOException;

/**
 * Creates a temporary solr data store, which is deleted on exit. Use this class with
 * the annotation, @ClassRule in tests requiring a temporary solr data store.
 *
 * Created 13/11/15
 * @author Edd
 */
public class TemporarySolrDataStore extends ExternalResource {
    // the following properties are defined in the solrconfig.xml files
    private static final String SOLR_DATA_DIR = "solr.data.dir";
    private static final String SOLR_PLUGIN_JAR = "solr.similarity.plugin";

    @ClassRule
    public static TemporaryFolder temporaryFolder = new TemporaryFolder();

    @Override
    public void before() throws IOException {
        temporaryFolder.create();
        System.setProperty(SOLR_DATA_DIR, temporaryFolder.getRoot().getAbsolutePath());
        System.setProperty(SOLR_PLUGIN_JAR, pathToSimilarityPlugin());
    }

    private String pathToSimilarityPlugin() {
        File file = new File("../solr-plugin/target/similarity_plugin.jar");

        if(!file.exists()) {
            throw new IllegalStateException("similarity_plugin.jar does not exist. Please generated the jar before " +
                    "running the tests");
        }

        return file.getAbsolutePath();
    }

    @Override
    public void after() {
        temporaryFolder.delete();
    }
}

Add custom solr similarity plugin so solrconfig can pick it up.


package hello;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import java.net.MalformedURLException;
import java.net.URL;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class GreetingControllerIntegrationTest {

	@LocalServerPort
	private int port;

	private URL greeting;

	@Autowired
	private TestRestTemplate template;

	@Before
	public void setUp() throws MalformedURLException {
		this.greeting = new URL("http://localhost:" + port + "/greeting");
	}

	@Test
	public void getGreeting() {
		ResponseEntity<String> response = template.getForEntity(greeting.toString(), String.class);
		assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
	}

}

package hello;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertThat;

import java.net.MalformedURLException;
import java.net.URL;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class GreetingControllerIntegrationTest {

	@LocalServerPort
	private int port;

	private URL greeting;

	@Autowired
	private TestRestTemplate template;

	@Before
	public void setUp() throws MalformedURLException {
		this.greeting = new URL("http://localhost:" + port + "/greeting");
	}

	@Test
	public void getGreeting() {
		ResponseEntity<String> response = template.getForEntity(greeting.toString(), String.class);
		assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
		assertThat(response.getBody(), containsString("Hello, World!"));
	}

}

Test view content in greeting integration test.


package org.puller;

import org.kohsuke.args4j.Localizable;

import java.util.Locale;

public class LocalizedString implements Localizable {
    private final String msg;

    public LocalizedString(final String msg) {
        this.msg = msg;
    }

    @Override
    public String formatWithLocale(final Locale locale, final Object... args) {
        return String.format(locale, msg, args);
    }

    @Override
    public String format(final Object... args) {
        return formatWithLocale(Locale.getDefault(), args);
    }
}

package org.puller;

import org.kohsuke.args4j.Localizable;

import java.text.MessageFormat;
import java.util.Locale;

public class LocalizedString implements Localizable {
    private final String msg;

    public LocalizedString(final String msg) {
        this.msg = msg;
    }

    @Override
    public String formatWithLocale(final Locale locale, final Object... args) {
        return MessageFormat.format(msg, args);
    }

    @Override
    public String format(final Object... args) {
        return formatWithLocale(Locale.getDefault(), args);
    }
}

Use MessageFormat to format localized strings


package net.simpvp.NoSpam;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;

public class CommandListener implements Listener {

	public CommandListener(NoSpam plugin) {
		plugin.getServer().getPluginManager().registerEvents(this, plugin);
	}

	@EventHandler(priority=EventPriority.LOW, ignoreCancelled=false)
	public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {

		Player player = event.getPlayer();

		String message = event.getMessage();

		/* Important: The spaces afterwards are necessary. Otherwise we get something like this being activated on /world because of /w */
		if (message.startsWith("/tell ")
				|| message.startsWith("/me ")
				|| message.startsWith("/msg ")
				|| message.startsWith("/w ")
				|| message.startsWith("/op ")) {

			boolean cancel = SpamHandler.isSpamming(player); // The Handler class checks if it's spam

			if ( cancel ) event.setCancelled(true);

				}

	}

}

package net.simpvp.NoSpam;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;

public class CommandListener implements Listener {

	public CommandListener(NoSpam plugin) {
		plugin.getServer().getPluginManager().registerEvents(this, plugin);
	}

	@EventHandler(priority=EventPriority.LOW, ignoreCancelled=false)
	public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {

		Player player = event.getPlayer();

		String message = event.getMessage().toLowerCase();

		/* Important: The spaces afterwards are necessary. Otherwise we get something like this being activated on /world because of /w */
		if (message.startsWith("/tell ")
				|| message.startsWith("/me ")
				|| message.startsWith("/msg ")
				|| message.startsWith("/w ")
				|| message.startsWith("/op ")
				|| message.equals("/op")) {

			boolean cancel = SpamHandler.isSpamming(player); // The Handler class checks if it's spam

			if ( cancel ) event.setCancelled(true);

		}

	}

}

Update list of blocked commands

Update list of blocked commands


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hp.hpl.jena.tdb.nodetable;

public class NodeTableReadonly extends NodeTableWrapper
{
    public NodeTableReadonly(NodeTable nodeTable)
    {
        super(nodeTable) ;
    }

}

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hp.hpl.jena.tdb.nodetable;

import com.hp.hpl.jena.graph.Node ;
import com.hp.hpl.jena.tdb.TDBException ;
import com.hp.hpl.jena.tdb.store.NodeId ;

public class NodeTableReadonly extends NodeTableWrapper
{
    public NodeTableReadonly(NodeTable nodeTable)
    {
        super(nodeTable) ;
    }

    @Override
    public NodeId getAllocateNodeId(Node node)
    {
        NodeId nodeId = getNodeIdForNode(node) ;
        if ( NodeId.isDoesNotExist(nodeId) )
            throw new TDBException("Allocation attempt on NodeTableReadonly") ;
        return nodeId ;
    }
}

Make a read-only node table check it is used read-only.

git-svn-id: bc509ec38c1227b3e85ea1246fda136342965d36@1348166 13f79535-47bb-0310-9956-ffa450edef68


package net.kencochrane.raven.log4j;

import net.kencochrane.raven.stub.SentryStub;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class SentryAppenderIT {
    private static final Logger logger = Logger.getLogger(SentryAppenderIT.class);
    private SentryStub sentryStub;

    @Before
    public void setUp() {
        sentryStub = new SentryStub();
        sentryStub.removeEvents();
    }

    @After
    public void tearDown() {
        sentryStub.removeEvents();
    }

    @Test
    public void testInfoLog() {
        assertThat(sentryStub.getEventCount(), is(0));
        logger.info("This is a test");
        assertThat(sentryStub.getEventCount(), is(1));
    }

    @Test
    public void testChainedExceptions() {
        assertThat(sentryStub.getEventCount(), is(0));
        logger.error("This is an exception",
                new UnsupportedOperationException("Test", new UnsupportedOperationException()));
        assertThat(sentryStub.getEventCount(), is(1));
    }
}

package net.kencochrane.raven.log4j;

import net.kencochrane.raven.stub.SentryStub;
import org.apache.log4j.Logger;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class SentryAppenderIT {
    private static final Logger logger = Logger.getLogger(SentryAppenderIT.class);
    private SentryStub sentryStub = new SentryStub();

    @AfterMethod
    public void tearDown() {
        sentryStub.removeEvents();
    }

    @Test
    public void testInfoLog() {
        assertThat(sentryStub.getEventCount(), is(0));
        logger.info("This is a test");
        assertThat(sentryStub.getEventCount(), is(1));
    }

    @Test
    public void testChainedExceptions() {
        assertThat(sentryStub.getEventCount(), is(0));
        logger.error("This is an exception",
                new UnsupportedOperationException("Test", new UnsupportedOperationException()));
        assertThat(sentryStub.getEventCount(), is(1));
    }
}

Move from junit to testng for integration tests


package org.pitest.cucumber;

import org.pitest.junit.CompoundTestUnitFinder;
import org.pitest.junit.JUnitCompatibleConfiguration;
import org.pitest.testapi.TestGroupConfig;
import org.pitest.testapi.TestUnitFinder;
import org.pitest.util.Log;

import java.util.List;

import static java.util.Arrays.asList;

public class CucumberJUnitCompatibleConfiguration extends JUnitCompatibleConfiguration {

    public CucumberJUnitCompatibleConfiguration(TestGroupConfig config) {
        super(config);
    }

    @Override
    public TestUnitFinder testUnitFinder() {
        final TestUnitFinder finder;
        if (isCucumberUsed()) {
            Log.getLogger().info("Cucumber detected, scenarios will be used");
            List<TestUnitFinder> finders
                    = asList(new CucumberTestUnitFinder(), super.testUnitFinder());
            finder = new CompoundTestUnitFinder(finders);
        } else {
            Log.getLogger().info("Cucumber not used in this project");
            finder = super.testUnitFinder();
        }
        return finder;
    }

    private boolean isCucumberUsed() {
        boolean result = false;
        try {
            Class.forName("cucumber.api.junit.Cucumber");
            result = true;
        } catch (ClassNotFoundException e) {
        }
        return result;
    }
}

package org.pitest.cucumber;

import org.pitest.junit.CompoundTestUnitFinder;
import org.pitest.junit.JUnitCompatibleConfiguration;
import org.pitest.testapi.TestGroupConfig;
import org.pitest.testapi.TestUnitFinder;
import org.pitest.util.Log;

import java.util.List;

import static java.util.Arrays.asList;

public class CucumberJUnitCompatibleConfiguration extends JUnitCompatibleConfiguration {

    public CucumberJUnitCompatibleConfiguration(TestGroupConfig config) {
        super(config);
    }

    @Override
    public TestUnitFinder testUnitFinder() {
        final TestUnitFinder finder;
        if (isCucumberUsed()) {
            Log.getLogger().fine("Cucumber detected, scenarios will be used");
            List<TestUnitFinder> finders
                    = asList(new CucumberTestUnitFinder(), super.testUnitFinder());
            finder = new CompoundTestUnitFinder(finders);
        } else {
            Log.getLogger().fine("Cucumber not used in this project");
            finder = super.testUnitFinder();
        }
        return finder;
    }

    private boolean isCucumberUsed() {
        boolean result = false;
        try {
            Class.forName("cucumber.api.junit.Cucumber");
            result = true;
        } catch (ClassNotFoundException e) {
        }
        return result;
    }
}

Reduce log level to avoid log polution

Reduce log level to avoid log polution


public class Sort {
	public enum DIRECTION {ASCENDING,DESCENDING};

	public void sort(Table _targetTable, DIRECTION d) {

	}
}

Revert "Started the sort method"

Revert "Started the sort method"

This reverts commit 932492206b882527940d291e596e551050f538cd.


/**
 * Copyright 2015 Palantir Technologies
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.palantir.atlasdb.config;

import java.io.File;
import java.io.IOException;

import javax.annotation.Nullable;

public final class AtlasDbConfigs {
    public static final String ATLASDB_CONFIG_ROOT = "/atlasdb";

    private AtlasDbConfigs() {
        // uninstantiable
    }

    public static AtlasDbConfig load(File configFile) throws IOException {
        return load(configFile, ATLASDB_CONFIG_ROOT);
    }

    public static AtlasDbConfig load(File configFile, @Nullable String configRoot) throws IOException {
        ConfigFinder finder = new ConfigFinder(configRoot);
        return finder.getConfig(configFile);
    }

    public static AtlasDbConfig loadFromString(String fileContents, @Nullable String configRoot) throws IOException {
        ConfigFinder finder = new ConfigFinder(configRoot);
        return finder.getConfig(fileContents);
    }
}

/**
 * Copyright 2015 Palantir Technologies
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.palantir.atlasdb.config;

import java.io.File;
import java.io.IOException;

import com.fasterxml.jackson.databind.JsonNode;

public final class AtlasDbConfigs {
    public static final String ATLASDB_CONFIG_ROOT = "/atlasdb";

    private AtlasDbConfigs() {
        // uninstantiable
    }

    public static AtlasDbConfig load(File configFile) throws IOException {
        return load(configFile, ATLASDB_CONFIG_ROOT);
    }

    public static AtlasDbConfig load(File configFile, String configRoot) throws IOException {
        ConfigFinder finder = new ConfigFinder(configRoot);
        return finder.getConfig(configFile);
    }

    public static AtlasDbConfig loadFromString(String fileContents, String configRoot) throws IOException {
        ConfigFinder finder = new ConfigFinder(configRoot);
        return finder.getConfig(fileContents);
    }
}

Revert "Update nullables and unused import"

This reverts commit 8ee3b4d8c5a67dcaf343ef195f750baca6e64aeb.


public class Tuple implements Comparable<Tuple> {
	private String contents;
	public Tuple(String contents) {
		this.contents = contents;
	}
	public String toString() {
		return "TUPLE {" + contents + "}";
	}
	public boolean equals(Object o) {
		return contents.equals(((Tuple)o).contents);
	}
	@Override
	public int compareTo(Tuple o) {
		return contents.compareTo(o.contents);
	}
	public int hashCode() {
		return contents.hashCode();
	}
}

public class Tuple implements Comparable<Tuple> {
	private String contents;

	public Tuple(String contents) {
		this.contents = contents;
	}

	@Override
	public String toString() {
		return "TUPLE {" + contents + "}";
	}

	@Override
	public boolean equals(Object o) {
		return contents.equals(((Tuple) o).contents);
	}

	@Override
	public int compareTo(Tuple o) {
		return contents.compareTo(o.contents);
	}

	@Override
	public int hashCode() {
		return contents.hashCode();
	}
}

Tweak formatting and add @OverrideS.

Tweak formatting and add @OverrideS.


/**
 * Abstract Syntax Tree for JUnit.
 *
 * <pre>
 * CompilationUnit ::= ClassDecl
 *
 * ClassDecl ::= TestMethod*
 *
 * TestMethod ::= Binding* TestStateMent*
 *
 * TestStatement ::= IsStatement
 *                 | IsNotStatement
 *                 | ThrowsStatement
 * </pre>
 *
 */
package yokohama.unit.ast_junit;

/**
 * Abstract Syntax Tree for JUnit.
 *
 * <pre>
 * CompilationUnit ::= ClassDecl
 *
 * ClassDecl ::= TestMethod*
 *
 * TestMethod ::= Binding* ActionStatement* TestStateMent* ActionStatement*
 *
 * TestStatement ::= IsStatement
 *                 | IsNotStatement
 *                 | ThrowsStatement
 * </pre>
 *
 */
package yokohama.unit.ast_junit;

Change BNF description for JUnit AST

Change BNF description for JUnit AST


/*-------------------------------------------------------------------------
*
* Copyright (c) 2004-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
*   $PostgreSQL: pgjdbc/org/postgresql/util/PSQLDriverVersion.java,v 1.20 2006/12/01 12:02:39 jurka Exp $
*
*-------------------------------------------------------------------------
*/
package org.postgresql.util;

import org.postgresql.Driver;

/**
 * This class holds the current build number and a utility program to print
 * it and the file it came from.  The primary purpose of this is to keep
 * from filling the cvs history of Driver.java.in with commits simply
 * changing the build number.  The utility program can also be helpful for
 * people to determine what version they really have and resolve problems
 * with old and unknown versions located somewhere in the classpath.
 */
public class PSQLDriverVersion {

    public static int buildNumber = 600;

    public static void main(String args[]) {
        java.net.URL url = Driver.class.getResource("/org/postgresql/Driver.class");
        System.out.println(Driver.getVersion());
        System.out.println("Found in: " + url);
    }

}

/*-------------------------------------------------------------------------
*
* Copyright (c) 2004-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
*   $PostgreSQL: pgjdbc/org/postgresql/util/PSQLDriverVersion.java,v 1.21 2006/12/01 12:06:21 jurka Exp $
*
*-------------------------------------------------------------------------
*/
package org.postgresql.util;

import org.postgresql.Driver;

/**
 * This class holds the current build number and a utility program to print
 * it and the file it came from.  The primary purpose of this is to keep
 * from filling the cvs history of Driver.java.in with commits simply
 * changing the build number.  The utility program can also be helpful for
 * people to determine what version they really have and resolve problems
 * with old and unknown versions located somewhere in the classpath.
 */
public class PSQLDriverVersion {

    public final static int buildNumber = 601;

    public static void main(String args[]) {
        java.net.URL url = Driver.class.getResource("/org/postgresql/Driver.class");
        System.out.println(Driver.getVersion());
        System.out.println("Found in: " + url);
    }

}

Prepare for release for 8.3dev-601.

Prepare for release for 8.3dev-601.


package in.co.nebulax.magpie;

public class Constants {

	// url to get data JSON
	public static String url = "http://10.0.2.2:1111/all";

	//JSON Node Names
	public static String TAG_DATA = "data";
	public static String TAG_DEVICE = "device";
	public static String TAG_STATUS = "status";
	public static String TAG_NAME = "name";
}

package in.co.nebulax.magpie;

public class Constants {

	// url to get data JSON
	public static String urlGet = "http://10.0.2.2:1111/all";
	public static String urlPost = "http://10.0.2.2:1111/change";

	//JSON Node Names
	public static String TAG_DATA = "data";
	public static String TAG_DEVICE = "device";
	public static String TAG_STATUS = "status";
	public static String TAG_NAME = "name";
}

Add url for post request

Add url for post request


package org.fest.assertions.api.android;

import java.util.List;

public final class Utils {
  public static String join(List<String> parts) {
    StringBuilder builder = new StringBuilder();
    for (String part : parts) {
      if (builder.length() > 0) {
        builder.append(", ");
      }
      builder.append(part);
    }
    return builder.toString();
  }

  private Utils() {
    // No instances.
  }
}

package org.fest.assertions.api.android;

import android.text.TextUtils;
import java.util.List;

public final class Utils {
  public static String join(List<String> parts) {
    return TextUtils.join(", ", parts);
  }

  private Utils() {
    // No instances.
  }
}

Change custom String joiner to use framework one.


package org.aikodi.chameleon.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * A debugging class that stores the current stacktrace.
 *
 * @author Marko van Dooren
 */
public class CreationStackTrace {

	private StackTraceElement[] _stackTrace;

	public List<StackTraceElement> trace() {
		return new ArrayList<StackTraceElement>(Arrays.asList(_stackTrace));
	}

	public CreationStackTrace() {
		try {
			throw new Exception();
		} catch (Exception e) {
			_stackTrace = e.getStackTrace();
		}
	}

}

package org.aikodi.chameleon.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * A debugging class that stores the current stacktrace.
 *
 * @author Marko van Dooren
 */
public class CreationStackTrace {

	private List<StackTraceElement> _stackTrace;

	public List<StackTraceElement> trace() {
		return new ArrayList<StackTraceElement>(_stackTrace);
	}

	public CreationStackTrace() {
		try {
			throw new Exception();
		} catch (Exception e) {
			_stackTrace = Arrays.asList(e.getStackTrace());
		}
	}

  public CreationStackTrace(int size) {
    try {
      throw new Exception();
    } catch (Exception e) {
      _stackTrace = Arrays.asList(e.getStackTrace()).subList(0, size);
    }
  }
}

Allow taking a limited snapshot of the full trace


/**
 * Copyright (c) 2012-2013 André Bargull
 * Alle Rechte vorbehalten / All Rights Reserved.  Use is subject to license terms.
 *
 * <https://github.com/anba/es6draft>
 */
package com.github.anba.es6draft.runtime.internal;

import com.github.anba.es6draft.runtime.ExecutionContext;

/**
 * Base class for internal exceptions
 */
@SuppressWarnings("serial")
public abstract class InternalException extends java.lang.RuntimeException {
    /**
     * {@inheritDoc}
     */
    public InternalException() {
        super();
    }

    /**
     * {@inheritDoc}
     */
    public InternalException(String message) {
        super(message);
    }

    /**
     * {@inheritDoc}
     */
    public InternalException(String message, Throwable cause) {
        super(message, cause);
    }

    /**
     * {@inheritDoc}
     */
    public InternalException(Throwable cause) {
        super(cause);
    }

    /**
     * {@inheritDoc}
     */
    protected InternalException(String message, Throwable cause, boolean enableSuppression,
            boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    /**
     * Returns a {@link ScriptException} for this exception object
     */
    public abstract ScriptException toScriptException(ExecutionContext cx);
}

/**
 * Copyright (c) 2012-2013 André Bargull
 * Alle Rechte vorbehalten / All Rights Reserved.  Use is subject to license terms.
 *
 * <https://github.com/anba/es6draft>
 */
package com.github.anba.es6draft.runtime.internal;

import com.github.anba.es6draft.runtime.ExecutionContext;

/**
 * Base class for internal exceptions
 */
@SuppressWarnings("serial")
public abstract class InternalException extends RuntimeException {
    /**
     * {@inheritDoc}
     */
    public InternalException() {
        super();
    }

    /**
     * {@inheritDoc}
     */
    public InternalException(String message) {
        super(message);
    }

    /**
     * {@inheritDoc}
     */
    public InternalException(String message, Throwable cause) {
        super(message, cause);
    }

    /**
     * {@inheritDoc}
     */
    public InternalException(Throwable cause) {
        super(cause);
    }

    /**
     * {@inheritDoc}
     */
    protected InternalException(String message, Throwable cause, boolean enableSuppression,
            boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    /**
     * Returns a {@link ScriptException} for this exception object
     */
    public abstract ScriptException toScriptException(ExecutionContext cx);
}

Remove unnecessary complete class name

Remove unnecessary complete class name


package com.tinkerpop.gremlin.structure;

import java.io.Serializable;

/**
 * @author Stephen Mallette (http://stephen.genoprime.com)
 */
public class MockSerializable implements Serializable {
    private String testField;

    public MockSerializable(final String testField) {
        this.testField = testField;
    }

    public String getTestField() {
        return this.testField;
    }

    public void setTestField(final String testField) {
        this.testField = testField;
    }

    @Override
    public boolean equals(Object oth) {
        if (this == oth) return true;
        else if (oth == null) return false;
        else if (!getClass().isInstance(oth)) return false;
        MockSerializable m = (MockSerializable) oth;
        if (testField == null) {
            return (m.testField == null);
        } else return testField.equals(m.testField);
    }
}

package com.tinkerpop.gremlin.structure;

import java.io.Serializable;

/**
 * @author Stephen Mallette (http://stephen.genoprime.com)
 */
public class MockSerializable implements Serializable {
    private String testField;

    private MockSerializable() {}

    public MockSerializable(final String testField) {
        this.testField = testField;
    }

    public String getTestField() {
        return this.testField;
    }

    public void setTestField(final String testField) {
        this.testField = testField;
    }

    @Override
    public boolean equals(Object oth) {
        if (this == oth) return true;
        else if (oth == null) return false;
        else if (!getClass().isInstance(oth)) return false;
        MockSerializable m = (MockSerializable) oth;
        if (testField == null) {
            return (m.testField == null);
        } else return testField.equals(m.testField);
    }
}

Add private constructor to mockserializable.


package com.lyubenblagoev.postfixrest.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfiguration {

    @Bean
    WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurer() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/api/v1/**");
            }
        };
    }
}

package com.lyubenblagoev.postfixrest.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfiguration {

    @Bean
    WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurer() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/api/v1/**")
                        .allowedMethods("*")
                        .allowedOrigins("*");
            }
        };
    }
}

Improve CORS configuration to allow all methods and origins


package jp.ne.opt.redshiftfake.views;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by ffarrell on 14/06/2018.
 *
 * Some system tables that exist in redshift do not necessarily exist in postgres
 *
 * This creates pg_tableef as a view on each connection if it does not exist
 */
public class SystemViews {

    private static final String createPgTableDefView =
            "CREATE VIEW pg_table_def (schemaname, tablename, \"column\", \"type\", \"encoding\", distkey, sortkey, \"notnull\") " +
                    "AS SELECT table_schema, table_name, column_name, data_type, 'none', false, 0, CASE is_nullable WHEN 'yes' THEN false ELSE true END " +
                    "FROM information_schema.columns;";

    public static void create(final Connection connection) throws SQLException {

        final ResultSet resultSet = connection.createStatement().executeQuery("SELECT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'pg_tab_def')");

        if(resultSet.next() && !resultSet.getBoolean(1)){
            connection.createStatement().execute(createPgTableDefView);
        }
    }

}

package jp.ne.opt.redshiftfake.views;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by frankfarrell on 14/06/2018.
 *
 * Some system tables that exist in redshift do not necessarily exist in postgres
 *
 * This creates pg_tableef as a view on each connection if it does not exist
 */
public class SystemViews {

    private static final String pgTableDefExistsQuery =
            "SELECT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'pg_table_def')";
    private static final String createPgTableDefView =
            "CREATE VIEW pg_table_def (schemaname, tablename, \"column\", \"type\", \"encoding\", distkey, sortkey, \"notnull\") " +
                    "AS SELECT table_schema, table_name, column_name, data_type, 'none', false, 0, CASE is_nullable WHEN 'yes' THEN false ELSE true END " +
                    "FROM information_schema.columns;";

    public static void create(final Connection connection) throws SQLException {

        final ResultSet resultSet = connection.createStatement().executeQuery(pgTableDefExistsQuery);

        if(resultSet.next() && !resultSet.getBoolean(1)){
            connection.createStatement().execute(createPgTableDefView);
        }
    }

}

chore: Correct typo in pg_table_def create view query


package jp.ne.opt.redshiftfake.views;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by ffarrell on 14/06/2018.
 *
 * Some system tables that exist in redshift do not necessarily exist in postgres
 *
 * This creates pg_tableef as a view on each connection if it does not exist
 */
public class SystemViews {

    private static final String createPgTableDefView =
            "CREATE VIEW pg_table_def (schemaname, tablename, \"column\", \"type\", \"encoding\", distkey, sortkey, \"notnull\") " +
                    "AS SELECT table_schema, table_name, column_name, data_type, 'none', false, 0, CASE is_nullable WHEN 'yes' THEN false ELSE true END " +
                    "FROM information_schema.columns;";

    public static void create(final Connection connection) throws SQLException {

        final ResultSet resultSet = connection.createStatement().executeQuery("SELECT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'pg_tab_def')");

        resultSet.first();
        if(!resultSet.getBoolean(1)){
            connection.createStatement().execute(createPgTableDefView);
        }
    }

}

package jp.ne.opt.redshiftfake.views;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by ffarrell on 14/06/2018.
 *
 * Some system tables that exist in redshift do not necessarily exist in postgres
 *
 * This creates pg_tableef as a view on each connection if it does not exist
 */
public class SystemViews {

    private static final String createPgTableDefView =
            "CREATE VIEW pg_table_def (schemaname, tablename, \"column\", \"type\", \"encoding\", distkey, sortkey, \"notnull\") " +
                    "AS SELECT table_schema, table_name, column_name, data_type, 'none', false, 0, CASE is_nullable WHEN 'yes' THEN false ELSE true END " +
                    "FROM information_schema.columns;";

    public static void create(final Connection connection) throws SQLException {

        final ResultSet resultSet = connection.createStatement().executeQuery("SELECT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'pg_tab_def')");

        if(resultSet.next() && !resultSet.getBoolean(1)){
            connection.createStatement().execute(createPgTableDefView);
        }
    }

}

Fix issue with FORWARD_ONLY resultSets

Fix issue with FORWARD_ONLY resultSets


package jkind;

public class JKindSettings extends Settings {
	public int n = 200;
	public int timeout = 100;

	public boolean excel = false;
	public boolean xml = false;
	public boolean xmlToStdout = false;

	public boolean boundedModelChecking = true;
	public boolean kInduction = true;
	public boolean invariantGeneration = true;
    public int pdrMax = 1;
	public boolean inductiveCounterexamples = false;
	public boolean reduceIvc = false;
	public boolean smoothCounterexamples = false;
    public boolean intervalGeneralization = false;
    public boolean inline = true;

	public SolverOption solver = SolverOption.SMTINTERPOL;
	public boolean scratch = false;

	public String writeAdvice = null;
	public String readAdvice = null;
}

package jkind;

public class JKindSettings extends Settings {
	public int n = Integer.MAX_VALUE;
	public int timeout = Integer.MAX_VALUE;

	public boolean excel = false;
	public boolean xml = false;
	public boolean xmlToStdout = false;

	public boolean boundedModelChecking = true;
	public boolean kInduction = true;
	public boolean invariantGeneration = true;
    public int pdrMax = 1;
	public boolean inductiveCounterexamples = false;
	public boolean reduceIvc = false;
	public boolean smoothCounterexamples = false;
    public boolean intervalGeneralization = false;
    public boolean inline = true;

	public SolverOption solver = SolverOption.SMTINTERPOL;
	public boolean scratch = false;

	public String writeAdvice = null;
	public String readAdvice = null;
}

Change timeout and depth to be effectively unbounded by default


package rs.pelotas.tracker.core;

import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.ws.rs.ApplicationPath;
import rs.pelotas.arch.batch.JobScheduler;
import rs.pelotas.arch.core.BaseApplication;
import rs.pelotas.tracker.batch.PositionJob;

/**
 *
 * @author Rafael Guterres
 */
@ApplicationPath("/api")
public class Application extends BaseApplication {

    @Inject
    JobScheduler scheduler;

    @Inject
    Logger logger;

    @Override
    public JobScheduler getScheduler() {
        return scheduler;
    }

    @Override
    public Logger getLogger() {
        return logger;
    }

    @PostConstruct
    @Override
    protected void init() {
        //TODO: implementar annotation para agendamento automatico
        scheduler.addJob(new PositionJob());
        scheduler.scheduleJobs();
    }
}

package rs.pelotas.tracker.core;

import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.ws.rs.ApplicationPath;
import rs.pelotas.arch.batch.JobScheduler;
import rs.pelotas.arch.core.BaseApplication;
import rs.pelotas.tracker.batch.PositionJob;

/**
 *
 * @author Rafael Guterres
 */
@ApplicationPath("/api")
public class Application extends BaseApplication {

    @Inject
    JobScheduler scheduler;

    @Inject
    Logger logger;

    @Override
    public JobScheduler getScheduler() {
        return scheduler;
    }

    @Override
    public Logger getLogger() {
        return logger;
    }

    @PostConstruct
    @Override
    protected void init() {
        //TODO: implementar annotation para agendamento automatico
        //scheduler.addJob(new PositionJob());
        //scheduler.scheduleJobs();
    }
}

FIX to Exception in thread "hornetq-expiry-reaper-thread" java.lang.OutOfMemoryError: unable to create new native thread


package jenkins.advancedqueue;

import hudson.Plugin;
import hudson.model.Job;
import hudson.model.Queue;
import jenkins.advancedqueue.sorter.ItemInfo;
import jenkins.advancedqueue.sorter.QueueItemCache;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution;

class PriorityConfigurationPlaceholderTaskHelper {

    boolean isPlaceholderTask(Queue.Task task) {
        return isPlaceholderTaskUsed() && task instanceof  ExecutorStepExecution.PlaceholderTask;
    }

    PriorityConfigurationCallback getPriority(ExecutorStepExecution.PlaceholderTask task, PriorityConfigurationCallback priorityCallback) {
        Job<?, ?> job = (Job<?, ?>) task.getOwnerTask();
        ItemInfo itemInfo = QueueItemCache.get().getItem(job.getName());
        itemInfo.getPriority();
        priorityCallback.setPrioritySelection(itemInfo.getPriority());
        return priorityCallback;
    }

    static boolean isPlaceholderTaskUsed() {
        Plugin plugin = Jenkins.getInstance().getPlugin("workflow-durable-task-step");
        return plugin != null && plugin.getWrapper().isActive();
    }

}

package jenkins.advancedqueue;

import hudson.Plugin;
import hudson.model.Job;
import hudson.model.Queue;
import jenkins.advancedqueue.sorter.ItemInfo;
import jenkins.advancedqueue.sorter.QueueItemCache;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution;

class PriorityConfigurationPlaceholderTaskHelper {

	boolean isPlaceholderTask(Queue.Task task) {
		return isPlaceholderTaskUsed() && task instanceof ExecutorStepExecution.PlaceholderTask;
	}

	PriorityConfigurationCallback getPriority(ExecutorStepExecution.PlaceholderTask task,
			PriorityConfigurationCallback priorityCallback) {
		Job<?, ?> job = (Job<?, ?>) task.getOwnerTask();
		ItemInfo itemInfo = QueueItemCache.get().getItem(job.getName());

		// Can be null if job didn't run yet

		if (itemInfo != null) {
			priorityCallback.setPrioritySelection(itemInfo.getPriority());
		} else {
			priorityCallback.setPrioritySelection(PrioritySorterConfiguration.get().getStrategy().getDefaultPriority());
		}

		return priorityCallback;
	}

	static boolean isPlaceholderTaskUsed() {
		Plugin plugin = Jenkins.getInstance().getPlugin("workflow-durable-task-step");
		return plugin != null && plugin.getWrapper().isActive();
	}

}

Fix upstream job priority retrieval

[JENKINS-42584] Fix upstream job priority retrieval

- NPE fix


package controllers;

import play.db.jpa.JPA;
import play.db.jpa.Transactional;
import play.mvc.Result;

import java.io.IOException;

import static play.mvc.Results.ok;

public class File {
    @Transactional
    public Result get(Long id) {
        models.FileMeta fileMeta = JPA.em().find(models.FileMeta.class, id);
        java.io.File file = models.FileManager.getFile(fileMeta);
        return ok(file).as(fileMeta.getMimeType());
    }

    @Transactional
    public Result getPreview(Long id) throws IOException {
        models.FileMeta fileMeta = JPA.em().find(models.FileMeta.class, id);
        java.io.File file = models.FileManager.getThumbnail(fileMeta);
        return ok(file).as(fileMeta.getMimeType());
    }
}

package controllers;

import play.db.jpa.JPA;
import play.db.jpa.Transactional;
import play.mvc.Result;

import java.io.IOException;

import static play.mvc.Results.ok;

public class File {
    @Transactional
    public Result get(Long id) {
        models.FileMeta fileMeta = JPA.em().find(models.FileMeta.class, id);
        java.io.File file = models.FileManager.getFile(fileMeta);
        return ok(file).as(fileMeta.getMimeType());
    }

    @Transactional
    public Result getPreview(Long id) throws IOException {
        models.FileMeta fileMeta = JPA.em().find(models.FileMeta.class, id);
        java.io.File file = models.FileManager.getThumbnail(fileMeta);
        return ok(file);
    }
}

Fix wrong Content-Type header in /file/min/


/**
 * Copyright (C) 2011-2020 Red Hat, Inc. (https://github.com/Commonjava/indy)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import javax.enterprise.context.ApplicationScoped;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@ApplicationScoped
public class SlashTolerationFilter
        implements Filter
{
    @Override
    public void init( final FilterConfig filterConfig )
                    throws ServletException
    {
    }

    @Override
    public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain )
            throws IOException, ServletException
    {
        final HttpServletRequest hsr = (HttpServletRequest) servletRequest;
        String newURI = hsr.getRequestURI().replaceAll( "/+", "/" );
        servletRequest.getRequestDispatcher(newURI).forward(servletRequest, servletResponse);
    }

    @Override
    public void destroy()
    {
    }

}

/**
 * Copyright (C) 2011-2020 Red Hat, Inc. (https://github.com/Commonjava/indy)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.commonjava.indy.bind.jaxrs;

import javax.enterprise.context.ApplicationScoped;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@ApplicationScoped
public class SlashTolerationFilter
        implements Filter
{
    @Override
    public void init( final FilterConfig filterConfig )
                    throws ServletException
    {
    }

    @Override
    public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain )
            throws IOException, ServletException
    {
        final HttpServletRequest hsr = (HttpServletRequest) servletRequest;
        String newURI = hsr.getRequestURI().replaceAll( "/+", "/" );
        servletRequest.getRequestDispatcher(newURI).forward(servletRequest, servletResponse);
    }

    @Override
    public void destroy()
    {
    }

}

Fix a wrong line problem

Fix a wrong line problem

   This problem will cause compilation error when after license header
   formatting, which is caused by the package line removed.


package me.eddiep.minecraft.ls.game.shop.impl;

import me.eddiep.minecraft.ls.Lavasurvival;
import me.eddiep.minecraft.ls.game.shop.Shop;
import me.eddiep.minecraft.ls.game.shop.ShopManager;
import me.eddiep.minecraft.ls.ranks.UserInfo;
import me.eddiep.minecraft.ls.ranks.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;

public class BankShopManager implements ShopManager {
    @Override
    public void shopClicked(Player owner, Shop shop) {
        UserManager um = Lavasurvival.INSTANCE.getUserManager();

        UserInfo user = um.getUser(owner.getUniqueId());

        Inventory bankInventory = user.createBankInventory();

        owner.openInventory(bankInventory);
    }

    @Override
    public boolean isShopInventory(Inventory inventory, Player owner) {
        return inventory.getTitle().equals("Bank");
    }

    @Override
    public void shopClosed(Player owner, Inventory inventory, Shop shop) {
        if (inventory.contains(shop.getOpener())) {
            inventory.remove(shop.getOpener());
            inventory.setItem(inventory.firstEmpty(), shop.getOpener());
        }

        UserManager um = Lavasurvival.INSTANCE.getUserManager();

        UserInfo user = um.getUser(owner.getUniqueId());

        user.saveBank(inventory);
    }
}

package me.eddiep.minecraft.ls.game.shop.impl;

import me.eddiep.minecraft.ls.Lavasurvival;
import me.eddiep.minecraft.ls.game.shop.Shop;
import me.eddiep.minecraft.ls.game.shop.ShopManager;
import me.eddiep.minecraft.ls.ranks.UserInfo;
import me.eddiep.minecraft.ls.ranks.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;

public class BankShopManager implements ShopManager {
    @Override
    public void shopClicked(Player owner, Shop shop) {
        UserManager um = Lavasurvival.INSTANCE.getUserManager();

        UserInfo user = um.getUser(owner.getUniqueId());

        Inventory bankInventory = user.createBankInventory();

        owner.openInventory(bankInventory);
    }

    @Override
    public boolean isShopInventory(Inventory inventory, Player owner) {
        return inventory.getTitle().equals("Bank");
    }

    @Override
    public void shopClosed(Player owner, Inventory inventory, Shop shop) {
        if (inventory.contains(shop.getOpener())) {
            inventory.remove(shop.getOpener());
            inventory.setItem(owner.getInventory().firstEmpty(), shop.getOpener());
        }

        UserManager um = Lavasurvival.INSTANCE.getUserManager();

        UserInfo user = um.getUser(owner.getUniqueId());

        user.saveBank(inventory);
    }
}

Fix being able to put bank item in bank

Fix being able to put bank item in bank


package org.pdxfinder.rdbms.repositories;

import org.pdxfinder.rdbms.dao.MappingEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface MappingEntityRepository extends JpaRepository<MappingEntity, Long> {

    MappingEntity findByMappingKey(String mappingKey);

    List<MappingEntity> findByMappedTermLabel(String mappedTermLabel);
}

package org.pdxfinder.rdbms.repositories;

import org.pdxfinder.rdbms.dao.MappingEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created by abayomi on 25/07/2019.
 */
@Repository
public interface MappingEntityRepository extends JpaRepository<MappingEntity, Long> {

    MappingEntity findByMappingKey(String mappingKey);

    List<MappingEntity> findByMappedTermLabel(String mappedTermLabel);

    @Query(value = "Select distinct me from MappingEntity me JOIN me.mappingValues mv " +
            "WHERE ((lower(me.entityType) = lower(:entityType)) OR :entityType = '') "+
            "AND ((KEY(mv) = :mappingLabel AND mv = :mappingValue) OR  :mappingValue = '') "
    )
    Page<MappingEntity> findByMultipleFilters(@Param("entityType") String entityType,

                                              @Param("mappingLabel") String mappingLabel,
                                              @Param("mappingValue") String mappingValue,

                                              Pageable pageable);

    @Query(value = "select me from MappingEntity me JOIN me.mappingValues mv WHERE KEY(mv) = :dataKey AND mv = :dataValue ")
    List<MappingEntity> findByAttributeAndValue(@Param("dataKey") String dataKey,
                                                @Param("dataValue") String dataValue);

}

Create Search Filter for the Persisted Mapping Entities


package org.adaptlab.chpir.android.participanttracker.validators;

/**
 * Created by mn127 on 3/3/15.
 */
public class CaregiverIdValidator extends ParticipantIdValidator {

    @Override
    public boolean validate(String value) {
        if (value.length() > 0) {
            return value.charAt(0) == 'E' && super.validate(value);
        }

        return false;
    }
}

package org.adaptlab.chpir.android.participanttracker.validators;

public class CaregiverIdValidator extends ParticipantIdValidator {

    @Override
    public boolean validate(String value) {
        if (value.length() > 0) {
            return value.charAt(0) == 'E' && super.validate(value);
        }

        return false;
    }
}

Clean up comments for caregiver id validator


package tars.testutil;

import tars.model.task.*;
import tars.model.tag.UniqueTagList;

/**
 * A mutable task object. For testing only.
 */
public class TestTask implements ReadOnlyTask {

    private Name name;
    private UniqueTagList tags;
    private DateTime dateTime;
    private Status status;
    private Priority priority;

    public TestTask() {
        tags = new UniqueTagList();
    }

    public void setName(Name name) {
        this.name = name;
    }

    @Override
    public Name getName() {
        return name;
    }

    @Override
    public DateTime getDateTime() {
        return dateTime;
    }

    @Override
    public Status getStatus() {
        return status;
    }

    @Override
    public Priority getPriority() {
        return priority;
    }

    @Override
    public UniqueTagList getTags() {
        return tags;
    }

    @Override
    public String toString() {
        return getAsText();
    }

    public String getAddCommand() {
        StringBuilder sb = new StringBuilder();
        sb.append("add " + this.getName().taskName + " ");
        sb.append("-dt " + this.getDateTime().toString() + " ");
        sb.append("-p " + this.getPriority().toString() + " ");
        this.getTags().getInternalList().stream().forEach(s -> sb.append("t/" + s.tagName + " "));
        return sb.toString();
    }
}

package tars.testutil;

import tars.model.task.*;
import tars.model.tag.UniqueTagList;

/**
 * A mutable task object. For testing only.
 */
public class TestTask implements ReadOnlyTask {

    private Name name;
    private UniqueTagList tags;
    private DateTime dateTime;
    private Status status;
    private Priority priority;

    public TestTask() {
        tags = new UniqueTagList();
    }

    public void setName(Name name) {
        this.name = name;
    }

    public void setDateTime(DateTime dateTime) {
        this.dateTime = dateTime;
    }

    public void setPriority(Priority priority) {
        this.priority = priority;
    }

    @Override
    public Name getName() {
        return name;
    }

    @Override
    public DateTime getDateTime() {
        return dateTime;
    }

    @Override
    public Status getStatus() {
        return status;
    }

    @Override
    public Priority getPriority() {
        return priority;
    }

    @Override
    public UniqueTagList getTags() {
        return tags;
    }

    @Override
    public String toString() {
        return getAsText();
    }

    public String getAddCommand() {
        StringBuilder sb = new StringBuilder();
        sb.append("add " + this.getName().taskName + " ");
        sb.append("-dt " + this.getDateTime().toString() + " ");
        sb.append("-p " + this.getPriority().toString() + " ");
        this.getTags().getInternalList().stream().forEach(s -> sb.append("t/" + s.tagName + " "));
        return sb.toString();
    }
}

Add setDateTime(DateTime) and setPriority(Priority) methods


package org.alien4cloud.tosca.model.instances;

import com.google.common.collect.Maps;
import lombok.Getter;
import lombok.Setter;
import org.alien4cloud.tosca.model.CSARDependency;
import org.alien4cloud.tosca.model.templates.NodeTemplate;
import org.elasticsearch.annotation.NestedObject;
import org.elasticsearch.annotation.ObjectField;
import org.elasticsearch.annotation.StringField;
import org.elasticsearch.annotation.query.FetchContext;
import org.elasticsearch.annotation.query.TermFilter;
import org.elasticsearch.mapping.IndexType;

import java.util.Map;

import static alien4cloud.dao.model.FetchContext.SUMMARY;

/**
 * An instance of a node.
 */
@Getter
@Setter
public class NodeInstance {
    // The node template actually does not include the type version (maybe we should add that to the node template ?).
    @TermFilter
    @StringField(indexType = IndexType.not_analyzed, includeInAll = false)
    private String typeVersion;

    @ObjectField
    private NodeTemplate nodeTemplate;

    @StringField(indexType = IndexType.not_analyzed, includeInAll = false)
    private Map<String, String> attributeValues = Maps.newHashMap();

    public void setAttribute(String key, String value) {
        attributeValues.put(key, value);
    }
}

package org.alien4cloud.tosca.model.instances;

import com.google.common.collect.Maps;
import lombok.Getter;
import lombok.Setter;
import org.alien4cloud.tosca.model.CSARDependency;
import org.alien4cloud.tosca.model.templates.NodeTemplate;
import org.elasticsearch.annotation.NestedObject;
import org.elasticsearch.annotation.ObjectField;
import org.elasticsearch.annotation.StringField;
import org.elasticsearch.annotation.query.FetchContext;
import org.elasticsearch.annotation.query.TermFilter;
import org.elasticsearch.mapping.IndexType;

import java.util.Map;

import static alien4cloud.dao.model.FetchContext.SUMMARY;

/**
 * An instance of a node.
 */
@Getter
@Setter
public class NodeInstance {
    // The node template actually does not include the type version (maybe we should add that to the node template ?).
    @TermFilter
    @StringField(indexType = IndexType.not_analyzed, includeInAll = false)
    private String typeVersion;

    @ObjectField
    private NodeTemplate nodeTemplate;

    @ObjectField(enabled = false)
    private Map<String, String> attributeValues = Maps.newHashMap();

    public void setAttribute(String key, String value) {
        attributeValues.put(key, value);
    }
}

[ALIEN-3636] Correct service attributes mapping to ES


package org.mozilla.mozstumbler;

import android.annotation.SuppressLint;

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.TimeZone;

public final class DateTimeUtils {
    private static final DateFormat sLocaleFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    private static final DateFormat sISO8601Format = new SimpleDateFormat("yyyy-MM-dd", Locale.US);

    static final long MILLISECONDS_PER_DAY = 86400000;  // milliseconds/day

    static {
        sISO8601Format.setTimeZone(TimeZone.getTimeZone("UTC"));
    }

    private DateTimeUtils() {
    }

    @SuppressLint("SimpleDateFormat")
    static String formatDate(Date date) {
        return sISO8601Format.format(date);
    }

    public static String formatTime(long time) {
        return formatDate(new Date(time));
    }

    static String formatTimeForLocale(long time) {
        return sLocaleFormat.format(time);
    }

    static String formatCurrentTime() {
        return formatTimeForLocale(System.currentTimeMillis());
    }
}

package org.mozilla.mozstumbler;

import android.annotation.SuppressLint;

import java.util.Calendar;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.TimeZone;

public final class DateTimeUtils {
    private static final DateFormat sLocaleFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    private static final DateFormat sISO8601Format = new SimpleDateFormat("yyyy-MM-dd", Locale.US);

    static final long MILLISECONDS_PER_DAY = 86400000;  // milliseconds/day

    static {
        sISO8601Format.setTimeZone(TimeZone.getTimeZone("UTC"));
    }

    private DateTimeUtils() {
    }

    @SuppressLint("SimpleDateFormat")
    static String formatDate(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.DAY_OF_MONTH,1);
        date = c.getTime();
        return sISO8601Format.format(date);
    }

    public static String formatTime(long time) {
        return formatDate(new Date(time));
    }

    static String formatTimeForLocale(long time) {
        return sLocaleFormat.format(time);
    }

    static String formatCurrentTime() {
        return formatTimeForLocale(System.currentTimeMillis());
    }
}

Modify the date format to YYYY-mm-01.

Modify the date format to YYYY-mm-01.

Match the mozilla/ichnaea/120 changes as done by @crankycoder and send the date as YYYY-mm-01 only (overwriting the day value).


package com.rmd.personal.projecteuler;

import java.util.ArrayList;
import java.util.List;

public final class Main {

    private List<Problem> problemList;

    private Main() {
        this.problemList = new ArrayList<Problem>();
        this.getProblemList().add(new Problem1());
    }

    private List<Problem> getProblemList() {
        return this.problemList;
    }

    public static void main(String[] args) {
        (new Main()).run();
    }

    private void run() {
        for (Problem problem : this.getProblemList()) {
            System.out.println("Problem: " + this.getProblemList().indexOf(problem));
            System.out.println(problem.getDescription());
            System.out.println(problem.run());
        }
    }
}

package com.rmd.personal.projecteuler;

import java.util.ArrayList;
import java.util.List;

public final class Main {

    private List<Problem> problemList;

    private Main() {
        this.problemList = new ArrayList<Problem>();
        this.getProblemList().add(new Problem1());
        this.getProblemList().add(new Problem2());
        this.getProblemList().add(new Problem3());
    }

    private List<Problem> getProblemList() {
        return this.problemList;
    }

    public static void main(String[] args) {
        (new Main()).run();
    }

    private void run() {
        for (Problem problem : this.getProblemList()) {
            System.out.println("Problem: " + this.getProblemList().indexOf(problem));
            System.out.println(problem.getDescription());
            System.out.println(problem.run());
        }
    }
}

Add problem 2 and 3 to main class.

Add problem 2 and 3 to main class.


package strings;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import static strings.BaseConversion.baseConversion;

class BaseConversionTest {

    private String expected;
    private String input;
    private int b1;
    private int b2;

    @Test
    void baseConversion1() {
        expected = "314F";
        input = "12623";
        b1 = 10;
        b2 = 16;

        test(expected, input, b1, b2);
    }

    @Test
    void baseConversion2() {
        expected = "2C996B726";
        input = "114152520463";
        b1 = 7;
        b2 = 13;

        test(expected, input, b1, b2);
    }

    @Test
    void baseConversion3() {
        expected = "111";
        input = "7";
        b1 = 10;
        b2 = 2;

        test(expected, input, b1, b2);
    }

    @Test
    void baseConversion4() {
        expected = "33CD";
        input = "10001100101001";
        b1 = 2;
        b2 = 14;

        test(expected, input, b1, b2);
    }

    private void test(String expected, String input, int b1, int b2) {
        assertEquals(expected, baseConversion(input, b1, b2));
    }

}

package strings;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import static strings.BaseConversion.baseConversion;

class BaseConversionTest {

    private String expected;
    private String input;
    private int b1;
    private int b2;

    @Test
    void baseConversion1() {
        expected = "314F";
        input = "12623";
        b1 = 10;
        b2 = 16;

        test(expected, input, b1, b2);
    }

    @Test
    void baseConversion2() {
        expected = "-6CC2";
        input = "-62543";
        b1 = 7;
        b2 = 13;

        test(expected, input, b1, b2);
    }

    @Test
    void baseConversion3() {
        expected = "111";
        input = "7";
        b1 = 10;
        b2 = 2;

        test(expected, input, b1, b2);
    }

    @Test
    void baseConversion4() {
        expected = "33CD";
        input = "10001100101001";
        b1 = 2;
        b2 = 14;

        test(expected, input, b1, b2);
    }

    private void test(String expected, String input, int b1, int b2) {
        assertEquals(expected, baseConversion(input, b1, b2));
    }

}

Remove test with integer > Integer.MAX. Replaced it with negative number test


package org.bouncycastle.crypto.tls;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * A generic interface for key exchange implementations in TLS 1.0.
 */
interface TlsKeyExchange
{
    static final short KE_RSA = 1;
//    static final short KE_RSA_EXPORT = 2;
    static final short KE_DHE_DSS = 3;
//    static final short KE_DHE_DSS_EXPORT = 4;
    static final short KE_DHE_RSA = 5;
//    static final short KE_DHE_RSA_EXPORT = 6;
    static final short KE_DH_DSS = 7;
    static final short KE_DH_RSA = 8;
//    static final short KE_DH_anon = 9;
    static final short KE_SRP = 10;
    static final short KE_SRP_DSS = 11;
    static final short KE_SRP_RSA = 12;

    void skipServerCertificate() throws IOException;

    void processServerCertificate(Certificate serverCertificate) throws IOException;

    void skipServerKeyExchange() throws IOException;

    void processServerKeyExchange(InputStream is, SecurityParameters securityParameters)
        throws IOException;

    void generateClientKeyExchange(OutputStream os) throws IOException;

    byte[] generatePremasterSecret() throws IOException;
}

package org.bouncycastle.crypto.tls;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * A generic interface for key exchange implementations in TLS 1.0.
 */
interface TlsKeyExchange
{
    static final short KE_RSA = 1;
//    static final short KE_RSA_EXPORT = 2;
    static final short KE_DHE_DSS = 3;
//    static final short KE_DHE_DSS_EXPORT = 4;
    static final short KE_DHE_RSA = 5;
//    static final short KE_DHE_RSA_EXPORT = 6;
    static final short KE_DH_DSS = 7;
    static final short KE_DH_RSA = 8;
//    static final short KE_DH_anon = 9;
    static final short KE_SRP = 10;
    static final short KE_SRP_DSS = 11;
    static final short KE_SRP_RSA = 12;
    static final short KE_ECDH_ECDSA = 13;
    static final short KE_ECDHE_ECDSA = 14;
    static final short KE_ECDH_RSA = 15;
    static final short KE_ECDHE_RSA = 16;
    static final short KE_ECDH_anon = 17;

    void skipServerCertificate() throws IOException;

    void processServerCertificate(Certificate serverCertificate) throws IOException;

    void skipServerKeyExchange() throws IOException;

    void processServerKeyExchange(InputStream is, SecurityParameters securityParameters)
        throws IOException;

    void generateClientKeyExchange(OutputStream os) throws IOException;

    byte[] generatePremasterSecret() throws IOException;
}

Add constants for EC key exchange methods


/*++

NASM Assembly Language Plugin
Copyright (c) 2017-2018 Aidan Khoury. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

--*/

package com.nasmlanguage.psi.impl;

import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.nasmlanguage.psi.NASMNamedElement;
import org.jetbrains.annotations.NotNull;

public abstract class NASMNamedElementImpl extends ASTWrapperPsiElement implements NASMNamedElement {
    public NASMNamedElementImpl(@NotNull ASTNode node) {
        super(node);
    }
}

/*++

NASM Assembly Language Plugin
Copyright (c) 2017-2018 Aidan Khoury

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

--*/

package com.nasmlanguage.psi.impl;

import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.nasmlanguage.psi.NASMNamedElement;
import org.jetbrains.annotations.NotNull;

public abstract class NASMNamedElementImpl extends ASTWrapperPsiElement implements NASMNamedElement {
    public NASMNamedElementImpl(@NotNull ASTNode node) {
        super(node);
    }
}

Update copyright notice with MIT license


package main.java.player;

import jgame.platform.JGEngine;

public class TDPlayerEngine extends JGEngine {

	public TDPlayerEngine() {
		super();
		initEngineComponent(960, 640);
	}

	@Override
	public void initCanvas() {
		setCanvasSettings(15, 10, 32, 32, null, null, null);
	}

	@Override
	public void initGame() {
		setFrameRate(35, 2);
	}

	public void doFrame() {

	}
}

package main.java.player;

import jgame.JGColor;
import jgame.JGPoint;
import jgame.platform.JGEngine;
import main.java.engine.Model;

public class TDPlayerEngine extends JGEngine {
    private Model model;

	public TDPlayerEngine() {
		super();
		initEngineComponent(960, 640);
	}

	@Override
	public void initCanvas() {
		setCanvasSettings(15, 10, 32, 32, null, JGColor.black, null);
	}

	@Override
	public void initGame() {
		setFrameRate(45, 1);
        this.model = new Model();
        model.setEngine(this);
        model.addNewPlayer();
        model.loadMap("testmap.json");
        defineMedia("/main/resources/media.tbl");
        model.setTemporaryWaveSchema();
	}

    @Override
    public void paintFrame() {
        highlightMouseoverTile();
        displayGameStats();
    }

    private void highlightMouseoverTile() {
        JGPoint mousePos = getMousePos();
        int curXTilePos = mousePos.x/tileWidth() * tileWidth();
        int curYTilePos = mousePos.y/tileHeight() * tileHeight();

        this.drawRect(curXTilePos, curYTilePos, tileWidth(), tileHeight(), false, false, 1.0, JGColor.yellow);
    }

    private void displayGameStats() {
    	this.drawString("Score: "+model.getScore(), 50, 25, -1);
    	this.drawString("Lives left: "+model.getPlayerLife(), 50, 50, -1);
    	this.drawString("Money: "+model.getMoney(), 50, 75, -1);
    	this.drawString("Game clock: "+model.getGameClock(), 50, 100, -1);
    }

    @Override
    public void doFrame() {
        super.doFrame();
        model.updateGameClockByFrame();
        if (getMouseButton(1)) {
            model.placeTower(getMouseX(), getMouseY());
        }
        if (model.getGameClock() % 100 == 0)
        	model.spawnNextWave();
        moveObjects();
//        model.spawnMonster(100, 150);
    }
}

Make player talk to engine

Make player talk to engine


package peergos.shared.storage;

import peergos.shared.crypto.hash.*;

import java.util.concurrent.*;
import java.util.function.*;

public class Transaction {

    /** Run a series of operations under a transaction, ensuring that it is closed correctly
     *
     * @param owner
     * @param processor
     * @param ipfs
     * @param <V>
     * @return
     */
    public static <V> CompletableFuture<V> run(PublicKeyHash owner,
                                               Function<TransactionId, CompletableFuture<V>> processor,
                                               ContentAddressedStorage ipfs) {
        CompletableFuture<V> res = new CompletableFuture<>();
        ipfs.startTransaction(owner).thenCompose(tid -> processor.apply(tid)
                .thenCompose(v -> ipfs.closeTransaction(owner, tid)
                        .thenApply(x -> res.complete(v)))
                .exceptionally(t -> {
                    ipfs.closeTransaction(owner, tid)
                            .thenApply(x -> res.completeExceptionally(t))
                            .exceptionally(e -> res.completeExceptionally(e));
                    return false;
                }));
        return res;
    }
}

package peergos.shared.storage;

import peergos.shared.crypto.hash.*;

import java.util.concurrent.*;
import java.util.function.*;

public class Transaction {

    /** Run a series of operations under a transaction, ensuring that it is closed correctly
     *
     * @param owner
     * @param processor
     * @param ipfs
     * @param <V>
     * @return
     */
    public static <V> CompletableFuture<V> run(PublicKeyHash owner,
                                               Function<TransactionId, CompletableFuture<V>> processor,
                                               ContentAddressedStorage ipfs) {
        CompletableFuture<V> res = new CompletableFuture<>();
        ipfs.startTransaction(owner).thenCompose(tid -> processor.apply(tid)
                .thenCompose(v -> ipfs.closeTransaction(owner, tid)
                        .thenApply(x -> res.complete(v)))
                .exceptionally(t -> {
                    ipfs.closeTransaction(owner, tid)
                            .thenApply(x -> res.completeExceptionally(t))
                            .exceptionally(e -> res.completeExceptionally(e));
                    return false;
                })).exceptionally(e -> res.completeExceptionally(e));
        return res;
    }
}

Make sure a transaction completes exceptionally if it fails to start


package com.meedan;

import android.app.Activity;

import java.util.*;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import com.meedan.ShareMenuModule;

public class ShareMenuPackage implements ReactPackage {

  public ShareMenuPackage() {
    super();
  }

  @Override
  public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();
    modules.add(new ShareMenuModule(reactContext));
    return modules;
  }

  @Override
  public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
  }

  @Override
  public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Collections.emptyList();
  }
}

package com.meedan;

import android.app.Activity;

import java.util.*;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import com.meedan.ShareMenuModule;

public class ShareMenuPackage implements ReactPackage {

  public ShareMenuPackage() {
    super();
  }

  @Override
  public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();
    modules.add(new ShareMenuModule(reactContext));
    return modules;
  }

  @Override
  public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Collections.emptyList();
  }
}

Fix Compilation Error in React Native 0.47.0


package com.github.ferstl.depgraph;

import java.io.File;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import io.takari.maven.testing.TestResources;
import io.takari.maven.testing.executor.MavenExecutionResult;
import io.takari.maven.testing.executor.MavenRuntime;
import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder;
import io.takari.maven.testing.executor.MavenVersions;
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;

@RunWith(MavenJUnitTestRunner.class)
@MavenVersions("3.3.9")
public class IntegrationTest {

  @Rule
  public final TestResources resources = new TestResources();

  private final MavenRuntime mavenRuntime;

  public IntegrationTest(MavenRuntimeBuilder builder) throws Exception {
    this.mavenRuntime = builder.build();
  }

  @Test
  public void graph() throws Exception {
    File basedir = this.resources.getBasedir("depgraph-maven-plugin-test");
    MavenExecutionResult result = this.mavenRuntime
        .forProject(basedir)
        .execute("clean", "depgraph:graph");

    result.assertErrorFreeLog();
  }
}

package com.github.ferstl.depgraph;

import java.io.File;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import io.takari.maven.testing.TestResources;
import io.takari.maven.testing.executor.MavenExecutionResult;
import io.takari.maven.testing.executor.MavenRuntime;
import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder;
import io.takari.maven.testing.executor.MavenVersions;
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
import static io.takari.maven.testing.TestResources.assertFilesPresent;

@RunWith(MavenJUnitTestRunner.class)
@MavenVersions("3.3.9")
public class IntegrationTest {

  @Rule
  public final TestResources resources = new TestResources();

  private final MavenRuntime mavenRuntime;

  public IntegrationTest(MavenRuntimeBuilder builder) throws Exception {
    this.mavenRuntime = builder.build();
  }

  @Test
  public void graph() throws Exception {
    File basedir = this.resources.getBasedir("depgraph-maven-plugin-test");
    MavenExecutionResult result = this.mavenRuntime
        .forProject(basedir)
        .execute("clean", "depgraph:graph");

    result.assertErrorFreeLog();
    assertFilesPresent(
        basedir,
        "module-1/target/dependency-graph.dot",
        "module-2/target/dependency-graph.dot",
        "sub-parent/module-3/target/dependency-graph.dot");
  }
}

Add assertion for dot files

Add assertion for dot files


package endtoend;

import static org.junit.Assert.assertEquals;
import me.moodcat.api.models.RoomModel;
import me.moodcat.api.models.SongModel;

import org.junit.Test;

public class ApiEndToEndTest extends EndToEndTest {

    @Test
    public void canRetrieveRooms() {
        RoomModel room = this.performGETRequest(RoomModel.class, "rooms/1");

        assertEquals(1, room.getId().intValue());
        assertEquals(1, room.getNowPlaying().getSong().getId().intValue());
    }

    @Test
    public void canRetrieveSongs() {
        SongModel song = this.performGETRequest(SongModel.class, "songs/1");

        assertEquals(1, song.getId().intValue());
        assertEquals(202330997, song.getSoundCloudId().intValue());
    }

}

package endtoend;

import static org.junit.Assert.assertEquals;

import java.util.List;

import javax.ws.rs.core.GenericType;

import me.moodcat.api.models.RoomModel;
import me.moodcat.api.models.SongModel;

import org.junit.Test;

public class ApiEndToEndTest extends EndToEndTest {

    @Test
    public void canRetrieveRoom() {
        RoomModel room = this.performGETRequest(RoomModel.class, "rooms/1");

        assertEquals(1, room.getId().intValue());
        assertEquals(1, room.getNowPlaying().getSong().getId().intValue());
    }

    @Test
    public void canRetrieveSongs() {
        SongModel song = this.performGETRequest(SongModel.class, "songs/1");

        assertEquals(1, song.getId().intValue());
        assertEquals(202330997, song.getSoundCloudId().intValue());
    }

    @Test
    public void canRetrieveRooms() {
        List<RoomModel> rooms = this.performGETRequestWithGenericType(new GenericType<List<RoomModel>>(){}, "rooms");

        assertEquals(1, rooms.get(0).getId().intValue());
    }

}

Test that might be failing. Let's see.

Test that might be failing. Let's see.


package de.stefanhoth.android.got2048.logic;

import de.stefanhoth.android.got2048.logic.model.Cell;
import de.stefanhoth.android.got2048.logic.model.Grid;
import de.stefanhoth.android.got2048.logic.model.MOVE_DIRECTION;

/**
 * TODO describe class
 *
 * @author Stefan Hoth <sh@jnamic.com>
 *         date: 20.03.14 20:40
 * @since TODO add version
 */
public class MCP {

    protected static final int DEFAULT_START_FIELDS = 2;
    protected static final int DEFAULT_START_VALUE = 2;
    private Grid playlingField;

    public MCP() {

        playlingField = new Grid();
    }

    protected Grid getPlaylingField() {
        return playlingField;
    }

    public void addStartCells() {

        Cell cell = playlingField.getRandomCell();

        cell.setValue(DEFAULT_START_VALUE);

        Cell nextCell = playlingField.getRandomCell();

        for (int count = playlingField.getActiveCells(); count < DEFAULT_START_FIELDS; count++) {
            while (cell.equals(nextCell)) {
                nextCell = playlingField.getRandomCell();
            }

            nextCell.setValue(DEFAULT_START_VALUE);
            cell = nextCell;
        }
    }

    public void move(MOVE_DIRECTION direction) {

        //left to right
        playlingField.moveCells();

    }
}

package de.stefanhoth.android.got2048.logic;

import de.stefanhoth.android.got2048.logic.model.Cell;
import de.stefanhoth.android.got2048.logic.model.Grid;
import de.stefanhoth.android.got2048.logic.model.MOVE_DIRECTION;

/**
 * TODO describe class
 *
 * @author Stefan Hoth <sh@jnamic.com>
 *         date: 20.03.14 20:40
 * @since TODO add version
 */
public class MCP {

    protected static final int DEFAULT_START_FIELDS = 2;
    protected static final int DEFAULT_START_VALUE = 2;
    private Grid playlingField;

    public MCP() {
        playlingField = new Grid();
    }

    public MCP(int gridSize) {
        playlingField = new Grid(gridSize);
    }

    protected Grid getPlaylingField() {
        return playlingField;
    }

    public void addStartCells() {

        Cell cell = playlingField.getRandomCell();

        cell.setValue(DEFAULT_START_VALUE);

        Cell nextCell = playlingField.getRandomCell();

        for (int count = playlingField.getActiveCells(); count < DEFAULT_START_FIELDS; count++) {
            while (cell.equals(nextCell)) {
                nextCell = playlingField.getRandomCell();
            }

            nextCell.setValue(DEFAULT_START_VALUE);
            cell = nextCell;
        }
    }

    public void move(MOVE_DIRECTION direction) {

        //left to right
        playlingField.moveCells();

    }
}

Enable customization of gridSize during instance creation